babylon.module.d.ts 5.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. readonly observers: Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static readonly LogCache: string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static LogLevels: number;
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static readonly Now: number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. /**
  486. * Returns client's state
  487. */
  488. readonly readyState: number;
  489. /**
  490. * Returns client's status
  491. */
  492. readonly status: number;
  493. /**
  494. * Returns client's status as a text
  495. */
  496. readonly statusText: string;
  497. /**
  498. * Returns client's response
  499. */
  500. readonly response: any;
  501. /**
  502. * Returns client's response url
  503. */
  504. readonly responseURL: string;
  505. /**
  506. * Returns client's response as text
  507. */
  508. readonly responseText: string;
  509. /**
  510. * Gets or sets the expected response type
  511. */
  512. responseType: XMLHttpRequestResponseType;
  513. /** @hidden */
  514. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  515. /** @hidden */
  516. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  517. /**
  518. * Cancels any network activity
  519. */
  520. abort(): void;
  521. /**
  522. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  523. * @param body defines an optional request body
  524. */
  525. send(body?: Document | BodyInit | null): void;
  526. /**
  527. * Sets the request method, request URL
  528. * @param method defines the method to use (GET, POST, etc..)
  529. * @param url defines the url to connect with
  530. */
  531. open(method: string, url: string): void;
  532. /**
  533. * Sets the value of a request header.
  534. * @param name The name of the header whose value is to be set
  535. * @param value The value to set as the body of the header
  536. */
  537. setRequestHeader(name: string, value: string): void;
  538. /**
  539. * Get the string containing the text of a particular header's value.
  540. * @param name The name of the header
  541. * @returns The string containing the text of the given header name
  542. */
  543. getResponseHeader(name: string): Nullable<string>;
  544. }
  545. }
  546. declare module "babylonjs/Misc/fileRequest" {
  547. import { Observable } from "babylonjs/Misc/observable";
  548. /**
  549. * File request interface
  550. */
  551. export interface IFileRequest {
  552. /**
  553. * Raised when the request is complete (success or error).
  554. */
  555. onCompleteObservable: Observable<IFileRequest>;
  556. /**
  557. * Aborts the request for a file.
  558. */
  559. abort: () => void;
  560. }
  561. }
  562. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  563. /**
  564. * Define options used to create a render target texture
  565. */
  566. export class RenderTargetCreationOptions {
  567. /**
  568. * Specifies is mipmaps must be generated
  569. */
  570. generateMipMaps?: boolean;
  571. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  572. generateDepthBuffer?: boolean;
  573. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  574. generateStencilBuffer?: boolean;
  575. /** Defines texture type (int by default) */
  576. type?: number;
  577. /** Defines sampling mode (trilinear by default) */
  578. samplingMode?: number;
  579. /** Defines format (RGBA by default) */
  580. format?: number;
  581. }
  582. }
  583. declare module "babylonjs/Instrumentation/timeToken" {
  584. import { Nullable } from "babylonjs/types";
  585. /**
  586. * @hidden
  587. **/
  588. export class _TimeToken {
  589. _startTimeQuery: Nullable<WebGLQuery>;
  590. _endTimeQuery: Nullable<WebGLQuery>;
  591. _timeElapsedQuery: Nullable<WebGLQuery>;
  592. _timeElapsedQueryEnded: boolean;
  593. }
  594. }
  595. declare module "babylonjs/Engines/constants" {
  596. /** Defines the cross module used constants to avoid circular dependncies */
  597. export class Constants {
  598. /** Defines that alpha blending is disabled */
  599. static readonly ALPHA_DISABLE: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  601. static readonly ALPHA_ADD: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_COMBINE: number;
  604. /** Defines that alpha blending is DEST - SRC * DEST */
  605. static readonly ALPHA_SUBTRACT: number;
  606. /** Defines that alpha blending is SRC * DEST */
  607. static readonly ALPHA_MULTIPLY: number;
  608. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  609. static readonly ALPHA_MAXIMIZED: number;
  610. /** Defines that alpha blending is SRC + DEST */
  611. static readonly ALPHA_ONEONE: number;
  612. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  613. static readonly ALPHA_PREMULTIPLIED: number;
  614. /**
  615. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  616. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  619. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  620. static readonly ALPHA_INTERPOLATE: number;
  621. /**
  622. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  623. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  624. */
  625. static readonly ALPHA_SCREENMODE: number;
  626. /**
  627. * Defines that alpha blending is SRC + DST
  628. * Alpha will be set to SRC ALPHA + DST ALPHA
  629. */
  630. static readonly ALPHA_ONEONE_ONEONE: number;
  631. /**
  632. * Defines that alpha blending is SRC * DST ALPHA + DST
  633. * Alpha will be set to 0
  634. */
  635. static readonly ALPHA_ALPHATOCOLOR: number;
  636. /**
  637. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  638. */
  639. static readonly ALPHA_REVERSEONEMINUS: number;
  640. /**
  641. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  642. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  643. */
  644. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  645. /**
  646. * Defines that alpha blending is SRC + DST
  647. * Alpha will be set to SRC ALPHA
  648. */
  649. static readonly ALPHA_ONEONE_ONEZERO: number;
  650. /**
  651. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  652. * Alpha will be set to DST ALPHA
  653. */
  654. static readonly ALPHA_EXCLUSION: number;
  655. /** Defines that alpha blending equation a SUM */
  656. static readonly ALPHA_EQUATION_ADD: number;
  657. /** Defines that alpha blending equation a SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  659. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  661. /** Defines that alpha blending equation a MAX operation */
  662. static readonly ALPHA_EQUATION_MAX: number;
  663. /** Defines that alpha blending equation a MIN operation */
  664. static readonly ALPHA_EQUATION_MIN: number;
  665. /**
  666. * Defines that alpha blending equation a DARKEN operation:
  667. * It takes the min of the src and sums the alpha channels.
  668. */
  669. static readonly ALPHA_EQUATION_DARKEN: number;
  670. /** Defines that the ressource is not delayed*/
  671. static readonly DELAYLOADSTATE_NONE: number;
  672. /** Defines that the ressource was successfully delay loaded */
  673. static readonly DELAYLOADSTATE_LOADED: number;
  674. /** Defines that the ressource is currently delay loading */
  675. static readonly DELAYLOADSTATE_LOADING: number;
  676. /** Defines that the ressource is delayed and has not started loading */
  677. static readonly DELAYLOADSTATE_NOTLOADED: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  679. static readonly NEVER: number;
  680. /** 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 */
  681. static readonly ALWAYS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  683. static readonly LESS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  685. static readonly EQUAL: number;
  686. /** 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 */
  687. static readonly LEQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  689. static readonly GREATER: number;
  690. /** 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 */
  691. static readonly GEQUAL: number;
  692. /** 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 */
  693. static readonly NOTEQUAL: number;
  694. /** Passed to stencilOperation to specify that stencil value must be kept */
  695. static readonly KEEP: number;
  696. /** Passed to stencilOperation to specify that stencil value must be replaced */
  697. static readonly REPLACE: number;
  698. /** Passed to stencilOperation to specify that stencil value must be incremented */
  699. static readonly INCR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be decremented */
  701. static readonly DECR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be inverted */
  703. static readonly INVERT: number;
  704. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  705. static readonly INCR_WRAP: number;
  706. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  707. static readonly DECR_WRAP: number;
  708. /** Texture is not repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  710. /** Texture is repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  712. /** Texture is repeating and mirrored */
  713. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  714. /** ALPHA */
  715. static readonly TEXTUREFORMAT_ALPHA: number;
  716. /** LUMINANCE */
  717. static readonly TEXTUREFORMAT_LUMINANCE: number;
  718. /** LUMINANCE_ALPHA */
  719. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  720. /** RGB */
  721. static readonly TEXTUREFORMAT_RGB: number;
  722. /** RGBA */
  723. static readonly TEXTUREFORMAT_RGBA: number;
  724. /** RED */
  725. static readonly TEXTUREFORMAT_RED: number;
  726. /** RED (2nd reference) */
  727. static readonly TEXTUREFORMAT_R: number;
  728. /** RG */
  729. static readonly TEXTUREFORMAT_RG: number;
  730. /** RED_INTEGER */
  731. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  732. /** RED_INTEGER (2nd reference) */
  733. static readonly TEXTUREFORMAT_R_INTEGER: number;
  734. /** RG_INTEGER */
  735. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  736. /** RGB_INTEGER */
  737. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  738. /** RGBA_INTEGER */
  739. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  740. /** UNSIGNED_BYTE */
  741. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  742. /** UNSIGNED_BYTE (2nd reference) */
  743. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  744. /** FLOAT */
  745. static readonly TEXTURETYPE_FLOAT: number;
  746. /** HALF_FLOAT */
  747. static readonly TEXTURETYPE_HALF_FLOAT: number;
  748. /** BYTE */
  749. static readonly TEXTURETYPE_BYTE: number;
  750. /** SHORT */
  751. static readonly TEXTURETYPE_SHORT: number;
  752. /** UNSIGNED_SHORT */
  753. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  754. /** INT */
  755. static readonly TEXTURETYPE_INT: number;
  756. /** UNSIGNED_INT */
  757. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  758. /** UNSIGNED_SHORT_4_4_4_4 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  760. /** UNSIGNED_SHORT_5_5_5_1 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  762. /** UNSIGNED_SHORT_5_6_5 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  764. /** UNSIGNED_INT_2_10_10_10_REV */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  766. /** UNSIGNED_INT_24_8 */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  768. /** UNSIGNED_INT_10F_11F_11F_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  770. /** UNSIGNED_INT_5_9_9_9_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  772. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  773. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  774. /** nearest is mag = nearest and min = nearest and mip = nearest */
  775. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  776. /** Bilinear is mag = linear and min = linear and mip = nearest */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** Trilinear is mag = linear and min = linear and mip = linear */
  779. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  780. /** nearest is mag = nearest and min = nearest and mip = linear */
  781. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  782. /** Bilinear is mag = linear and min = linear and mip = nearest */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  786. /** mag = nearest and min = nearest and mip = nearest */
  787. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = nearest */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = linear */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  792. /** mag = nearest and min = linear and mip = none */
  793. static readonly TEXTURE_NEAREST_LINEAR: number;
  794. /** mag = nearest and min = nearest and mip = none */
  795. static readonly TEXTURE_NEAREST_NEAREST: number;
  796. /** mag = linear and min = nearest and mip = nearest */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  798. /** mag = linear and min = nearest and mip = linear */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  800. /** mag = linear and min = linear and mip = none */
  801. static readonly TEXTURE_LINEAR_LINEAR: number;
  802. /** mag = linear and min = nearest and mip = none */
  803. static readonly TEXTURE_LINEAR_NEAREST: number;
  804. /** Explicit coordinates mode */
  805. static readonly TEXTURE_EXPLICIT_MODE: number;
  806. /** Spherical coordinates mode */
  807. static readonly TEXTURE_SPHERICAL_MODE: number;
  808. /** Planar coordinates mode */
  809. static readonly TEXTURE_PLANAR_MODE: number;
  810. /** Cubic coordinates mode */
  811. static readonly TEXTURE_CUBIC_MODE: number;
  812. /** Projection coordinates mode */
  813. static readonly TEXTURE_PROJECTION_MODE: number;
  814. /** Skybox coordinates mode */
  815. static readonly TEXTURE_SKYBOX_MODE: number;
  816. /** Inverse Cubic coordinates mode */
  817. static readonly TEXTURE_INVCUBIC_MODE: number;
  818. /** Equirectangular coordinates mode */
  819. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed Mirrored coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  824. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  825. static readonly SCALEMODE_FLOOR: number;
  826. /** Defines that texture rescaling will look for the nearest power of 2 size */
  827. static readonly SCALEMODE_NEAREST: number;
  828. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  829. static readonly SCALEMODE_CEILING: number;
  830. /**
  831. * The dirty texture flag value
  832. */
  833. static readonly MATERIAL_TextureDirtyFlag: number;
  834. /**
  835. * The dirty light flag value
  836. */
  837. static readonly MATERIAL_LightDirtyFlag: number;
  838. /**
  839. * The dirty fresnel flag value
  840. */
  841. static readonly MATERIAL_FresnelDirtyFlag: number;
  842. /**
  843. * The dirty attribute flag value
  844. */
  845. static readonly MATERIAL_AttributesDirtyFlag: number;
  846. /**
  847. * The dirty misc flag value
  848. */
  849. static readonly MATERIAL_MiscDirtyFlag: number;
  850. /**
  851. * The all dirty flag value
  852. */
  853. static readonly MATERIAL_AllDirtyFlag: number;
  854. /**
  855. * Returns the triangle fill mode
  856. */
  857. static readonly MATERIAL_TriangleFillMode: number;
  858. /**
  859. * Returns the wireframe mode
  860. */
  861. static readonly MATERIAL_WireFrameFillMode: number;
  862. /**
  863. * Returns the point fill mode
  864. */
  865. static readonly MATERIAL_PointFillMode: number;
  866. /**
  867. * Returns the point list draw mode
  868. */
  869. static readonly MATERIAL_PointListDrawMode: number;
  870. /**
  871. * Returns the line list draw mode
  872. */
  873. static readonly MATERIAL_LineListDrawMode: number;
  874. /**
  875. * Returns the line loop draw mode
  876. */
  877. static readonly MATERIAL_LineLoopDrawMode: number;
  878. /**
  879. * Returns the line strip draw mode
  880. */
  881. static readonly MATERIAL_LineStripDrawMode: number;
  882. /**
  883. * Returns the triangle strip draw mode
  884. */
  885. static readonly MATERIAL_TriangleStripDrawMode: number;
  886. /**
  887. * Returns the triangle fan draw mode
  888. */
  889. static readonly MATERIAL_TriangleFanDrawMode: number;
  890. /**
  891. * Stores the clock-wise side orientation
  892. */
  893. static readonly MATERIAL_ClockWiseSideOrientation: number;
  894. /**
  895. * Stores the counter clock-wise side orientation
  896. */
  897. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  898. /**
  899. * Nothing
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_NothingTrigger: number;
  903. /**
  904. * On pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnPickTrigger: number;
  908. /**
  909. * On left pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnLeftPickTrigger: number;
  913. /**
  914. * On right pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnRightPickTrigger: number;
  918. /**
  919. * On center pick
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnCenterPickTrigger: number;
  923. /**
  924. * On pick down
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickDownTrigger: number;
  928. /**
  929. * On double pick
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnDoublePickTrigger: number;
  933. /**
  934. * On pick up
  935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickUpTrigger: number;
  938. /**
  939. * On pick out.
  940. * This trigger will only be raised if you also declared a OnPickDown
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickOutTrigger: number;
  944. /**
  945. * On long press
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnLongPressTrigger: number;
  949. /**
  950. * On pointer over
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPointerOverTrigger: number;
  954. /**
  955. * On pointer out
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnPointerOutTrigger: number;
  959. /**
  960. * On every frame
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnEveryFrameTrigger: number;
  964. /**
  965. * On intersection enter
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnIntersectionEnterTrigger: number;
  969. /**
  970. * On intersection exit
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnIntersectionExitTrigger: number;
  974. /**
  975. * On key down
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnKeyDownTrigger: number;
  979. /**
  980. * On key up
  981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnKeyUpTrigger: number;
  984. /**
  985. * Billboard mode will only apply to Y axis
  986. */
  987. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  988. /**
  989. * Billboard mode will apply to all axes
  990. */
  991. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  992. /**
  993. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  994. */
  995. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  996. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  997. * Test order :
  998. * Is the bounding sphere outside the frustum ?
  999. * If not, are the bounding box vertices outside the frustum ?
  1000. * It not, then the cullable object is in the frustum.
  1001. */
  1002. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1003. /** Culling strategy : Bounding Sphere Only.
  1004. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1005. * It's also less accurate than the standard because some not visible objects can still be selected.
  1006. * Test : is the bounding sphere outside the frustum ?
  1007. * If not, then the cullable object is in the frustum.
  1008. */
  1009. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1010. /** Culling strategy : Optimistic Inclusion.
  1011. * This in an inclusion test first, then the standard exclusion test.
  1012. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1013. * 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.
  1014. * Anyway, it's as accurate as the standard strategy.
  1015. * Test :
  1016. * Is the cullable object bounding sphere center in the frustum ?
  1017. * If not, apply the default culling strategy.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1020. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1021. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1022. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1023. * 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.
  1024. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1025. * Test :
  1026. * Is the cullable object bounding sphere center in the frustum ?
  1027. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1030. /**
  1031. * No logging while loading
  1032. */
  1033. static readonly SCENELOADER_NO_LOGGING: number;
  1034. /**
  1035. * Minimal logging while loading
  1036. */
  1037. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1038. /**
  1039. * Summary logging while loading
  1040. */
  1041. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1042. /**
  1043. * Detailled logging while loading
  1044. */
  1045. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1046. }
  1047. }
  1048. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1049. import { Nullable } from "babylonjs/types";
  1050. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1051. /**
  1052. * This represents the required contract to create a new type of texture loader.
  1053. */
  1054. export interface IInternalTextureLoader {
  1055. /**
  1056. * Defines wether the loader supports cascade loading the different faces.
  1057. */
  1058. supportCascades: boolean;
  1059. /**
  1060. * This returns if the loader support the current file information.
  1061. * @param extension defines the file extension of the file being loaded
  1062. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1063. * @param fallback defines the fallback internal texture if any
  1064. * @param isBase64 defines whether the texture is encoded as a base64
  1065. * @param isBuffer defines whether the texture data are stored as a buffer
  1066. * @returns true if the loader can load the specified file
  1067. */
  1068. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1069. /**
  1070. * Transform the url before loading if required.
  1071. * @param rootUrl the url of the texture
  1072. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1073. * @returns the transformed texture
  1074. */
  1075. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1076. /**
  1077. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1078. * @param rootUrl the url of the texture
  1079. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1080. * @returns the fallback texture
  1081. */
  1082. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1083. /**
  1084. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1085. * @param data contains the texture data
  1086. * @param texture defines the BabylonJS internal texture
  1087. * @param createPolynomials will be true if polynomials have been requested
  1088. * @param onLoad defines the callback to trigger once the texture is ready
  1089. * @param onError defines the callback to trigger in case of error
  1090. */
  1091. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1092. /**
  1093. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1094. * @param data contains the texture data
  1095. * @param texture defines the BabylonJS internal texture
  1096. * @param callback defines the method to call once ready to upload
  1097. */
  1098. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1099. }
  1100. }
  1101. declare module "babylonjs/Engines/IPipelineContext" {
  1102. /**
  1103. * Class used to store and describe the pipeline context associated with an effect
  1104. */
  1105. export interface IPipelineContext {
  1106. /**
  1107. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1108. */
  1109. isAsync: boolean;
  1110. /**
  1111. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1112. */
  1113. isReady: boolean;
  1114. /** @hidden */
  1115. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1116. }
  1117. }
  1118. declare module "babylonjs/Meshes/dataBuffer" {
  1119. /**
  1120. * Class used to store gfx data (like WebGLBuffer)
  1121. */
  1122. export class DataBuffer {
  1123. /**
  1124. * Gets or sets the number of objects referencing this buffer
  1125. */
  1126. references: number;
  1127. /** Gets or sets the size of the underlying buffer */
  1128. capacity: number;
  1129. /**
  1130. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1131. */
  1132. is32Bits: boolean;
  1133. /**
  1134. * Gets the underlying buffer
  1135. */
  1136. readonly underlyingResource: any;
  1137. }
  1138. }
  1139. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1140. /** @hidden */
  1141. export interface IShaderProcessor {
  1142. attributeProcessor?: (attribute: string) => string;
  1143. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1144. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1145. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1146. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1147. lineProcessor?: (line: string, isFragment: boolean) => string;
  1148. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1149. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1150. }
  1151. }
  1152. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1153. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1154. /** @hidden */
  1155. export interface ProcessingOptions {
  1156. defines: string[];
  1157. indexParameters: any;
  1158. isFragment: boolean;
  1159. shouldUseHighPrecisionShader: boolean;
  1160. supportsUniformBuffers: boolean;
  1161. shadersRepository: string;
  1162. includesShadersStore: {
  1163. [key: string]: string;
  1164. };
  1165. processor?: IShaderProcessor;
  1166. version: string;
  1167. platformName: string;
  1168. lookForClosingBracketForUniformBuffer?: boolean;
  1169. }
  1170. }
  1171. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1172. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1173. /** @hidden */
  1174. export class ShaderCodeNode {
  1175. line: string;
  1176. children: ShaderCodeNode[];
  1177. additionalDefineKey?: string;
  1178. additionalDefineValue?: string;
  1179. isValid(preprocessors: {
  1180. [key: string]: string;
  1181. }): boolean;
  1182. process(preprocessors: {
  1183. [key: string]: string;
  1184. }, options: ProcessingOptions): string;
  1185. }
  1186. }
  1187. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1188. /** @hidden */
  1189. export class ShaderCodeCursor {
  1190. private _lines;
  1191. lineIndex: number;
  1192. readonly currentLine: string;
  1193. readonly canRead: boolean;
  1194. lines: string[];
  1195. }
  1196. }
  1197. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1198. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1199. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1200. /** @hidden */
  1201. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1202. process(preprocessors: {
  1203. [key: string]: string;
  1204. }, options: ProcessingOptions): string;
  1205. }
  1206. }
  1207. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1208. /** @hidden */
  1209. export class ShaderDefineExpression {
  1210. isTrue(preprocessors: {
  1211. [key: string]: string;
  1212. }): boolean;
  1213. }
  1214. }
  1215. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1216. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1217. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1218. /** @hidden */
  1219. export class ShaderCodeTestNode extends ShaderCodeNode {
  1220. testExpression: ShaderDefineExpression;
  1221. isValid(preprocessors: {
  1222. [key: string]: string;
  1223. }): boolean;
  1224. }
  1225. }
  1226. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1227. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1228. /** @hidden */
  1229. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1230. define: string;
  1231. not: boolean;
  1232. constructor(define: string, not?: boolean);
  1233. isTrue(preprocessors: {
  1234. [key: string]: string;
  1235. }): boolean;
  1236. }
  1237. }
  1238. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1239. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1240. /** @hidden */
  1241. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1242. leftOperand: ShaderDefineExpression;
  1243. rightOperand: ShaderDefineExpression;
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. }
  1248. }
  1249. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1250. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1251. /** @hidden */
  1252. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1253. leftOperand: ShaderDefineExpression;
  1254. rightOperand: ShaderDefineExpression;
  1255. isTrue(preprocessors: {
  1256. [key: string]: string;
  1257. }): boolean;
  1258. }
  1259. }
  1260. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1261. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1262. /** @hidden */
  1263. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1264. define: string;
  1265. operand: string;
  1266. testValue: string;
  1267. constructor(define: string, operand: string, testValue: string);
  1268. isTrue(preprocessors: {
  1269. [key: string]: string;
  1270. }): boolean;
  1271. }
  1272. }
  1273. declare module "babylonjs/Offline/IOfflineProvider" {
  1274. /**
  1275. * Class used to enable access to offline support
  1276. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1277. */
  1278. export interface IOfflineProvider {
  1279. /**
  1280. * Gets a boolean indicating if scene must be saved in the database
  1281. */
  1282. enableSceneOffline: boolean;
  1283. /**
  1284. * Gets a boolean indicating if textures must be saved in the database
  1285. */
  1286. enableTexturesOffline: boolean;
  1287. /**
  1288. * Open the offline support and make it available
  1289. * @param successCallback defines the callback to call on success
  1290. * @param errorCallback defines the callback to call on error
  1291. */
  1292. open(successCallback: () => void, errorCallback: () => void): void;
  1293. /**
  1294. * Loads an image from the offline support
  1295. * @param url defines the url to load from
  1296. * @param image defines the target DOM image
  1297. */
  1298. loadImage(url: string, image: HTMLImageElement): void;
  1299. /**
  1300. * Loads a file from offline support
  1301. * @param url defines the URL to load from
  1302. * @param sceneLoaded defines a callback to call on success
  1303. * @param progressCallBack defines a callback to call when progress changed
  1304. * @param errorCallback defines a callback to call on error
  1305. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1306. */
  1307. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1308. }
  1309. }
  1310. declare module "babylonjs/Misc/filesInputStore" {
  1311. /**
  1312. * Class used to help managing file picking and drag'n'drop
  1313. * File Storage
  1314. */
  1315. export class FilesInputStore {
  1316. /**
  1317. * List of files ready to be loaded
  1318. */
  1319. static FilesToLoad: {
  1320. [key: string]: File;
  1321. };
  1322. }
  1323. }
  1324. declare module "babylonjs/Misc/retryStrategy" {
  1325. import { WebRequest } from "babylonjs/Misc/webRequest";
  1326. /**
  1327. * Class used to define a retry strategy when error happens while loading assets
  1328. */
  1329. export class RetryStrategy {
  1330. /**
  1331. * Function used to defines an exponential back off strategy
  1332. * @param maxRetries defines the maximum number of retries (3 by default)
  1333. * @param baseInterval defines the interval between retries
  1334. * @returns the strategy function to use
  1335. */
  1336. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1337. }
  1338. }
  1339. declare module "babylonjs/Misc/baseError" {
  1340. /**
  1341. * @ignore
  1342. * Application error to support additional information when loading a file
  1343. */
  1344. export abstract class BaseError extends Error {
  1345. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1346. }
  1347. }
  1348. declare module "babylonjs/Misc/fileTools" {
  1349. import { WebRequest } from "babylonjs/Misc/webRequest";
  1350. import { Nullable } from "babylonjs/types";
  1351. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1352. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1353. import { BaseError } from "babylonjs/Misc/baseError";
  1354. /** @ignore */
  1355. export class LoadFileError extends BaseError {
  1356. request?: WebRequest;
  1357. file?: File;
  1358. /**
  1359. * Creates a new LoadFileError
  1360. * @param message defines the message of the error
  1361. * @param request defines the optional web request
  1362. * @param file defines the optional file
  1363. */
  1364. constructor(message: string, object?: WebRequest | File);
  1365. }
  1366. /** @ignore */
  1367. export class RequestFileError extends BaseError {
  1368. request: WebRequest;
  1369. /**
  1370. * Creates a new LoadFileError
  1371. * @param message defines the message of the error
  1372. * @param request defines the optional web request
  1373. */
  1374. constructor(message: string, request: WebRequest);
  1375. }
  1376. /** @ignore */
  1377. export class ReadFileError extends BaseError {
  1378. file: File;
  1379. /**
  1380. * Creates a new ReadFileError
  1381. * @param message defines the message of the error
  1382. * @param file defines the optional file
  1383. */
  1384. constructor(message: string, file: File);
  1385. }
  1386. /**
  1387. * @hidden
  1388. */
  1389. export class FileTools {
  1390. /**
  1391. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1392. */
  1393. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1394. /**
  1395. * Gets or sets the base URL to use to load assets
  1396. */
  1397. static BaseUrl: string;
  1398. /**
  1399. * Default behaviour for cors in the application.
  1400. * It can be a string if the expected behavior is identical in the entire app.
  1401. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1402. */
  1403. static CorsBehavior: string | ((url: string | string[]) => string);
  1404. /**
  1405. * Gets or sets a function used to pre-process url before using them to load assets
  1406. */
  1407. static PreprocessUrl: (url: string) => string;
  1408. /**
  1409. * Removes unwanted characters from an url
  1410. * @param url defines the url to clean
  1411. * @returns the cleaned url
  1412. */
  1413. private static _CleanUrl;
  1414. /**
  1415. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1416. * @param url define the url we are trying
  1417. * @param element define the dom element where to configure the cors policy
  1418. */
  1419. static SetCorsBehavior(url: string | string[], element: {
  1420. crossOrigin: string | null;
  1421. }): void;
  1422. /**
  1423. * Loads an image as an HTMLImageElement.
  1424. * @param input url string, ArrayBuffer, or Blob to load
  1425. * @param onLoad callback called when the image successfully loads
  1426. * @param onError callback called when the image fails to load
  1427. * @param offlineProvider offline provider for caching
  1428. * @param mimeType optional mime type
  1429. * @returns the HTMLImageElement of the loaded image
  1430. */
  1431. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1432. /**
  1433. * Reads a file from a File object
  1434. * @param file defines the file to load
  1435. * @param onSuccess defines the callback to call when data is loaded
  1436. * @param onProgress defines the callback to call during loading process
  1437. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1438. * @param onError defines the callback to call when an error occurs
  1439. * @returns a file request object
  1440. */
  1441. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1442. /**
  1443. * Loads a file from a url
  1444. * @param url url to load
  1445. * @param onSuccess callback called when the file successfully loads
  1446. * @param onProgress callback called while file is loading (if the server supports this mode)
  1447. * @param offlineProvider defines the offline provider for caching
  1448. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1449. * @param onError callback called when the file fails to load
  1450. * @returns a file request object
  1451. */
  1452. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1453. /**
  1454. * Loads a file
  1455. * @param url url to load
  1456. * @param onSuccess callback called when the file successfully loads
  1457. * @param onProgress callback called while file is loading (if the server supports this mode)
  1458. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1459. * @param onError callback called when the file fails to load
  1460. * @param onOpened callback called when the web request is opened
  1461. * @returns a file request object
  1462. */
  1463. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1464. /**
  1465. * Checks if the loaded document was accessed via `file:`-Protocol.
  1466. * @returns boolean
  1467. */
  1468. static IsFileURL(): boolean;
  1469. }
  1470. }
  1471. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1472. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1473. /** @hidden */
  1474. export class ShaderProcessor {
  1475. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1476. private static _ProcessPrecision;
  1477. private static _ExtractOperation;
  1478. private static _BuildSubExpression;
  1479. private static _BuildExpression;
  1480. private static _MoveCursorWithinIf;
  1481. private static _MoveCursor;
  1482. private static _EvaluatePreProcessors;
  1483. private static _PreparePreProcessors;
  1484. private static _ProcessShaderConversion;
  1485. private static _ProcessIncludes;
  1486. }
  1487. }
  1488. declare module "babylonjs/Maths/math.like" {
  1489. import { float, int, DeepImmutable } from "babylonjs/types";
  1490. /**
  1491. * @hidden
  1492. */
  1493. export interface IColor4Like {
  1494. r: float;
  1495. g: float;
  1496. b: float;
  1497. a: float;
  1498. }
  1499. /**
  1500. * @hidden
  1501. */
  1502. export interface IColor3Like {
  1503. r: float;
  1504. g: float;
  1505. b: float;
  1506. }
  1507. /**
  1508. * @hidden
  1509. */
  1510. export interface IVector4Like {
  1511. x: float;
  1512. y: float;
  1513. z: float;
  1514. w: float;
  1515. }
  1516. /**
  1517. * @hidden
  1518. */
  1519. export interface IVector3Like {
  1520. x: float;
  1521. y: float;
  1522. z: float;
  1523. }
  1524. /**
  1525. * @hidden
  1526. */
  1527. export interface IVector2Like {
  1528. x: float;
  1529. y: float;
  1530. }
  1531. /**
  1532. * @hidden
  1533. */
  1534. export interface IMatrixLike {
  1535. toArray(): DeepImmutable<Float32Array>;
  1536. updateFlag: int;
  1537. }
  1538. /**
  1539. * @hidden
  1540. */
  1541. export interface IViewportLike {
  1542. x: float;
  1543. y: float;
  1544. width: float;
  1545. height: float;
  1546. }
  1547. /**
  1548. * @hidden
  1549. */
  1550. export interface IPlaneLike {
  1551. normal: IVector3Like;
  1552. d: float;
  1553. normalize(): void;
  1554. }
  1555. }
  1556. declare module "babylonjs/Materials/iEffectFallbacks" {
  1557. import { Effect } from "babylonjs/Materials/effect";
  1558. /**
  1559. * Interface used to define common properties for effect fallbacks
  1560. */
  1561. export interface IEffectFallbacks {
  1562. /**
  1563. * Removes the defines that should be removed when falling back.
  1564. * @param currentDefines defines the current define statements for the shader.
  1565. * @param effect defines the current effect we try to compile
  1566. * @returns The resulting defines with defines of the current rank removed.
  1567. */
  1568. reduce(currentDefines: string, effect: Effect): string;
  1569. /**
  1570. * Removes the fallback from the bound mesh.
  1571. */
  1572. unBindMesh(): void;
  1573. /**
  1574. * Checks to see if more fallbacks are still availible.
  1575. */
  1576. hasMoreFallbacks: boolean;
  1577. }
  1578. }
  1579. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1580. /**
  1581. * Class used to evalaute queries containing `and` and `or` operators
  1582. */
  1583. export class AndOrNotEvaluator {
  1584. /**
  1585. * Evaluate a query
  1586. * @param query defines the query to evaluate
  1587. * @param evaluateCallback defines the callback used to filter result
  1588. * @returns true if the query matches
  1589. */
  1590. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1591. private static _HandleParenthesisContent;
  1592. private static _SimplifyNegation;
  1593. }
  1594. }
  1595. declare module "babylonjs/Misc/tags" {
  1596. /**
  1597. * Class used to store custom tags
  1598. */
  1599. export class Tags {
  1600. /**
  1601. * Adds support for tags on the given object
  1602. * @param obj defines the object to use
  1603. */
  1604. static EnableFor(obj: any): void;
  1605. /**
  1606. * Removes tags support
  1607. * @param obj defines the object to use
  1608. */
  1609. static DisableFor(obj: any): void;
  1610. /**
  1611. * Gets a boolean indicating if the given object has tags
  1612. * @param obj defines the object to use
  1613. * @returns a boolean
  1614. */
  1615. static HasTags(obj: any): boolean;
  1616. /**
  1617. * Gets the tags available on a given object
  1618. * @param obj defines the object to use
  1619. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1620. * @returns the tags
  1621. */
  1622. static GetTags(obj: any, asString?: boolean): any;
  1623. /**
  1624. * Adds tags to an object
  1625. * @param obj defines the object to use
  1626. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1627. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1628. */
  1629. static AddTagsTo(obj: any, tagsString: string): void;
  1630. /**
  1631. * @hidden
  1632. */
  1633. static _AddTagTo(obj: any, tag: string): void;
  1634. /**
  1635. * Removes specific tags from a specific object
  1636. * @param obj defines the object to use
  1637. * @param tagsString defines the tags to remove
  1638. */
  1639. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1640. /**
  1641. * @hidden
  1642. */
  1643. static _RemoveTagFrom(obj: any, tag: string): void;
  1644. /**
  1645. * Defines if tags hosted on an object match a given query
  1646. * @param obj defines the object to use
  1647. * @param tagsQuery defines the tag query
  1648. * @returns a boolean
  1649. */
  1650. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1651. }
  1652. }
  1653. declare module "babylonjs/Maths/math.scalar" {
  1654. /**
  1655. * Scalar computation library
  1656. */
  1657. export class Scalar {
  1658. /**
  1659. * Two pi constants convenient for computation.
  1660. */
  1661. static TwoPi: number;
  1662. /**
  1663. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1664. * @param a number
  1665. * @param b number
  1666. * @param epsilon (default = 1.401298E-45)
  1667. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1668. */
  1669. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1670. /**
  1671. * Returns a string : the upper case translation of the number i to hexadecimal.
  1672. * @param i number
  1673. * @returns the upper case translation of the number i to hexadecimal.
  1674. */
  1675. static ToHex(i: number): string;
  1676. /**
  1677. * Returns -1 if value is negative and +1 is value is positive.
  1678. * @param value the value
  1679. * @returns the value itself if it's equal to zero.
  1680. */
  1681. static Sign(value: number): number;
  1682. /**
  1683. * Returns the value itself if it's between min and max.
  1684. * Returns min if the value is lower than min.
  1685. * Returns max if the value is greater than max.
  1686. * @param value the value to clmap
  1687. * @param min the min value to clamp to (default: 0)
  1688. * @param max the max value to clamp to (default: 1)
  1689. * @returns the clamped value
  1690. */
  1691. static Clamp(value: number, min?: number, max?: number): number;
  1692. /**
  1693. * the log2 of value.
  1694. * @param value the value to compute log2 of
  1695. * @returns the log2 of value.
  1696. */
  1697. static Log2(value: number): number;
  1698. /**
  1699. * Loops the value, so that it is never larger than length and never smaller than 0.
  1700. *
  1701. * This is similar to the modulo operator but it works with floating point numbers.
  1702. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1703. * With t = 5 and length = 2.5, the result would be 0.0.
  1704. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1705. * @param value the value
  1706. * @param length the length
  1707. * @returns the looped value
  1708. */
  1709. static Repeat(value: number, length: number): number;
  1710. /**
  1711. * Normalize the value between 0.0 and 1.0 using min and max values
  1712. * @param value value to normalize
  1713. * @param min max to normalize between
  1714. * @param max min to normalize between
  1715. * @returns the normalized value
  1716. */
  1717. static Normalize(value: number, min: number, max: number): number;
  1718. /**
  1719. * Denormalize the value from 0.0 and 1.0 using min and max values
  1720. * @param normalized value to denormalize
  1721. * @param min max to denormalize between
  1722. * @param max min to denormalize between
  1723. * @returns the denormalized value
  1724. */
  1725. static Denormalize(normalized: number, min: number, max: number): number;
  1726. /**
  1727. * Calculates the shortest difference between two given angles given in degrees.
  1728. * @param current current angle in degrees
  1729. * @param target target angle in degrees
  1730. * @returns the delta
  1731. */
  1732. static DeltaAngle(current: number, target: number): number;
  1733. /**
  1734. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1735. * @param tx value
  1736. * @param length length
  1737. * @returns The returned value will move back and forth between 0 and length
  1738. */
  1739. static PingPong(tx: number, length: number): number;
  1740. /**
  1741. * Interpolates between min and max with smoothing at the limits.
  1742. *
  1743. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1744. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1745. * @param from from
  1746. * @param to to
  1747. * @param tx value
  1748. * @returns the smooth stepped value
  1749. */
  1750. static SmoothStep(from: number, to: number, tx: number): number;
  1751. /**
  1752. * Moves a value current towards target.
  1753. *
  1754. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1755. * Negative values of maxDelta pushes the value away from target.
  1756. * @param current current value
  1757. * @param target target value
  1758. * @param maxDelta max distance to move
  1759. * @returns resulting value
  1760. */
  1761. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1762. /**
  1763. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1764. *
  1765. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1766. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1767. * @param current current value
  1768. * @param target target value
  1769. * @param maxDelta max distance to move
  1770. * @returns resulting angle
  1771. */
  1772. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1773. /**
  1774. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1775. * @param start start value
  1776. * @param end target value
  1777. * @param amount amount to lerp between
  1778. * @returns the lerped value
  1779. */
  1780. static Lerp(start: number, end: number, amount: number): number;
  1781. /**
  1782. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1783. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1784. * @param start start value
  1785. * @param end target value
  1786. * @param amount amount to lerp between
  1787. * @returns the lerped value
  1788. */
  1789. static LerpAngle(start: number, end: number, amount: number): number;
  1790. /**
  1791. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1792. * @param a start value
  1793. * @param b target value
  1794. * @param value value between a and b
  1795. * @returns the inverseLerp value
  1796. */
  1797. static InverseLerp(a: number, b: number, value: number): number;
  1798. /**
  1799. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1800. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1801. * @param value1 spline value
  1802. * @param tangent1 spline value
  1803. * @param value2 spline value
  1804. * @param tangent2 spline value
  1805. * @param amount input value
  1806. * @returns hermite result
  1807. */
  1808. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1809. /**
  1810. * Returns a random float number between and min and max values
  1811. * @param min min value of random
  1812. * @param max max value of random
  1813. * @returns random value
  1814. */
  1815. static RandomRange(min: number, max: number): number;
  1816. /**
  1817. * This function returns percentage of a number in a given range.
  1818. *
  1819. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1820. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1821. * @param number to convert to percentage
  1822. * @param min min range
  1823. * @param max max range
  1824. * @returns the percentage
  1825. */
  1826. static RangeToPercent(number: number, min: number, max: number): number;
  1827. /**
  1828. * This function returns number that corresponds to the percentage in a given range.
  1829. *
  1830. * PercentToRange(0.34,0,100) will return 34.
  1831. * @param percent to convert to number
  1832. * @param min min range
  1833. * @param max max range
  1834. * @returns the number
  1835. */
  1836. static PercentToRange(percent: number, min: number, max: number): number;
  1837. /**
  1838. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1839. * @param angle The angle to normalize in radian.
  1840. * @return The converted angle.
  1841. */
  1842. static NormalizeRadians(angle: number): number;
  1843. }
  1844. }
  1845. declare module "babylonjs/Maths/math.constants" {
  1846. /**
  1847. * Constant used to convert a value to gamma space
  1848. * @ignorenaming
  1849. */
  1850. export const ToGammaSpace: number;
  1851. /**
  1852. * Constant used to convert a value to linear space
  1853. * @ignorenaming
  1854. */
  1855. export const ToLinearSpace = 2.2;
  1856. /**
  1857. * Constant used to define the minimal number value in Babylon.js
  1858. * @ignorenaming
  1859. */
  1860. let Epsilon: number;
  1861. export { Epsilon };
  1862. }
  1863. declare module "babylonjs/Maths/math.viewport" {
  1864. /**
  1865. * Class used to represent a viewport on screen
  1866. */
  1867. export class Viewport {
  1868. /** viewport left coordinate */
  1869. x: number;
  1870. /** viewport top coordinate */
  1871. y: number;
  1872. /**viewport width */
  1873. width: number;
  1874. /** viewport height */
  1875. height: number;
  1876. /**
  1877. * Creates a Viewport object located at (x, y) and sized (width, height)
  1878. * @param x defines viewport left coordinate
  1879. * @param y defines viewport top coordinate
  1880. * @param width defines the viewport width
  1881. * @param height defines the viewport height
  1882. */
  1883. constructor(
  1884. /** viewport left coordinate */
  1885. x: number,
  1886. /** viewport top coordinate */
  1887. y: number,
  1888. /**viewport width */
  1889. width: number,
  1890. /** viewport height */
  1891. height: number);
  1892. /**
  1893. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1894. * @param renderWidth defines the rendering width
  1895. * @param renderHeight defines the rendering height
  1896. * @returns a new Viewport
  1897. */
  1898. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1899. /**
  1900. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1901. * @param renderWidth defines the rendering width
  1902. * @param renderHeight defines the rendering height
  1903. * @param ref defines the target viewport
  1904. * @returns the current viewport
  1905. */
  1906. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1907. /**
  1908. * Returns a new Viewport copied from the current one
  1909. * @returns a new Viewport
  1910. */
  1911. clone(): Viewport;
  1912. }
  1913. }
  1914. declare module "babylonjs/Misc/arrayTools" {
  1915. /**
  1916. * Class containing a set of static utilities functions for arrays.
  1917. */
  1918. export class ArrayTools {
  1919. /**
  1920. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1921. * @param size the number of element to construct and put in the array
  1922. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1923. * @returns a new array filled with new objects
  1924. */
  1925. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1926. }
  1927. }
  1928. declare module "babylonjs/Maths/math.vector" {
  1929. import { Viewport } from "babylonjs/Maths/math.viewport";
  1930. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1931. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1932. /**
  1933. * Class representing a vector containing 2 coordinates
  1934. */
  1935. export class Vector2 {
  1936. /** defines the first coordinate */
  1937. x: number;
  1938. /** defines the second coordinate */
  1939. y: number;
  1940. /**
  1941. * Creates a new Vector2 from the given x and y coordinates
  1942. * @param x defines the first coordinate
  1943. * @param y defines the second coordinate
  1944. */
  1945. constructor(
  1946. /** defines the first coordinate */
  1947. x?: number,
  1948. /** defines the second coordinate */
  1949. y?: number);
  1950. /**
  1951. * Gets a string with the Vector2 coordinates
  1952. * @returns a string with the Vector2 coordinates
  1953. */
  1954. toString(): string;
  1955. /**
  1956. * Gets class name
  1957. * @returns the string "Vector2"
  1958. */
  1959. getClassName(): string;
  1960. /**
  1961. * Gets current vector hash code
  1962. * @returns the Vector2 hash code as a number
  1963. */
  1964. getHashCode(): number;
  1965. /**
  1966. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1967. * @param array defines the source array
  1968. * @param index defines the offset in source array
  1969. * @returns the current Vector2
  1970. */
  1971. toArray(array: FloatArray, index?: number): Vector2;
  1972. /**
  1973. * Copy the current vector to an array
  1974. * @returns a new array with 2 elements: the Vector2 coordinates.
  1975. */
  1976. asArray(): number[];
  1977. /**
  1978. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1979. * @param source defines the source Vector2
  1980. * @returns the current updated Vector2
  1981. */
  1982. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1983. /**
  1984. * Sets the Vector2 coordinates with the given floats
  1985. * @param x defines the first coordinate
  1986. * @param y defines the second coordinate
  1987. * @returns the current updated Vector2
  1988. */
  1989. copyFromFloats(x: number, y: number): Vector2;
  1990. /**
  1991. * Sets the Vector2 coordinates with the given floats
  1992. * @param x defines the first coordinate
  1993. * @param y defines the second coordinate
  1994. * @returns the current updated Vector2
  1995. */
  1996. set(x: number, y: number): Vector2;
  1997. /**
  1998. * Add another vector with the current one
  1999. * @param otherVector defines the other vector
  2000. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2001. */
  2002. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2003. /**
  2004. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2005. * @param otherVector defines the other vector
  2006. * @param result defines the target vector
  2007. * @returns the unmodified current Vector2
  2008. */
  2009. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2010. /**
  2011. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2012. * @param otherVector defines the other vector
  2013. * @returns the current updated Vector2
  2014. */
  2015. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2016. /**
  2017. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2018. * @param otherVector defines the other vector
  2019. * @returns a new Vector2
  2020. */
  2021. addVector3(otherVector: Vector3): Vector2;
  2022. /**
  2023. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2024. * @param otherVector defines the other vector
  2025. * @returns a new Vector2
  2026. */
  2027. subtract(otherVector: Vector2): Vector2;
  2028. /**
  2029. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2030. * @param otherVector defines the other vector
  2031. * @param result defines the target vector
  2032. * @returns the unmodified current Vector2
  2033. */
  2034. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2035. /**
  2036. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2037. * @param otherVector defines the other vector
  2038. * @returns the current updated Vector2
  2039. */
  2040. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2041. /**
  2042. * Multiplies in place the current Vector2 coordinates by the given ones
  2043. * @param otherVector defines the other vector
  2044. * @returns the current updated Vector2
  2045. */
  2046. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2047. /**
  2048. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2049. * @param otherVector defines the other vector
  2050. * @returns a new Vector2
  2051. */
  2052. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2053. /**
  2054. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2055. * @param otherVector defines the other vector
  2056. * @param result defines the target vector
  2057. * @returns the unmodified current Vector2
  2058. */
  2059. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2060. /**
  2061. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2062. * @param x defines the first coordinate
  2063. * @param y defines the second coordinate
  2064. * @returns a new Vector2
  2065. */
  2066. multiplyByFloats(x: number, y: number): Vector2;
  2067. /**
  2068. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2069. * @param otherVector defines the other vector
  2070. * @returns a new Vector2
  2071. */
  2072. divide(otherVector: Vector2): Vector2;
  2073. /**
  2074. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2075. * @param otherVector defines the other vector
  2076. * @param result defines the target vector
  2077. * @returns the unmodified current Vector2
  2078. */
  2079. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2080. /**
  2081. * Divides the current Vector2 coordinates by the given ones
  2082. * @param otherVector defines the other vector
  2083. * @returns the current updated Vector2
  2084. */
  2085. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2086. /**
  2087. * Gets a new Vector2 with current Vector2 negated coordinates
  2088. * @returns a new Vector2
  2089. */
  2090. negate(): Vector2;
  2091. /**
  2092. * Multiply the Vector2 coordinates by scale
  2093. * @param scale defines the scaling factor
  2094. * @returns the current updated Vector2
  2095. */
  2096. scaleInPlace(scale: number): Vector2;
  2097. /**
  2098. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2099. * @param scale defines the scaling factor
  2100. * @returns a new Vector2
  2101. */
  2102. scale(scale: number): Vector2;
  2103. /**
  2104. * Scale the current Vector2 values by a factor to a given Vector2
  2105. * @param scale defines the scale factor
  2106. * @param result defines the Vector2 object where to store the result
  2107. * @returns the unmodified current Vector2
  2108. */
  2109. scaleToRef(scale: number, result: Vector2): Vector2;
  2110. /**
  2111. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2112. * @param scale defines the scale factor
  2113. * @param result defines the Vector2 object where to store the result
  2114. * @returns the unmodified current Vector2
  2115. */
  2116. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2117. /**
  2118. * Gets a boolean if two vectors are equals
  2119. * @param otherVector defines the other vector
  2120. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2121. */
  2122. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2123. /**
  2124. * Gets a boolean if two vectors are equals (using an epsilon value)
  2125. * @param otherVector defines the other vector
  2126. * @param epsilon defines the minimal distance to consider equality
  2127. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2128. */
  2129. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2130. /**
  2131. * Gets a new Vector2 from current Vector2 floored values
  2132. * @returns a new Vector2
  2133. */
  2134. floor(): Vector2;
  2135. /**
  2136. * Gets a new Vector2 from current Vector2 floored values
  2137. * @returns a new Vector2
  2138. */
  2139. fract(): Vector2;
  2140. /**
  2141. * Gets the length of the vector
  2142. * @returns the vector length (float)
  2143. */
  2144. length(): number;
  2145. /**
  2146. * Gets the vector squared length
  2147. * @returns the vector squared length (float)
  2148. */
  2149. lengthSquared(): number;
  2150. /**
  2151. * Normalize the vector
  2152. * @returns the current updated Vector2
  2153. */
  2154. normalize(): Vector2;
  2155. /**
  2156. * Gets a new Vector2 copied from the Vector2
  2157. * @returns a new Vector2
  2158. */
  2159. clone(): Vector2;
  2160. /**
  2161. * Gets a new Vector2(0, 0)
  2162. * @returns a new Vector2
  2163. */
  2164. static Zero(): Vector2;
  2165. /**
  2166. * Gets a new Vector2(1, 1)
  2167. * @returns a new Vector2
  2168. */
  2169. static One(): Vector2;
  2170. /**
  2171. * Gets a new Vector2 set from the given index element of the given array
  2172. * @param array defines the data source
  2173. * @param offset defines the offset in the data source
  2174. * @returns a new Vector2
  2175. */
  2176. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2177. /**
  2178. * Sets "result" from the given index element of the given array
  2179. * @param array defines the data source
  2180. * @param offset defines the offset in the data source
  2181. * @param result defines the target vector
  2182. */
  2183. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2184. /**
  2185. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2186. * @param value1 defines 1st point of control
  2187. * @param value2 defines 2nd point of control
  2188. * @param value3 defines 3rd point of control
  2189. * @param value4 defines 4th point of control
  2190. * @param amount defines the interpolation factor
  2191. * @returns a new Vector2
  2192. */
  2193. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2194. /**
  2195. * 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".
  2196. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2197. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2198. * @param value defines the value to clamp
  2199. * @param min defines the lower limit
  2200. * @param max defines the upper limit
  2201. * @returns a new Vector2
  2202. */
  2203. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2204. /**
  2205. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2206. * @param value1 defines the 1st control point
  2207. * @param tangent1 defines the outgoing tangent
  2208. * @param value2 defines the 2nd control point
  2209. * @param tangent2 defines the incoming tangent
  2210. * @param amount defines the interpolation factor
  2211. * @returns a new Vector2
  2212. */
  2213. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2214. /**
  2215. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2216. * @param start defines the start vector
  2217. * @param end defines the end vector
  2218. * @param amount defines the interpolation factor
  2219. * @returns a new Vector2
  2220. */
  2221. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2222. /**
  2223. * Gets the dot product of the vector "left" and the vector "right"
  2224. * @param left defines first vector
  2225. * @param right defines second vector
  2226. * @returns the dot product (float)
  2227. */
  2228. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2229. /**
  2230. * Returns a new Vector2 equal to the normalized given vector
  2231. * @param vector defines the vector to normalize
  2232. * @returns a new Vector2
  2233. */
  2234. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2235. /**
  2236. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2237. * @param left defines 1st vector
  2238. * @param right defines 2nd vector
  2239. * @returns a new Vector2
  2240. */
  2241. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2242. /**
  2243. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2244. * @param left defines 1st vector
  2245. * @param right defines 2nd vector
  2246. * @returns a new Vector2
  2247. */
  2248. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2249. /**
  2250. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2251. * @param vector defines the vector to transform
  2252. * @param transformation defines the matrix to apply
  2253. * @returns a new Vector2
  2254. */
  2255. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2256. /**
  2257. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2258. * @param vector defines the vector to transform
  2259. * @param transformation defines the matrix to apply
  2260. * @param result defines the target vector
  2261. */
  2262. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2263. /**
  2264. * Determines if a given vector is included in a triangle
  2265. * @param p defines the vector to test
  2266. * @param p0 defines 1st triangle point
  2267. * @param p1 defines 2nd triangle point
  2268. * @param p2 defines 3rd triangle point
  2269. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2270. */
  2271. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2272. /**
  2273. * Gets the distance between the vectors "value1" and "value2"
  2274. * @param value1 defines first vector
  2275. * @param value2 defines second vector
  2276. * @returns the distance between vectors
  2277. */
  2278. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2279. /**
  2280. * Returns the squared distance between the vectors "value1" and "value2"
  2281. * @param value1 defines first vector
  2282. * @param value2 defines second vector
  2283. * @returns the squared distance between vectors
  2284. */
  2285. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2286. /**
  2287. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2288. * @param value1 defines first vector
  2289. * @param value2 defines second vector
  2290. * @returns a new Vector2
  2291. */
  2292. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2293. /**
  2294. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2295. * @param p defines the middle point
  2296. * @param segA defines one point of the segment
  2297. * @param segB defines the other point of the segment
  2298. * @returns the shortest distance
  2299. */
  2300. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2301. }
  2302. /**
  2303. * Class used to store (x,y,z) vector representation
  2304. * A Vector3 is the main object used in 3D geometry
  2305. * It can represent etiher the coordinates of a point the space, either a direction
  2306. * Reminder: js uses a left handed forward facing system
  2307. */
  2308. export class Vector3 {
  2309. /**
  2310. * Defines the first coordinates (on X axis)
  2311. */
  2312. x: number;
  2313. /**
  2314. * Defines the second coordinates (on Y axis)
  2315. */
  2316. y: number;
  2317. /**
  2318. * Defines the third coordinates (on Z axis)
  2319. */
  2320. z: number;
  2321. private static _UpReadOnly;
  2322. private static _ZeroReadOnly;
  2323. /**
  2324. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2325. * @param x defines the first coordinates (on X axis)
  2326. * @param y defines the second coordinates (on Y axis)
  2327. * @param z defines the third coordinates (on Z axis)
  2328. */
  2329. constructor(
  2330. /**
  2331. * Defines the first coordinates (on X axis)
  2332. */
  2333. x?: number,
  2334. /**
  2335. * Defines the second coordinates (on Y axis)
  2336. */
  2337. y?: number,
  2338. /**
  2339. * Defines the third coordinates (on Z axis)
  2340. */
  2341. z?: number);
  2342. /**
  2343. * Creates a string representation of the Vector3
  2344. * @returns a string with the Vector3 coordinates.
  2345. */
  2346. toString(): string;
  2347. /**
  2348. * Gets the class name
  2349. * @returns the string "Vector3"
  2350. */
  2351. getClassName(): string;
  2352. /**
  2353. * Creates the Vector3 hash code
  2354. * @returns a number which tends to be unique between Vector3 instances
  2355. */
  2356. getHashCode(): number;
  2357. /**
  2358. * Creates an array containing three elements : the coordinates of the Vector3
  2359. * @returns a new array of numbers
  2360. */
  2361. asArray(): number[];
  2362. /**
  2363. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2364. * @param array defines the destination array
  2365. * @param index defines the offset in the destination array
  2366. * @returns the current Vector3
  2367. */
  2368. toArray(array: FloatArray, index?: number): Vector3;
  2369. /**
  2370. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2371. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2372. */
  2373. toQuaternion(): Quaternion;
  2374. /**
  2375. * Adds the given vector to the current Vector3
  2376. * @param otherVector defines the second operand
  2377. * @returns the current updated Vector3
  2378. */
  2379. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2380. /**
  2381. * Adds the given coordinates to the current Vector3
  2382. * @param x defines the x coordinate of the operand
  2383. * @param y defines the y coordinate of the operand
  2384. * @param z defines the z coordinate of the operand
  2385. * @returns the current updated Vector3
  2386. */
  2387. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2388. /**
  2389. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2390. * @param otherVector defines the second operand
  2391. * @returns the resulting Vector3
  2392. */
  2393. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2394. /**
  2395. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2396. * @param otherVector defines the second operand
  2397. * @param result defines the Vector3 object where to store the result
  2398. * @returns the current Vector3
  2399. */
  2400. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2401. /**
  2402. * Subtract the given vector from the current Vector3
  2403. * @param otherVector defines the second operand
  2404. * @returns the current updated Vector3
  2405. */
  2406. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2407. /**
  2408. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2409. * @param otherVector defines the second operand
  2410. * @returns the resulting Vector3
  2411. */
  2412. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2413. /**
  2414. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2415. * @param otherVector defines the second operand
  2416. * @param result defines the Vector3 object where to store the result
  2417. * @returns the current Vector3
  2418. */
  2419. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2420. /**
  2421. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2422. * @param x defines the x coordinate of the operand
  2423. * @param y defines the y coordinate of the operand
  2424. * @param z defines the z coordinate of the operand
  2425. * @returns the resulting Vector3
  2426. */
  2427. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2428. /**
  2429. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2430. * @param x defines the x coordinate of the operand
  2431. * @param y defines the y coordinate of the operand
  2432. * @param z defines the z coordinate of the operand
  2433. * @param result defines the Vector3 object where to store the result
  2434. * @returns the current Vector3
  2435. */
  2436. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2437. /**
  2438. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2439. * @returns a new Vector3
  2440. */
  2441. negate(): Vector3;
  2442. /**
  2443. * Multiplies the Vector3 coordinates by the float "scale"
  2444. * @param scale defines the multiplier factor
  2445. * @returns the current updated Vector3
  2446. */
  2447. scaleInPlace(scale: number): Vector3;
  2448. /**
  2449. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2450. * @param scale defines the multiplier factor
  2451. * @returns a new Vector3
  2452. */
  2453. scale(scale: number): Vector3;
  2454. /**
  2455. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2456. * @param scale defines the multiplier factor
  2457. * @param result defines the Vector3 object where to store the result
  2458. * @returns the current Vector3
  2459. */
  2460. scaleToRef(scale: number, result: Vector3): Vector3;
  2461. /**
  2462. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2463. * @param scale defines the scale factor
  2464. * @param result defines the Vector3 object where to store the result
  2465. * @returns the unmodified current Vector3
  2466. */
  2467. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2468. /**
  2469. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2470. * @param otherVector defines the second operand
  2471. * @returns true if both vectors are equals
  2472. */
  2473. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2474. /**
  2475. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2476. * @param otherVector defines the second operand
  2477. * @param epsilon defines the minimal distance to define values as equals
  2478. * @returns true if both vectors are distant less than epsilon
  2479. */
  2480. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2481. /**
  2482. * Returns true if the current Vector3 coordinates equals the given floats
  2483. * @param x defines the x coordinate of the operand
  2484. * @param y defines the y coordinate of the operand
  2485. * @param z defines the z coordinate of the operand
  2486. * @returns true if both vectors are equals
  2487. */
  2488. equalsToFloats(x: number, y: number, z: number): boolean;
  2489. /**
  2490. * Multiplies the current Vector3 coordinates by the given ones
  2491. * @param otherVector defines the second operand
  2492. * @returns the current updated Vector3
  2493. */
  2494. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2495. /**
  2496. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2497. * @param otherVector defines the second operand
  2498. * @returns the new Vector3
  2499. */
  2500. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2501. /**
  2502. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2503. * @param otherVector defines the second operand
  2504. * @param result defines the Vector3 object where to store the result
  2505. * @returns the current Vector3
  2506. */
  2507. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2508. /**
  2509. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2510. * @param x defines the x coordinate of the operand
  2511. * @param y defines the y coordinate of the operand
  2512. * @param z defines the z coordinate of the operand
  2513. * @returns the new Vector3
  2514. */
  2515. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2516. /**
  2517. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2518. * @param otherVector defines the second operand
  2519. * @returns the new Vector3
  2520. */
  2521. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2522. /**
  2523. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2524. * @param otherVector defines the second operand
  2525. * @param result defines the Vector3 object where to store the result
  2526. * @returns the current Vector3
  2527. */
  2528. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2529. /**
  2530. * Divides the current Vector3 coordinates by the given ones.
  2531. * @param otherVector defines the second operand
  2532. * @returns the current updated Vector3
  2533. */
  2534. divideInPlace(otherVector: Vector3): Vector3;
  2535. /**
  2536. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2537. * @param other defines the second operand
  2538. * @returns the current updated Vector3
  2539. */
  2540. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2541. /**
  2542. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2543. * @param other defines the second operand
  2544. * @returns the current updated Vector3
  2545. */
  2546. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2547. /**
  2548. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2549. * @param x defines the x coordinate of the operand
  2550. * @param y defines the y coordinate of the operand
  2551. * @param z defines the z coordinate of the operand
  2552. * @returns the current updated Vector3
  2553. */
  2554. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2555. /**
  2556. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2557. * @param x defines the x coordinate of the operand
  2558. * @param y defines the y coordinate of the operand
  2559. * @param z defines the z coordinate of the operand
  2560. * @returns the current updated Vector3
  2561. */
  2562. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2563. /**
  2564. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2565. * Check if is non uniform within a certain amount of decimal places to account for this
  2566. * @param epsilon the amount the values can differ
  2567. * @returns if the the vector is non uniform to a certain number of decimal places
  2568. */
  2569. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2570. /**
  2571. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2572. */
  2573. readonly isNonUniform: boolean;
  2574. /**
  2575. * Gets a new Vector3 from current Vector3 floored values
  2576. * @returns a new Vector3
  2577. */
  2578. floor(): Vector3;
  2579. /**
  2580. * Gets a new Vector3 from current Vector3 floored values
  2581. * @returns a new Vector3
  2582. */
  2583. fract(): Vector3;
  2584. /**
  2585. * Gets the length of the Vector3
  2586. * @returns the length of the Vector3
  2587. */
  2588. length(): number;
  2589. /**
  2590. * Gets the squared length of the Vector3
  2591. * @returns squared length of the Vector3
  2592. */
  2593. lengthSquared(): number;
  2594. /**
  2595. * Normalize the current Vector3.
  2596. * Please note that this is an in place operation.
  2597. * @returns the current updated Vector3
  2598. */
  2599. normalize(): Vector3;
  2600. /**
  2601. * Reorders the x y z properties of the vector in place
  2602. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2603. * @returns the current updated vector
  2604. */
  2605. reorderInPlace(order: string): this;
  2606. /**
  2607. * Rotates the vector around 0,0,0 by a quaternion
  2608. * @param quaternion the rotation quaternion
  2609. * @param result vector to store the result
  2610. * @returns the resulting vector
  2611. */
  2612. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2613. /**
  2614. * Rotates a vector around a given point
  2615. * @param quaternion the rotation quaternion
  2616. * @param point the point to rotate around
  2617. * @param result vector to store the result
  2618. * @returns the resulting vector
  2619. */
  2620. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2621. /**
  2622. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2623. * The cross product is then orthogonal to both current and "other"
  2624. * @param other defines the right operand
  2625. * @returns the cross product
  2626. */
  2627. cross(other: Vector3): Vector3;
  2628. /**
  2629. * Normalize the current Vector3 with the given input length.
  2630. * Please note that this is an in place operation.
  2631. * @param len the length of the vector
  2632. * @returns the current updated Vector3
  2633. */
  2634. normalizeFromLength(len: number): Vector3;
  2635. /**
  2636. * Normalize the current Vector3 to a new vector
  2637. * @returns the new Vector3
  2638. */
  2639. normalizeToNew(): Vector3;
  2640. /**
  2641. * Normalize the current Vector3 to the reference
  2642. * @param reference define the Vector3 to update
  2643. * @returns the updated Vector3
  2644. */
  2645. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2646. /**
  2647. * Creates a new Vector3 copied from the current Vector3
  2648. * @returns the new Vector3
  2649. */
  2650. clone(): Vector3;
  2651. /**
  2652. * Copies the given vector coordinates to the current Vector3 ones
  2653. * @param source defines the source Vector3
  2654. * @returns the current updated Vector3
  2655. */
  2656. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2657. /**
  2658. * Copies the given floats to the current Vector3 coordinates
  2659. * @param x defines the x coordinate of the operand
  2660. * @param y defines the y coordinate of the operand
  2661. * @param z defines the z coordinate of the operand
  2662. * @returns the current updated Vector3
  2663. */
  2664. copyFromFloats(x: number, y: number, z: number): Vector3;
  2665. /**
  2666. * Copies the given floats to the current Vector3 coordinates
  2667. * @param x defines the x coordinate of the operand
  2668. * @param y defines the y coordinate of the operand
  2669. * @param z defines the z coordinate of the operand
  2670. * @returns the current updated Vector3
  2671. */
  2672. set(x: number, y: number, z: number): Vector3;
  2673. /**
  2674. * Copies the given float to the current Vector3 coordinates
  2675. * @param v defines the x, y and z coordinates of the operand
  2676. * @returns the current updated Vector3
  2677. */
  2678. setAll(v: number): Vector3;
  2679. /**
  2680. * Get the clip factor between two vectors
  2681. * @param vector0 defines the first operand
  2682. * @param vector1 defines the second operand
  2683. * @param axis defines the axis to use
  2684. * @param size defines the size along the axis
  2685. * @returns the clip factor
  2686. */
  2687. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2688. /**
  2689. * Get angle between two vectors
  2690. * @param vector0 angle between vector0 and vector1
  2691. * @param vector1 angle between vector0 and vector1
  2692. * @param normal direction of the normal
  2693. * @return the angle between vector0 and vector1
  2694. */
  2695. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2696. /**
  2697. * Returns a new Vector3 set from the index "offset" of the given array
  2698. * @param array defines the source array
  2699. * @param offset defines the offset in the source array
  2700. * @returns the new Vector3
  2701. */
  2702. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2703. /**
  2704. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2705. * @param array defines the source array
  2706. * @param offset defines the offset in the source array
  2707. * @returns the new Vector3
  2708. * @deprecated Please use FromArray instead.
  2709. */
  2710. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2711. /**
  2712. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2713. * @param array defines the source array
  2714. * @param offset defines the offset in the source array
  2715. * @param result defines the Vector3 where to store the result
  2716. */
  2717. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2718. /**
  2719. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2720. * @param array defines the source array
  2721. * @param offset defines the offset in the source array
  2722. * @param result defines the Vector3 where to store the result
  2723. * @deprecated Please use FromArrayToRef instead.
  2724. */
  2725. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2726. /**
  2727. * Sets the given vector "result" with the given floats.
  2728. * @param x defines the x coordinate of the source
  2729. * @param y defines the y coordinate of the source
  2730. * @param z defines the z coordinate of the source
  2731. * @param result defines the Vector3 where to store the result
  2732. */
  2733. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2734. /**
  2735. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2736. * @returns a new empty Vector3
  2737. */
  2738. static Zero(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2741. * @returns a new unit Vector3
  2742. */
  2743. static One(): Vector3;
  2744. /**
  2745. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2746. * @returns a new up Vector3
  2747. */
  2748. static Up(): Vector3;
  2749. /**
  2750. * Gets a up Vector3 that must not be updated
  2751. */
  2752. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2753. /**
  2754. * Gets a zero Vector3 that must not be updated
  2755. */
  2756. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2759. * @returns a new down Vector3
  2760. */
  2761. static Down(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2764. * @returns a new forward Vector3
  2765. */
  2766. static Forward(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2769. * @returns a new forward Vector3
  2770. */
  2771. static Backward(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2774. * @returns a new right Vector3
  2775. */
  2776. static Right(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2779. * @returns a new left Vector3
  2780. */
  2781. static Left(): Vector3;
  2782. /**
  2783. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2784. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2785. * @param vector defines the Vector3 to transform
  2786. * @param transformation defines the transformation matrix
  2787. * @returns the transformed Vector3
  2788. */
  2789. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2790. /**
  2791. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2792. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2793. * @param vector defines the Vector3 to transform
  2794. * @param transformation defines the transformation matrix
  2795. * @param result defines the Vector3 where to store the result
  2796. */
  2797. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2798. /**
  2799. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2800. * This method computes tranformed coordinates only, not transformed direction vectors
  2801. * @param x define the x coordinate of the source vector
  2802. * @param y define the y coordinate of the source vector
  2803. * @param z define the z coordinate of the source vector
  2804. * @param transformation defines the transformation matrix
  2805. * @param result defines the Vector3 where to store the result
  2806. */
  2807. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2808. /**
  2809. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2810. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2811. * @param vector defines the Vector3 to transform
  2812. * @param transformation defines the transformation matrix
  2813. * @returns the new Vector3
  2814. */
  2815. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2816. /**
  2817. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2818. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2819. * @param vector defines the Vector3 to transform
  2820. * @param transformation defines the transformation matrix
  2821. * @param result defines the Vector3 where to store the result
  2822. */
  2823. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2824. /**
  2825. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2826. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2827. * @param x define the x coordinate of the source vector
  2828. * @param y define the y coordinate of the source vector
  2829. * @param z define the z coordinate of the source vector
  2830. * @param transformation defines the transformation matrix
  2831. * @param result defines the Vector3 where to store the result
  2832. */
  2833. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2834. /**
  2835. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2836. * @param value1 defines the first control point
  2837. * @param value2 defines the second control point
  2838. * @param value3 defines the third control point
  2839. * @param value4 defines the fourth control point
  2840. * @param amount defines the amount on the spline to use
  2841. * @returns the new Vector3
  2842. */
  2843. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2844. /**
  2845. * 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"
  2846. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2847. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2848. * @param value defines the current value
  2849. * @param min defines the lower range value
  2850. * @param max defines the upper range value
  2851. * @returns the new Vector3
  2852. */
  2853. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2854. /**
  2855. * 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"
  2856. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2857. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2858. * @param value defines the current value
  2859. * @param min defines the lower range value
  2860. * @param max defines the upper range value
  2861. * @param result defines the Vector3 where to store the result
  2862. */
  2863. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2864. /**
  2865. * Checks if a given vector is inside a specific range
  2866. * @param v defines the vector to test
  2867. * @param min defines the minimum range
  2868. * @param max defines the maximum range
  2869. */
  2870. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2871. /**
  2872. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2873. * @param value1 defines the first control point
  2874. * @param tangent1 defines the first tangent vector
  2875. * @param value2 defines the second control point
  2876. * @param tangent2 defines the second tangent vector
  2877. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2878. * @returns the new Vector3
  2879. */
  2880. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2881. /**
  2882. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2883. * @param start defines the start value
  2884. * @param end defines the end value
  2885. * @param amount max defines amount between both (between 0 and 1)
  2886. * @returns the new Vector3
  2887. */
  2888. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2889. /**
  2890. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2891. * @param start defines the start value
  2892. * @param end defines the end value
  2893. * @param amount max defines amount between both (between 0 and 1)
  2894. * @param result defines the Vector3 where to store the result
  2895. */
  2896. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2897. /**
  2898. * Returns the dot product (float) between the vectors "left" and "right"
  2899. * @param left defines the left operand
  2900. * @param right defines the right operand
  2901. * @returns the dot product
  2902. */
  2903. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2904. /**
  2905. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2906. * The cross product is then orthogonal to both "left" and "right"
  2907. * @param left defines the left operand
  2908. * @param right defines the right operand
  2909. * @returns the cross product
  2910. */
  2911. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2912. /**
  2913. * Sets the given vector "result" with the cross product of "left" and "right"
  2914. * The cross product is then orthogonal to both "left" and "right"
  2915. * @param left defines the left operand
  2916. * @param right defines the right operand
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2920. /**
  2921. * Returns a new Vector3 as the normalization of the given vector
  2922. * @param vector defines the Vector3 to normalize
  2923. * @returns the new Vector3
  2924. */
  2925. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2926. /**
  2927. * Sets the given vector "result" with the normalization of the given first vector
  2928. * @param vector defines the Vector3 to normalize
  2929. * @param result defines the Vector3 where to store the result
  2930. */
  2931. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2932. /**
  2933. * Project a Vector3 onto screen space
  2934. * @param vector defines the Vector3 to project
  2935. * @param world defines the world matrix to use
  2936. * @param transform defines the transform (view x projection) matrix to use
  2937. * @param viewport defines the screen viewport to use
  2938. * @returns the new Vector3
  2939. */
  2940. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2941. /** @hidden */
  2942. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2943. /**
  2944. * Unproject from screen space to object space
  2945. * @param source defines the screen space Vector3 to use
  2946. * @param viewportWidth defines the current width of the viewport
  2947. * @param viewportHeight defines the current height of the viewport
  2948. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2949. * @param transform defines the transform (view x projection) matrix to use
  2950. * @returns the new Vector3
  2951. */
  2952. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2953. /**
  2954. * Unproject from screen space to object space
  2955. * @param source defines the screen space Vector3 to use
  2956. * @param viewportWidth defines the current width of the viewport
  2957. * @param viewportHeight defines the current height of the viewport
  2958. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2959. * @param view defines the view matrix to use
  2960. * @param projection defines the projection matrix to use
  2961. * @returns the new Vector3
  2962. */
  2963. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2964. /**
  2965. * Unproject from screen space to object space
  2966. * @param source defines the screen space Vector3 to use
  2967. * @param viewportWidth defines the current width of the viewport
  2968. * @param viewportHeight defines the current height of the viewport
  2969. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2970. * @param view defines the view matrix to use
  2971. * @param projection defines the projection matrix to use
  2972. * @param result defines the Vector3 where to store the result
  2973. */
  2974. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2975. /**
  2976. * Unproject from screen space to object space
  2977. * @param sourceX defines the screen space x coordinate to use
  2978. * @param sourceY defines the screen space y coordinate to use
  2979. * @param sourceZ defines the screen space z coordinate to use
  2980. * @param viewportWidth defines the current width of the viewport
  2981. * @param viewportHeight defines the current height of the viewport
  2982. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2983. * @param view defines the view matrix to use
  2984. * @param projection defines the projection matrix to use
  2985. * @param result defines the Vector3 where to store the result
  2986. */
  2987. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2988. /**
  2989. * Gets the minimal coordinate values between two Vector3
  2990. * @param left defines the first operand
  2991. * @param right defines the second operand
  2992. * @returns the new Vector3
  2993. */
  2994. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2995. /**
  2996. * Gets the maximal coordinate values between two Vector3
  2997. * @param left defines the first operand
  2998. * @param right defines the second operand
  2999. * @returns the new Vector3
  3000. */
  3001. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3002. /**
  3003. * Returns the distance between the vectors "value1" and "value2"
  3004. * @param value1 defines the first operand
  3005. * @param value2 defines the second operand
  3006. * @returns the distance
  3007. */
  3008. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3009. /**
  3010. * Returns the squared distance between the vectors "value1" and "value2"
  3011. * @param value1 defines the first operand
  3012. * @param value2 defines the second operand
  3013. * @returns the squared distance
  3014. */
  3015. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3016. /**
  3017. * Returns a new Vector3 located at the center between "value1" and "value2"
  3018. * @param value1 defines the first operand
  3019. * @param value2 defines the second operand
  3020. * @returns the new Vector3
  3021. */
  3022. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3023. /**
  3024. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3025. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3026. * to something in order to rotate it from its local system to the given target system
  3027. * Note: axis1, axis2 and axis3 are normalized during this operation
  3028. * @param axis1 defines the first axis
  3029. * @param axis2 defines the second axis
  3030. * @param axis3 defines the third axis
  3031. * @returns a new Vector3
  3032. */
  3033. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3034. /**
  3035. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3036. * @param axis1 defines the first axis
  3037. * @param axis2 defines the second axis
  3038. * @param axis3 defines the third axis
  3039. * @param ref defines the Vector3 where to store the result
  3040. */
  3041. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3042. }
  3043. /**
  3044. * Vector4 class created for EulerAngle class conversion to Quaternion
  3045. */
  3046. export class Vector4 {
  3047. /** x value of the vector */
  3048. x: number;
  3049. /** y value of the vector */
  3050. y: number;
  3051. /** z value of the vector */
  3052. z: number;
  3053. /** w value of the vector */
  3054. w: number;
  3055. /**
  3056. * Creates a Vector4 object from the given floats.
  3057. * @param x x value of the vector
  3058. * @param y y value of the vector
  3059. * @param z z value of the vector
  3060. * @param w w value of the vector
  3061. */
  3062. constructor(
  3063. /** x value of the vector */
  3064. x: number,
  3065. /** y value of the vector */
  3066. y: number,
  3067. /** z value of the vector */
  3068. z: number,
  3069. /** w value of the vector */
  3070. w: number);
  3071. /**
  3072. * Returns the string with the Vector4 coordinates.
  3073. * @returns a string containing all the vector values
  3074. */
  3075. toString(): string;
  3076. /**
  3077. * Returns the string "Vector4".
  3078. * @returns "Vector4"
  3079. */
  3080. getClassName(): string;
  3081. /**
  3082. * Returns the Vector4 hash code.
  3083. * @returns a unique hash code
  3084. */
  3085. getHashCode(): number;
  3086. /**
  3087. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3088. * @returns the resulting array
  3089. */
  3090. asArray(): number[];
  3091. /**
  3092. * Populates the given array from the given index with the Vector4 coordinates.
  3093. * @param array array to populate
  3094. * @param index index of the array to start at (default: 0)
  3095. * @returns the Vector4.
  3096. */
  3097. toArray(array: FloatArray, index?: number): Vector4;
  3098. /**
  3099. * Adds the given vector to the current Vector4.
  3100. * @param otherVector the vector to add
  3101. * @returns the updated Vector4.
  3102. */
  3103. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3104. /**
  3105. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3106. * @param otherVector the vector to add
  3107. * @returns the resulting vector
  3108. */
  3109. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3110. /**
  3111. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3112. * @param otherVector the vector to add
  3113. * @param result the vector to store the result
  3114. * @returns the current Vector4.
  3115. */
  3116. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3117. /**
  3118. * Subtract in place the given vector from the current Vector4.
  3119. * @param otherVector the vector to subtract
  3120. * @returns the updated Vector4.
  3121. */
  3122. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3123. /**
  3124. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3125. * @param otherVector the vector to add
  3126. * @returns the new vector with the result
  3127. */
  3128. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3129. /**
  3130. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3131. * @param otherVector the vector to subtract
  3132. * @param result the vector to store the result
  3133. * @returns the current Vector4.
  3134. */
  3135. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3136. /**
  3137. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3138. */
  3139. /**
  3140. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3141. * @param x value to subtract
  3142. * @param y value to subtract
  3143. * @param z value to subtract
  3144. * @param w value to subtract
  3145. * @returns new vector containing the result
  3146. */
  3147. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3148. /**
  3149. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3150. * @param x value to subtract
  3151. * @param y value to subtract
  3152. * @param z value to subtract
  3153. * @param w value to subtract
  3154. * @param result the vector to store the result in
  3155. * @returns the current Vector4.
  3156. */
  3157. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3158. /**
  3159. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3160. * @returns a new vector with the negated values
  3161. */
  3162. negate(): Vector4;
  3163. /**
  3164. * Multiplies the current Vector4 coordinates by scale (float).
  3165. * @param scale the number to scale with
  3166. * @returns the updated Vector4.
  3167. */
  3168. scaleInPlace(scale: number): Vector4;
  3169. /**
  3170. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3171. * @param scale the number to scale with
  3172. * @returns a new vector with the result
  3173. */
  3174. scale(scale: number): Vector4;
  3175. /**
  3176. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3177. * @param scale the number to scale with
  3178. * @param result a vector to store the result in
  3179. * @returns the current Vector4.
  3180. */
  3181. scaleToRef(scale: number, result: Vector4): Vector4;
  3182. /**
  3183. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3184. * @param scale defines the scale factor
  3185. * @param result defines the Vector4 object where to store the result
  3186. * @returns the unmodified current Vector4
  3187. */
  3188. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3189. /**
  3190. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3191. * @param otherVector the vector to compare against
  3192. * @returns true if they are equal
  3193. */
  3194. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3195. /**
  3196. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3197. * @param otherVector vector to compare against
  3198. * @param epsilon (Default: very small number)
  3199. * @returns true if they are equal
  3200. */
  3201. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3202. /**
  3203. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3204. * @param x x value to compare against
  3205. * @param y y value to compare against
  3206. * @param z z value to compare against
  3207. * @param w w value to compare against
  3208. * @returns true if equal
  3209. */
  3210. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3211. /**
  3212. * Multiplies in place the current Vector4 by the given one.
  3213. * @param otherVector vector to multiple with
  3214. * @returns the updated Vector4.
  3215. */
  3216. multiplyInPlace(otherVector: Vector4): Vector4;
  3217. /**
  3218. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3219. * @param otherVector vector to multiple with
  3220. * @returns resulting new vector
  3221. */
  3222. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3223. /**
  3224. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3225. * @param otherVector vector to multiple with
  3226. * @param result vector to store the result
  3227. * @returns the current Vector4.
  3228. */
  3229. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3230. /**
  3231. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3232. * @param x x value multiply with
  3233. * @param y y value multiply with
  3234. * @param z z value multiply with
  3235. * @param w w value multiply with
  3236. * @returns resulting new vector
  3237. */
  3238. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3239. /**
  3240. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3241. * @param otherVector vector to devide with
  3242. * @returns resulting new vector
  3243. */
  3244. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3245. /**
  3246. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3247. * @param otherVector vector to devide with
  3248. * @param result vector to store the result
  3249. * @returns the current Vector4.
  3250. */
  3251. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3252. /**
  3253. * Divides the current Vector3 coordinates by the given ones.
  3254. * @param otherVector vector to devide with
  3255. * @returns the updated Vector3.
  3256. */
  3257. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3258. /**
  3259. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3260. * @param other defines the second operand
  3261. * @returns the current updated Vector4
  3262. */
  3263. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3264. /**
  3265. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3266. * @param other defines the second operand
  3267. * @returns the current updated Vector4
  3268. */
  3269. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3270. /**
  3271. * Gets a new Vector4 from current Vector4 floored values
  3272. * @returns a new Vector4
  3273. */
  3274. floor(): Vector4;
  3275. /**
  3276. * Gets a new Vector4 from current Vector3 floored values
  3277. * @returns a new Vector4
  3278. */
  3279. fract(): Vector4;
  3280. /**
  3281. * Returns the Vector4 length (float).
  3282. * @returns the length
  3283. */
  3284. length(): number;
  3285. /**
  3286. * Returns the Vector4 squared length (float).
  3287. * @returns the length squared
  3288. */
  3289. lengthSquared(): number;
  3290. /**
  3291. * Normalizes in place the Vector4.
  3292. * @returns the updated Vector4.
  3293. */
  3294. normalize(): Vector4;
  3295. /**
  3296. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3297. * @returns this converted to a new vector3
  3298. */
  3299. toVector3(): Vector3;
  3300. /**
  3301. * Returns a new Vector4 copied from the current one.
  3302. * @returns the new cloned vector
  3303. */
  3304. clone(): Vector4;
  3305. /**
  3306. * Updates the current Vector4 with the given one coordinates.
  3307. * @param source the source vector to copy from
  3308. * @returns the updated Vector4.
  3309. */
  3310. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3311. /**
  3312. * Updates the current Vector4 coordinates with the given floats.
  3313. * @param x float to copy from
  3314. * @param y float to copy from
  3315. * @param z float to copy from
  3316. * @param w float to copy from
  3317. * @returns the updated Vector4.
  3318. */
  3319. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3320. /**
  3321. * Updates the current Vector4 coordinates with the given floats.
  3322. * @param x float to set from
  3323. * @param y float to set from
  3324. * @param z float to set from
  3325. * @param w float to set from
  3326. * @returns the updated Vector4.
  3327. */
  3328. set(x: number, y: number, z: number, w: number): Vector4;
  3329. /**
  3330. * Copies the given float to the current Vector3 coordinates
  3331. * @param v defines the x, y, z and w coordinates of the operand
  3332. * @returns the current updated Vector3
  3333. */
  3334. setAll(v: number): Vector4;
  3335. /**
  3336. * Returns a new Vector4 set from the starting index of the given array.
  3337. * @param array the array to pull values from
  3338. * @param offset the offset into the array to start at
  3339. * @returns the new vector
  3340. */
  3341. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3342. /**
  3343. * Updates the given vector "result" from the starting index of the given array.
  3344. * @param array the array to pull values from
  3345. * @param offset the offset into the array to start at
  3346. * @param result the vector to store the result in
  3347. */
  3348. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3349. /**
  3350. * Updates the given vector "result" from the starting index of the given Float32Array.
  3351. * @param array the array to pull values from
  3352. * @param offset the offset into the array to start at
  3353. * @param result the vector to store the result in
  3354. */
  3355. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3356. /**
  3357. * Updates the given vector "result" coordinates from the given floats.
  3358. * @param x float to set from
  3359. * @param y float to set from
  3360. * @param z float to set from
  3361. * @param w float to set from
  3362. * @param result the vector to the floats in
  3363. */
  3364. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3365. /**
  3366. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3367. * @returns the new vector
  3368. */
  3369. static Zero(): Vector4;
  3370. /**
  3371. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3372. * @returns the new vector
  3373. */
  3374. static One(): Vector4;
  3375. /**
  3376. * Returns a new normalized Vector4 from the given one.
  3377. * @param vector the vector to normalize
  3378. * @returns the vector
  3379. */
  3380. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3381. /**
  3382. * Updates the given vector "result" from the normalization of the given one.
  3383. * @param vector the vector to normalize
  3384. * @param result the vector to store the result in
  3385. */
  3386. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3387. /**
  3388. * Returns a vector with the minimum values from the left and right vectors
  3389. * @param left left vector to minimize
  3390. * @param right right vector to minimize
  3391. * @returns a new vector with the minimum of the left and right vector values
  3392. */
  3393. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3394. /**
  3395. * Returns a vector with the maximum values from the left and right vectors
  3396. * @param left left vector to maximize
  3397. * @param right right vector to maximize
  3398. * @returns a new vector with the maximum of the left and right vector values
  3399. */
  3400. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3401. /**
  3402. * Returns the distance (float) between the vectors "value1" and "value2".
  3403. * @param value1 value to calulate the distance between
  3404. * @param value2 value to calulate the distance between
  3405. * @return the distance between the two vectors
  3406. */
  3407. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3408. /**
  3409. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3410. * @param value1 value to calulate the distance between
  3411. * @param value2 value to calulate the distance between
  3412. * @return the distance between the two vectors squared
  3413. */
  3414. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3415. /**
  3416. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3417. * @param value1 value to calulate the center between
  3418. * @param value2 value to calulate the center between
  3419. * @return the center between the two vectors
  3420. */
  3421. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3422. /**
  3423. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3424. * This methods computes transformed normalized direction vectors only.
  3425. * @param vector the vector to transform
  3426. * @param transformation the transformation matrix to apply
  3427. * @returns the new vector
  3428. */
  3429. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3430. /**
  3431. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3432. * This methods computes transformed normalized direction vectors only.
  3433. * @param vector the vector to transform
  3434. * @param transformation the transformation matrix to apply
  3435. * @param result the vector to store the result in
  3436. */
  3437. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3438. /**
  3439. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3440. * This methods computes transformed normalized direction vectors only.
  3441. * @param x value to transform
  3442. * @param y value to transform
  3443. * @param z value to transform
  3444. * @param w value to transform
  3445. * @param transformation the transformation matrix to apply
  3446. * @param result the vector to store the results in
  3447. */
  3448. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3449. /**
  3450. * Creates a new Vector4 from a Vector3
  3451. * @param source defines the source data
  3452. * @param w defines the 4th component (default is 0)
  3453. * @returns a new Vector4
  3454. */
  3455. static FromVector3(source: Vector3, w?: number): Vector4;
  3456. }
  3457. /**
  3458. * Class used to store quaternion data
  3459. * @see https://en.wikipedia.org/wiki/Quaternion
  3460. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3461. */
  3462. export class Quaternion {
  3463. /** defines the first component (0 by default) */
  3464. x: number;
  3465. /** defines the second component (0 by default) */
  3466. y: number;
  3467. /** defines the third component (0 by default) */
  3468. z: number;
  3469. /** defines the fourth component (1.0 by default) */
  3470. w: number;
  3471. /**
  3472. * Creates a new Quaternion from the given floats
  3473. * @param x defines the first component (0 by default)
  3474. * @param y defines the second component (0 by default)
  3475. * @param z defines the third component (0 by default)
  3476. * @param w defines the fourth component (1.0 by default)
  3477. */
  3478. constructor(
  3479. /** defines the first component (0 by default) */
  3480. x?: number,
  3481. /** defines the second component (0 by default) */
  3482. y?: number,
  3483. /** defines the third component (0 by default) */
  3484. z?: number,
  3485. /** defines the fourth component (1.0 by default) */
  3486. w?: number);
  3487. /**
  3488. * Gets a string representation for the current quaternion
  3489. * @returns a string with the Quaternion coordinates
  3490. */
  3491. toString(): string;
  3492. /**
  3493. * Gets the class name of the quaternion
  3494. * @returns the string "Quaternion"
  3495. */
  3496. getClassName(): string;
  3497. /**
  3498. * Gets a hash code for this quaternion
  3499. * @returns the quaternion hash code
  3500. */
  3501. getHashCode(): number;
  3502. /**
  3503. * Copy the quaternion to an array
  3504. * @returns a new array populated with 4 elements from the quaternion coordinates
  3505. */
  3506. asArray(): number[];
  3507. /**
  3508. * Check if two quaternions are equals
  3509. * @param otherQuaternion defines the second operand
  3510. * @return true if the current quaternion and the given one coordinates are strictly equals
  3511. */
  3512. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3513. /**
  3514. * Clone the current quaternion
  3515. * @returns a new quaternion copied from the current one
  3516. */
  3517. clone(): Quaternion;
  3518. /**
  3519. * Copy a quaternion to the current one
  3520. * @param other defines the other quaternion
  3521. * @returns the updated current quaternion
  3522. */
  3523. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3524. /**
  3525. * Updates the current quaternion with the given float coordinates
  3526. * @param x defines the x coordinate
  3527. * @param y defines the y coordinate
  3528. * @param z defines the z coordinate
  3529. * @param w defines the w coordinate
  3530. * @returns the updated current quaternion
  3531. */
  3532. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3533. /**
  3534. * Updates the current quaternion from the given float coordinates
  3535. * @param x defines the x coordinate
  3536. * @param y defines the y coordinate
  3537. * @param z defines the z coordinate
  3538. * @param w defines the w coordinate
  3539. * @returns the updated current quaternion
  3540. */
  3541. set(x: number, y: number, z: number, w: number): Quaternion;
  3542. /**
  3543. * Adds two quaternions
  3544. * @param other defines the second operand
  3545. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3546. */
  3547. add(other: DeepImmutable<Quaternion>): Quaternion;
  3548. /**
  3549. * Add a quaternion to the current one
  3550. * @param other defines the quaternion to add
  3551. * @returns the current quaternion
  3552. */
  3553. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3554. /**
  3555. * Subtract two quaternions
  3556. * @param other defines the second operand
  3557. * @returns a new quaternion as the subtraction result of the given one from the current one
  3558. */
  3559. subtract(other: Quaternion): Quaternion;
  3560. /**
  3561. * Multiplies the current quaternion by a scale factor
  3562. * @param value defines the scale factor
  3563. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3564. */
  3565. scale(value: number): Quaternion;
  3566. /**
  3567. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3568. * @param scale defines the scale factor
  3569. * @param result defines the Quaternion object where to store the result
  3570. * @returns the unmodified current quaternion
  3571. */
  3572. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3573. /**
  3574. * Multiplies in place the current quaternion by a scale factor
  3575. * @param value defines the scale factor
  3576. * @returns the current modified quaternion
  3577. */
  3578. scaleInPlace(value: number): Quaternion;
  3579. /**
  3580. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3581. * @param scale defines the scale factor
  3582. * @param result defines the Quaternion object where to store the result
  3583. * @returns the unmodified current quaternion
  3584. */
  3585. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3586. /**
  3587. * Multiplies two quaternions
  3588. * @param q1 defines the second operand
  3589. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3590. */
  3591. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3592. /**
  3593. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3594. * @param q1 defines the second operand
  3595. * @param result defines the target quaternion
  3596. * @returns the current quaternion
  3597. */
  3598. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3599. /**
  3600. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3601. * @param q1 defines the second operand
  3602. * @returns the currentupdated quaternion
  3603. */
  3604. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3605. /**
  3606. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3607. * @param ref defines the target quaternion
  3608. * @returns the current quaternion
  3609. */
  3610. conjugateToRef(ref: Quaternion): Quaternion;
  3611. /**
  3612. * Conjugates in place (1-q) the current quaternion
  3613. * @returns the current updated quaternion
  3614. */
  3615. conjugateInPlace(): Quaternion;
  3616. /**
  3617. * Conjugates in place (1-q) the current quaternion
  3618. * @returns a new quaternion
  3619. */
  3620. conjugate(): Quaternion;
  3621. /**
  3622. * Gets length of current quaternion
  3623. * @returns the quaternion length (float)
  3624. */
  3625. length(): number;
  3626. /**
  3627. * Normalize in place the current quaternion
  3628. * @returns the current updated quaternion
  3629. */
  3630. normalize(): Quaternion;
  3631. /**
  3632. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3633. * @param order is a reserved parameter and is ignore for now
  3634. * @returns a new Vector3 containing the Euler angles
  3635. */
  3636. toEulerAngles(order?: string): Vector3;
  3637. /**
  3638. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3639. * @param result defines the vector which will be filled with the Euler angles
  3640. * @param order is a reserved parameter and is ignore for now
  3641. * @returns the current unchanged quaternion
  3642. */
  3643. toEulerAnglesToRef(result: Vector3): Quaternion;
  3644. /**
  3645. * Updates the given rotation matrix with the current quaternion values
  3646. * @param result defines the target matrix
  3647. * @returns the current unchanged quaternion
  3648. */
  3649. toRotationMatrix(result: Matrix): Quaternion;
  3650. /**
  3651. * Updates the current quaternion from the given rotation matrix values
  3652. * @param matrix defines the source matrix
  3653. * @returns the current updated quaternion
  3654. */
  3655. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3656. /**
  3657. * Creates a new quaternion from a rotation matrix
  3658. * @param matrix defines the source matrix
  3659. * @returns a new quaternion created from the given rotation matrix values
  3660. */
  3661. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3662. /**
  3663. * Updates the given quaternion with the given rotation matrix values
  3664. * @param matrix defines the source matrix
  3665. * @param result defines the target quaternion
  3666. */
  3667. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3668. /**
  3669. * Returns the dot product (float) between the quaternions "left" and "right"
  3670. * @param left defines the left operand
  3671. * @param right defines the right operand
  3672. * @returns the dot product
  3673. */
  3674. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3675. /**
  3676. * Checks if the two quaternions are close to each other
  3677. * @param quat0 defines the first quaternion to check
  3678. * @param quat1 defines the second quaternion to check
  3679. * @returns true if the two quaternions are close to each other
  3680. */
  3681. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3682. /**
  3683. * Creates an empty quaternion
  3684. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3685. */
  3686. static Zero(): Quaternion;
  3687. /**
  3688. * Inverse a given quaternion
  3689. * @param q defines the source quaternion
  3690. * @returns a new quaternion as the inverted current quaternion
  3691. */
  3692. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3693. /**
  3694. * Inverse a given quaternion
  3695. * @param q defines the source quaternion
  3696. * @param result the quaternion the result will be stored in
  3697. * @returns the result quaternion
  3698. */
  3699. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3700. /**
  3701. * Creates an identity quaternion
  3702. * @returns the identity quaternion
  3703. */
  3704. static Identity(): Quaternion;
  3705. /**
  3706. * Gets a boolean indicating if the given quaternion is identity
  3707. * @param quaternion defines the quaternion to check
  3708. * @returns true if the quaternion is identity
  3709. */
  3710. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3711. /**
  3712. * Creates a quaternion from a rotation around an axis
  3713. * @param axis defines the axis to use
  3714. * @param angle defines the angle to use
  3715. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3716. */
  3717. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3718. /**
  3719. * Creates a rotation around an axis and stores it into the given quaternion
  3720. * @param axis defines the axis to use
  3721. * @param angle defines the angle to use
  3722. * @param result defines the target quaternion
  3723. * @returns the target quaternion
  3724. */
  3725. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3726. /**
  3727. * Creates a new quaternion from data stored into an array
  3728. * @param array defines the data source
  3729. * @param offset defines the offset in the source array where the data starts
  3730. * @returns a new quaternion
  3731. */
  3732. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3733. /**
  3734. * Create a quaternion from Euler rotation angles
  3735. * @param x Pitch
  3736. * @param y Yaw
  3737. * @param z Roll
  3738. * @returns the new Quaternion
  3739. */
  3740. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3741. /**
  3742. * Updates a quaternion from Euler rotation angles
  3743. * @param x Pitch
  3744. * @param y Yaw
  3745. * @param z Roll
  3746. * @param result the quaternion to store the result
  3747. * @returns the updated quaternion
  3748. */
  3749. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3750. /**
  3751. * Create a quaternion from Euler rotation vector
  3752. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3753. * @returns the new Quaternion
  3754. */
  3755. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3756. /**
  3757. * Updates a quaternion from Euler rotation vector
  3758. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3759. * @param result the quaternion to store the result
  3760. * @returns the updated quaternion
  3761. */
  3762. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3763. /**
  3764. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3765. * @param yaw defines the rotation around Y axis
  3766. * @param pitch defines the rotation around X axis
  3767. * @param roll defines the rotation around Z axis
  3768. * @returns the new quaternion
  3769. */
  3770. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3771. /**
  3772. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3773. * @param yaw defines the rotation around Y axis
  3774. * @param pitch defines the rotation around X axis
  3775. * @param roll defines the rotation around Z axis
  3776. * @param result defines the target quaternion
  3777. */
  3778. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3779. /**
  3780. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3781. * @param alpha defines the rotation around first axis
  3782. * @param beta defines the rotation around second axis
  3783. * @param gamma defines the rotation around third axis
  3784. * @returns the new quaternion
  3785. */
  3786. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3787. /**
  3788. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3789. * @param alpha defines the rotation around first axis
  3790. * @param beta defines the rotation around second axis
  3791. * @param gamma defines the rotation around third axis
  3792. * @param result defines the target quaternion
  3793. */
  3794. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3795. /**
  3796. * 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)
  3797. * @param axis1 defines the first axis
  3798. * @param axis2 defines the second axis
  3799. * @param axis3 defines the third axis
  3800. * @returns the new quaternion
  3801. */
  3802. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3803. /**
  3804. * 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
  3805. * @param axis1 defines the first axis
  3806. * @param axis2 defines the second axis
  3807. * @param axis3 defines the third axis
  3808. * @param ref defines the target quaternion
  3809. */
  3810. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3811. /**
  3812. * Interpolates between two quaternions
  3813. * @param left defines first quaternion
  3814. * @param right defines second quaternion
  3815. * @param amount defines the gradient to use
  3816. * @returns the new interpolated quaternion
  3817. */
  3818. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3819. /**
  3820. * Interpolates between two quaternions and stores it into a target quaternion
  3821. * @param left defines first quaternion
  3822. * @param right defines second quaternion
  3823. * @param amount defines the gradient to use
  3824. * @param result defines the target quaternion
  3825. */
  3826. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3827. /**
  3828. * Interpolate between two quaternions using Hermite interpolation
  3829. * @param value1 defines first quaternion
  3830. * @param tangent1 defines the incoming tangent
  3831. * @param value2 defines second quaternion
  3832. * @param tangent2 defines the outgoing tangent
  3833. * @param amount defines the target quaternion
  3834. * @returns the new interpolated quaternion
  3835. */
  3836. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3837. }
  3838. /**
  3839. * Class used to store matrix data (4x4)
  3840. */
  3841. export class Matrix {
  3842. private static _updateFlagSeed;
  3843. private static _identityReadOnly;
  3844. private _isIdentity;
  3845. private _isIdentityDirty;
  3846. private _isIdentity3x2;
  3847. private _isIdentity3x2Dirty;
  3848. /**
  3849. * Gets the update flag of the matrix which is an unique number for the matrix.
  3850. * It will be incremented every time the matrix data change.
  3851. * You can use it to speed the comparison between two versions of the same matrix.
  3852. */
  3853. updateFlag: number;
  3854. private readonly _m;
  3855. /**
  3856. * Gets the internal data of the matrix
  3857. */
  3858. readonly m: DeepImmutable<Float32Array>;
  3859. /** @hidden */
  3860. _markAsUpdated(): void;
  3861. /** @hidden */
  3862. private _updateIdentityStatus;
  3863. /**
  3864. * Creates an empty matrix (filled with zeros)
  3865. */
  3866. constructor();
  3867. /**
  3868. * Check if the current matrix is identity
  3869. * @returns true is the matrix is the identity matrix
  3870. */
  3871. isIdentity(): boolean;
  3872. /**
  3873. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3874. * @returns true is the matrix is the identity matrix
  3875. */
  3876. isIdentityAs3x2(): boolean;
  3877. /**
  3878. * Gets the determinant of the matrix
  3879. * @returns the matrix determinant
  3880. */
  3881. determinant(): number;
  3882. /**
  3883. * Returns the matrix as a Float32Array
  3884. * @returns the matrix underlying array
  3885. */
  3886. toArray(): DeepImmutable<Float32Array>;
  3887. /**
  3888. * Returns the matrix as a Float32Array
  3889. * @returns the matrix underlying array.
  3890. */
  3891. asArray(): DeepImmutable<Float32Array>;
  3892. /**
  3893. * Inverts the current matrix in place
  3894. * @returns the current inverted matrix
  3895. */
  3896. invert(): Matrix;
  3897. /**
  3898. * Sets all the matrix elements to zero
  3899. * @returns the current matrix
  3900. */
  3901. reset(): Matrix;
  3902. /**
  3903. * Adds the current matrix with a second one
  3904. * @param other defines the matrix to add
  3905. * @returns a new matrix as the addition of the current matrix and the given one
  3906. */
  3907. add(other: DeepImmutable<Matrix>): Matrix;
  3908. /**
  3909. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3910. * @param other defines the matrix to add
  3911. * @param result defines the target matrix
  3912. * @returns the current matrix
  3913. */
  3914. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3915. /**
  3916. * Adds in place the given matrix to the current matrix
  3917. * @param other defines the second operand
  3918. * @returns the current updated matrix
  3919. */
  3920. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3921. /**
  3922. * Sets the given matrix to the current inverted Matrix
  3923. * @param other defines the target matrix
  3924. * @returns the unmodified current matrix
  3925. */
  3926. invertToRef(other: Matrix): Matrix;
  3927. /**
  3928. * add a value at the specified position in the current Matrix
  3929. * @param index the index of the value within the matrix. between 0 and 15.
  3930. * @param value the value to be added
  3931. * @returns the current updated matrix
  3932. */
  3933. addAtIndex(index: number, value: number): Matrix;
  3934. /**
  3935. * mutiply the specified position in the current Matrix by a value
  3936. * @param index the index of the value within the matrix. between 0 and 15.
  3937. * @param value the value to be added
  3938. * @returns the current updated matrix
  3939. */
  3940. multiplyAtIndex(index: number, value: number): Matrix;
  3941. /**
  3942. * Inserts the translation vector (using 3 floats) in the current matrix
  3943. * @param x defines the 1st component of the translation
  3944. * @param y defines the 2nd component of the translation
  3945. * @param z defines the 3rd component of the translation
  3946. * @returns the current updated matrix
  3947. */
  3948. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3949. /**
  3950. * Adds the translation vector (using 3 floats) in the current matrix
  3951. * @param x defines the 1st component of the translation
  3952. * @param y defines the 2nd component of the translation
  3953. * @param z defines the 3rd component of the translation
  3954. * @returns the current updated matrix
  3955. */
  3956. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3957. /**
  3958. * Inserts the translation vector in the current matrix
  3959. * @param vector3 defines the translation to insert
  3960. * @returns the current updated matrix
  3961. */
  3962. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3963. /**
  3964. * Gets the translation value of the current matrix
  3965. * @returns a new Vector3 as the extracted translation from the matrix
  3966. */
  3967. getTranslation(): Vector3;
  3968. /**
  3969. * Fill a Vector3 with the extracted translation from the matrix
  3970. * @param result defines the Vector3 where to store the translation
  3971. * @returns the current matrix
  3972. */
  3973. getTranslationToRef(result: Vector3): Matrix;
  3974. /**
  3975. * Remove rotation and scaling part from the matrix
  3976. * @returns the updated matrix
  3977. */
  3978. removeRotationAndScaling(): Matrix;
  3979. /**
  3980. * Multiply two matrices
  3981. * @param other defines the second operand
  3982. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3983. */
  3984. multiply(other: DeepImmutable<Matrix>): Matrix;
  3985. /**
  3986. * Copy the current matrix from the given one
  3987. * @param other defines the source matrix
  3988. * @returns the current updated matrix
  3989. */
  3990. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3991. /**
  3992. * Populates the given array from the starting index with the current matrix values
  3993. * @param array defines the target array
  3994. * @param offset defines the offset in the target array where to start storing values
  3995. * @returns the current matrix
  3996. */
  3997. copyToArray(array: Float32Array, offset?: number): Matrix;
  3998. /**
  3999. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4000. * @param other defines the second operand
  4001. * @param result defines the matrix where to store the multiplication
  4002. * @returns the current matrix
  4003. */
  4004. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4005. /**
  4006. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4007. * @param other defines the second operand
  4008. * @param result defines the array where to store the multiplication
  4009. * @param offset defines the offset in the target array where to start storing values
  4010. * @returns the current matrix
  4011. */
  4012. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4013. /**
  4014. * Check equality between this matrix and a second one
  4015. * @param value defines the second matrix to compare
  4016. * @returns true is the current matrix and the given one values are strictly equal
  4017. */
  4018. equals(value: DeepImmutable<Matrix>): boolean;
  4019. /**
  4020. * Clone the current matrix
  4021. * @returns a new matrix from the current matrix
  4022. */
  4023. clone(): Matrix;
  4024. /**
  4025. * Returns the name of the current matrix class
  4026. * @returns the string "Matrix"
  4027. */
  4028. getClassName(): string;
  4029. /**
  4030. * Gets the hash code of the current matrix
  4031. * @returns the hash code
  4032. */
  4033. getHashCode(): number;
  4034. /**
  4035. * Decomposes the current Matrix into a translation, rotation and scaling components
  4036. * @param scale defines the scale vector3 given as a reference to update
  4037. * @param rotation defines the rotation quaternion given as a reference to update
  4038. * @param translation defines the translation vector3 given as a reference to update
  4039. * @returns true if operation was successful
  4040. */
  4041. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4042. /**
  4043. * Gets specific row of the matrix
  4044. * @param index defines the number of the row to get
  4045. * @returns the index-th row of the current matrix as a new Vector4
  4046. */
  4047. getRow(index: number): Nullable<Vector4>;
  4048. /**
  4049. * Sets the index-th row of the current matrix to the vector4 values
  4050. * @param index defines the number of the row to set
  4051. * @param row defines the target vector4
  4052. * @returns the updated current matrix
  4053. */
  4054. setRow(index: number, row: Vector4): Matrix;
  4055. /**
  4056. * Compute the transpose of the matrix
  4057. * @returns the new transposed matrix
  4058. */
  4059. transpose(): Matrix;
  4060. /**
  4061. * Compute the transpose of the matrix and store it in a given matrix
  4062. * @param result defines the target matrix
  4063. * @returns the current matrix
  4064. */
  4065. transposeToRef(result: Matrix): Matrix;
  4066. /**
  4067. * Sets the index-th row of the current matrix with the given 4 x float values
  4068. * @param index defines the row index
  4069. * @param x defines the x component to set
  4070. * @param y defines the y component to set
  4071. * @param z defines the z component to set
  4072. * @param w defines the w component to set
  4073. * @returns the updated current matrix
  4074. */
  4075. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4076. /**
  4077. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4078. * @param scale defines the scale factor
  4079. * @returns a new matrix
  4080. */
  4081. scale(scale: number): Matrix;
  4082. /**
  4083. * Scale the current matrix values by a factor to a given result matrix
  4084. * @param scale defines the scale factor
  4085. * @param result defines the matrix to store the result
  4086. * @returns the current matrix
  4087. */
  4088. scaleToRef(scale: number, result: Matrix): Matrix;
  4089. /**
  4090. * Scale the current matrix values by a factor and add the result to a given matrix
  4091. * @param scale defines the scale factor
  4092. * @param result defines the Matrix to store the result
  4093. * @returns the current matrix
  4094. */
  4095. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4096. /**
  4097. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4098. * @param ref matrix to store the result
  4099. */
  4100. toNormalMatrix(ref: Matrix): void;
  4101. /**
  4102. * Gets only rotation part of the current matrix
  4103. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4104. */
  4105. getRotationMatrix(): Matrix;
  4106. /**
  4107. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4108. * @param result defines the target matrix to store data to
  4109. * @returns the current matrix
  4110. */
  4111. getRotationMatrixToRef(result: Matrix): Matrix;
  4112. /**
  4113. * Toggles model matrix from being right handed to left handed in place and vice versa
  4114. */
  4115. toggleModelMatrixHandInPlace(): void;
  4116. /**
  4117. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4118. */
  4119. toggleProjectionMatrixHandInPlace(): void;
  4120. /**
  4121. * Creates a matrix from an array
  4122. * @param array defines the source array
  4123. * @param offset defines an offset in the source array
  4124. * @returns a new Matrix set from the starting index of the given array
  4125. */
  4126. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4127. /**
  4128. * Copy the content of an array into a given matrix
  4129. * @param array defines the source array
  4130. * @param offset defines an offset in the source array
  4131. * @param result defines the target matrix
  4132. */
  4133. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4134. /**
  4135. * Stores an array into a matrix after having multiplied each component by a given factor
  4136. * @param array defines the source array
  4137. * @param offset defines the offset in the source array
  4138. * @param scale defines the scaling factor
  4139. * @param result defines the target matrix
  4140. */
  4141. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4142. /**
  4143. * Gets an identity matrix that must not be updated
  4144. */
  4145. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4146. /**
  4147. * Stores a list of values (16) inside a given matrix
  4148. * @param initialM11 defines 1st value of 1st row
  4149. * @param initialM12 defines 2nd value of 1st row
  4150. * @param initialM13 defines 3rd value of 1st row
  4151. * @param initialM14 defines 4th value of 1st row
  4152. * @param initialM21 defines 1st value of 2nd row
  4153. * @param initialM22 defines 2nd value of 2nd row
  4154. * @param initialM23 defines 3rd value of 2nd row
  4155. * @param initialM24 defines 4th value of 2nd row
  4156. * @param initialM31 defines 1st value of 3rd row
  4157. * @param initialM32 defines 2nd value of 3rd row
  4158. * @param initialM33 defines 3rd value of 3rd row
  4159. * @param initialM34 defines 4th value of 3rd row
  4160. * @param initialM41 defines 1st value of 4th row
  4161. * @param initialM42 defines 2nd value of 4th row
  4162. * @param initialM43 defines 3rd value of 4th row
  4163. * @param initialM44 defines 4th value of 4th row
  4164. * @param result defines the target matrix
  4165. */
  4166. 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;
  4167. /**
  4168. * Creates new matrix from a list of values (16)
  4169. * @param initialM11 defines 1st value of 1st row
  4170. * @param initialM12 defines 2nd value of 1st row
  4171. * @param initialM13 defines 3rd value of 1st row
  4172. * @param initialM14 defines 4th value of 1st row
  4173. * @param initialM21 defines 1st value of 2nd row
  4174. * @param initialM22 defines 2nd value of 2nd row
  4175. * @param initialM23 defines 3rd value of 2nd row
  4176. * @param initialM24 defines 4th value of 2nd row
  4177. * @param initialM31 defines 1st value of 3rd row
  4178. * @param initialM32 defines 2nd value of 3rd row
  4179. * @param initialM33 defines 3rd value of 3rd row
  4180. * @param initialM34 defines 4th value of 3rd row
  4181. * @param initialM41 defines 1st value of 4th row
  4182. * @param initialM42 defines 2nd value of 4th row
  4183. * @param initialM43 defines 3rd value of 4th row
  4184. * @param initialM44 defines 4th value of 4th row
  4185. * @returns the new matrix
  4186. */
  4187. 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;
  4188. /**
  4189. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4190. * @param scale defines the scale vector3
  4191. * @param rotation defines the rotation quaternion
  4192. * @param translation defines the translation vector3
  4193. * @returns a new matrix
  4194. */
  4195. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4196. /**
  4197. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4198. * @param scale defines the scale vector3
  4199. * @param rotation defines the rotation quaternion
  4200. * @param translation defines the translation vector3
  4201. * @param result defines the target matrix
  4202. */
  4203. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4204. /**
  4205. * Creates a new identity matrix
  4206. * @returns a new identity matrix
  4207. */
  4208. static Identity(): Matrix;
  4209. /**
  4210. * Creates a new identity matrix and stores the result in a given matrix
  4211. * @param result defines the target matrix
  4212. */
  4213. static IdentityToRef(result: Matrix): void;
  4214. /**
  4215. * Creates a new zero matrix
  4216. * @returns a new zero matrix
  4217. */
  4218. static Zero(): Matrix;
  4219. /**
  4220. * Creates a new rotation matrix for "angle" radians around the X axis
  4221. * @param angle defines the angle (in radians) to use
  4222. * @return the new matrix
  4223. */
  4224. static RotationX(angle: number): Matrix;
  4225. /**
  4226. * Creates a new matrix as the invert of a given matrix
  4227. * @param source defines the source matrix
  4228. * @returns the new matrix
  4229. */
  4230. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4231. /**
  4232. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4233. * @param angle defines the angle (in radians) to use
  4234. * @param result defines the target matrix
  4235. */
  4236. static RotationXToRef(angle: number, result: Matrix): void;
  4237. /**
  4238. * Creates a new rotation matrix for "angle" radians around the Y axis
  4239. * @param angle defines the angle (in radians) to use
  4240. * @return the new matrix
  4241. */
  4242. static RotationY(angle: number): Matrix;
  4243. /**
  4244. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4245. * @param angle defines the angle (in radians) to use
  4246. * @param result defines the target matrix
  4247. */
  4248. static RotationYToRef(angle: number, result: Matrix): void;
  4249. /**
  4250. * Creates a new rotation matrix for "angle" radians around the Z axis
  4251. * @param angle defines the angle (in radians) to use
  4252. * @return the new matrix
  4253. */
  4254. static RotationZ(angle: number): Matrix;
  4255. /**
  4256. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4257. * @param angle defines the angle (in radians) to use
  4258. * @param result defines the target matrix
  4259. */
  4260. static RotationZToRef(angle: number, result: Matrix): void;
  4261. /**
  4262. * Creates a new rotation matrix for "angle" radians around the given axis
  4263. * @param axis defines the axis to use
  4264. * @param angle defines the angle (in radians) to use
  4265. * @return the new matrix
  4266. */
  4267. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4268. /**
  4269. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4270. * @param axis defines the axis to use
  4271. * @param angle defines the angle (in radians) to use
  4272. * @param result defines the target matrix
  4273. */
  4274. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4275. /**
  4276. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4277. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4278. * @param from defines the vector to align
  4279. * @param to defines the vector to align to
  4280. * @param result defines the target matrix
  4281. */
  4282. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4283. /**
  4284. * Creates a rotation matrix
  4285. * @param yaw defines the yaw angle in radians (Y axis)
  4286. * @param pitch defines the pitch angle in radians (X axis)
  4287. * @param roll defines the roll angle in radians (X axis)
  4288. * @returns the new rotation matrix
  4289. */
  4290. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4291. /**
  4292. * Creates a rotation matrix and stores it in a given matrix
  4293. * @param yaw defines the yaw angle in radians (Y axis)
  4294. * @param pitch defines the pitch angle in radians (X axis)
  4295. * @param roll defines the roll angle in radians (X axis)
  4296. * @param result defines the target matrix
  4297. */
  4298. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4299. /**
  4300. * Creates a scaling matrix
  4301. * @param x defines the scale factor on X axis
  4302. * @param y defines the scale factor on Y axis
  4303. * @param z defines the scale factor on Z axis
  4304. * @returns the new matrix
  4305. */
  4306. static Scaling(x: number, y: number, z: number): Matrix;
  4307. /**
  4308. * Creates a scaling matrix and stores it in a given matrix
  4309. * @param x defines the scale factor on X axis
  4310. * @param y defines the scale factor on Y axis
  4311. * @param z defines the scale factor on Z axis
  4312. * @param result defines the target matrix
  4313. */
  4314. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4315. /**
  4316. * Creates a translation matrix
  4317. * @param x defines the translation on X axis
  4318. * @param y defines the translation on Y axis
  4319. * @param z defines the translationon Z axis
  4320. * @returns the new matrix
  4321. */
  4322. static Translation(x: number, y: number, z: number): Matrix;
  4323. /**
  4324. * Creates a translation matrix and stores it in a given matrix
  4325. * @param x defines the translation on X axis
  4326. * @param y defines the translation on Y axis
  4327. * @param z defines the translationon Z axis
  4328. * @param result defines the target matrix
  4329. */
  4330. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4331. /**
  4332. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4333. * @param startValue defines the start value
  4334. * @param endValue defines the end value
  4335. * @param gradient defines the gradient factor
  4336. * @returns the new matrix
  4337. */
  4338. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4339. /**
  4340. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4341. * @param startValue defines the start value
  4342. * @param endValue defines the end value
  4343. * @param gradient defines the gradient factor
  4344. * @param result defines the Matrix object where to store data
  4345. */
  4346. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4347. /**
  4348. * Builds a new matrix whose values are computed by:
  4349. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4350. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4351. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4352. * @param startValue defines the first matrix
  4353. * @param endValue defines the second matrix
  4354. * @param gradient defines the gradient between the two matrices
  4355. * @returns the new matrix
  4356. */
  4357. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4358. /**
  4359. * Update a matrix to values which are computed by:
  4360. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4361. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4362. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4363. * @param startValue defines the first matrix
  4364. * @param endValue defines the second matrix
  4365. * @param gradient defines the gradient between the two matrices
  4366. * @param result defines the target matrix
  4367. */
  4368. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4369. /**
  4370. * 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"
  4371. * This function works in left handed mode
  4372. * @param eye defines the final position of the entity
  4373. * @param target defines where the entity should look at
  4374. * @param up defines the up vector for the entity
  4375. * @returns the new matrix
  4376. */
  4377. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4378. /**
  4379. * 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".
  4380. * This function works in left handed mode
  4381. * @param eye defines the final position of the entity
  4382. * @param target defines where the entity should look at
  4383. * @param up defines the up vector for the entity
  4384. * @param result defines the target matrix
  4385. */
  4386. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4387. /**
  4388. * 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"
  4389. * This function works in right handed mode
  4390. * @param eye defines the final position of the entity
  4391. * @param target defines where the entity should look at
  4392. * @param up defines the up vector for the entity
  4393. * @returns the new matrix
  4394. */
  4395. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4396. /**
  4397. * 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".
  4398. * This function works in right handed mode
  4399. * @param eye defines the final position of the entity
  4400. * @param target defines where the entity should look at
  4401. * @param up defines the up vector for the entity
  4402. * @param result defines the target matrix
  4403. */
  4404. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4405. /**
  4406. * Create a left-handed orthographic projection matrix
  4407. * @param width defines the viewport width
  4408. * @param height defines the viewport height
  4409. * @param znear defines the near clip plane
  4410. * @param zfar defines the far clip plane
  4411. * @returns a new matrix as a left-handed orthographic projection matrix
  4412. */
  4413. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4414. /**
  4415. * Store a left-handed orthographic projection to a given matrix
  4416. * @param width defines the viewport width
  4417. * @param height defines the viewport height
  4418. * @param znear defines the near clip plane
  4419. * @param zfar defines the far clip plane
  4420. * @param result defines the target matrix
  4421. */
  4422. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4423. /**
  4424. * Create a left-handed orthographic projection matrix
  4425. * @param left defines the viewport left coordinate
  4426. * @param right defines the viewport right coordinate
  4427. * @param bottom defines the viewport bottom coordinate
  4428. * @param top defines the viewport top coordinate
  4429. * @param znear defines the near clip plane
  4430. * @param zfar defines the far clip plane
  4431. * @returns a new matrix as a left-handed orthographic projection matrix
  4432. */
  4433. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4434. /**
  4435. * Stores a left-handed orthographic projection into a given matrix
  4436. * @param left defines the viewport left coordinate
  4437. * @param right defines the viewport right coordinate
  4438. * @param bottom defines the viewport bottom coordinate
  4439. * @param top defines the viewport top coordinate
  4440. * @param znear defines the near clip plane
  4441. * @param zfar defines the far clip plane
  4442. * @param result defines the target matrix
  4443. */
  4444. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4445. /**
  4446. * Creates a right-handed orthographic projection matrix
  4447. * @param left defines the viewport left coordinate
  4448. * @param right defines the viewport right coordinate
  4449. * @param bottom defines the viewport bottom coordinate
  4450. * @param top defines the viewport top coordinate
  4451. * @param znear defines the near clip plane
  4452. * @param zfar defines the far clip plane
  4453. * @returns a new matrix as a right-handed orthographic projection matrix
  4454. */
  4455. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4456. /**
  4457. * Stores a right-handed orthographic projection into a given matrix
  4458. * @param left defines the viewport left coordinate
  4459. * @param right defines the viewport right coordinate
  4460. * @param bottom defines the viewport bottom coordinate
  4461. * @param top defines the viewport top coordinate
  4462. * @param znear defines the near clip plane
  4463. * @param zfar defines the far clip plane
  4464. * @param result defines the target matrix
  4465. */
  4466. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4467. /**
  4468. * Creates a left-handed perspective projection matrix
  4469. * @param width defines the viewport width
  4470. * @param height defines the viewport height
  4471. * @param znear defines the near clip plane
  4472. * @param zfar defines the far clip plane
  4473. * @returns a new matrix as a left-handed perspective projection matrix
  4474. */
  4475. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4476. /**
  4477. * Creates a left-handed perspective projection matrix
  4478. * @param fov defines the horizontal field of view
  4479. * @param aspect defines the aspect ratio
  4480. * @param znear defines the near clip plane
  4481. * @param zfar defines the far clip plane
  4482. * @returns a new matrix as a left-handed perspective projection matrix
  4483. */
  4484. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4485. /**
  4486. * Stores a left-handed perspective projection into a given matrix
  4487. * @param fov defines the horizontal field of view
  4488. * @param aspect defines the aspect ratio
  4489. * @param znear defines the near clip plane
  4490. * @param zfar defines the far clip plane
  4491. * @param result defines the target matrix
  4492. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4493. */
  4494. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4495. /**
  4496. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4497. * @param fov defines the horizontal field of view
  4498. * @param aspect defines the aspect ratio
  4499. * @param znear defines the near clip plane
  4500. * @param zfar not used as infinity is used as far clip
  4501. * @param result defines the target matrix
  4502. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4503. */
  4504. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4505. /**
  4506. * Creates a right-handed perspective projection matrix
  4507. * @param fov defines the horizontal field of view
  4508. * @param aspect defines the aspect ratio
  4509. * @param znear defines the near clip plane
  4510. * @param zfar defines the far clip plane
  4511. * @returns a new matrix as a right-handed perspective projection matrix
  4512. */
  4513. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4514. /**
  4515. * Stores a right-handed perspective projection into a given matrix
  4516. * @param fov defines the horizontal field of view
  4517. * @param aspect defines the aspect ratio
  4518. * @param znear defines the near clip plane
  4519. * @param zfar defines the far clip plane
  4520. * @param result defines the target matrix
  4521. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4522. */
  4523. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4524. /**
  4525. * Stores a right-handed perspective projection into a given matrix
  4526. * @param fov defines the horizontal field of view
  4527. * @param aspect defines the aspect ratio
  4528. * @param znear defines the near clip plane
  4529. * @param zfar not used as infinity is used as far clip
  4530. * @param result defines the target matrix
  4531. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4532. */
  4533. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4534. /**
  4535. * Stores a perspective projection for WebVR info a given matrix
  4536. * @param fov defines the field of view
  4537. * @param znear defines the near clip plane
  4538. * @param zfar defines the far clip plane
  4539. * @param result defines the target matrix
  4540. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4541. */
  4542. static PerspectiveFovWebVRToRef(fov: {
  4543. upDegrees: number;
  4544. downDegrees: number;
  4545. leftDegrees: number;
  4546. rightDegrees: number;
  4547. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4548. /**
  4549. * Computes a complete transformation matrix
  4550. * @param viewport defines the viewport to use
  4551. * @param world defines the world matrix
  4552. * @param view defines the view matrix
  4553. * @param projection defines the projection matrix
  4554. * @param zmin defines the near clip plane
  4555. * @param zmax defines the far clip plane
  4556. * @returns the transformation matrix
  4557. */
  4558. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4559. /**
  4560. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4561. * @param matrix defines the matrix to use
  4562. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4563. */
  4564. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4565. /**
  4566. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4567. * @param matrix defines the matrix to use
  4568. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4569. */
  4570. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4571. /**
  4572. * Compute the transpose of a given matrix
  4573. * @param matrix defines the matrix to transpose
  4574. * @returns the new matrix
  4575. */
  4576. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4577. /**
  4578. * Compute the transpose of a matrix and store it in a target matrix
  4579. * @param matrix defines the matrix to transpose
  4580. * @param result defines the target matrix
  4581. */
  4582. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4583. /**
  4584. * Computes a reflection matrix from a plane
  4585. * @param plane defines the reflection plane
  4586. * @returns a new matrix
  4587. */
  4588. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4589. /**
  4590. * Computes a reflection matrix from a plane
  4591. * @param plane defines the reflection plane
  4592. * @param result defines the target matrix
  4593. */
  4594. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4595. /**
  4596. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4597. * @param xaxis defines the value of the 1st axis
  4598. * @param yaxis defines the value of the 2nd axis
  4599. * @param zaxis defines the value of the 3rd axis
  4600. * @param result defines the target matrix
  4601. */
  4602. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4603. /**
  4604. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4605. * @param quat defines the quaternion to use
  4606. * @param result defines the target matrix
  4607. */
  4608. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4609. }
  4610. /**
  4611. * @hidden
  4612. */
  4613. export class TmpVectors {
  4614. static Vector2: Vector2[];
  4615. static Vector3: Vector3[];
  4616. static Vector4: Vector4[];
  4617. static Quaternion: Quaternion[];
  4618. static Matrix: Matrix[];
  4619. }
  4620. }
  4621. declare module "babylonjs/Maths/math.path" {
  4622. import { DeepImmutable, Nullable } from "babylonjs/types";
  4623. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4624. /**
  4625. * Defines potential orientation for back face culling
  4626. */
  4627. export enum Orientation {
  4628. /**
  4629. * Clockwise
  4630. */
  4631. CW = 0,
  4632. /** Counter clockwise */
  4633. CCW = 1
  4634. }
  4635. /** Class used to represent a Bezier curve */
  4636. export class BezierCurve {
  4637. /**
  4638. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4639. * @param t defines the time
  4640. * @param x1 defines the left coordinate on X axis
  4641. * @param y1 defines the left coordinate on Y axis
  4642. * @param x2 defines the right coordinate on X axis
  4643. * @param y2 defines the right coordinate on Y axis
  4644. * @returns the interpolated value
  4645. */
  4646. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4647. }
  4648. /**
  4649. * Defines angle representation
  4650. */
  4651. export class Angle {
  4652. private _radians;
  4653. /**
  4654. * Creates an Angle object of "radians" radians (float).
  4655. * @param radians the angle in radians
  4656. */
  4657. constructor(radians: number);
  4658. /**
  4659. * Get value in degrees
  4660. * @returns the Angle value in degrees (float)
  4661. */
  4662. degrees(): number;
  4663. /**
  4664. * Get value in radians
  4665. * @returns the Angle value in radians (float)
  4666. */
  4667. radians(): number;
  4668. /**
  4669. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4670. * @param a defines first vector
  4671. * @param b defines second vector
  4672. * @returns a new Angle
  4673. */
  4674. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4675. /**
  4676. * Gets a new Angle object from the given float in radians
  4677. * @param radians defines the angle value in radians
  4678. * @returns a new Angle
  4679. */
  4680. static FromRadians(radians: number): Angle;
  4681. /**
  4682. * Gets a new Angle object from the given float in degrees
  4683. * @param degrees defines the angle value in degrees
  4684. * @returns a new Angle
  4685. */
  4686. static FromDegrees(degrees: number): Angle;
  4687. }
  4688. /**
  4689. * This represents an arc in a 2d space.
  4690. */
  4691. export class Arc2 {
  4692. /** Defines the start point of the arc */
  4693. startPoint: Vector2;
  4694. /** Defines the mid point of the arc */
  4695. midPoint: Vector2;
  4696. /** Defines the end point of the arc */
  4697. endPoint: Vector2;
  4698. /**
  4699. * Defines the center point of the arc.
  4700. */
  4701. centerPoint: Vector2;
  4702. /**
  4703. * Defines the radius of the arc.
  4704. */
  4705. radius: number;
  4706. /**
  4707. * Defines the angle of the arc (from mid point to end point).
  4708. */
  4709. angle: Angle;
  4710. /**
  4711. * Defines the start angle of the arc (from start point to middle point).
  4712. */
  4713. startAngle: Angle;
  4714. /**
  4715. * Defines the orientation of the arc (clock wise/counter clock wise).
  4716. */
  4717. orientation: Orientation;
  4718. /**
  4719. * Creates an Arc object from the three given points : start, middle and end.
  4720. * @param startPoint Defines the start point of the arc
  4721. * @param midPoint Defines the midlle point of the arc
  4722. * @param endPoint Defines the end point of the arc
  4723. */
  4724. constructor(
  4725. /** Defines the start point of the arc */
  4726. startPoint: Vector2,
  4727. /** Defines the mid point of the arc */
  4728. midPoint: Vector2,
  4729. /** Defines the end point of the arc */
  4730. endPoint: Vector2);
  4731. }
  4732. /**
  4733. * Represents a 2D path made up of multiple 2D points
  4734. */
  4735. export class Path2 {
  4736. private _points;
  4737. private _length;
  4738. /**
  4739. * If the path start and end point are the same
  4740. */
  4741. closed: boolean;
  4742. /**
  4743. * Creates a Path2 object from the starting 2D coordinates x and y.
  4744. * @param x the starting points x value
  4745. * @param y the starting points y value
  4746. */
  4747. constructor(x: number, y: number);
  4748. /**
  4749. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4750. * @param x the added points x value
  4751. * @param y the added points y value
  4752. * @returns the updated Path2.
  4753. */
  4754. addLineTo(x: number, y: number): Path2;
  4755. /**
  4756. * 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.
  4757. * @param midX middle point x value
  4758. * @param midY middle point y value
  4759. * @param endX end point x value
  4760. * @param endY end point y value
  4761. * @param numberOfSegments (default: 36)
  4762. * @returns the updated Path2.
  4763. */
  4764. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4765. /**
  4766. * Closes the Path2.
  4767. * @returns the Path2.
  4768. */
  4769. close(): Path2;
  4770. /**
  4771. * Gets the sum of the distance between each sequential point in the path
  4772. * @returns the Path2 total length (float).
  4773. */
  4774. length(): number;
  4775. /**
  4776. * Gets the points which construct the path
  4777. * @returns the Path2 internal array of points.
  4778. */
  4779. getPoints(): Vector2[];
  4780. /**
  4781. * Retreives the point at the distance aways from the starting point
  4782. * @param normalizedLengthPosition the length along the path to retreive the point from
  4783. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4784. */
  4785. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4786. /**
  4787. * Creates a new path starting from an x and y position
  4788. * @param x starting x value
  4789. * @param y starting y value
  4790. * @returns a new Path2 starting at the coordinates (x, y).
  4791. */
  4792. static StartingAt(x: number, y: number): Path2;
  4793. }
  4794. /**
  4795. * Represents a 3D path made up of multiple 3D points
  4796. */
  4797. export class Path3D {
  4798. /**
  4799. * an array of Vector3, the curve axis of the Path3D
  4800. */
  4801. path: Vector3[];
  4802. private _curve;
  4803. private _distances;
  4804. private _tangents;
  4805. private _normals;
  4806. private _binormals;
  4807. private _raw;
  4808. private _alignTangentsWithPath;
  4809. private readonly _pointAtData;
  4810. /**
  4811. * new Path3D(path, normal, raw)
  4812. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4813. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4814. * @param path an array of Vector3, the curve axis of the Path3D
  4815. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4816. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4817. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4818. */
  4819. constructor(
  4820. /**
  4821. * an array of Vector3, the curve axis of the Path3D
  4822. */
  4823. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4824. /**
  4825. * Returns the Path3D array of successive Vector3 designing its curve.
  4826. * @returns the Path3D array of successive Vector3 designing its curve.
  4827. */
  4828. getCurve(): Vector3[];
  4829. /**
  4830. * Returns the Path3D array of successive Vector3 designing its curve.
  4831. * @returns the Path3D array of successive Vector3 designing its curve.
  4832. */
  4833. getPoints(): Vector3[];
  4834. /**
  4835. * @returns the computed length (float) of the path.
  4836. */
  4837. length(): number;
  4838. /**
  4839. * Returns an array populated with tangent vectors on each Path3D curve point.
  4840. * @returns an array populated with tangent vectors on each Path3D curve point.
  4841. */
  4842. getTangents(): Vector3[];
  4843. /**
  4844. * Returns an array populated with normal vectors on each Path3D curve point.
  4845. * @returns an array populated with normal vectors on each Path3D curve point.
  4846. */
  4847. getNormals(): Vector3[];
  4848. /**
  4849. * Returns an array populated with binormal vectors on each Path3D curve point.
  4850. * @returns an array populated with binormal vectors on each Path3D curve point.
  4851. */
  4852. getBinormals(): Vector3[];
  4853. /**
  4854. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4855. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4856. */
  4857. getDistances(): number[];
  4858. /**
  4859. * Returns an interpolated point along this path
  4860. * @param position the position of the point along this path, from 0.0 to 1.0
  4861. * @returns a new Vector3 as the point
  4862. */
  4863. getPointAt(position: number): Vector3;
  4864. /**
  4865. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4866. * @param position the position of the point along this path, from 0.0 to 1.0
  4867. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4868. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4869. */
  4870. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4871. /**
  4872. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4873. * @param position the position of the point along this path, from 0.0 to 1.0
  4874. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4875. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4876. */
  4877. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4878. /**
  4879. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4880. * @param position the position of the point along this path, from 0.0 to 1.0
  4881. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4882. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4883. */
  4884. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4885. /**
  4886. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4887. * @param position the position of the point along this path, from 0.0 to 1.0
  4888. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4889. */
  4890. getDistanceAt(position: number): number;
  4891. /**
  4892. * Returns the array index of the previous point of an interpolated point along this path
  4893. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4894. * @returns the array index
  4895. */
  4896. getPreviousPointIndexAt(position: number): number;
  4897. /**
  4898. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4899. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4900. * @returns the sub position
  4901. */
  4902. getSubPositionAt(position: number): number;
  4903. /**
  4904. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4905. * @param target the vector of which to get the closest position to
  4906. * @returns the position of the closest virtual point on this path to the target vector
  4907. */
  4908. getClosestPositionTo(target: Vector3): number;
  4909. /**
  4910. * Returns a sub path (slice) of this path
  4911. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4912. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4913. * @returns a sub path (slice) of this path
  4914. */
  4915. slice(start?: number, end?: number): Path3D;
  4916. /**
  4917. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4918. * @param path path which all values are copied into the curves points
  4919. * @param firstNormal which should be projected onto the curve
  4920. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4921. * @returns the same object updated.
  4922. */
  4923. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4924. private _compute;
  4925. private _getFirstNonNullVector;
  4926. private _getLastNonNullVector;
  4927. private _normalVector;
  4928. /**
  4929. * Updates the point at data for an interpolated point along this curve
  4930. * @param position the position of the point along this curve, from 0.0 to 1.0
  4931. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4932. * @returns the (updated) point at data
  4933. */
  4934. private _updatePointAtData;
  4935. /**
  4936. * Updates the point at data from the specified parameters
  4937. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4938. * @param point the interpolated point
  4939. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4940. */
  4941. private _setPointAtData;
  4942. /**
  4943. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4944. */
  4945. private _updateInterpolationMatrix;
  4946. }
  4947. /**
  4948. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4949. * A Curve3 is designed from a series of successive Vector3.
  4950. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4951. */
  4952. export class Curve3 {
  4953. private _points;
  4954. private _length;
  4955. /**
  4956. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4957. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4958. * @param v1 (Vector3) the control point
  4959. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4960. * @param nbPoints (integer) the wanted number of points in the curve
  4961. * @returns the created Curve3
  4962. */
  4963. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4964. /**
  4965. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4966. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4967. * @param v1 (Vector3) the first control point
  4968. * @param v2 (Vector3) the second control point
  4969. * @param v3 (Vector3) the end point of the Cubic Bezier
  4970. * @param nbPoints (integer) the wanted number of points in the curve
  4971. * @returns the created Curve3
  4972. */
  4973. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4974. /**
  4975. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4976. * @param p1 (Vector3) the origin point of the Hermite Spline
  4977. * @param t1 (Vector3) the tangent vector at the origin point
  4978. * @param p2 (Vector3) the end point of the Hermite Spline
  4979. * @param t2 (Vector3) the tangent vector at the end point
  4980. * @param nbPoints (integer) the wanted number of points in the curve
  4981. * @returns the created Curve3
  4982. */
  4983. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4984. /**
  4985. * Returns a Curve3 object along a CatmullRom Spline curve :
  4986. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4987. * @param nbPoints (integer) the wanted number of points between each curve control points
  4988. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4989. * @returns the created Curve3
  4990. */
  4991. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4992. /**
  4993. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4994. * A Curve3 is designed from a series of successive Vector3.
  4995. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4996. * @param points points which make up the curve
  4997. */
  4998. constructor(points: Vector3[]);
  4999. /**
  5000. * @returns the Curve3 stored array of successive Vector3
  5001. */
  5002. getPoints(): Vector3[];
  5003. /**
  5004. * @returns the computed length (float) of the curve.
  5005. */
  5006. length(): number;
  5007. /**
  5008. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5009. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5010. * curveA and curveB keep unchanged.
  5011. * @param curve the curve to continue from this curve
  5012. * @returns the newly constructed curve
  5013. */
  5014. continue(curve: DeepImmutable<Curve3>): Curve3;
  5015. private _computeLength;
  5016. }
  5017. }
  5018. declare module "babylonjs/Animations/easing" {
  5019. /**
  5020. * This represents the main contract an easing function should follow.
  5021. * Easing functions are used throughout the animation system.
  5022. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5023. */
  5024. export interface IEasingFunction {
  5025. /**
  5026. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5027. * of the easing function.
  5028. * The link below provides some of the most common examples of easing functions.
  5029. * @see https://easings.net/
  5030. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5031. * @returns the corresponding value on the curve defined by the easing function
  5032. */
  5033. ease(gradient: number): number;
  5034. }
  5035. /**
  5036. * Base class used for every default easing function.
  5037. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5038. */
  5039. export class EasingFunction implements IEasingFunction {
  5040. /**
  5041. * Interpolation follows the mathematical formula associated with the easing function.
  5042. */
  5043. static readonly EASINGMODE_EASEIN: number;
  5044. /**
  5045. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5046. */
  5047. static readonly EASINGMODE_EASEOUT: number;
  5048. /**
  5049. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5050. */
  5051. static readonly EASINGMODE_EASEINOUT: number;
  5052. private _easingMode;
  5053. /**
  5054. * Sets the easing mode of the current function.
  5055. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5056. */
  5057. setEasingMode(easingMode: number): void;
  5058. /**
  5059. * Gets the current easing mode.
  5060. * @returns the easing mode
  5061. */
  5062. getEasingMode(): number;
  5063. /**
  5064. * @hidden
  5065. */
  5066. easeInCore(gradient: number): number;
  5067. /**
  5068. * Given an input gradient between 0 and 1, this returns the corresponding value
  5069. * of the easing function.
  5070. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5071. * @returns the corresponding value on the curve defined by the easing function
  5072. */
  5073. ease(gradient: number): number;
  5074. }
  5075. /**
  5076. * Easing function with a circle shape (see link below).
  5077. * @see https://easings.net/#easeInCirc
  5078. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5079. */
  5080. export class CircleEase extends EasingFunction implements IEasingFunction {
  5081. /** @hidden */
  5082. easeInCore(gradient: number): number;
  5083. }
  5084. /**
  5085. * Easing function with a ease back shape (see link below).
  5086. * @see https://easings.net/#easeInBack
  5087. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5088. */
  5089. export class BackEase extends EasingFunction implements IEasingFunction {
  5090. /** Defines the amplitude of the function */
  5091. amplitude: number;
  5092. /**
  5093. * Instantiates a back ease easing
  5094. * @see https://easings.net/#easeInBack
  5095. * @param amplitude Defines the amplitude of the function
  5096. */
  5097. constructor(
  5098. /** Defines the amplitude of the function */
  5099. amplitude?: number);
  5100. /** @hidden */
  5101. easeInCore(gradient: number): number;
  5102. }
  5103. /**
  5104. * Easing function with a bouncing shape (see link below).
  5105. * @see https://easings.net/#easeInBounce
  5106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5107. */
  5108. export class BounceEase extends EasingFunction implements IEasingFunction {
  5109. /** Defines the number of bounces */
  5110. bounces: number;
  5111. /** Defines the amplitude of the bounce */
  5112. bounciness: number;
  5113. /**
  5114. * Instantiates a bounce easing
  5115. * @see https://easings.net/#easeInBounce
  5116. * @param bounces Defines the number of bounces
  5117. * @param bounciness Defines the amplitude of the bounce
  5118. */
  5119. constructor(
  5120. /** Defines the number of bounces */
  5121. bounces?: number,
  5122. /** Defines the amplitude of the bounce */
  5123. bounciness?: number);
  5124. /** @hidden */
  5125. easeInCore(gradient: number): number;
  5126. }
  5127. /**
  5128. * Easing function with a power of 3 shape (see link below).
  5129. * @see https://easings.net/#easeInCubic
  5130. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5131. */
  5132. export class CubicEase extends EasingFunction implements IEasingFunction {
  5133. /** @hidden */
  5134. easeInCore(gradient: number): number;
  5135. }
  5136. /**
  5137. * Easing function with an elastic shape (see link below).
  5138. * @see https://easings.net/#easeInElastic
  5139. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5140. */
  5141. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5142. /** Defines the number of oscillations*/
  5143. oscillations: number;
  5144. /** Defines the amplitude of the oscillations*/
  5145. springiness: number;
  5146. /**
  5147. * Instantiates an elastic easing function
  5148. * @see https://easings.net/#easeInElastic
  5149. * @param oscillations Defines the number of oscillations
  5150. * @param springiness Defines the amplitude of the oscillations
  5151. */
  5152. constructor(
  5153. /** Defines the number of oscillations*/
  5154. oscillations?: number,
  5155. /** Defines the amplitude of the oscillations*/
  5156. springiness?: number);
  5157. /** @hidden */
  5158. easeInCore(gradient: number): number;
  5159. }
  5160. /**
  5161. * Easing function with an exponential shape (see link below).
  5162. * @see https://easings.net/#easeInExpo
  5163. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5164. */
  5165. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5166. /** Defines the exponent of the function */
  5167. exponent: number;
  5168. /**
  5169. * Instantiates an exponential easing function
  5170. * @see https://easings.net/#easeInExpo
  5171. * @param exponent Defines the exponent of the function
  5172. */
  5173. constructor(
  5174. /** Defines the exponent of the function */
  5175. exponent?: number);
  5176. /** @hidden */
  5177. easeInCore(gradient: number): number;
  5178. }
  5179. /**
  5180. * Easing function with a power shape (see link below).
  5181. * @see https://easings.net/#easeInQuad
  5182. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5183. */
  5184. export class PowerEase extends EasingFunction implements IEasingFunction {
  5185. /** Defines the power of the function */
  5186. power: number;
  5187. /**
  5188. * Instantiates an power base easing function
  5189. * @see https://easings.net/#easeInQuad
  5190. * @param power Defines the power of the function
  5191. */
  5192. constructor(
  5193. /** Defines the power of the function */
  5194. power?: number);
  5195. /** @hidden */
  5196. easeInCore(gradient: number): number;
  5197. }
  5198. /**
  5199. * Easing function with a power of 2 shape (see link below).
  5200. * @see https://easings.net/#easeInQuad
  5201. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5202. */
  5203. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5204. /** @hidden */
  5205. easeInCore(gradient: number): number;
  5206. }
  5207. /**
  5208. * Easing function with a power of 4 shape (see link below).
  5209. * @see https://easings.net/#easeInQuart
  5210. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5211. */
  5212. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5213. /** @hidden */
  5214. easeInCore(gradient: number): number;
  5215. }
  5216. /**
  5217. * Easing function with a power of 5 shape (see link below).
  5218. * @see https://easings.net/#easeInQuint
  5219. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5220. */
  5221. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5222. /** @hidden */
  5223. easeInCore(gradient: number): number;
  5224. }
  5225. /**
  5226. * Easing function with a sin shape (see link below).
  5227. * @see https://easings.net/#easeInSine
  5228. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5229. */
  5230. export class SineEase extends EasingFunction implements IEasingFunction {
  5231. /** @hidden */
  5232. easeInCore(gradient: number): number;
  5233. }
  5234. /**
  5235. * Easing function with a bezier shape (see link below).
  5236. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5237. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5238. */
  5239. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5240. /** Defines the x component of the start tangent in the bezier curve */
  5241. x1: number;
  5242. /** Defines the y component of the start tangent in the bezier curve */
  5243. y1: number;
  5244. /** Defines the x component of the end tangent in the bezier curve */
  5245. x2: number;
  5246. /** Defines the y component of the end tangent in the bezier curve */
  5247. y2: number;
  5248. /**
  5249. * Instantiates a bezier function
  5250. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5251. * @param x1 Defines the x component of the start tangent in the bezier curve
  5252. * @param y1 Defines the y component of the start tangent in the bezier curve
  5253. * @param x2 Defines the x component of the end tangent in the bezier curve
  5254. * @param y2 Defines the y component of the end tangent in the bezier curve
  5255. */
  5256. constructor(
  5257. /** Defines the x component of the start tangent in the bezier curve */
  5258. x1?: number,
  5259. /** Defines the y component of the start tangent in the bezier curve */
  5260. y1?: number,
  5261. /** Defines the x component of the end tangent in the bezier curve */
  5262. x2?: number,
  5263. /** Defines the y component of the end tangent in the bezier curve */
  5264. y2?: number);
  5265. /** @hidden */
  5266. easeInCore(gradient: number): number;
  5267. }
  5268. }
  5269. declare module "babylonjs/Maths/math.color" {
  5270. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5271. /**
  5272. * Class used to hold a RBG color
  5273. */
  5274. export class Color3 {
  5275. /**
  5276. * Defines the red component (between 0 and 1, default is 0)
  5277. */
  5278. r: number;
  5279. /**
  5280. * Defines the green component (between 0 and 1, default is 0)
  5281. */
  5282. g: number;
  5283. /**
  5284. * Defines the blue component (between 0 and 1, default is 0)
  5285. */
  5286. b: number;
  5287. /**
  5288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5289. * @param r defines the red component (between 0 and 1, default is 0)
  5290. * @param g defines the green component (between 0 and 1, default is 0)
  5291. * @param b defines the blue component (between 0 and 1, default is 0)
  5292. */
  5293. constructor(
  5294. /**
  5295. * Defines the red component (between 0 and 1, default is 0)
  5296. */
  5297. r?: number,
  5298. /**
  5299. * Defines the green component (between 0 and 1, default is 0)
  5300. */
  5301. g?: number,
  5302. /**
  5303. * Defines the blue component (between 0 and 1, default is 0)
  5304. */
  5305. b?: number);
  5306. /**
  5307. * Creates a string with the Color3 current values
  5308. * @returns the string representation of the Color3 object
  5309. */
  5310. toString(): string;
  5311. /**
  5312. * Returns the string "Color3"
  5313. * @returns "Color3"
  5314. */
  5315. getClassName(): string;
  5316. /**
  5317. * Compute the Color3 hash code
  5318. * @returns an unique number that can be used to hash Color3 objects
  5319. */
  5320. getHashCode(): number;
  5321. /**
  5322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5323. * @param array defines the array where to store the r,g,b components
  5324. * @param index defines an optional index in the target array to define where to start storing values
  5325. * @returns the current Color3 object
  5326. */
  5327. toArray(array: FloatArray, index?: number): Color3;
  5328. /**
  5329. * Returns a new Color4 object from the current Color3 and the given alpha
  5330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5331. * @returns a new Color4 object
  5332. */
  5333. toColor4(alpha?: number): Color4;
  5334. /**
  5335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5336. * @returns the new array
  5337. */
  5338. asArray(): number[];
  5339. /**
  5340. * Returns the luminance value
  5341. * @returns a float value
  5342. */
  5343. toLuminance(): number;
  5344. /**
  5345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5346. * @param otherColor defines the second operand
  5347. * @returns the new Color3 object
  5348. */
  5349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5350. /**
  5351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5352. * @param otherColor defines the second operand
  5353. * @param result defines the Color3 object where to store the result
  5354. * @returns the current Color3
  5355. */
  5356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5357. /**
  5358. * Determines equality between Color3 objects
  5359. * @param otherColor defines the second operand
  5360. * @returns true if the rgb values are equal to the given ones
  5361. */
  5362. equals(otherColor: DeepImmutable<Color3>): boolean;
  5363. /**
  5364. * Determines equality between the current Color3 object and a set of r,b,g values
  5365. * @param r defines the red component to check
  5366. * @param g defines the green component to check
  5367. * @param b defines the blue component to check
  5368. * @returns true if the rgb values are equal to the given ones
  5369. */
  5370. equalsFloats(r: number, g: number, b: number): boolean;
  5371. /**
  5372. * Multiplies in place each rgb value by scale
  5373. * @param scale defines the scaling factor
  5374. * @returns the updated Color3
  5375. */
  5376. scale(scale: number): Color3;
  5377. /**
  5378. * Multiplies the rgb values by scale and stores the result into "result"
  5379. * @param scale defines the scaling factor
  5380. * @param result defines the Color3 object where to store the result
  5381. * @returns the unmodified current Color3
  5382. */
  5383. scaleToRef(scale: number, result: Color3): Color3;
  5384. /**
  5385. * Scale the current Color3 values by a factor and add the result to a given Color3
  5386. * @param scale defines the scale factor
  5387. * @param result defines color to store the result into
  5388. * @returns the unmodified current Color3
  5389. */
  5390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5391. /**
  5392. * Clamps the rgb values by the min and max values and stores the result into "result"
  5393. * @param min defines minimum clamping value (default is 0)
  5394. * @param max defines maximum clamping value (default is 1)
  5395. * @param result defines color to store the result into
  5396. * @returns the original Color3
  5397. */
  5398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5399. /**
  5400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5401. * @param otherColor defines the second operand
  5402. * @returns the new Color3
  5403. */
  5404. add(otherColor: DeepImmutable<Color3>): Color3;
  5405. /**
  5406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5407. * @param otherColor defines the second operand
  5408. * @param result defines Color3 object to store the result into
  5409. * @returns the unmodified current Color3
  5410. */
  5411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5412. /**
  5413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5414. * @param otherColor defines the second operand
  5415. * @returns the new Color3
  5416. */
  5417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5418. /**
  5419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5420. * @param otherColor defines the second operand
  5421. * @param result defines Color3 object to store the result into
  5422. * @returns the unmodified current Color3
  5423. */
  5424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5425. /**
  5426. * Copy the current object
  5427. * @returns a new Color3 copied the current one
  5428. */
  5429. clone(): Color3;
  5430. /**
  5431. * Copies the rgb values from the source in the current Color3
  5432. * @param source defines the source Color3 object
  5433. * @returns the updated Color3 object
  5434. */
  5435. copyFrom(source: DeepImmutable<Color3>): Color3;
  5436. /**
  5437. * Updates the Color3 rgb values from the given floats
  5438. * @param r defines the red component to read from
  5439. * @param g defines the green component to read from
  5440. * @param b defines the blue component to read from
  5441. * @returns the current Color3 object
  5442. */
  5443. copyFromFloats(r: number, g: number, b: number): Color3;
  5444. /**
  5445. * Updates the Color3 rgb values from the given floats
  5446. * @param r defines the red component to read from
  5447. * @param g defines the green component to read from
  5448. * @param b defines the blue component to read from
  5449. * @returns the current Color3 object
  5450. */
  5451. set(r: number, g: number, b: number): Color3;
  5452. /**
  5453. * Compute the Color3 hexadecimal code as a string
  5454. * @returns a string containing the hexadecimal representation of the Color3 object
  5455. */
  5456. toHexString(): string;
  5457. /**
  5458. * Computes a new Color3 converted from the current one to linear space
  5459. * @returns a new Color3 object
  5460. */
  5461. toLinearSpace(): Color3;
  5462. /**
  5463. * Converts current color in rgb space to HSV values
  5464. * @returns a new color3 representing the HSV values
  5465. */
  5466. toHSV(): Color3;
  5467. /**
  5468. * Converts current color in rgb space to HSV values
  5469. * @param result defines the Color3 where to store the HSV values
  5470. */
  5471. toHSVToRef(result: Color3): void;
  5472. /**
  5473. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5474. * @param convertedColor defines the Color3 object where to store the linear space version
  5475. * @returns the unmodified Color3
  5476. */
  5477. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5478. /**
  5479. * Computes a new Color3 converted from the current one to gamma space
  5480. * @returns a new Color3 object
  5481. */
  5482. toGammaSpace(): Color3;
  5483. /**
  5484. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5485. * @param convertedColor defines the Color3 object where to store the gamma space version
  5486. * @returns the unmodified Color3
  5487. */
  5488. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5489. private static _BlackReadOnly;
  5490. /**
  5491. * Convert Hue, saturation and value to a Color3 (RGB)
  5492. * @param hue defines the hue
  5493. * @param saturation defines the saturation
  5494. * @param value defines the value
  5495. * @param result defines the Color3 where to store the RGB values
  5496. */
  5497. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5498. /**
  5499. * Creates a new Color3 from the string containing valid hexadecimal values
  5500. * @param hex defines a string containing valid hexadecimal values
  5501. * @returns a new Color3 object
  5502. */
  5503. static FromHexString(hex: string): Color3;
  5504. /**
  5505. * Creates a new Color3 from the starting index of the given array
  5506. * @param array defines the source array
  5507. * @param offset defines an offset in the source array
  5508. * @returns a new Color3 object
  5509. */
  5510. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5511. /**
  5512. * Creates a new Color3 from integer values (< 256)
  5513. * @param r defines the red component to read from (value between 0 and 255)
  5514. * @param g defines the green component to read from (value between 0 and 255)
  5515. * @param b defines the blue component to read from (value between 0 and 255)
  5516. * @returns a new Color3 object
  5517. */
  5518. static FromInts(r: number, g: number, b: number): Color3;
  5519. /**
  5520. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5521. * @param start defines the start Color3 value
  5522. * @param end defines the end Color3 value
  5523. * @param amount defines the gradient value between start and end
  5524. * @returns a new Color3 object
  5525. */
  5526. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5527. /**
  5528. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5529. * @param left defines the start value
  5530. * @param right defines the end value
  5531. * @param amount defines the gradient factor
  5532. * @param result defines the Color3 object where to store the result
  5533. */
  5534. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5535. /**
  5536. * Returns a Color3 value containing a red color
  5537. * @returns a new Color3 object
  5538. */
  5539. static Red(): Color3;
  5540. /**
  5541. * Returns a Color3 value containing a green color
  5542. * @returns a new Color3 object
  5543. */
  5544. static Green(): Color3;
  5545. /**
  5546. * Returns a Color3 value containing a blue color
  5547. * @returns a new Color3 object
  5548. */
  5549. static Blue(): Color3;
  5550. /**
  5551. * Returns a Color3 value containing a black color
  5552. * @returns a new Color3 object
  5553. */
  5554. static Black(): Color3;
  5555. /**
  5556. * Gets a Color3 value containing a black color that must not be updated
  5557. */
  5558. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5559. /**
  5560. * Returns a Color3 value containing a white color
  5561. * @returns a new Color3 object
  5562. */
  5563. static White(): Color3;
  5564. /**
  5565. * Returns a Color3 value containing a purple color
  5566. * @returns a new Color3 object
  5567. */
  5568. static Purple(): Color3;
  5569. /**
  5570. * Returns a Color3 value containing a magenta color
  5571. * @returns a new Color3 object
  5572. */
  5573. static Magenta(): Color3;
  5574. /**
  5575. * Returns a Color3 value containing a yellow color
  5576. * @returns a new Color3 object
  5577. */
  5578. static Yellow(): Color3;
  5579. /**
  5580. * Returns a Color3 value containing a gray color
  5581. * @returns a new Color3 object
  5582. */
  5583. static Gray(): Color3;
  5584. /**
  5585. * Returns a Color3 value containing a teal color
  5586. * @returns a new Color3 object
  5587. */
  5588. static Teal(): Color3;
  5589. /**
  5590. * Returns a Color3 value containing a random color
  5591. * @returns a new Color3 object
  5592. */
  5593. static Random(): Color3;
  5594. }
  5595. /**
  5596. * Class used to hold a RBGA color
  5597. */
  5598. export class Color4 {
  5599. /**
  5600. * Defines the red component (between 0 and 1, default is 0)
  5601. */
  5602. r: number;
  5603. /**
  5604. * Defines the green component (between 0 and 1, default is 0)
  5605. */
  5606. g: number;
  5607. /**
  5608. * Defines the blue component (between 0 and 1, default is 0)
  5609. */
  5610. b: number;
  5611. /**
  5612. * Defines the alpha component (between 0 and 1, default is 1)
  5613. */
  5614. a: number;
  5615. /**
  5616. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5617. * @param r defines the red component (between 0 and 1, default is 0)
  5618. * @param g defines the green component (between 0 and 1, default is 0)
  5619. * @param b defines the blue component (between 0 and 1, default is 0)
  5620. * @param a defines the alpha component (between 0 and 1, default is 1)
  5621. */
  5622. constructor(
  5623. /**
  5624. * Defines the red component (between 0 and 1, default is 0)
  5625. */
  5626. r?: number,
  5627. /**
  5628. * Defines the green component (between 0 and 1, default is 0)
  5629. */
  5630. g?: number,
  5631. /**
  5632. * Defines the blue component (between 0 and 1, default is 0)
  5633. */
  5634. b?: number,
  5635. /**
  5636. * Defines the alpha component (between 0 and 1, default is 1)
  5637. */
  5638. a?: number);
  5639. /**
  5640. * Adds in place the given Color4 values to the current Color4 object
  5641. * @param right defines the second operand
  5642. * @returns the current updated Color4 object
  5643. */
  5644. addInPlace(right: DeepImmutable<Color4>): Color4;
  5645. /**
  5646. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5647. * @returns the new array
  5648. */
  5649. asArray(): number[];
  5650. /**
  5651. * Stores from the starting index in the given array the Color4 successive values
  5652. * @param array defines the array where to store the r,g,b components
  5653. * @param index defines an optional index in the target array to define where to start storing values
  5654. * @returns the current Color4 object
  5655. */
  5656. toArray(array: number[], index?: number): Color4;
  5657. /**
  5658. * Determines equality between Color4 objects
  5659. * @param otherColor defines the second operand
  5660. * @returns true if the rgba values are equal to the given ones
  5661. */
  5662. equals(otherColor: DeepImmutable<Color4>): boolean;
  5663. /**
  5664. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5665. * @param right defines the second operand
  5666. * @returns a new Color4 object
  5667. */
  5668. add(right: DeepImmutable<Color4>): Color4;
  5669. /**
  5670. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5671. * @param right defines the second operand
  5672. * @returns a new Color4 object
  5673. */
  5674. subtract(right: DeepImmutable<Color4>): Color4;
  5675. /**
  5676. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5677. * @param right defines the second operand
  5678. * @param result defines the Color4 object where to store the result
  5679. * @returns the current Color4 object
  5680. */
  5681. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5682. /**
  5683. * Creates a new Color4 with the current Color4 values multiplied by scale
  5684. * @param scale defines the scaling factor to apply
  5685. * @returns a new Color4 object
  5686. */
  5687. scale(scale: number): Color4;
  5688. /**
  5689. * Multiplies the current Color4 values by scale and stores the result in "result"
  5690. * @param scale defines the scaling factor to apply
  5691. * @param result defines the Color4 object where to store the result
  5692. * @returns the current unmodified Color4
  5693. */
  5694. scaleToRef(scale: number, result: Color4): Color4;
  5695. /**
  5696. * Scale the current Color4 values by a factor and add the result to a given Color4
  5697. * @param scale defines the scale factor
  5698. * @param result defines the Color4 object where to store the result
  5699. * @returns the unmodified current Color4
  5700. */
  5701. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5702. /**
  5703. * Clamps the rgb values by the min and max values and stores the result into "result"
  5704. * @param min defines minimum clamping value (default is 0)
  5705. * @param max defines maximum clamping value (default is 1)
  5706. * @param result defines color to store the result into.
  5707. * @returns the cuurent Color4
  5708. */
  5709. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5710. /**
  5711. * Multipy an Color4 value by another and return a new Color4 object
  5712. * @param color defines the Color4 value to multiply by
  5713. * @returns a new Color4 object
  5714. */
  5715. multiply(color: Color4): Color4;
  5716. /**
  5717. * Multipy a Color4 value by another and push the result in a reference value
  5718. * @param color defines the Color4 value to multiply by
  5719. * @param result defines the Color4 to fill the result in
  5720. * @returns the result Color4
  5721. */
  5722. multiplyToRef(color: Color4, result: Color4): Color4;
  5723. /**
  5724. * Creates a string with the Color4 current values
  5725. * @returns the string representation of the Color4 object
  5726. */
  5727. toString(): string;
  5728. /**
  5729. * Returns the string "Color4"
  5730. * @returns "Color4"
  5731. */
  5732. getClassName(): string;
  5733. /**
  5734. * Compute the Color4 hash code
  5735. * @returns an unique number that can be used to hash Color4 objects
  5736. */
  5737. getHashCode(): number;
  5738. /**
  5739. * Creates a new Color4 copied from the current one
  5740. * @returns a new Color4 object
  5741. */
  5742. clone(): Color4;
  5743. /**
  5744. * Copies the given Color4 values into the current one
  5745. * @param source defines the source Color4 object
  5746. * @returns the current updated Color4 object
  5747. */
  5748. copyFrom(source: Color4): Color4;
  5749. /**
  5750. * Copies the given float values into the current one
  5751. * @param r defines the red component to read from
  5752. * @param g defines the green component to read from
  5753. * @param b defines the blue component to read from
  5754. * @param a defines the alpha component to read from
  5755. * @returns the current updated Color4 object
  5756. */
  5757. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5758. /**
  5759. * Copies the given float values into the current one
  5760. * @param r defines the red component to read from
  5761. * @param g defines the green component to read from
  5762. * @param b defines the blue component to read from
  5763. * @param a defines the alpha component to read from
  5764. * @returns the current updated Color4 object
  5765. */
  5766. set(r: number, g: number, b: number, a: number): Color4;
  5767. /**
  5768. * Compute the Color4 hexadecimal code as a string
  5769. * @returns a string containing the hexadecimal representation of the Color4 object
  5770. */
  5771. toHexString(): string;
  5772. /**
  5773. * Computes a new Color4 converted from the current one to linear space
  5774. * @returns a new Color4 object
  5775. */
  5776. toLinearSpace(): Color4;
  5777. /**
  5778. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5779. * @param convertedColor defines the Color4 object where to store the linear space version
  5780. * @returns the unmodified Color4
  5781. */
  5782. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5783. /**
  5784. * Computes a new Color4 converted from the current one to gamma space
  5785. * @returns a new Color4 object
  5786. */
  5787. toGammaSpace(): Color4;
  5788. /**
  5789. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5790. * @param convertedColor defines the Color4 object where to store the gamma space version
  5791. * @returns the unmodified Color4
  5792. */
  5793. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5794. /**
  5795. * Creates a new Color4 from the string containing valid hexadecimal values
  5796. * @param hex defines a string containing valid hexadecimal values
  5797. * @returns a new Color4 object
  5798. */
  5799. static FromHexString(hex: string): Color4;
  5800. /**
  5801. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5802. * @param left defines the start value
  5803. * @param right defines the end value
  5804. * @param amount defines the gradient factor
  5805. * @returns a new Color4 object
  5806. */
  5807. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5808. /**
  5809. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5810. * @param left defines the start value
  5811. * @param right defines the end value
  5812. * @param amount defines the gradient factor
  5813. * @param result defines the Color4 object where to store data
  5814. */
  5815. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5816. /**
  5817. * Creates a new Color4 from a Color3 and an alpha value
  5818. * @param color3 defines the source Color3 to read from
  5819. * @param alpha defines the alpha component (1.0 by default)
  5820. * @returns a new Color4 object
  5821. */
  5822. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5823. /**
  5824. * Creates a new Color4 from the starting index element of the given array
  5825. * @param array defines the source array to read from
  5826. * @param offset defines the offset in the source array
  5827. * @returns a new Color4 object
  5828. */
  5829. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5830. /**
  5831. * Creates a new Color3 from integer values (< 256)
  5832. * @param r defines the red component to read from (value between 0 and 255)
  5833. * @param g defines the green component to read from (value between 0 and 255)
  5834. * @param b defines the blue component to read from (value between 0 and 255)
  5835. * @param a defines the alpha component to read from (value between 0 and 255)
  5836. * @returns a new Color3 object
  5837. */
  5838. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5839. /**
  5840. * Check the content of a given array and convert it to an array containing RGBA data
  5841. * If the original array was already containing count * 4 values then it is returned directly
  5842. * @param colors defines the array to check
  5843. * @param count defines the number of RGBA data to expect
  5844. * @returns an array containing count * 4 values (RGBA)
  5845. */
  5846. static CheckColors4(colors: number[], count: number): number[];
  5847. }
  5848. /**
  5849. * @hidden
  5850. */
  5851. export class TmpColors {
  5852. static Color3: Color3[];
  5853. static Color4: Color4[];
  5854. }
  5855. }
  5856. declare module "babylonjs/Animations/animationKey" {
  5857. /**
  5858. * Defines an interface which represents an animation key frame
  5859. */
  5860. export interface IAnimationKey {
  5861. /**
  5862. * Frame of the key frame
  5863. */
  5864. frame: number;
  5865. /**
  5866. * Value at the specifies key frame
  5867. */
  5868. value: any;
  5869. /**
  5870. * The input tangent for the cubic hermite spline
  5871. */
  5872. inTangent?: any;
  5873. /**
  5874. * The output tangent for the cubic hermite spline
  5875. */
  5876. outTangent?: any;
  5877. /**
  5878. * The animation interpolation type
  5879. */
  5880. interpolation?: AnimationKeyInterpolation;
  5881. }
  5882. /**
  5883. * Enum for the animation key frame interpolation type
  5884. */
  5885. export enum AnimationKeyInterpolation {
  5886. /**
  5887. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5888. */
  5889. STEP = 1
  5890. }
  5891. }
  5892. declare module "babylonjs/Animations/animationRange" {
  5893. /**
  5894. * Represents the range of an animation
  5895. */
  5896. export class AnimationRange {
  5897. /**The name of the animation range**/
  5898. name: string;
  5899. /**The starting frame of the animation */
  5900. from: number;
  5901. /**The ending frame of the animation*/
  5902. to: number;
  5903. /**
  5904. * Initializes the range of an animation
  5905. * @param name The name of the animation range
  5906. * @param from The starting frame of the animation
  5907. * @param to The ending frame of the animation
  5908. */
  5909. constructor(
  5910. /**The name of the animation range**/
  5911. name: string,
  5912. /**The starting frame of the animation */
  5913. from: number,
  5914. /**The ending frame of the animation*/
  5915. to: number);
  5916. /**
  5917. * Makes a copy of the animation range
  5918. * @returns A copy of the animation range
  5919. */
  5920. clone(): AnimationRange;
  5921. }
  5922. }
  5923. declare module "babylonjs/Animations/animationEvent" {
  5924. /**
  5925. * Composed of a frame, and an action function
  5926. */
  5927. export class AnimationEvent {
  5928. /** The frame for which the event is triggered **/
  5929. frame: number;
  5930. /** The event to perform when triggered **/
  5931. action: (currentFrame: number) => void;
  5932. /** Specifies if the event should be triggered only once**/
  5933. onlyOnce?: boolean | undefined;
  5934. /**
  5935. * Specifies if the animation event is done
  5936. */
  5937. isDone: boolean;
  5938. /**
  5939. * Initializes the animation event
  5940. * @param frame The frame for which the event is triggered
  5941. * @param action The event to perform when triggered
  5942. * @param onlyOnce Specifies if the event should be triggered only once
  5943. */
  5944. constructor(
  5945. /** The frame for which the event is triggered **/
  5946. frame: number,
  5947. /** The event to perform when triggered **/
  5948. action: (currentFrame: number) => void,
  5949. /** Specifies if the event should be triggered only once**/
  5950. onlyOnce?: boolean | undefined);
  5951. /** @hidden */
  5952. _clone(): AnimationEvent;
  5953. }
  5954. }
  5955. declare module "babylonjs/Behaviors/behavior" {
  5956. import { Nullable } from "babylonjs/types";
  5957. /**
  5958. * Interface used to define a behavior
  5959. */
  5960. export interface Behavior<T> {
  5961. /** gets or sets behavior's name */
  5962. name: string;
  5963. /**
  5964. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5965. */
  5966. init(): void;
  5967. /**
  5968. * Called when the behavior is attached to a target
  5969. * @param target defines the target where the behavior is attached to
  5970. */
  5971. attach(target: T): void;
  5972. /**
  5973. * Called when the behavior is detached from its target
  5974. */
  5975. detach(): void;
  5976. }
  5977. /**
  5978. * Interface implemented by classes supporting behaviors
  5979. */
  5980. export interface IBehaviorAware<T> {
  5981. /**
  5982. * Attach a behavior
  5983. * @param behavior defines the behavior to attach
  5984. * @returns the current host
  5985. */
  5986. addBehavior(behavior: Behavior<T>): T;
  5987. /**
  5988. * Remove a behavior from the current object
  5989. * @param behavior defines the behavior to detach
  5990. * @returns the current host
  5991. */
  5992. removeBehavior(behavior: Behavior<T>): T;
  5993. /**
  5994. * Gets a behavior using its name to search
  5995. * @param name defines the name to search
  5996. * @returns the behavior or null if not found
  5997. */
  5998. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5999. }
  6000. }
  6001. declare module "babylonjs/Misc/smartArray" {
  6002. /**
  6003. * Defines an array and its length.
  6004. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6005. */
  6006. export interface ISmartArrayLike<T> {
  6007. /**
  6008. * The data of the array.
  6009. */
  6010. data: Array<T>;
  6011. /**
  6012. * The active length of the array.
  6013. */
  6014. length: number;
  6015. }
  6016. /**
  6017. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6018. */
  6019. export class SmartArray<T> implements ISmartArrayLike<T> {
  6020. /**
  6021. * The full set of data from the array.
  6022. */
  6023. data: Array<T>;
  6024. /**
  6025. * The active length of the array.
  6026. */
  6027. length: number;
  6028. protected _id: number;
  6029. /**
  6030. * Instantiates a Smart Array.
  6031. * @param capacity defines the default capacity of the array.
  6032. */
  6033. constructor(capacity: number);
  6034. /**
  6035. * Pushes a value at the end of the active data.
  6036. * @param value defines the object to push in the array.
  6037. */
  6038. push(value: T): void;
  6039. /**
  6040. * Iterates over the active data and apply the lambda to them.
  6041. * @param func defines the action to apply on each value.
  6042. */
  6043. forEach(func: (content: T) => void): void;
  6044. /**
  6045. * Sorts the full sets of data.
  6046. * @param compareFn defines the comparison function to apply.
  6047. */
  6048. sort(compareFn: (a: T, b: T) => number): void;
  6049. /**
  6050. * Resets the active data to an empty array.
  6051. */
  6052. reset(): void;
  6053. /**
  6054. * Releases all the data from the array as well as the array.
  6055. */
  6056. dispose(): void;
  6057. /**
  6058. * Concats the active data with a given array.
  6059. * @param array defines the data to concatenate with.
  6060. */
  6061. concat(array: any): void;
  6062. /**
  6063. * Returns the position of a value in the active data.
  6064. * @param value defines the value to find the index for
  6065. * @returns the index if found in the active data otherwise -1
  6066. */
  6067. indexOf(value: T): number;
  6068. /**
  6069. * Returns whether an element is part of the active data.
  6070. * @param value defines the value to look for
  6071. * @returns true if found in the active data otherwise false
  6072. */
  6073. contains(value: T): boolean;
  6074. private static _GlobalId;
  6075. }
  6076. /**
  6077. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6078. * The data in this array can only be present once
  6079. */
  6080. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6081. private _duplicateId;
  6082. /**
  6083. * Pushes a value at the end of the active data.
  6084. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6085. * @param value defines the object to push in the array.
  6086. */
  6087. push(value: T): void;
  6088. /**
  6089. * Pushes a value at the end of the active data.
  6090. * If the data is already present, it won t be added again
  6091. * @param value defines the object to push in the array.
  6092. * @returns true if added false if it was already present
  6093. */
  6094. pushNoDuplicate(value: T): boolean;
  6095. /**
  6096. * Resets the active data to an empty array.
  6097. */
  6098. reset(): void;
  6099. /**
  6100. * Concats the active data with a given array.
  6101. * This ensures no dupplicate will be present in the result.
  6102. * @param array defines the data to concatenate with.
  6103. */
  6104. concatWithNoDuplicate(array: any): void;
  6105. }
  6106. }
  6107. declare module "babylonjs/Cameras/cameraInputsManager" {
  6108. import { Nullable } from "babylonjs/types";
  6109. import { Camera } from "babylonjs/Cameras/camera";
  6110. /**
  6111. * @ignore
  6112. * This is a list of all the different input types that are available in the application.
  6113. * Fo instance: ArcRotateCameraGamepadInput...
  6114. */
  6115. export var CameraInputTypes: {};
  6116. /**
  6117. * This is the contract to implement in order to create a new input class.
  6118. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6119. */
  6120. export interface ICameraInput<TCamera extends Camera> {
  6121. /**
  6122. * Defines the camera the input is attached to.
  6123. */
  6124. camera: Nullable<TCamera>;
  6125. /**
  6126. * Gets the class name of the current intput.
  6127. * @returns the class name
  6128. */
  6129. getClassName(): string;
  6130. /**
  6131. * Get the friendly name associated with the input class.
  6132. * @returns the input friendly name
  6133. */
  6134. getSimpleName(): string;
  6135. /**
  6136. * Attach the input controls to a specific dom element to get the input from.
  6137. * @param element Defines the element the controls should be listened from
  6138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6139. */
  6140. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6141. /**
  6142. * Detach the current controls from the specified dom element.
  6143. * @param element Defines the element to stop listening the inputs from
  6144. */
  6145. detachControl(element: Nullable<HTMLElement>): void;
  6146. /**
  6147. * Update the current camera state depending on the inputs that have been used this frame.
  6148. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6149. */
  6150. checkInputs?: () => void;
  6151. }
  6152. /**
  6153. * Represents a map of input types to input instance or input index to input instance.
  6154. */
  6155. export interface CameraInputsMap<TCamera extends Camera> {
  6156. /**
  6157. * Accessor to the input by input type.
  6158. */
  6159. [name: string]: ICameraInput<TCamera>;
  6160. /**
  6161. * Accessor to the input by input index.
  6162. */
  6163. [idx: number]: ICameraInput<TCamera>;
  6164. }
  6165. /**
  6166. * This represents the input manager used within a camera.
  6167. * It helps dealing with all the different kind of input attached to a camera.
  6168. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6169. */
  6170. export class CameraInputsManager<TCamera extends Camera> {
  6171. /**
  6172. * Defines the list of inputs attahed to the camera.
  6173. */
  6174. attached: CameraInputsMap<TCamera>;
  6175. /**
  6176. * Defines the dom element the camera is collecting inputs from.
  6177. * This is null if the controls have not been attached.
  6178. */
  6179. attachedElement: Nullable<HTMLElement>;
  6180. /**
  6181. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6182. */
  6183. noPreventDefault: boolean;
  6184. /**
  6185. * Defined the camera the input manager belongs to.
  6186. */
  6187. camera: TCamera;
  6188. /**
  6189. * Update the current camera state depending on the inputs that have been used this frame.
  6190. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6191. */
  6192. checkInputs: () => void;
  6193. /**
  6194. * Instantiate a new Camera Input Manager.
  6195. * @param camera Defines the camera the input manager blongs to
  6196. */
  6197. constructor(camera: TCamera);
  6198. /**
  6199. * Add an input method to a camera
  6200. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6201. * @param input camera input method
  6202. */
  6203. add(input: ICameraInput<TCamera>): void;
  6204. /**
  6205. * Remove a specific input method from a camera
  6206. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6207. * @param inputToRemove camera input method
  6208. */
  6209. remove(inputToRemove: ICameraInput<TCamera>): void;
  6210. /**
  6211. * Remove a specific input type from a camera
  6212. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6213. * @param inputType the type of the input to remove
  6214. */
  6215. removeByType(inputType: string): void;
  6216. private _addCheckInputs;
  6217. /**
  6218. * Attach the input controls to the currently attached dom element to listen the events from.
  6219. * @param input Defines the input to attach
  6220. */
  6221. attachInput(input: ICameraInput<TCamera>): void;
  6222. /**
  6223. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6224. * @param element Defines the dom element to collect the events from
  6225. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6226. */
  6227. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6228. /**
  6229. * Detach the current manager inputs controls from a specific dom element.
  6230. * @param element Defines the dom element to collect the events from
  6231. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6232. */
  6233. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6234. /**
  6235. * Rebuild the dynamic inputCheck function from the current list of
  6236. * defined inputs in the manager.
  6237. */
  6238. rebuildInputCheck(): void;
  6239. /**
  6240. * Remove all attached input methods from a camera
  6241. */
  6242. clear(): void;
  6243. /**
  6244. * Serialize the current input manager attached to a camera.
  6245. * This ensures than once parsed,
  6246. * the input associated to the camera will be identical to the current ones
  6247. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6248. */
  6249. serialize(serializedCamera: any): void;
  6250. /**
  6251. * Parses an input manager serialized JSON to restore the previous list of inputs
  6252. * and states associated to a camera.
  6253. * @param parsedCamera Defines the JSON to parse
  6254. */
  6255. parse(parsedCamera: any): void;
  6256. }
  6257. }
  6258. declare module "babylonjs/Meshes/buffer" {
  6259. import { Nullable, DataArray } from "babylonjs/types";
  6260. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6261. /**
  6262. * Class used to store data that will be store in GPU memory
  6263. */
  6264. export class Buffer {
  6265. private _engine;
  6266. private _buffer;
  6267. /** @hidden */
  6268. _data: Nullable<DataArray>;
  6269. private _updatable;
  6270. private _instanced;
  6271. private _divisor;
  6272. /**
  6273. * Gets the byte stride.
  6274. */
  6275. readonly byteStride: number;
  6276. /**
  6277. * Constructor
  6278. * @param engine the engine
  6279. * @param data the data to use for this buffer
  6280. * @param updatable whether the data is updatable
  6281. * @param stride the stride (optional)
  6282. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6283. * @param instanced whether the buffer is instanced (optional)
  6284. * @param useBytes set to true if the stride in in bytes (optional)
  6285. * @param divisor sets an optional divisor for instances (1 by default)
  6286. */
  6287. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6288. /**
  6289. * Create a new VertexBuffer based on the current buffer
  6290. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6291. * @param offset defines offset in the buffer (0 by default)
  6292. * @param size defines the size in floats of attributes (position is 3 for instance)
  6293. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6294. * @param instanced defines if the vertex buffer contains indexed data
  6295. * @param useBytes defines if the offset and stride are in bytes *
  6296. * @param divisor sets an optional divisor for instances (1 by default)
  6297. * @returns the new vertex buffer
  6298. */
  6299. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6300. /**
  6301. * Gets a boolean indicating if the Buffer is updatable?
  6302. * @returns true if the buffer is updatable
  6303. */
  6304. isUpdatable(): boolean;
  6305. /**
  6306. * Gets current buffer's data
  6307. * @returns a DataArray or null
  6308. */
  6309. getData(): Nullable<DataArray>;
  6310. /**
  6311. * Gets underlying native buffer
  6312. * @returns underlying native buffer
  6313. */
  6314. getBuffer(): Nullable<DataBuffer>;
  6315. /**
  6316. * Gets the stride in float32 units (i.e. byte stride / 4).
  6317. * May not be an integer if the byte stride is not divisible by 4.
  6318. * @returns the stride in float32 units
  6319. * @deprecated Please use byteStride instead.
  6320. */
  6321. getStrideSize(): number;
  6322. /**
  6323. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6324. * @param data defines the data to store
  6325. */
  6326. create(data?: Nullable<DataArray>): void;
  6327. /** @hidden */
  6328. _rebuild(): void;
  6329. /**
  6330. * Update current buffer data
  6331. * @param data defines the data to store
  6332. */
  6333. update(data: DataArray): void;
  6334. /**
  6335. * Updates the data directly.
  6336. * @param data the new data
  6337. * @param offset the new offset
  6338. * @param vertexCount the vertex count (optional)
  6339. * @param useBytes set to true if the offset is in bytes
  6340. */
  6341. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6342. /**
  6343. * Release all resources
  6344. */
  6345. dispose(): void;
  6346. }
  6347. /**
  6348. * Specialized buffer used to store vertex data
  6349. */
  6350. export class VertexBuffer {
  6351. /** @hidden */
  6352. _buffer: Buffer;
  6353. private _kind;
  6354. private _size;
  6355. private _ownsBuffer;
  6356. private _instanced;
  6357. private _instanceDivisor;
  6358. /**
  6359. * The byte type.
  6360. */
  6361. static readonly BYTE: number;
  6362. /**
  6363. * The unsigned byte type.
  6364. */
  6365. static readonly UNSIGNED_BYTE: number;
  6366. /**
  6367. * The short type.
  6368. */
  6369. static readonly SHORT: number;
  6370. /**
  6371. * The unsigned short type.
  6372. */
  6373. static readonly UNSIGNED_SHORT: number;
  6374. /**
  6375. * The integer type.
  6376. */
  6377. static readonly INT: number;
  6378. /**
  6379. * The unsigned integer type.
  6380. */
  6381. static readonly UNSIGNED_INT: number;
  6382. /**
  6383. * The float type.
  6384. */
  6385. static readonly FLOAT: number;
  6386. /**
  6387. * Gets or sets the instance divisor when in instanced mode
  6388. */
  6389. instanceDivisor: number;
  6390. /**
  6391. * Gets the byte stride.
  6392. */
  6393. readonly byteStride: number;
  6394. /**
  6395. * Gets the byte offset.
  6396. */
  6397. readonly byteOffset: number;
  6398. /**
  6399. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6400. */
  6401. readonly normalized: boolean;
  6402. /**
  6403. * Gets the data type of each component in the array.
  6404. */
  6405. readonly type: number;
  6406. /**
  6407. * Constructor
  6408. * @param engine the engine
  6409. * @param data the data to use for this vertex buffer
  6410. * @param kind the vertex buffer kind
  6411. * @param updatable whether the data is updatable
  6412. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6413. * @param stride the stride (optional)
  6414. * @param instanced whether the buffer is instanced (optional)
  6415. * @param offset the offset of the data (optional)
  6416. * @param size the number of components (optional)
  6417. * @param type the type of the component (optional)
  6418. * @param normalized whether the data contains normalized data (optional)
  6419. * @param useBytes set to true if stride and offset are in bytes (optional)
  6420. * @param divisor defines the instance divisor to use (1 by default)
  6421. */
  6422. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6423. /** @hidden */
  6424. _rebuild(): void;
  6425. /**
  6426. * Returns the kind of the VertexBuffer (string)
  6427. * @returns a string
  6428. */
  6429. getKind(): string;
  6430. /**
  6431. * Gets a boolean indicating if the VertexBuffer is updatable?
  6432. * @returns true if the buffer is updatable
  6433. */
  6434. isUpdatable(): boolean;
  6435. /**
  6436. * Gets current buffer's data
  6437. * @returns a DataArray or null
  6438. */
  6439. getData(): Nullable<DataArray>;
  6440. /**
  6441. * Gets underlying native buffer
  6442. * @returns underlying native buffer
  6443. */
  6444. getBuffer(): Nullable<DataBuffer>;
  6445. /**
  6446. * Gets the stride in float32 units (i.e. byte stride / 4).
  6447. * May not be an integer if the byte stride is not divisible by 4.
  6448. * @returns the stride in float32 units
  6449. * @deprecated Please use byteStride instead.
  6450. */
  6451. getStrideSize(): number;
  6452. /**
  6453. * Returns the offset as a multiple of the type byte length.
  6454. * @returns the offset in bytes
  6455. * @deprecated Please use byteOffset instead.
  6456. */
  6457. getOffset(): number;
  6458. /**
  6459. * Returns the number of components per vertex attribute (integer)
  6460. * @returns the size in float
  6461. */
  6462. getSize(): number;
  6463. /**
  6464. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6465. * @returns true if this buffer is instanced
  6466. */
  6467. getIsInstanced(): boolean;
  6468. /**
  6469. * Returns the instancing divisor, zero for non-instanced (integer).
  6470. * @returns a number
  6471. */
  6472. getInstanceDivisor(): number;
  6473. /**
  6474. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6475. * @param data defines the data to store
  6476. */
  6477. create(data?: DataArray): void;
  6478. /**
  6479. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6480. * This function will create a new buffer if the current one is not updatable
  6481. * @param data defines the data to store
  6482. */
  6483. update(data: DataArray): void;
  6484. /**
  6485. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6486. * Returns the directly updated WebGLBuffer.
  6487. * @param data the new data
  6488. * @param offset the new offset
  6489. * @param useBytes set to true if the offset is in bytes
  6490. */
  6491. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6492. /**
  6493. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6494. */
  6495. dispose(): void;
  6496. /**
  6497. * Enumerates each value of this vertex buffer as numbers.
  6498. * @param count the number of values to enumerate
  6499. * @param callback the callback function called for each value
  6500. */
  6501. forEach(count: number, callback: (value: number, index: number) => void): void;
  6502. /**
  6503. * Positions
  6504. */
  6505. static readonly PositionKind: string;
  6506. /**
  6507. * Normals
  6508. */
  6509. static readonly NormalKind: string;
  6510. /**
  6511. * Tangents
  6512. */
  6513. static readonly TangentKind: string;
  6514. /**
  6515. * Texture coordinates
  6516. */
  6517. static readonly UVKind: string;
  6518. /**
  6519. * Texture coordinates 2
  6520. */
  6521. static readonly UV2Kind: string;
  6522. /**
  6523. * Texture coordinates 3
  6524. */
  6525. static readonly UV3Kind: string;
  6526. /**
  6527. * Texture coordinates 4
  6528. */
  6529. static readonly UV4Kind: string;
  6530. /**
  6531. * Texture coordinates 5
  6532. */
  6533. static readonly UV5Kind: string;
  6534. /**
  6535. * Texture coordinates 6
  6536. */
  6537. static readonly UV6Kind: string;
  6538. /**
  6539. * Colors
  6540. */
  6541. static readonly ColorKind: string;
  6542. /**
  6543. * Matrix indices (for bones)
  6544. */
  6545. static readonly MatricesIndicesKind: string;
  6546. /**
  6547. * Matrix weights (for bones)
  6548. */
  6549. static readonly MatricesWeightsKind: string;
  6550. /**
  6551. * Additional matrix indices (for bones)
  6552. */
  6553. static readonly MatricesIndicesExtraKind: string;
  6554. /**
  6555. * Additional matrix weights (for bones)
  6556. */
  6557. static readonly MatricesWeightsExtraKind: string;
  6558. /**
  6559. * Deduces the stride given a kind.
  6560. * @param kind The kind string to deduce
  6561. * @returns The deduced stride
  6562. */
  6563. static DeduceStride(kind: string): number;
  6564. /**
  6565. * Gets the byte length of the given type.
  6566. * @param type the type
  6567. * @returns the number of bytes
  6568. */
  6569. static GetTypeByteLength(type: number): number;
  6570. /**
  6571. * Enumerates each value of the given parameters as numbers.
  6572. * @param data the data to enumerate
  6573. * @param byteOffset the byte offset of the data
  6574. * @param byteStride the byte stride of the data
  6575. * @param componentCount the number of components per element
  6576. * @param componentType the type of the component
  6577. * @param count the number of values to enumerate
  6578. * @param normalized whether the data is normalized
  6579. * @param callback the callback function called for each value
  6580. */
  6581. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6582. private static _GetFloatValue;
  6583. }
  6584. }
  6585. declare module "babylonjs/Collisions/intersectionInfo" {
  6586. import { Nullable } from "babylonjs/types";
  6587. /**
  6588. * @hidden
  6589. */
  6590. export class IntersectionInfo {
  6591. bu: Nullable<number>;
  6592. bv: Nullable<number>;
  6593. distance: number;
  6594. faceId: number;
  6595. subMeshId: number;
  6596. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6597. }
  6598. }
  6599. declare module "babylonjs/Maths/math.plane" {
  6600. import { DeepImmutable } from "babylonjs/types";
  6601. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6602. /**
  6603. * Represens a plane by the equation ax + by + cz + d = 0
  6604. */
  6605. export class Plane {
  6606. private static _TmpMatrix;
  6607. /**
  6608. * Normal of the plane (a,b,c)
  6609. */
  6610. normal: Vector3;
  6611. /**
  6612. * d component of the plane
  6613. */
  6614. d: number;
  6615. /**
  6616. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6617. * @param a a component of the plane
  6618. * @param b b component of the plane
  6619. * @param c c component of the plane
  6620. * @param d d component of the plane
  6621. */
  6622. constructor(a: number, b: number, c: number, d: number);
  6623. /**
  6624. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6625. */
  6626. asArray(): number[];
  6627. /**
  6628. * @returns a new plane copied from the current Plane.
  6629. */
  6630. clone(): Plane;
  6631. /**
  6632. * @returns the string "Plane".
  6633. */
  6634. getClassName(): string;
  6635. /**
  6636. * @returns the Plane hash code.
  6637. */
  6638. getHashCode(): number;
  6639. /**
  6640. * Normalize the current Plane in place.
  6641. * @returns the updated Plane.
  6642. */
  6643. normalize(): Plane;
  6644. /**
  6645. * Applies a transformation the plane and returns the result
  6646. * @param transformation the transformation matrix to be applied to the plane
  6647. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6648. */
  6649. transform(transformation: DeepImmutable<Matrix>): Plane;
  6650. /**
  6651. * Calcualtte the dot product between the point and the plane normal
  6652. * @param point point to calculate the dot product with
  6653. * @returns the dot product (float) of the point coordinates and the plane normal.
  6654. */
  6655. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6656. /**
  6657. * Updates the current Plane from the plane defined by the three given points.
  6658. * @param point1 one of the points used to contruct the plane
  6659. * @param point2 one of the points used to contruct the plane
  6660. * @param point3 one of the points used to contruct the plane
  6661. * @returns the updated Plane.
  6662. */
  6663. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6664. /**
  6665. * Checks if the plane is facing a given direction
  6666. * @param direction the direction to check if the plane is facing
  6667. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6668. * @returns True is the vector "direction" is the same side than the plane normal.
  6669. */
  6670. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6671. /**
  6672. * Calculates the distance to a point
  6673. * @param point point to calculate distance to
  6674. * @returns the signed distance (float) from the given point to the Plane.
  6675. */
  6676. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6677. /**
  6678. * Creates a plane from an array
  6679. * @param array the array to create a plane from
  6680. * @returns a new Plane from the given array.
  6681. */
  6682. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6683. /**
  6684. * Creates a plane from three points
  6685. * @param point1 point used to create the plane
  6686. * @param point2 point used to create the plane
  6687. * @param point3 point used to create the plane
  6688. * @returns a new Plane defined by the three given points.
  6689. */
  6690. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6691. /**
  6692. * Creates a plane from an origin point and a normal
  6693. * @param origin origin of the plane to be constructed
  6694. * @param normal normal of the plane to be constructed
  6695. * @returns a new Plane the normal vector to this plane at the given origin point.
  6696. * Note : the vector "normal" is updated because normalized.
  6697. */
  6698. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6699. /**
  6700. * Calculates the distance from a plane and a point
  6701. * @param origin origin of the plane to be constructed
  6702. * @param normal normal of the plane to be constructed
  6703. * @param point point to calculate distance to
  6704. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6705. */
  6706. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6707. }
  6708. }
  6709. declare module "babylonjs/Culling/boundingSphere" {
  6710. import { DeepImmutable } from "babylonjs/types";
  6711. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6712. import { Plane } from "babylonjs/Maths/math.plane";
  6713. /**
  6714. * Class used to store bounding sphere information
  6715. */
  6716. export class BoundingSphere {
  6717. /**
  6718. * Gets the center of the bounding sphere in local space
  6719. */
  6720. readonly center: Vector3;
  6721. /**
  6722. * Radius of the bounding sphere in local space
  6723. */
  6724. radius: number;
  6725. /**
  6726. * Gets the center of the bounding sphere in world space
  6727. */
  6728. readonly centerWorld: Vector3;
  6729. /**
  6730. * Radius of the bounding sphere in world space
  6731. */
  6732. radiusWorld: number;
  6733. /**
  6734. * Gets the minimum vector in local space
  6735. */
  6736. readonly minimum: Vector3;
  6737. /**
  6738. * Gets the maximum vector in local space
  6739. */
  6740. readonly maximum: Vector3;
  6741. private _worldMatrix;
  6742. private static readonly TmpVector3;
  6743. /**
  6744. * Creates a new bounding sphere
  6745. * @param min defines the minimum vector (in local space)
  6746. * @param max defines the maximum vector (in local space)
  6747. * @param worldMatrix defines the new world matrix
  6748. */
  6749. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6750. /**
  6751. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6752. * @param min defines the new minimum vector (in local space)
  6753. * @param max defines the new maximum vector (in local space)
  6754. * @param worldMatrix defines the new world matrix
  6755. */
  6756. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6757. /**
  6758. * Scale the current bounding sphere by applying a scale factor
  6759. * @param factor defines the scale factor to apply
  6760. * @returns the current bounding box
  6761. */
  6762. scale(factor: number): BoundingSphere;
  6763. /**
  6764. * Gets the world matrix of the bounding box
  6765. * @returns a matrix
  6766. */
  6767. getWorldMatrix(): DeepImmutable<Matrix>;
  6768. /** @hidden */
  6769. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6770. /**
  6771. * Tests if the bounding sphere is intersecting the frustum planes
  6772. * @param frustumPlanes defines the frustum planes to test
  6773. * @returns true if there is an intersection
  6774. */
  6775. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6776. /**
  6777. * Tests if the bounding sphere center is in between the frustum planes.
  6778. * Used for optimistic fast inclusion.
  6779. * @param frustumPlanes defines the frustum planes to test
  6780. * @returns true if the sphere center is in between the frustum planes
  6781. */
  6782. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6783. /**
  6784. * Tests if a point is inside the bounding sphere
  6785. * @param point defines the point to test
  6786. * @returns true if the point is inside the bounding sphere
  6787. */
  6788. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6789. /**
  6790. * Checks if two sphere intersct
  6791. * @param sphere0 sphere 0
  6792. * @param sphere1 sphere 1
  6793. * @returns true if the speres intersect
  6794. */
  6795. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6796. }
  6797. }
  6798. declare module "babylonjs/Culling/boundingBox" {
  6799. import { DeepImmutable } from "babylonjs/types";
  6800. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6801. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6802. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6803. import { Plane } from "babylonjs/Maths/math.plane";
  6804. /**
  6805. * Class used to store bounding box information
  6806. */
  6807. export class BoundingBox implements ICullable {
  6808. /**
  6809. * Gets the 8 vectors representing the bounding box in local space
  6810. */
  6811. readonly vectors: Vector3[];
  6812. /**
  6813. * Gets the center of the bounding box in local space
  6814. */
  6815. readonly center: Vector3;
  6816. /**
  6817. * Gets the center of the bounding box in world space
  6818. */
  6819. readonly centerWorld: Vector3;
  6820. /**
  6821. * Gets the extend size in local space
  6822. */
  6823. readonly extendSize: Vector3;
  6824. /**
  6825. * Gets the extend size in world space
  6826. */
  6827. readonly extendSizeWorld: Vector3;
  6828. /**
  6829. * Gets the OBB (object bounding box) directions
  6830. */
  6831. readonly directions: Vector3[];
  6832. /**
  6833. * Gets the 8 vectors representing the bounding box in world space
  6834. */
  6835. readonly vectorsWorld: Vector3[];
  6836. /**
  6837. * Gets the minimum vector in world space
  6838. */
  6839. readonly minimumWorld: Vector3;
  6840. /**
  6841. * Gets the maximum vector in world space
  6842. */
  6843. readonly maximumWorld: Vector3;
  6844. /**
  6845. * Gets the minimum vector in local space
  6846. */
  6847. readonly minimum: Vector3;
  6848. /**
  6849. * Gets the maximum vector in local space
  6850. */
  6851. readonly maximum: Vector3;
  6852. private _worldMatrix;
  6853. private static readonly TmpVector3;
  6854. /**
  6855. * @hidden
  6856. */
  6857. _tag: number;
  6858. /**
  6859. * Creates a new bounding box
  6860. * @param min defines the minimum vector (in local space)
  6861. * @param max defines the maximum vector (in local space)
  6862. * @param worldMatrix defines the new world matrix
  6863. */
  6864. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6865. /**
  6866. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6867. * @param min defines the new minimum vector (in local space)
  6868. * @param max defines the new maximum vector (in local space)
  6869. * @param worldMatrix defines the new world matrix
  6870. */
  6871. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6872. /**
  6873. * Scale the current bounding box by applying a scale factor
  6874. * @param factor defines the scale factor to apply
  6875. * @returns the current bounding box
  6876. */
  6877. scale(factor: number): BoundingBox;
  6878. /**
  6879. * Gets the world matrix of the bounding box
  6880. * @returns a matrix
  6881. */
  6882. getWorldMatrix(): DeepImmutable<Matrix>;
  6883. /** @hidden */
  6884. _update(world: DeepImmutable<Matrix>): void;
  6885. /**
  6886. * Tests if the bounding box is intersecting the frustum planes
  6887. * @param frustumPlanes defines the frustum planes to test
  6888. * @returns true if there is an intersection
  6889. */
  6890. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6891. /**
  6892. * Tests if the bounding box is entirely inside the frustum planes
  6893. * @param frustumPlanes defines the frustum planes to test
  6894. * @returns true if there is an inclusion
  6895. */
  6896. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6897. /**
  6898. * Tests if a point is inside the bounding box
  6899. * @param point defines the point to test
  6900. * @returns true if the point is inside the bounding box
  6901. */
  6902. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6903. /**
  6904. * Tests if the bounding box intersects with a bounding sphere
  6905. * @param sphere defines the sphere to test
  6906. * @returns true if there is an intersection
  6907. */
  6908. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6909. /**
  6910. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6911. * @param min defines the min vector to use
  6912. * @param max defines the max vector to use
  6913. * @returns true if there is an intersection
  6914. */
  6915. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6916. /**
  6917. * Tests if two bounding boxes are intersections
  6918. * @param box0 defines the first box to test
  6919. * @param box1 defines the second box to test
  6920. * @returns true if there is an intersection
  6921. */
  6922. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6923. /**
  6924. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6925. * @param minPoint defines the minimum vector of the bounding box
  6926. * @param maxPoint defines the maximum vector of the bounding box
  6927. * @param sphereCenter defines the sphere center
  6928. * @param sphereRadius defines the sphere radius
  6929. * @returns true if there is an intersection
  6930. */
  6931. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6932. /**
  6933. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6934. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6935. * @param frustumPlanes defines the frustum planes to test
  6936. * @return true if there is an inclusion
  6937. */
  6938. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6939. /**
  6940. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6941. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6942. * @param frustumPlanes defines the frustum planes to test
  6943. * @return true if there is an intersection
  6944. */
  6945. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6946. }
  6947. }
  6948. declare module "babylonjs/Collisions/collider" {
  6949. import { Nullable, IndicesArray } from "babylonjs/types";
  6950. import { Vector3 } from "babylonjs/Maths/math.vector";
  6951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6952. import { Plane } from "babylonjs/Maths/math.plane";
  6953. /** @hidden */
  6954. export class Collider {
  6955. /** Define if a collision was found */
  6956. collisionFound: boolean;
  6957. /**
  6958. * Define last intersection point in local space
  6959. */
  6960. intersectionPoint: Vector3;
  6961. /**
  6962. * Define last collided mesh
  6963. */
  6964. collidedMesh: Nullable<AbstractMesh>;
  6965. private _collisionPoint;
  6966. private _planeIntersectionPoint;
  6967. private _tempVector;
  6968. private _tempVector2;
  6969. private _tempVector3;
  6970. private _tempVector4;
  6971. private _edge;
  6972. private _baseToVertex;
  6973. private _destinationPoint;
  6974. private _slidePlaneNormal;
  6975. private _displacementVector;
  6976. /** @hidden */
  6977. _radius: Vector3;
  6978. /** @hidden */
  6979. _retry: number;
  6980. private _velocity;
  6981. private _basePoint;
  6982. private _epsilon;
  6983. /** @hidden */
  6984. _velocityWorldLength: number;
  6985. /** @hidden */
  6986. _basePointWorld: Vector3;
  6987. private _velocityWorld;
  6988. private _normalizedVelocity;
  6989. /** @hidden */
  6990. _initialVelocity: Vector3;
  6991. /** @hidden */
  6992. _initialPosition: Vector3;
  6993. private _nearestDistance;
  6994. private _collisionMask;
  6995. collisionMask: number;
  6996. /**
  6997. * Gets the plane normal used to compute the sliding response (in local space)
  6998. */
  6999. readonly slidePlaneNormal: Vector3;
  7000. /** @hidden */
  7001. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7002. /** @hidden */
  7003. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7004. /** @hidden */
  7005. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7006. /** @hidden */
  7007. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7008. /** @hidden */
  7009. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7010. /** @hidden */
  7011. _getResponse(pos: Vector3, vel: Vector3): void;
  7012. }
  7013. }
  7014. declare module "babylonjs/Culling/boundingInfo" {
  7015. import { DeepImmutable } from "babylonjs/types";
  7016. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7017. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7018. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7019. import { Plane } from "babylonjs/Maths/math.plane";
  7020. import { Collider } from "babylonjs/Collisions/collider";
  7021. /**
  7022. * Interface for cullable objects
  7023. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7024. */
  7025. export interface ICullable {
  7026. /**
  7027. * Checks if the object or part of the object is in the frustum
  7028. * @param frustumPlanes Camera near/planes
  7029. * @returns true if the object is in frustum otherwise false
  7030. */
  7031. isInFrustum(frustumPlanes: Plane[]): boolean;
  7032. /**
  7033. * Checks if a cullable object (mesh...) is in the camera frustum
  7034. * Unlike isInFrustum this cheks the full bounding box
  7035. * @param frustumPlanes Camera near/planes
  7036. * @returns true if the object is in frustum otherwise false
  7037. */
  7038. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7039. }
  7040. /**
  7041. * Info for a bounding data of a mesh
  7042. */
  7043. export class BoundingInfo implements ICullable {
  7044. /**
  7045. * Bounding box for the mesh
  7046. */
  7047. readonly boundingBox: BoundingBox;
  7048. /**
  7049. * Bounding sphere for the mesh
  7050. */
  7051. readonly boundingSphere: BoundingSphere;
  7052. private _isLocked;
  7053. private static readonly TmpVector3;
  7054. /**
  7055. * Constructs bounding info
  7056. * @param minimum min vector of the bounding box/sphere
  7057. * @param maximum max vector of the bounding box/sphere
  7058. * @param worldMatrix defines the new world matrix
  7059. */
  7060. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7061. /**
  7062. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7063. * @param min defines the new minimum vector (in local space)
  7064. * @param max defines the new maximum vector (in local space)
  7065. * @param worldMatrix defines the new world matrix
  7066. */
  7067. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7068. /**
  7069. * min vector of the bounding box/sphere
  7070. */
  7071. readonly minimum: Vector3;
  7072. /**
  7073. * max vector of the bounding box/sphere
  7074. */
  7075. readonly maximum: Vector3;
  7076. /**
  7077. * If the info is locked and won't be updated to avoid perf overhead
  7078. */
  7079. isLocked: boolean;
  7080. /**
  7081. * Updates the bounding sphere and box
  7082. * @param world world matrix to be used to update
  7083. */
  7084. update(world: DeepImmutable<Matrix>): void;
  7085. /**
  7086. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7087. * @param center New center of the bounding info
  7088. * @param extend New extend of the bounding info
  7089. * @returns the current bounding info
  7090. */
  7091. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7092. /**
  7093. * Scale the current bounding info by applying a scale factor
  7094. * @param factor defines the scale factor to apply
  7095. * @returns the current bounding info
  7096. */
  7097. scale(factor: number): BoundingInfo;
  7098. /**
  7099. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7100. * @param frustumPlanes defines the frustum to test
  7101. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7102. * @returns true if the bounding info is in the frustum planes
  7103. */
  7104. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7105. /**
  7106. * Gets the world distance between the min and max points of the bounding box
  7107. */
  7108. readonly diagonalLength: number;
  7109. /**
  7110. * Checks if a cullable object (mesh...) is in the camera frustum
  7111. * Unlike isInFrustum this cheks the full bounding box
  7112. * @param frustumPlanes Camera near/planes
  7113. * @returns true if the object is in frustum otherwise false
  7114. */
  7115. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7116. /** @hidden */
  7117. _checkCollision(collider: Collider): boolean;
  7118. /**
  7119. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7120. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7121. * @param point the point to check intersection with
  7122. * @returns if the point intersects
  7123. */
  7124. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7125. /**
  7126. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7127. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7128. * @param boundingInfo the bounding info to check intersection with
  7129. * @param precise if the intersection should be done using OBB
  7130. * @returns if the bounding info intersects
  7131. */
  7132. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7133. }
  7134. }
  7135. declare module "babylonjs/Maths/math.functions" {
  7136. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7137. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7138. /**
  7139. * Extracts minimum and maximum values from a list of indexed positions
  7140. * @param positions defines the positions to use
  7141. * @param indices defines the indices to the positions
  7142. * @param indexStart defines the start index
  7143. * @param indexCount defines the end index
  7144. * @param bias defines bias value to add to the result
  7145. * @return minimum and maximum values
  7146. */
  7147. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7148. minimum: Vector3;
  7149. maximum: Vector3;
  7150. };
  7151. /**
  7152. * Extracts minimum and maximum values from a list of positions
  7153. * @param positions defines the positions to use
  7154. * @param start defines the start index in the positions array
  7155. * @param count defines the number of positions to handle
  7156. * @param bias defines bias value to add to the result
  7157. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7158. * @return minimum and maximum values
  7159. */
  7160. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7161. minimum: Vector3;
  7162. maximum: Vector3;
  7163. };
  7164. }
  7165. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7166. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7167. /** @hidden */
  7168. export class WebGLDataBuffer extends DataBuffer {
  7169. private _buffer;
  7170. constructor(resource: WebGLBuffer);
  7171. readonly underlyingResource: any;
  7172. }
  7173. }
  7174. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7175. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7176. import { Nullable } from "babylonjs/types";
  7177. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7178. /** @hidden */
  7179. export class WebGLPipelineContext implements IPipelineContext {
  7180. engine: ThinEngine;
  7181. program: Nullable<WebGLProgram>;
  7182. context?: WebGLRenderingContext;
  7183. vertexShader?: WebGLShader;
  7184. fragmentShader?: WebGLShader;
  7185. isParallelCompiled: boolean;
  7186. onCompiled?: () => void;
  7187. transformFeedback?: WebGLTransformFeedback | null;
  7188. readonly isAsync: boolean;
  7189. readonly isReady: boolean;
  7190. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7191. }
  7192. }
  7193. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7194. import { FloatArray, Nullable } from "babylonjs/types";
  7195. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7196. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7197. module "babylonjs/Engines/thinEngine" {
  7198. interface ThinEngine {
  7199. /**
  7200. * Create an uniform buffer
  7201. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7202. * @param elements defines the content of the uniform buffer
  7203. * @returns the webGL uniform buffer
  7204. */
  7205. createUniformBuffer(elements: FloatArray): DataBuffer;
  7206. /**
  7207. * Create a dynamic uniform buffer
  7208. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7209. * @param elements defines the content of the uniform buffer
  7210. * @returns the webGL uniform buffer
  7211. */
  7212. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7213. /**
  7214. * Update an existing uniform buffer
  7215. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7216. * @param uniformBuffer defines the target uniform buffer
  7217. * @param elements defines the content to update
  7218. * @param offset defines the offset in the uniform buffer where update should start
  7219. * @param count defines the size of the data to update
  7220. */
  7221. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7222. /**
  7223. * Bind an uniform buffer to the current webGL context
  7224. * @param buffer defines the buffer to bind
  7225. */
  7226. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7227. /**
  7228. * Bind a buffer to the current webGL context at a given location
  7229. * @param buffer defines the buffer to bind
  7230. * @param location defines the index where to bind the buffer
  7231. */
  7232. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7233. /**
  7234. * Bind a specific block at a given index in a specific shader program
  7235. * @param pipelineContext defines the pipeline context to use
  7236. * @param blockName defines the block name
  7237. * @param index defines the index where to bind the block
  7238. */
  7239. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7240. }
  7241. }
  7242. }
  7243. declare module "babylonjs/Materials/uniformBuffer" {
  7244. import { Nullable, FloatArray } from "babylonjs/types";
  7245. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7246. import { Engine } from "babylonjs/Engines/engine";
  7247. import { Effect } from "babylonjs/Materials/effect";
  7248. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7249. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7250. import { Color3 } from "babylonjs/Maths/math.color";
  7251. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7252. /**
  7253. * Uniform buffer objects.
  7254. *
  7255. * Handles blocks of uniform on the GPU.
  7256. *
  7257. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7258. *
  7259. * For more information, please refer to :
  7260. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7261. */
  7262. export class UniformBuffer {
  7263. private _engine;
  7264. private _buffer;
  7265. private _data;
  7266. private _bufferData;
  7267. private _dynamic?;
  7268. private _uniformLocations;
  7269. private _uniformSizes;
  7270. private _uniformLocationPointer;
  7271. private _needSync;
  7272. private _noUBO;
  7273. private _currentEffect;
  7274. /** @hidden */
  7275. _alreadyBound: boolean;
  7276. private static _MAX_UNIFORM_SIZE;
  7277. private static _tempBuffer;
  7278. /**
  7279. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7280. * This is dynamic to allow compat with webgl 1 and 2.
  7281. * You will need to pass the name of the uniform as well as the value.
  7282. */
  7283. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7284. /**
  7285. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7286. * This is dynamic to allow compat with webgl 1 and 2.
  7287. * You will need to pass the name of the uniform as well as the value.
  7288. */
  7289. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7290. /**
  7291. * Lambda to Update a single float in a uniform buffer.
  7292. * This is dynamic to allow compat with webgl 1 and 2.
  7293. * You will need to pass the name of the uniform as well as the value.
  7294. */
  7295. updateFloat: (name: string, x: number) => void;
  7296. /**
  7297. * Lambda to Update a vec2 of float in a uniform buffer.
  7298. * This is dynamic to allow compat with webgl 1 and 2.
  7299. * You will need to pass the name of the uniform as well as the value.
  7300. */
  7301. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7302. /**
  7303. * Lambda to Update a vec3 of float in a uniform buffer.
  7304. * This is dynamic to allow compat with webgl 1 and 2.
  7305. * You will need to pass the name of the uniform as well as the value.
  7306. */
  7307. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7308. /**
  7309. * Lambda to Update a vec4 of float in a uniform buffer.
  7310. * This is dynamic to allow compat with webgl 1 and 2.
  7311. * You will need to pass the name of the uniform as well as the value.
  7312. */
  7313. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7314. /**
  7315. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7316. * This is dynamic to allow compat with webgl 1 and 2.
  7317. * You will need to pass the name of the uniform as well as the value.
  7318. */
  7319. updateMatrix: (name: string, mat: Matrix) => void;
  7320. /**
  7321. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7322. * This is dynamic to allow compat with webgl 1 and 2.
  7323. * You will need to pass the name of the uniform as well as the value.
  7324. */
  7325. updateVector3: (name: string, vector: Vector3) => void;
  7326. /**
  7327. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7328. * This is dynamic to allow compat with webgl 1 and 2.
  7329. * You will need to pass the name of the uniform as well as the value.
  7330. */
  7331. updateVector4: (name: string, vector: Vector4) => void;
  7332. /**
  7333. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7334. * This is dynamic to allow compat with webgl 1 and 2.
  7335. * You will need to pass the name of the uniform as well as the value.
  7336. */
  7337. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7338. /**
  7339. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7340. * This is dynamic to allow compat with webgl 1 and 2.
  7341. * You will need to pass the name of the uniform as well as the value.
  7342. */
  7343. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7344. /**
  7345. * Instantiates a new Uniform buffer objects.
  7346. *
  7347. * Handles blocks of uniform on the GPU.
  7348. *
  7349. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7350. *
  7351. * For more information, please refer to :
  7352. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7353. * @param engine Define the engine the buffer is associated with
  7354. * @param data Define the data contained in the buffer
  7355. * @param dynamic Define if the buffer is updatable
  7356. */
  7357. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7358. /**
  7359. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7360. * or just falling back on setUniformXXX calls.
  7361. */
  7362. readonly useUbo: boolean;
  7363. /**
  7364. * Indicates if the WebGL underlying uniform buffer is in sync
  7365. * with the javascript cache data.
  7366. */
  7367. readonly isSync: boolean;
  7368. /**
  7369. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7370. * Also, a dynamic UniformBuffer will disable cache verification and always
  7371. * update the underlying WebGL uniform buffer to the GPU.
  7372. * @returns if Dynamic, otherwise false
  7373. */
  7374. isDynamic(): boolean;
  7375. /**
  7376. * The data cache on JS side.
  7377. * @returns the underlying data as a float array
  7378. */
  7379. getData(): Float32Array;
  7380. /**
  7381. * The underlying WebGL Uniform buffer.
  7382. * @returns the webgl buffer
  7383. */
  7384. getBuffer(): Nullable<DataBuffer>;
  7385. /**
  7386. * std140 layout specifies how to align data within an UBO structure.
  7387. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7388. * for specs.
  7389. */
  7390. private _fillAlignment;
  7391. /**
  7392. * Adds an uniform in the buffer.
  7393. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7394. * for the layout to be correct !
  7395. * @param name Name of the uniform, as used in the uniform block in the shader.
  7396. * @param size Data size, or data directly.
  7397. */
  7398. addUniform(name: string, size: number | number[]): void;
  7399. /**
  7400. * Adds a Matrix 4x4 to the uniform buffer.
  7401. * @param name Name of the uniform, as used in the uniform block in the shader.
  7402. * @param mat A 4x4 matrix.
  7403. */
  7404. addMatrix(name: string, mat: Matrix): void;
  7405. /**
  7406. * Adds a vec2 to the uniform buffer.
  7407. * @param name Name of the uniform, as used in the uniform block in the shader.
  7408. * @param x Define the x component value of the vec2
  7409. * @param y Define the y component value of the vec2
  7410. */
  7411. addFloat2(name: string, x: number, y: number): void;
  7412. /**
  7413. * Adds a vec3 to the uniform buffer.
  7414. * @param name Name of the uniform, as used in the uniform block in the shader.
  7415. * @param x Define the x component value of the vec3
  7416. * @param y Define the y component value of the vec3
  7417. * @param z Define the z component value of the vec3
  7418. */
  7419. addFloat3(name: string, x: number, y: number, z: number): void;
  7420. /**
  7421. * Adds a vec3 to the uniform buffer.
  7422. * @param name Name of the uniform, as used in the uniform block in the shader.
  7423. * @param color Define the vec3 from a Color
  7424. */
  7425. addColor3(name: string, color: Color3): void;
  7426. /**
  7427. * Adds a vec4 to the uniform buffer.
  7428. * @param name Name of the uniform, as used in the uniform block in the shader.
  7429. * @param color Define the rgb components from a Color
  7430. * @param alpha Define the a component of the vec4
  7431. */
  7432. addColor4(name: string, color: Color3, alpha: number): void;
  7433. /**
  7434. * Adds a vec3 to the uniform buffer.
  7435. * @param name Name of the uniform, as used in the uniform block in the shader.
  7436. * @param vector Define the vec3 components from a Vector
  7437. */
  7438. addVector3(name: string, vector: Vector3): void;
  7439. /**
  7440. * Adds a Matrix 3x3 to the uniform buffer.
  7441. * @param name Name of the uniform, as used in the uniform block in the shader.
  7442. */
  7443. addMatrix3x3(name: string): void;
  7444. /**
  7445. * Adds a Matrix 2x2 to the uniform buffer.
  7446. * @param name Name of the uniform, as used in the uniform block in the shader.
  7447. */
  7448. addMatrix2x2(name: string): void;
  7449. /**
  7450. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7451. */
  7452. create(): void;
  7453. /** @hidden */
  7454. _rebuild(): void;
  7455. /**
  7456. * Updates the WebGL Uniform Buffer on the GPU.
  7457. * If the `dynamic` flag is set to true, no cache comparison is done.
  7458. * Otherwise, the buffer will be updated only if the cache differs.
  7459. */
  7460. update(): void;
  7461. /**
  7462. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7463. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7464. * @param data Define the flattened data
  7465. * @param size Define the size of the data.
  7466. */
  7467. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7468. private _valueCache;
  7469. private _cacheMatrix;
  7470. private _updateMatrix3x3ForUniform;
  7471. private _updateMatrix3x3ForEffect;
  7472. private _updateMatrix2x2ForEffect;
  7473. private _updateMatrix2x2ForUniform;
  7474. private _updateFloatForEffect;
  7475. private _updateFloatForUniform;
  7476. private _updateFloat2ForEffect;
  7477. private _updateFloat2ForUniform;
  7478. private _updateFloat3ForEffect;
  7479. private _updateFloat3ForUniform;
  7480. private _updateFloat4ForEffect;
  7481. private _updateFloat4ForUniform;
  7482. private _updateMatrixForEffect;
  7483. private _updateMatrixForUniform;
  7484. private _updateVector3ForEffect;
  7485. private _updateVector3ForUniform;
  7486. private _updateVector4ForEffect;
  7487. private _updateVector4ForUniform;
  7488. private _updateColor3ForEffect;
  7489. private _updateColor3ForUniform;
  7490. private _updateColor4ForEffect;
  7491. private _updateColor4ForUniform;
  7492. /**
  7493. * Sets a sampler uniform on the effect.
  7494. * @param name Define the name of the sampler.
  7495. * @param texture Define the texture to set in the sampler
  7496. */
  7497. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7498. /**
  7499. * Directly updates the value of the uniform in the cache AND on the GPU.
  7500. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7501. * @param data Define the flattened data
  7502. */
  7503. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7504. /**
  7505. * Binds this uniform buffer to an effect.
  7506. * @param effect Define the effect to bind the buffer to
  7507. * @param name Name of the uniform block in the shader.
  7508. */
  7509. bindToEffect(effect: Effect, name: string): void;
  7510. /**
  7511. * Disposes the uniform buffer.
  7512. */
  7513. dispose(): void;
  7514. }
  7515. }
  7516. declare module "babylonjs/Misc/iInspectable" {
  7517. /**
  7518. * Enum that determines the text-wrapping mode to use.
  7519. */
  7520. export enum InspectableType {
  7521. /**
  7522. * Checkbox for booleans
  7523. */
  7524. Checkbox = 0,
  7525. /**
  7526. * Sliders for numbers
  7527. */
  7528. Slider = 1,
  7529. /**
  7530. * Vector3
  7531. */
  7532. Vector3 = 2,
  7533. /**
  7534. * Quaternions
  7535. */
  7536. Quaternion = 3,
  7537. /**
  7538. * Color3
  7539. */
  7540. Color3 = 4,
  7541. /**
  7542. * String
  7543. */
  7544. String = 5
  7545. }
  7546. /**
  7547. * Interface used to define custom inspectable properties.
  7548. * This interface is used by the inspector to display custom property grids
  7549. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7550. */
  7551. export interface IInspectable {
  7552. /**
  7553. * Gets the label to display
  7554. */
  7555. label: string;
  7556. /**
  7557. * Gets the name of the property to edit
  7558. */
  7559. propertyName: string;
  7560. /**
  7561. * Gets the type of the editor to use
  7562. */
  7563. type: InspectableType;
  7564. /**
  7565. * Gets the minimum value of the property when using in "slider" mode
  7566. */
  7567. min?: number;
  7568. /**
  7569. * Gets the maximum value of the property when using in "slider" mode
  7570. */
  7571. max?: number;
  7572. /**
  7573. * Gets the setp to use when using in "slider" mode
  7574. */
  7575. step?: number;
  7576. }
  7577. }
  7578. declare module "babylonjs/Misc/timingTools" {
  7579. /**
  7580. * Class used to provide helper for timing
  7581. */
  7582. export class TimingTools {
  7583. /**
  7584. * Polyfill for setImmediate
  7585. * @param action defines the action to execute after the current execution block
  7586. */
  7587. static SetImmediate(action: () => void): void;
  7588. }
  7589. }
  7590. declare module "babylonjs/Misc/instantiationTools" {
  7591. /**
  7592. * Class used to enable instatition of objects by class name
  7593. */
  7594. export class InstantiationTools {
  7595. /**
  7596. * Use this object to register external classes like custom textures or material
  7597. * to allow the laoders to instantiate them
  7598. */
  7599. static RegisteredExternalClasses: {
  7600. [key: string]: Object;
  7601. };
  7602. /**
  7603. * Tries to instantiate a new object from a given class name
  7604. * @param className defines the class name to instantiate
  7605. * @returns the new object or null if the system was not able to do the instantiation
  7606. */
  7607. static Instantiate(className: string): any;
  7608. }
  7609. }
  7610. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7611. /**
  7612. * Define options used to create a depth texture
  7613. */
  7614. export class DepthTextureCreationOptions {
  7615. /** Specifies whether or not a stencil should be allocated in the texture */
  7616. generateStencil?: boolean;
  7617. /** Specifies whether or not bilinear filtering is enable on the texture */
  7618. bilinearFiltering?: boolean;
  7619. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7620. comparisonFunction?: number;
  7621. /** Specifies if the created texture is a cube texture */
  7622. isCube?: boolean;
  7623. }
  7624. }
  7625. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7626. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7627. import { Nullable } from "babylonjs/types";
  7628. import { Scene } from "babylonjs/scene";
  7629. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7630. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7631. module "babylonjs/Engines/thinEngine" {
  7632. interface ThinEngine {
  7633. /**
  7634. * Creates a depth stencil cube texture.
  7635. * This is only available in WebGL 2.
  7636. * @param size The size of face edge in the cube texture.
  7637. * @param options The options defining the cube texture.
  7638. * @returns The cube texture
  7639. */
  7640. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7641. /**
  7642. * Creates a cube texture
  7643. * @param rootUrl defines the url where the files to load is located
  7644. * @param scene defines the current scene
  7645. * @param files defines the list of files to load (1 per face)
  7646. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7647. * @param onLoad defines an optional callback raised when the texture is loaded
  7648. * @param onError defines an optional callback raised if there is an issue to load the texture
  7649. * @param format defines the format of the data
  7650. * @param forcedExtension defines the extension to use to pick the right loader
  7651. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7652. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7653. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7654. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7655. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7656. * @returns the cube texture as an InternalTexture
  7657. */
  7658. 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;
  7659. /**
  7660. * Creates a cube texture
  7661. * @param rootUrl defines the url where the files to load is located
  7662. * @param scene defines the current scene
  7663. * @param files defines the list of files to load (1 per face)
  7664. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7665. * @param onLoad defines an optional callback raised when the texture is loaded
  7666. * @param onError defines an optional callback raised if there is an issue to load the texture
  7667. * @param format defines the format of the data
  7668. * @param forcedExtension defines the extension to use to pick the right loader
  7669. * @returns the cube texture as an InternalTexture
  7670. */
  7671. 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;
  7672. /**
  7673. * Creates a cube texture
  7674. * @param rootUrl defines the url where the files to load is located
  7675. * @param scene defines the current scene
  7676. * @param files defines the list of files to load (1 per face)
  7677. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7678. * @param onLoad defines an optional callback raised when the texture is loaded
  7679. * @param onError defines an optional callback raised if there is an issue to load the texture
  7680. * @param format defines the format of the data
  7681. * @param forcedExtension defines the extension to use to pick the right loader
  7682. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7683. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7684. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7685. * @returns the cube texture as an InternalTexture
  7686. */
  7687. 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;
  7688. /** @hidden */
  7689. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7690. /** @hidden */
  7691. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7692. /** @hidden */
  7693. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7694. /** @hidden */
  7695. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7696. /**
  7697. * @hidden
  7698. */
  7699. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7700. }
  7701. }
  7702. }
  7703. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7704. import { Nullable } from "babylonjs/types";
  7705. import { Scene } from "babylonjs/scene";
  7706. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7707. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7708. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7709. /**
  7710. * Class for creating a cube texture
  7711. */
  7712. export class CubeTexture extends BaseTexture {
  7713. private _delayedOnLoad;
  7714. /**
  7715. * The url of the texture
  7716. */
  7717. url: string;
  7718. /**
  7719. * Gets or sets the center of the bounding box associated with the cube texture.
  7720. * It must define where the camera used to render the texture was set
  7721. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7722. */
  7723. boundingBoxPosition: Vector3;
  7724. private _boundingBoxSize;
  7725. /**
  7726. * Gets or sets the size of the bounding box associated with the cube texture
  7727. * When defined, the cubemap will switch to local mode
  7728. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7729. * @example https://www.babylonjs-playground.com/#RNASML
  7730. */
  7731. /**
  7732. * Returns the bounding box size
  7733. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7734. */
  7735. boundingBoxSize: Vector3;
  7736. protected _rotationY: number;
  7737. /**
  7738. * Sets texture matrix rotation angle around Y axis in radians.
  7739. */
  7740. /**
  7741. * Gets texture matrix rotation angle around Y axis radians.
  7742. */
  7743. rotationY: number;
  7744. /**
  7745. * Are mip maps generated for this texture or not.
  7746. */
  7747. readonly noMipmap: boolean;
  7748. private _noMipmap;
  7749. private _files;
  7750. protected _forcedExtension: Nullable<string>;
  7751. private _extensions;
  7752. private _textureMatrix;
  7753. private _format;
  7754. private _createPolynomials;
  7755. /** @hidden */
  7756. _prefiltered: boolean;
  7757. /**
  7758. * Creates a cube texture from an array of image urls
  7759. * @param files defines an array of image urls
  7760. * @param scene defines the hosting scene
  7761. * @param noMipmap specifies if mip maps are not used
  7762. * @returns a cube texture
  7763. */
  7764. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7765. /**
  7766. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7767. * @param url defines the url of the prefiltered texture
  7768. * @param scene defines the scene the texture is attached to
  7769. * @param forcedExtension defines the extension of the file if different from the url
  7770. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7771. * @return the prefiltered texture
  7772. */
  7773. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7774. /**
  7775. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7776. * as prefiltered data.
  7777. * @param rootUrl defines the url of the texture or the root name of the six images
  7778. * @param scene defines the scene the texture is attached to
  7779. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7780. * @param noMipmap defines if mipmaps should be created or not
  7781. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7782. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7783. * @param onError defines a callback triggered in case of error during load
  7784. * @param format defines the internal format to use for the texture once loaded
  7785. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7786. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7787. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7788. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7789. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7790. * @return the cube texture
  7791. */
  7792. 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);
  7793. /**
  7794. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7795. */
  7796. readonly isPrefiltered: boolean;
  7797. /**
  7798. * Get the current class name of the texture useful for serialization or dynamic coding.
  7799. * @returns "CubeTexture"
  7800. */
  7801. getClassName(): string;
  7802. /**
  7803. * Update the url (and optional buffer) of this texture if url was null during construction.
  7804. * @param url the url of the texture
  7805. * @param forcedExtension defines the extension to use
  7806. * @param onLoad callback called when the texture is loaded (defaults to null)
  7807. */
  7808. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7809. /**
  7810. * Delays loading of the cube texture
  7811. * @param forcedExtension defines the extension to use
  7812. */
  7813. delayLoad(forcedExtension?: string): void;
  7814. /**
  7815. * Returns the reflection texture matrix
  7816. * @returns the reflection texture matrix
  7817. */
  7818. getReflectionTextureMatrix(): Matrix;
  7819. /**
  7820. * Sets the reflection texture matrix
  7821. * @param value Reflection texture matrix
  7822. */
  7823. setReflectionTextureMatrix(value: Matrix): void;
  7824. /**
  7825. * Parses text to create a cube texture
  7826. * @param parsedTexture define the serialized text to read from
  7827. * @param scene defines the hosting scene
  7828. * @param rootUrl defines the root url of the cube texture
  7829. * @returns a cube texture
  7830. */
  7831. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7832. /**
  7833. * Makes a clone, or deep copy, of the cube texture
  7834. * @returns a new cube texture
  7835. */
  7836. clone(): CubeTexture;
  7837. }
  7838. }
  7839. declare module "babylonjs/Materials/materialDefines" {
  7840. /**
  7841. * Manages the defines for the Material
  7842. */
  7843. export class MaterialDefines {
  7844. /** @hidden */
  7845. protected _keys: string[];
  7846. private _isDirty;
  7847. /** @hidden */
  7848. _renderId: number;
  7849. /** @hidden */
  7850. _areLightsDirty: boolean;
  7851. /** @hidden */
  7852. _areLightsDisposed: boolean;
  7853. /** @hidden */
  7854. _areAttributesDirty: boolean;
  7855. /** @hidden */
  7856. _areTexturesDirty: boolean;
  7857. /** @hidden */
  7858. _areFresnelDirty: boolean;
  7859. /** @hidden */
  7860. _areMiscDirty: boolean;
  7861. /** @hidden */
  7862. _areImageProcessingDirty: boolean;
  7863. /** @hidden */
  7864. _normals: boolean;
  7865. /** @hidden */
  7866. _uvs: boolean;
  7867. /** @hidden */
  7868. _needNormals: boolean;
  7869. /** @hidden */
  7870. _needUVs: boolean;
  7871. [id: string]: any;
  7872. /**
  7873. * Specifies if the material needs to be re-calculated
  7874. */
  7875. readonly isDirty: boolean;
  7876. /**
  7877. * Marks the material to indicate that it has been re-calculated
  7878. */
  7879. markAsProcessed(): void;
  7880. /**
  7881. * Marks the material to indicate that it needs to be re-calculated
  7882. */
  7883. markAsUnprocessed(): void;
  7884. /**
  7885. * Marks the material to indicate all of its defines need to be re-calculated
  7886. */
  7887. markAllAsDirty(): void;
  7888. /**
  7889. * Marks the material to indicate that image processing needs to be re-calculated
  7890. */
  7891. markAsImageProcessingDirty(): void;
  7892. /**
  7893. * Marks the material to indicate the lights need to be re-calculated
  7894. * @param disposed Defines whether the light is dirty due to dispose or not
  7895. */
  7896. markAsLightDirty(disposed?: boolean): void;
  7897. /**
  7898. * Marks the attribute state as changed
  7899. */
  7900. markAsAttributesDirty(): void;
  7901. /**
  7902. * Marks the texture state as changed
  7903. */
  7904. markAsTexturesDirty(): void;
  7905. /**
  7906. * Marks the fresnel state as changed
  7907. */
  7908. markAsFresnelDirty(): void;
  7909. /**
  7910. * Marks the misc state as changed
  7911. */
  7912. markAsMiscDirty(): void;
  7913. /**
  7914. * Rebuilds the material defines
  7915. */
  7916. rebuild(): void;
  7917. /**
  7918. * Specifies if two material defines are equal
  7919. * @param other - A material define instance to compare to
  7920. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7921. */
  7922. isEqual(other: MaterialDefines): boolean;
  7923. /**
  7924. * Clones this instance's defines to another instance
  7925. * @param other - material defines to clone values to
  7926. */
  7927. cloneTo(other: MaterialDefines): void;
  7928. /**
  7929. * Resets the material define values
  7930. */
  7931. reset(): void;
  7932. /**
  7933. * Converts the material define values to a string
  7934. * @returns - String of material define information
  7935. */
  7936. toString(): string;
  7937. }
  7938. }
  7939. declare module "babylonjs/Materials/colorCurves" {
  7940. import { Effect } from "babylonjs/Materials/effect";
  7941. /**
  7942. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7943. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7944. * 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;
  7945. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7946. */
  7947. export class ColorCurves {
  7948. private _dirty;
  7949. private _tempColor;
  7950. private _globalCurve;
  7951. private _highlightsCurve;
  7952. private _midtonesCurve;
  7953. private _shadowsCurve;
  7954. private _positiveCurve;
  7955. private _negativeCurve;
  7956. private _globalHue;
  7957. private _globalDensity;
  7958. private _globalSaturation;
  7959. private _globalExposure;
  7960. /**
  7961. * Gets the global Hue value.
  7962. * 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).
  7963. */
  7964. /**
  7965. * Sets the global Hue value.
  7966. * 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).
  7967. */
  7968. globalHue: number;
  7969. /**
  7970. * Gets the global Density value.
  7971. * 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.
  7972. * Values less than zero provide a filter of opposite hue.
  7973. */
  7974. /**
  7975. * Sets the global Density value.
  7976. * 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.
  7977. * Values less than zero provide a filter of opposite hue.
  7978. */
  7979. globalDensity: number;
  7980. /**
  7981. * Gets the global Saturation value.
  7982. * 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.
  7983. */
  7984. /**
  7985. * Sets the global Saturation value.
  7986. * 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.
  7987. */
  7988. globalSaturation: number;
  7989. /**
  7990. * Gets the global Exposure value.
  7991. * 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.
  7992. */
  7993. /**
  7994. * Sets the global Exposure value.
  7995. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7996. */
  7997. globalExposure: number;
  7998. private _highlightsHue;
  7999. private _highlightsDensity;
  8000. private _highlightsSaturation;
  8001. private _highlightsExposure;
  8002. /**
  8003. * Gets the highlights Hue value.
  8004. * 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).
  8005. */
  8006. /**
  8007. * Sets the highlights Hue value.
  8008. * 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).
  8009. */
  8010. highlightsHue: number;
  8011. /**
  8012. * Gets the highlights Density value.
  8013. * 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.
  8014. * Values less than zero provide a filter of opposite hue.
  8015. */
  8016. /**
  8017. * Sets the highlights Density value.
  8018. * 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.
  8019. * Values less than zero provide a filter of opposite hue.
  8020. */
  8021. highlightsDensity: number;
  8022. /**
  8023. * Gets the highlights Saturation value.
  8024. * 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.
  8025. */
  8026. /**
  8027. * Sets the highlights Saturation value.
  8028. * 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.
  8029. */
  8030. highlightsSaturation: number;
  8031. /**
  8032. * Gets the highlights Exposure value.
  8033. * 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.
  8034. */
  8035. /**
  8036. * Sets the highlights Exposure value.
  8037. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8038. */
  8039. highlightsExposure: number;
  8040. private _midtonesHue;
  8041. private _midtonesDensity;
  8042. private _midtonesSaturation;
  8043. private _midtonesExposure;
  8044. /**
  8045. * Gets the midtones Hue value.
  8046. * 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).
  8047. */
  8048. /**
  8049. * Sets the midtones Hue value.
  8050. * 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).
  8051. */
  8052. midtonesHue: number;
  8053. /**
  8054. * Gets the midtones Density value.
  8055. * 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.
  8056. * Values less than zero provide a filter of opposite hue.
  8057. */
  8058. /**
  8059. * Sets the midtones Density value.
  8060. * 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.
  8061. * Values less than zero provide a filter of opposite hue.
  8062. */
  8063. midtonesDensity: number;
  8064. /**
  8065. * Gets the midtones Saturation value.
  8066. * 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.
  8067. */
  8068. /**
  8069. * Sets the midtones Saturation value.
  8070. * 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.
  8071. */
  8072. midtonesSaturation: number;
  8073. /**
  8074. * Gets the midtones Exposure value.
  8075. * 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.
  8076. */
  8077. /**
  8078. * Sets the midtones Exposure value.
  8079. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8080. */
  8081. midtonesExposure: number;
  8082. private _shadowsHue;
  8083. private _shadowsDensity;
  8084. private _shadowsSaturation;
  8085. private _shadowsExposure;
  8086. /**
  8087. * Gets the shadows Hue value.
  8088. * 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).
  8089. */
  8090. /**
  8091. * Sets the shadows Hue value.
  8092. * 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).
  8093. */
  8094. shadowsHue: number;
  8095. /**
  8096. * Gets the shadows Density value.
  8097. * 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.
  8098. * Values less than zero provide a filter of opposite hue.
  8099. */
  8100. /**
  8101. * Sets the shadows Density value.
  8102. * 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.
  8103. * Values less than zero provide a filter of opposite hue.
  8104. */
  8105. shadowsDensity: number;
  8106. /**
  8107. * Gets the shadows Saturation value.
  8108. * 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.
  8109. */
  8110. /**
  8111. * Sets the shadows Saturation value.
  8112. * 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.
  8113. */
  8114. shadowsSaturation: number;
  8115. /**
  8116. * Gets the shadows Exposure value.
  8117. * 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.
  8118. */
  8119. /**
  8120. * Sets the shadows Exposure value.
  8121. * 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.
  8122. */
  8123. shadowsExposure: number;
  8124. /**
  8125. * Returns the class name
  8126. * @returns The class name
  8127. */
  8128. getClassName(): string;
  8129. /**
  8130. * Binds the color curves to the shader.
  8131. * @param colorCurves The color curve to bind
  8132. * @param effect The effect to bind to
  8133. * @param positiveUniform The positive uniform shader parameter
  8134. * @param neutralUniform The neutral uniform shader parameter
  8135. * @param negativeUniform The negative uniform shader parameter
  8136. */
  8137. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8138. /**
  8139. * Prepare the list of uniforms associated with the ColorCurves effects.
  8140. * @param uniformsList The list of uniforms used in the effect
  8141. */
  8142. static PrepareUniforms(uniformsList: string[]): void;
  8143. /**
  8144. * Returns color grading data based on a hue, density, saturation and exposure value.
  8145. * @param filterHue The hue of the color filter.
  8146. * @param filterDensity The density of the color filter.
  8147. * @param saturation The saturation.
  8148. * @param exposure The exposure.
  8149. * @param result The result data container.
  8150. */
  8151. private getColorGradingDataToRef;
  8152. /**
  8153. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8154. * @param value The input slider value in range [-100,100].
  8155. * @returns Adjusted value.
  8156. */
  8157. private static applyColorGradingSliderNonlinear;
  8158. /**
  8159. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8160. * @param hue The hue (H) input.
  8161. * @param saturation The saturation (S) input.
  8162. * @param brightness The brightness (B) input.
  8163. * @result An RGBA color represented as Vector4.
  8164. */
  8165. private static fromHSBToRef;
  8166. /**
  8167. * Returns a value clamped between min and max
  8168. * @param value The value to clamp
  8169. * @param min The minimum of value
  8170. * @param max The maximum of value
  8171. * @returns The clamped value.
  8172. */
  8173. private static clamp;
  8174. /**
  8175. * Clones the current color curve instance.
  8176. * @return The cloned curves
  8177. */
  8178. clone(): ColorCurves;
  8179. /**
  8180. * Serializes the current color curve instance to a json representation.
  8181. * @return a JSON representation
  8182. */
  8183. serialize(): any;
  8184. /**
  8185. * Parses the color curve from a json representation.
  8186. * @param source the JSON source to parse
  8187. * @return The parsed curves
  8188. */
  8189. static Parse(source: any): ColorCurves;
  8190. }
  8191. }
  8192. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8193. import { Observable } from "babylonjs/Misc/observable";
  8194. import { Nullable } from "babylonjs/types";
  8195. import { Color4 } from "babylonjs/Maths/math.color";
  8196. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8197. import { Effect } from "babylonjs/Materials/effect";
  8198. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8199. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8200. /**
  8201. * Interface to follow in your material defines to integrate easily the
  8202. * Image proccessing functions.
  8203. * @hidden
  8204. */
  8205. export interface IImageProcessingConfigurationDefines {
  8206. IMAGEPROCESSING: boolean;
  8207. VIGNETTE: boolean;
  8208. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8209. VIGNETTEBLENDMODEOPAQUE: boolean;
  8210. TONEMAPPING: boolean;
  8211. TONEMAPPING_ACES: boolean;
  8212. CONTRAST: boolean;
  8213. EXPOSURE: boolean;
  8214. COLORCURVES: boolean;
  8215. COLORGRADING: boolean;
  8216. COLORGRADING3D: boolean;
  8217. SAMPLER3DGREENDEPTH: boolean;
  8218. SAMPLER3DBGRMAP: boolean;
  8219. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8220. }
  8221. /**
  8222. * @hidden
  8223. */
  8224. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8225. IMAGEPROCESSING: boolean;
  8226. VIGNETTE: boolean;
  8227. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8228. VIGNETTEBLENDMODEOPAQUE: boolean;
  8229. TONEMAPPING: boolean;
  8230. TONEMAPPING_ACES: boolean;
  8231. CONTRAST: boolean;
  8232. COLORCURVES: boolean;
  8233. COLORGRADING: boolean;
  8234. COLORGRADING3D: boolean;
  8235. SAMPLER3DGREENDEPTH: boolean;
  8236. SAMPLER3DBGRMAP: boolean;
  8237. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8238. EXPOSURE: boolean;
  8239. constructor();
  8240. }
  8241. /**
  8242. * This groups together the common properties used for image processing either in direct forward pass
  8243. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8244. * or not.
  8245. */
  8246. export class ImageProcessingConfiguration {
  8247. /**
  8248. * Default tone mapping applied in BabylonJS.
  8249. */
  8250. static readonly TONEMAPPING_STANDARD: number;
  8251. /**
  8252. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8253. * to other engines rendering to increase portability.
  8254. */
  8255. static readonly TONEMAPPING_ACES: number;
  8256. /**
  8257. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8258. */
  8259. colorCurves: Nullable<ColorCurves>;
  8260. private _colorCurvesEnabled;
  8261. /**
  8262. * Gets wether the color curves effect is enabled.
  8263. */
  8264. /**
  8265. * Sets wether the color curves effect is enabled.
  8266. */
  8267. colorCurvesEnabled: boolean;
  8268. private _colorGradingTexture;
  8269. /**
  8270. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8271. */
  8272. /**
  8273. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8274. */
  8275. colorGradingTexture: Nullable<BaseTexture>;
  8276. private _colorGradingEnabled;
  8277. /**
  8278. * Gets wether the color grading effect is enabled.
  8279. */
  8280. /**
  8281. * Sets wether the color grading effect is enabled.
  8282. */
  8283. colorGradingEnabled: boolean;
  8284. private _colorGradingWithGreenDepth;
  8285. /**
  8286. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8287. */
  8288. /**
  8289. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8290. */
  8291. colorGradingWithGreenDepth: boolean;
  8292. private _colorGradingBGR;
  8293. /**
  8294. * Gets wether the color grading texture contains BGR values.
  8295. */
  8296. /**
  8297. * Sets wether the color grading texture contains BGR values.
  8298. */
  8299. colorGradingBGR: boolean;
  8300. /** @hidden */
  8301. _exposure: number;
  8302. /**
  8303. * Gets the Exposure used in the effect.
  8304. */
  8305. /**
  8306. * Sets the Exposure used in the effect.
  8307. */
  8308. exposure: number;
  8309. private _toneMappingEnabled;
  8310. /**
  8311. * Gets wether the tone mapping effect is enabled.
  8312. */
  8313. /**
  8314. * Sets wether the tone mapping effect is enabled.
  8315. */
  8316. toneMappingEnabled: boolean;
  8317. private _toneMappingType;
  8318. /**
  8319. * Gets the type of tone mapping effect.
  8320. */
  8321. /**
  8322. * Sets the type of tone mapping effect used in BabylonJS.
  8323. */
  8324. toneMappingType: number;
  8325. protected _contrast: number;
  8326. /**
  8327. * Gets the contrast used in the effect.
  8328. */
  8329. /**
  8330. * Sets the contrast used in the effect.
  8331. */
  8332. contrast: number;
  8333. /**
  8334. * Vignette stretch size.
  8335. */
  8336. vignetteStretch: number;
  8337. /**
  8338. * Vignette centre X Offset.
  8339. */
  8340. vignetteCentreX: number;
  8341. /**
  8342. * Vignette centre Y Offset.
  8343. */
  8344. vignetteCentreY: number;
  8345. /**
  8346. * Vignette weight or intensity of the vignette effect.
  8347. */
  8348. vignetteWeight: number;
  8349. /**
  8350. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8351. * if vignetteEnabled is set to true.
  8352. */
  8353. vignetteColor: Color4;
  8354. /**
  8355. * Camera field of view used by the Vignette effect.
  8356. */
  8357. vignetteCameraFov: number;
  8358. private _vignetteBlendMode;
  8359. /**
  8360. * Gets the vignette blend mode allowing different kind of effect.
  8361. */
  8362. /**
  8363. * Sets the vignette blend mode allowing different kind of effect.
  8364. */
  8365. vignetteBlendMode: number;
  8366. private _vignetteEnabled;
  8367. /**
  8368. * Gets wether the vignette effect is enabled.
  8369. */
  8370. /**
  8371. * Sets wether the vignette effect is enabled.
  8372. */
  8373. vignetteEnabled: boolean;
  8374. private _applyByPostProcess;
  8375. /**
  8376. * Gets wether the image processing is applied through a post process or not.
  8377. */
  8378. /**
  8379. * Sets wether the image processing is applied through a post process or not.
  8380. */
  8381. applyByPostProcess: boolean;
  8382. private _isEnabled;
  8383. /**
  8384. * Gets wether the image processing is enabled or not.
  8385. */
  8386. /**
  8387. * Sets wether the image processing is enabled or not.
  8388. */
  8389. isEnabled: boolean;
  8390. /**
  8391. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8392. */
  8393. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8394. /**
  8395. * Method called each time the image processing information changes requires to recompile the effect.
  8396. */
  8397. protected _updateParameters(): void;
  8398. /**
  8399. * Gets the current class name.
  8400. * @return "ImageProcessingConfiguration"
  8401. */
  8402. getClassName(): string;
  8403. /**
  8404. * Prepare the list of uniforms associated with the Image Processing effects.
  8405. * @param uniforms The list of uniforms used in the effect
  8406. * @param defines the list of defines currently in use
  8407. */
  8408. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8409. /**
  8410. * Prepare the list of samplers associated with the Image Processing effects.
  8411. * @param samplersList The list of uniforms used in the effect
  8412. * @param defines the list of defines currently in use
  8413. */
  8414. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8415. /**
  8416. * Prepare the list of defines associated to the shader.
  8417. * @param defines the list of defines to complete
  8418. * @param forPostProcess Define if we are currently in post process mode or not
  8419. */
  8420. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8421. /**
  8422. * Returns true if all the image processing information are ready.
  8423. * @returns True if ready, otherwise, false
  8424. */
  8425. isReady(): boolean;
  8426. /**
  8427. * Binds the image processing to the shader.
  8428. * @param effect The effect to bind to
  8429. * @param overrideAspectRatio Override the aspect ratio of the effect
  8430. */
  8431. bind(effect: Effect, overrideAspectRatio?: number): void;
  8432. /**
  8433. * Clones the current image processing instance.
  8434. * @return The cloned image processing
  8435. */
  8436. clone(): ImageProcessingConfiguration;
  8437. /**
  8438. * Serializes the current image processing instance to a json representation.
  8439. * @return a JSON representation
  8440. */
  8441. serialize(): any;
  8442. /**
  8443. * Parses the image processing from a json representation.
  8444. * @param source the JSON source to parse
  8445. * @return The parsed image processing
  8446. */
  8447. static Parse(source: any): ImageProcessingConfiguration;
  8448. private static _VIGNETTEMODE_MULTIPLY;
  8449. private static _VIGNETTEMODE_OPAQUE;
  8450. /**
  8451. * Used to apply the vignette as a mix with the pixel color.
  8452. */
  8453. static readonly VIGNETTEMODE_MULTIPLY: number;
  8454. /**
  8455. * Used to apply the vignette as a replacement of the pixel color.
  8456. */
  8457. static readonly VIGNETTEMODE_OPAQUE: number;
  8458. }
  8459. }
  8460. declare module "babylonjs/Shaders/postprocess.vertex" {
  8461. /** @hidden */
  8462. export var postprocessVertexShader: {
  8463. name: string;
  8464. shader: string;
  8465. };
  8466. }
  8467. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8468. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8469. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8470. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8471. module "babylonjs/Engines/thinEngine" {
  8472. interface ThinEngine {
  8473. /**
  8474. * Creates a new render target texture
  8475. * @param size defines the size of the texture
  8476. * @param options defines the options used to create the texture
  8477. * @returns a new render target texture stored in an InternalTexture
  8478. */
  8479. createRenderTargetTexture(size: number | {
  8480. width: number;
  8481. height: number;
  8482. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8483. /**
  8484. * Creates a depth stencil texture.
  8485. * This is only available in WebGL 2 or with the depth texture extension available.
  8486. * @param size The size of face edge in the texture.
  8487. * @param options The options defining the texture.
  8488. * @returns The texture
  8489. */
  8490. createDepthStencilTexture(size: number | {
  8491. width: number;
  8492. height: number;
  8493. }, options: DepthTextureCreationOptions): InternalTexture;
  8494. /** @hidden */
  8495. _createDepthStencilTexture(size: number | {
  8496. width: number;
  8497. height: number;
  8498. }, options: DepthTextureCreationOptions): InternalTexture;
  8499. }
  8500. }
  8501. }
  8502. declare module "babylonjs/Maths/math.axis" {
  8503. import { Vector3 } from "babylonjs/Maths/math.vector";
  8504. /** Defines supported spaces */
  8505. export enum Space {
  8506. /** Local (object) space */
  8507. LOCAL = 0,
  8508. /** World space */
  8509. WORLD = 1,
  8510. /** Bone space */
  8511. BONE = 2
  8512. }
  8513. /** Defines the 3 main axes */
  8514. export class Axis {
  8515. /** X axis */
  8516. static X: Vector3;
  8517. /** Y axis */
  8518. static Y: Vector3;
  8519. /** Z axis */
  8520. static Z: Vector3;
  8521. }
  8522. }
  8523. declare module "babylonjs/Cameras/targetCamera" {
  8524. import { Nullable } from "babylonjs/types";
  8525. import { Camera } from "babylonjs/Cameras/camera";
  8526. import { Scene } from "babylonjs/scene";
  8527. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8528. /**
  8529. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8530. * This is the base of the follow, arc rotate cameras and Free camera
  8531. * @see http://doc.babylonjs.com/features/cameras
  8532. */
  8533. export class TargetCamera extends Camera {
  8534. private static _RigCamTransformMatrix;
  8535. private static _TargetTransformMatrix;
  8536. private static _TargetFocalPoint;
  8537. /**
  8538. * Define the current direction the camera is moving to
  8539. */
  8540. cameraDirection: Vector3;
  8541. /**
  8542. * Define the current rotation the camera is rotating to
  8543. */
  8544. cameraRotation: Vector2;
  8545. /**
  8546. * When set, the up vector of the camera will be updated by the rotation of the camera
  8547. */
  8548. updateUpVectorFromRotation: boolean;
  8549. private _tmpQuaternion;
  8550. /**
  8551. * Define the current rotation of the camera
  8552. */
  8553. rotation: Vector3;
  8554. /**
  8555. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8556. */
  8557. rotationQuaternion: Quaternion;
  8558. /**
  8559. * Define the current speed of the camera
  8560. */
  8561. speed: number;
  8562. /**
  8563. * Add constraint to the camera to prevent it to move freely in all directions and
  8564. * around all axis.
  8565. */
  8566. noRotationConstraint: boolean;
  8567. /**
  8568. * Define the current target of the camera as an object or a position.
  8569. */
  8570. lockedTarget: any;
  8571. /** @hidden */
  8572. _currentTarget: Vector3;
  8573. /** @hidden */
  8574. _initialFocalDistance: number;
  8575. /** @hidden */
  8576. _viewMatrix: Matrix;
  8577. /** @hidden */
  8578. _camMatrix: Matrix;
  8579. /** @hidden */
  8580. _cameraTransformMatrix: Matrix;
  8581. /** @hidden */
  8582. _cameraRotationMatrix: Matrix;
  8583. /** @hidden */
  8584. _referencePoint: Vector3;
  8585. /** @hidden */
  8586. _transformedReferencePoint: Vector3;
  8587. protected _globalCurrentTarget: Vector3;
  8588. protected _globalCurrentUpVector: Vector3;
  8589. /** @hidden */
  8590. _reset: () => void;
  8591. private _defaultUp;
  8592. /**
  8593. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8594. * This is the base of the follow, arc rotate cameras and Free camera
  8595. * @see http://doc.babylonjs.com/features/cameras
  8596. * @param name Defines the name of the camera in the scene
  8597. * @param position Defines the start position of the camera in the scene
  8598. * @param scene Defines the scene the camera belongs to
  8599. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8600. */
  8601. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8602. /**
  8603. * Gets the position in front of the camera at a given distance.
  8604. * @param distance The distance from the camera we want the position to be
  8605. * @returns the position
  8606. */
  8607. getFrontPosition(distance: number): Vector3;
  8608. /** @hidden */
  8609. _getLockedTargetPosition(): Nullable<Vector3>;
  8610. private _storedPosition;
  8611. private _storedRotation;
  8612. private _storedRotationQuaternion;
  8613. /**
  8614. * Store current camera state of the camera (fov, position, rotation, etc..)
  8615. * @returns the camera
  8616. */
  8617. storeState(): Camera;
  8618. /**
  8619. * Restored camera state. You must call storeState() first
  8620. * @returns whether it was successful or not
  8621. * @hidden
  8622. */
  8623. _restoreStateValues(): boolean;
  8624. /** @hidden */
  8625. _initCache(): void;
  8626. /** @hidden */
  8627. _updateCache(ignoreParentClass?: boolean): void;
  8628. /** @hidden */
  8629. _isSynchronizedViewMatrix(): boolean;
  8630. /** @hidden */
  8631. _computeLocalCameraSpeed(): number;
  8632. /**
  8633. * Defines the target the camera should look at.
  8634. * @param target Defines the new target as a Vector or a mesh
  8635. */
  8636. setTarget(target: Vector3): void;
  8637. /**
  8638. * Return the current target position of the camera. This value is expressed in local space.
  8639. * @returns the target position
  8640. */
  8641. getTarget(): Vector3;
  8642. /** @hidden */
  8643. _decideIfNeedsToMove(): boolean;
  8644. /** @hidden */
  8645. _updatePosition(): void;
  8646. /** @hidden */
  8647. _checkInputs(): void;
  8648. protected _updateCameraRotationMatrix(): void;
  8649. /**
  8650. * 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)
  8651. * @returns the current camera
  8652. */
  8653. private _rotateUpVectorWithCameraRotationMatrix;
  8654. private _cachedRotationZ;
  8655. private _cachedQuaternionRotationZ;
  8656. /** @hidden */
  8657. _getViewMatrix(): Matrix;
  8658. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8659. /**
  8660. * @hidden
  8661. */
  8662. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8663. /**
  8664. * @hidden
  8665. */
  8666. _updateRigCameras(): void;
  8667. private _getRigCamPositionAndTarget;
  8668. /**
  8669. * Gets the current object class name.
  8670. * @return the class name
  8671. */
  8672. getClassName(): string;
  8673. }
  8674. }
  8675. declare module "babylonjs/Events/keyboardEvents" {
  8676. /**
  8677. * Gather the list of keyboard event types as constants.
  8678. */
  8679. export class KeyboardEventTypes {
  8680. /**
  8681. * The keydown event is fired when a key becomes active (pressed).
  8682. */
  8683. static readonly KEYDOWN: number;
  8684. /**
  8685. * The keyup event is fired when a key has been released.
  8686. */
  8687. static readonly KEYUP: number;
  8688. }
  8689. /**
  8690. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8691. */
  8692. export class KeyboardInfo {
  8693. /**
  8694. * Defines the type of event (KeyboardEventTypes)
  8695. */
  8696. type: number;
  8697. /**
  8698. * Defines the related dom event
  8699. */
  8700. event: KeyboardEvent;
  8701. /**
  8702. * Instantiates a new keyboard info.
  8703. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8704. * @param type Defines the type of event (KeyboardEventTypes)
  8705. * @param event Defines the related dom event
  8706. */
  8707. constructor(
  8708. /**
  8709. * Defines the type of event (KeyboardEventTypes)
  8710. */
  8711. type: number,
  8712. /**
  8713. * Defines the related dom event
  8714. */
  8715. event: KeyboardEvent);
  8716. }
  8717. /**
  8718. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8719. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8720. */
  8721. export class KeyboardInfoPre extends KeyboardInfo {
  8722. /**
  8723. * Defines the type of event (KeyboardEventTypes)
  8724. */
  8725. type: number;
  8726. /**
  8727. * Defines the related dom event
  8728. */
  8729. event: KeyboardEvent;
  8730. /**
  8731. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8732. */
  8733. skipOnPointerObservable: boolean;
  8734. /**
  8735. * Instantiates a new keyboard pre info.
  8736. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8737. * @param type Defines the type of event (KeyboardEventTypes)
  8738. * @param event Defines the related dom event
  8739. */
  8740. constructor(
  8741. /**
  8742. * Defines the type of event (KeyboardEventTypes)
  8743. */
  8744. type: number,
  8745. /**
  8746. * Defines the related dom event
  8747. */
  8748. event: KeyboardEvent);
  8749. }
  8750. }
  8751. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8752. import { Nullable } from "babylonjs/types";
  8753. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8754. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8755. /**
  8756. * Manage the keyboard inputs to control the movement of a free camera.
  8757. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8758. */
  8759. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8760. /**
  8761. * Defines the camera the input is attached to.
  8762. */
  8763. camera: FreeCamera;
  8764. /**
  8765. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8766. */
  8767. keysUp: number[];
  8768. /**
  8769. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8770. */
  8771. keysDown: number[];
  8772. /**
  8773. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8774. */
  8775. keysLeft: number[];
  8776. /**
  8777. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8778. */
  8779. keysRight: number[];
  8780. private _keys;
  8781. private _onCanvasBlurObserver;
  8782. private _onKeyboardObserver;
  8783. private _engine;
  8784. private _scene;
  8785. /**
  8786. * Attach the input controls to a specific dom element to get the input from.
  8787. * @param element Defines the element the controls should be listened from
  8788. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8789. */
  8790. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8791. /**
  8792. * Detach the current controls from the specified dom element.
  8793. * @param element Defines the element to stop listening the inputs from
  8794. */
  8795. detachControl(element: Nullable<HTMLElement>): void;
  8796. /**
  8797. * Update the current camera state depending on the inputs that have been used this frame.
  8798. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8799. */
  8800. checkInputs(): void;
  8801. /**
  8802. * Gets the class name of the current intput.
  8803. * @returns the class name
  8804. */
  8805. getClassName(): string;
  8806. /** @hidden */
  8807. _onLostFocus(): void;
  8808. /**
  8809. * Get the friendly name associated with the input class.
  8810. * @returns the input friendly name
  8811. */
  8812. getSimpleName(): string;
  8813. }
  8814. }
  8815. declare module "babylonjs/Lights/shadowLight" {
  8816. import { Camera } from "babylonjs/Cameras/camera";
  8817. import { Scene } from "babylonjs/scene";
  8818. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8820. import { Light } from "babylonjs/Lights/light";
  8821. /**
  8822. * Interface describing all the common properties and methods a shadow light needs to implement.
  8823. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8824. * as well as binding the different shadow properties to the effects.
  8825. */
  8826. export interface IShadowLight extends Light {
  8827. /**
  8828. * The light id in the scene (used in scene.findLighById for instance)
  8829. */
  8830. id: string;
  8831. /**
  8832. * The position the shdow will be casted from.
  8833. */
  8834. position: Vector3;
  8835. /**
  8836. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8837. */
  8838. direction: Vector3;
  8839. /**
  8840. * The transformed position. Position of the light in world space taking parenting in account.
  8841. */
  8842. transformedPosition: Vector3;
  8843. /**
  8844. * The transformed direction. Direction of the light in world space taking parenting in account.
  8845. */
  8846. transformedDirection: Vector3;
  8847. /**
  8848. * The friendly name of the light in the scene.
  8849. */
  8850. name: string;
  8851. /**
  8852. * Defines the shadow projection clipping minimum z value.
  8853. */
  8854. shadowMinZ: number;
  8855. /**
  8856. * Defines the shadow projection clipping maximum z value.
  8857. */
  8858. shadowMaxZ: number;
  8859. /**
  8860. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8861. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8862. */
  8863. computeTransformedInformation(): boolean;
  8864. /**
  8865. * Gets the scene the light belongs to.
  8866. * @returns The scene
  8867. */
  8868. getScene(): Scene;
  8869. /**
  8870. * Callback defining a custom Projection Matrix Builder.
  8871. * This can be used to override the default projection matrix computation.
  8872. */
  8873. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8874. /**
  8875. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8876. * @param matrix The materix to updated with the projection information
  8877. * @param viewMatrix The transform matrix of the light
  8878. * @param renderList The list of mesh to render in the map
  8879. * @returns The current light
  8880. */
  8881. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8882. /**
  8883. * Gets the current depth scale used in ESM.
  8884. * @returns The scale
  8885. */
  8886. getDepthScale(): number;
  8887. /**
  8888. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8889. * @returns true if a cube texture needs to be use
  8890. */
  8891. needCube(): boolean;
  8892. /**
  8893. * Detects if the projection matrix requires to be recomputed this frame.
  8894. * @returns true if it requires to be recomputed otherwise, false.
  8895. */
  8896. needProjectionMatrixCompute(): boolean;
  8897. /**
  8898. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8899. */
  8900. forceProjectionMatrixCompute(): void;
  8901. /**
  8902. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8903. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8904. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8905. */
  8906. getShadowDirection(faceIndex?: number): Vector3;
  8907. /**
  8908. * Gets the minZ used for shadow according to both the scene and the light.
  8909. * @param activeCamera The camera we are returning the min for
  8910. * @returns the depth min z
  8911. */
  8912. getDepthMinZ(activeCamera: Camera): number;
  8913. /**
  8914. * Gets the maxZ used for shadow according to both the scene and the light.
  8915. * @param activeCamera The camera we are returning the max for
  8916. * @returns the depth max z
  8917. */
  8918. getDepthMaxZ(activeCamera: Camera): number;
  8919. }
  8920. /**
  8921. * Base implementation IShadowLight
  8922. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8923. */
  8924. export abstract class ShadowLight extends Light implements IShadowLight {
  8925. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8926. protected _position: Vector3;
  8927. protected _setPosition(value: Vector3): void;
  8928. /**
  8929. * Sets the position the shadow will be casted from. Also use as the light position for both
  8930. * point and spot lights.
  8931. */
  8932. /**
  8933. * Sets the position the shadow will be casted from. Also use as the light position for both
  8934. * point and spot lights.
  8935. */
  8936. position: Vector3;
  8937. protected _direction: Vector3;
  8938. protected _setDirection(value: Vector3): void;
  8939. /**
  8940. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8941. * Also use as the light direction on spot and directional lights.
  8942. */
  8943. /**
  8944. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8945. * Also use as the light direction on spot and directional lights.
  8946. */
  8947. direction: Vector3;
  8948. private _shadowMinZ;
  8949. /**
  8950. * Gets the shadow projection clipping minimum z value.
  8951. */
  8952. /**
  8953. * Sets the shadow projection clipping minimum z value.
  8954. */
  8955. shadowMinZ: number;
  8956. private _shadowMaxZ;
  8957. /**
  8958. * Sets the shadow projection clipping maximum z value.
  8959. */
  8960. /**
  8961. * Gets the shadow projection clipping maximum z value.
  8962. */
  8963. shadowMaxZ: number;
  8964. /**
  8965. * Callback defining a custom Projection Matrix Builder.
  8966. * This can be used to override the default projection matrix computation.
  8967. */
  8968. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8969. /**
  8970. * The transformed position. Position of the light in world space taking parenting in account.
  8971. */
  8972. transformedPosition: Vector3;
  8973. /**
  8974. * The transformed direction. Direction of the light in world space taking parenting in account.
  8975. */
  8976. transformedDirection: Vector3;
  8977. private _needProjectionMatrixCompute;
  8978. /**
  8979. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8980. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8981. */
  8982. computeTransformedInformation(): boolean;
  8983. /**
  8984. * Return the depth scale used for the shadow map.
  8985. * @returns the depth scale.
  8986. */
  8987. getDepthScale(): number;
  8988. /**
  8989. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8990. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8991. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8992. */
  8993. getShadowDirection(faceIndex?: number): Vector3;
  8994. /**
  8995. * Returns the ShadowLight absolute position in the World.
  8996. * @returns the position vector in world space
  8997. */
  8998. getAbsolutePosition(): Vector3;
  8999. /**
  9000. * Sets the ShadowLight direction toward the passed target.
  9001. * @param target The point to target in local space
  9002. * @returns the updated ShadowLight direction
  9003. */
  9004. setDirectionToTarget(target: Vector3): Vector3;
  9005. /**
  9006. * Returns the light rotation in euler definition.
  9007. * @returns the x y z rotation in local space.
  9008. */
  9009. getRotation(): Vector3;
  9010. /**
  9011. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9012. * @returns true if a cube texture needs to be use
  9013. */
  9014. needCube(): boolean;
  9015. /**
  9016. * Detects if the projection matrix requires to be recomputed this frame.
  9017. * @returns true if it requires to be recomputed otherwise, false.
  9018. */
  9019. needProjectionMatrixCompute(): boolean;
  9020. /**
  9021. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9022. */
  9023. forceProjectionMatrixCompute(): void;
  9024. /** @hidden */
  9025. _initCache(): void;
  9026. /** @hidden */
  9027. _isSynchronized(): boolean;
  9028. /**
  9029. * Computes the world matrix of the node
  9030. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9031. * @returns the world matrix
  9032. */
  9033. computeWorldMatrix(force?: boolean): Matrix;
  9034. /**
  9035. * Gets the minZ used for shadow according to both the scene and the light.
  9036. * @param activeCamera The camera we are returning the min for
  9037. * @returns the depth min z
  9038. */
  9039. getDepthMinZ(activeCamera: Camera): number;
  9040. /**
  9041. * Gets the maxZ used for shadow according to both the scene and the light.
  9042. * @param activeCamera The camera we are returning the max for
  9043. * @returns the depth max z
  9044. */
  9045. getDepthMaxZ(activeCamera: Camera): number;
  9046. /**
  9047. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9048. * @param matrix The materix to updated with the projection information
  9049. * @param viewMatrix The transform matrix of the light
  9050. * @param renderList The list of mesh to render in the map
  9051. * @returns The current light
  9052. */
  9053. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9054. }
  9055. }
  9056. declare module "babylonjs/Materials/effectFallbacks" {
  9057. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9058. import { Effect } from "babylonjs/Materials/effect";
  9059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9060. /**
  9061. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9062. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9063. */
  9064. export class EffectFallbacks implements IEffectFallbacks {
  9065. private _defines;
  9066. private _currentRank;
  9067. private _maxRank;
  9068. private _mesh;
  9069. /**
  9070. * Removes the fallback from the bound mesh.
  9071. */
  9072. unBindMesh(): void;
  9073. /**
  9074. * Adds a fallback on the specified property.
  9075. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9076. * @param define The name of the define in the shader
  9077. */
  9078. addFallback(rank: number, define: string): void;
  9079. /**
  9080. * Sets the mesh to use CPU skinning when needing to fallback.
  9081. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9082. * @param mesh The mesh to use the fallbacks.
  9083. */
  9084. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9085. /**
  9086. * Checks to see if more fallbacks are still availible.
  9087. */
  9088. readonly hasMoreFallbacks: boolean;
  9089. /**
  9090. * Removes the defines that should be removed when falling back.
  9091. * @param currentDefines defines the current define statements for the shader.
  9092. * @param effect defines the current effect we try to compile
  9093. * @returns The resulting defines with defines of the current rank removed.
  9094. */
  9095. reduce(currentDefines: string, effect: Effect): string;
  9096. }
  9097. }
  9098. declare module "babylonjs/Materials/materialHelper" {
  9099. import { Nullable } from "babylonjs/types";
  9100. import { Scene } from "babylonjs/scene";
  9101. import { Engine } from "babylonjs/Engines/engine";
  9102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9103. import { Light } from "babylonjs/Lights/light";
  9104. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9105. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9106. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9107. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9108. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9109. /**
  9110. * "Static Class" containing the most commonly used helper while dealing with material for
  9111. * rendering purpose.
  9112. *
  9113. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9114. *
  9115. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9116. */
  9117. export class MaterialHelper {
  9118. /**
  9119. * Bind the current view position to an effect.
  9120. * @param effect The effect to be bound
  9121. * @param scene The scene the eyes position is used from
  9122. */
  9123. static BindEyePosition(effect: Effect, scene: Scene): void;
  9124. /**
  9125. * Helps preparing the defines values about the UVs in used in the effect.
  9126. * UVs are shared as much as we can accross channels in the shaders.
  9127. * @param texture The texture we are preparing the UVs for
  9128. * @param defines The defines to update
  9129. * @param key The channel key "diffuse", "specular"... used in the shader
  9130. */
  9131. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9132. /**
  9133. * Binds a texture matrix value to its corrsponding uniform
  9134. * @param texture The texture to bind the matrix for
  9135. * @param uniformBuffer The uniform buffer receivin the data
  9136. * @param key The channel key "diffuse", "specular"... used in the shader
  9137. */
  9138. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9139. /**
  9140. * Gets the current status of the fog (should it be enabled?)
  9141. * @param mesh defines the mesh to evaluate for fog support
  9142. * @param scene defines the hosting scene
  9143. * @returns true if fog must be enabled
  9144. */
  9145. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9146. /**
  9147. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9148. * @param mesh defines the current mesh
  9149. * @param scene defines the current scene
  9150. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9151. * @param pointsCloud defines if point cloud rendering has to be turned on
  9152. * @param fogEnabled defines if fog has to be turned on
  9153. * @param alphaTest defines if alpha testing has to be turned on
  9154. * @param defines defines the current list of defines
  9155. */
  9156. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9157. /**
  9158. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9159. * @param scene defines the current scene
  9160. * @param engine defines the current engine
  9161. * @param defines specifies the list of active defines
  9162. * @param useInstances defines if instances have to be turned on
  9163. * @param useClipPlane defines if clip plane have to be turned on
  9164. */
  9165. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9166. /**
  9167. * Prepares the defines for bones
  9168. * @param mesh The mesh containing the geometry data we will draw
  9169. * @param defines The defines to update
  9170. */
  9171. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9172. /**
  9173. * Prepares the defines for morph targets
  9174. * @param mesh The mesh containing the geometry data we will draw
  9175. * @param defines The defines to update
  9176. */
  9177. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9178. /**
  9179. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9180. * @param mesh The mesh containing the geometry data we will draw
  9181. * @param defines The defines to update
  9182. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9183. * @param useBones Precise whether bones should be used or not (override mesh info)
  9184. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9185. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9186. * @returns false if defines are considered not dirty and have not been checked
  9187. */
  9188. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9189. /**
  9190. * Prepares the defines related to multiview
  9191. * @param scene The scene we are intending to draw
  9192. * @param defines The defines to update
  9193. */
  9194. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9195. /**
  9196. * Prepares the defines related to the light information passed in parameter
  9197. * @param scene The scene we are intending to draw
  9198. * @param mesh The mesh the effect is compiling for
  9199. * @param light The light the effect is compiling for
  9200. * @param lightIndex The index of the light
  9201. * @param defines The defines to update
  9202. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9203. * @param state Defines the current state regarding what is needed (normals, etc...)
  9204. */
  9205. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9206. needNormals: boolean;
  9207. needRebuild: boolean;
  9208. shadowEnabled: boolean;
  9209. specularEnabled: boolean;
  9210. lightmapMode: boolean;
  9211. }): void;
  9212. /**
  9213. * Prepares the defines related to the light information passed in parameter
  9214. * @param scene The scene we are intending to draw
  9215. * @param mesh The mesh the effect is compiling for
  9216. * @param defines The defines to update
  9217. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9218. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9219. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9220. * @returns true if normals will be required for the rest of the effect
  9221. */
  9222. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9223. /**
  9224. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9225. * @param lightIndex defines the light index
  9226. * @param uniformsList The uniform list
  9227. * @param samplersList The sampler list
  9228. * @param projectedLightTexture defines if projected texture must be used
  9229. * @param uniformBuffersList defines an optional list of uniform buffers
  9230. */
  9231. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9232. /**
  9233. * Prepares the uniforms and samplers list to be used in the effect
  9234. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9235. * @param samplersList The sampler list
  9236. * @param defines The defines helping in the list generation
  9237. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9238. */
  9239. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9240. /**
  9241. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9242. * @param defines The defines to update while falling back
  9243. * @param fallbacks The authorized effect fallbacks
  9244. * @param maxSimultaneousLights The maximum number of lights allowed
  9245. * @param rank the current rank of the Effect
  9246. * @returns The newly affected rank
  9247. */
  9248. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9249. private static _TmpMorphInfluencers;
  9250. /**
  9251. * Prepares the list of attributes required for morph targets according to the effect defines.
  9252. * @param attribs The current list of supported attribs
  9253. * @param mesh The mesh to prepare the morph targets attributes for
  9254. * @param influencers The number of influencers
  9255. */
  9256. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9257. /**
  9258. * Prepares the list of attributes required for morph targets according to the effect defines.
  9259. * @param attribs The current list of supported attribs
  9260. * @param mesh The mesh to prepare the morph targets attributes for
  9261. * @param defines The current Defines of the effect
  9262. */
  9263. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9264. /**
  9265. * Prepares the list of attributes required for bones according to the effect defines.
  9266. * @param attribs The current list of supported attribs
  9267. * @param mesh The mesh to prepare the bones attributes for
  9268. * @param defines The current Defines of the effect
  9269. * @param fallbacks The current efffect fallback strategy
  9270. */
  9271. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9272. /**
  9273. * Check and prepare the list of attributes required for instances according to the effect defines.
  9274. * @param attribs The current list of supported attribs
  9275. * @param defines The current MaterialDefines of the effect
  9276. */
  9277. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9278. /**
  9279. * Add the list of attributes required for instances to the attribs array.
  9280. * @param attribs The current list of supported attribs
  9281. */
  9282. static PushAttributesForInstances(attribs: string[]): void;
  9283. /**
  9284. * Binds the light information to the effect.
  9285. * @param light The light containing the generator
  9286. * @param effect The effect we are binding the data to
  9287. * @param lightIndex The light index in the effect used to render
  9288. */
  9289. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9290. /**
  9291. * Binds the lights information from the scene to the effect for the given mesh.
  9292. * @param light Light to bind
  9293. * @param lightIndex Light index
  9294. * @param scene The scene where the light belongs to
  9295. * @param effect The effect we are binding the data to
  9296. * @param useSpecular Defines if specular is supported
  9297. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9298. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9299. */
  9300. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9301. /**
  9302. * Binds the lights information from the scene to the effect for the given mesh.
  9303. * @param scene The scene the lights belongs to
  9304. * @param mesh The mesh we are binding the information to render
  9305. * @param effect The effect we are binding the data to
  9306. * @param defines The generated defines for the effect
  9307. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9308. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9309. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9310. */
  9311. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9312. private static _tempFogColor;
  9313. /**
  9314. * Binds the fog information from the scene to the effect for the given mesh.
  9315. * @param scene The scene the lights belongs to
  9316. * @param mesh The mesh we are binding the information to render
  9317. * @param effect The effect we are binding the data to
  9318. * @param linearSpace Defines if the fog effect is applied in linear space
  9319. */
  9320. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9321. /**
  9322. * Binds the bones information from the mesh to the effect.
  9323. * @param mesh The mesh we are binding the information to render
  9324. * @param effect The effect we are binding the data to
  9325. */
  9326. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9327. /**
  9328. * Binds the morph targets information from the mesh to the effect.
  9329. * @param abstractMesh The mesh we are binding the information to render
  9330. * @param effect The effect we are binding the data to
  9331. */
  9332. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9333. /**
  9334. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9335. * @param defines The generated defines used in the effect
  9336. * @param effect The effect we are binding the data to
  9337. * @param scene The scene we are willing to render with logarithmic scale for
  9338. */
  9339. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9340. /**
  9341. * Binds the clip plane information from the scene to the effect.
  9342. * @param scene The scene the clip plane information are extracted from
  9343. * @param effect The effect we are binding the data to
  9344. */
  9345. static BindClipPlane(effect: Effect, scene: Scene): void;
  9346. }
  9347. }
  9348. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9349. /** @hidden */
  9350. export var packingFunctions: {
  9351. name: string;
  9352. shader: string;
  9353. };
  9354. }
  9355. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9356. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9357. /** @hidden */
  9358. export var shadowMapPixelShader: {
  9359. name: string;
  9360. shader: string;
  9361. };
  9362. }
  9363. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9364. /** @hidden */
  9365. export var bonesDeclaration: {
  9366. name: string;
  9367. shader: string;
  9368. };
  9369. }
  9370. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9371. /** @hidden */
  9372. export var morphTargetsVertexGlobalDeclaration: {
  9373. name: string;
  9374. shader: string;
  9375. };
  9376. }
  9377. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9378. /** @hidden */
  9379. export var morphTargetsVertexDeclaration: {
  9380. name: string;
  9381. shader: string;
  9382. };
  9383. }
  9384. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9385. /** @hidden */
  9386. export var instancesDeclaration: {
  9387. name: string;
  9388. shader: string;
  9389. };
  9390. }
  9391. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9392. /** @hidden */
  9393. export var helperFunctions: {
  9394. name: string;
  9395. shader: string;
  9396. };
  9397. }
  9398. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9399. /** @hidden */
  9400. export var morphTargetsVertex: {
  9401. name: string;
  9402. shader: string;
  9403. };
  9404. }
  9405. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9406. /** @hidden */
  9407. export var instancesVertex: {
  9408. name: string;
  9409. shader: string;
  9410. };
  9411. }
  9412. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9413. /** @hidden */
  9414. export var bonesVertex: {
  9415. name: string;
  9416. shader: string;
  9417. };
  9418. }
  9419. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9420. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9421. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9422. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9423. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9424. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9425. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9426. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9427. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9428. /** @hidden */
  9429. export var shadowMapVertexShader: {
  9430. name: string;
  9431. shader: string;
  9432. };
  9433. }
  9434. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9435. /** @hidden */
  9436. export var depthBoxBlurPixelShader: {
  9437. name: string;
  9438. shader: string;
  9439. };
  9440. }
  9441. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9442. import { Nullable } from "babylonjs/types";
  9443. import { Scene } from "babylonjs/scene";
  9444. import { Matrix } from "babylonjs/Maths/math.vector";
  9445. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9447. import { Mesh } from "babylonjs/Meshes/mesh";
  9448. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9449. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9450. import { Effect } from "babylonjs/Materials/effect";
  9451. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9452. import "babylonjs/Shaders/shadowMap.fragment";
  9453. import "babylonjs/Shaders/shadowMap.vertex";
  9454. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9455. import { Observable } from "babylonjs/Misc/observable";
  9456. /**
  9457. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9458. */
  9459. export interface ICustomShaderOptions {
  9460. /**
  9461. * Gets or sets the custom shader name to use
  9462. */
  9463. shaderName: string;
  9464. /**
  9465. * The list of attribute names used in the shader
  9466. */
  9467. attributes?: string[];
  9468. /**
  9469. * The list of unifrom names used in the shader
  9470. */
  9471. uniforms?: string[];
  9472. /**
  9473. * The list of sampler names used in the shader
  9474. */
  9475. samplers?: string[];
  9476. /**
  9477. * The list of defines used in the shader
  9478. */
  9479. defines?: string[];
  9480. }
  9481. /**
  9482. * Interface to implement to create a shadow generator compatible with BJS.
  9483. */
  9484. export interface IShadowGenerator {
  9485. /**
  9486. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9487. * @returns The render target texture if present otherwise, null
  9488. */
  9489. getShadowMap(): Nullable<RenderTargetTexture>;
  9490. /**
  9491. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9492. * @returns The render target texture if the shadow map is present otherwise, null
  9493. */
  9494. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9495. /**
  9496. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9497. * @param subMesh The submesh we want to render in the shadow map
  9498. * @param useInstances Defines wether will draw in the map using instances
  9499. * @returns true if ready otherwise, false
  9500. */
  9501. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9502. /**
  9503. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9504. * @param defines Defines of the material we want to update
  9505. * @param lightIndex Index of the light in the enabled light list of the material
  9506. */
  9507. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9508. /**
  9509. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9510. * defined in the generator but impacting the effect).
  9511. * It implies the unifroms available on the materials are the standard BJS ones.
  9512. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9513. * @param effect The effect we are binfing the information for
  9514. */
  9515. bindShadowLight(lightIndex: string, effect: Effect): void;
  9516. /**
  9517. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9518. * (eq to shadow prjection matrix * light transform matrix)
  9519. * @returns The transform matrix used to create the shadow map
  9520. */
  9521. getTransformMatrix(): Matrix;
  9522. /**
  9523. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9524. * Cube and 2D textures for instance.
  9525. */
  9526. recreateShadowMap(): void;
  9527. /**
  9528. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9529. * @param onCompiled Callback triggered at the and of the effects compilation
  9530. * @param options Sets of optional options forcing the compilation with different modes
  9531. */
  9532. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9533. useInstances: boolean;
  9534. }>): void;
  9535. /**
  9536. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9537. * @param options Sets of optional options forcing the compilation with different modes
  9538. * @returns A promise that resolves when the compilation completes
  9539. */
  9540. forceCompilationAsync(options?: Partial<{
  9541. useInstances: boolean;
  9542. }>): Promise<void>;
  9543. /**
  9544. * Serializes the shadow generator setup to a json object.
  9545. * @returns The serialized JSON object
  9546. */
  9547. serialize(): any;
  9548. /**
  9549. * Disposes the Shadow map and related Textures and effects.
  9550. */
  9551. dispose(): void;
  9552. }
  9553. /**
  9554. * Default implementation IShadowGenerator.
  9555. * This is the main object responsible of generating shadows in the framework.
  9556. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9557. */
  9558. export class ShadowGenerator implements IShadowGenerator {
  9559. /**
  9560. * Shadow generator mode None: no filtering applied.
  9561. */
  9562. static readonly FILTER_NONE: number;
  9563. /**
  9564. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9565. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9566. */
  9567. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9568. /**
  9569. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9570. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9571. */
  9572. static readonly FILTER_POISSONSAMPLING: number;
  9573. /**
  9574. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9575. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9576. */
  9577. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9578. /**
  9579. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9580. * edge artifacts on steep falloff.
  9581. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9582. */
  9583. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9584. /**
  9585. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9586. * edge artifacts on steep falloff.
  9587. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9588. */
  9589. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9590. /**
  9591. * Shadow generator mode PCF: Percentage Closer Filtering
  9592. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9593. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9594. */
  9595. static readonly FILTER_PCF: number;
  9596. /**
  9597. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9598. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9599. * Contact Hardening
  9600. */
  9601. static readonly FILTER_PCSS: number;
  9602. /**
  9603. * Reserved for PCF and PCSS
  9604. * Highest Quality.
  9605. *
  9606. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9607. *
  9608. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9609. */
  9610. static readonly QUALITY_HIGH: number;
  9611. /**
  9612. * Reserved for PCF and PCSS
  9613. * Good tradeoff for quality/perf cross devices
  9614. *
  9615. * Execute PCF on a 3*3 kernel.
  9616. *
  9617. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9618. */
  9619. static readonly QUALITY_MEDIUM: number;
  9620. /**
  9621. * Reserved for PCF and PCSS
  9622. * The lowest quality but the fastest.
  9623. *
  9624. * Execute PCF on a 1*1 kernel.
  9625. *
  9626. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9627. */
  9628. static readonly QUALITY_LOW: number;
  9629. /** Gets or sets the custom shader name to use */
  9630. customShaderOptions: ICustomShaderOptions;
  9631. /**
  9632. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9633. */
  9634. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9635. /**
  9636. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9637. */
  9638. onAfterShadowMapRenderObservable: Observable<Effect>;
  9639. /**
  9640. * Observable triggered before a mesh is rendered in the shadow map.
  9641. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9642. */
  9643. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9644. /**
  9645. * Observable triggered after a mesh is rendered in the shadow map.
  9646. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9647. */
  9648. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9649. private _bias;
  9650. /**
  9651. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9652. */
  9653. /**
  9654. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9655. */
  9656. bias: number;
  9657. private _normalBias;
  9658. /**
  9659. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9660. */
  9661. /**
  9662. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9663. */
  9664. normalBias: number;
  9665. private _blurBoxOffset;
  9666. /**
  9667. * Gets the blur box offset: offset applied during the blur pass.
  9668. * Only useful if useKernelBlur = false
  9669. */
  9670. /**
  9671. * Sets the blur box offset: offset applied during the blur pass.
  9672. * Only useful if useKernelBlur = false
  9673. */
  9674. blurBoxOffset: number;
  9675. private _blurScale;
  9676. /**
  9677. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9678. * 2 means half of the size.
  9679. */
  9680. /**
  9681. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9682. * 2 means half of the size.
  9683. */
  9684. blurScale: number;
  9685. private _blurKernel;
  9686. /**
  9687. * Gets the blur kernel: kernel size of the blur pass.
  9688. * Only useful if useKernelBlur = true
  9689. */
  9690. /**
  9691. * Sets the blur kernel: kernel size of the blur pass.
  9692. * Only useful if useKernelBlur = true
  9693. */
  9694. blurKernel: number;
  9695. private _useKernelBlur;
  9696. /**
  9697. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9698. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9699. */
  9700. /**
  9701. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9702. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9703. */
  9704. useKernelBlur: boolean;
  9705. private _depthScale;
  9706. /**
  9707. * Gets the depth scale used in ESM mode.
  9708. */
  9709. /**
  9710. * Sets the depth scale used in ESM mode.
  9711. * This can override the scale stored on the light.
  9712. */
  9713. depthScale: number;
  9714. private _filter;
  9715. /**
  9716. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9717. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9718. */
  9719. /**
  9720. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9721. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9722. */
  9723. filter: number;
  9724. /**
  9725. * Gets if the current filter is set to Poisson Sampling.
  9726. */
  9727. /**
  9728. * Sets the current filter to Poisson Sampling.
  9729. */
  9730. usePoissonSampling: boolean;
  9731. /**
  9732. * Gets if the current filter is set to ESM.
  9733. */
  9734. /**
  9735. * Sets the current filter is to ESM.
  9736. */
  9737. useExponentialShadowMap: boolean;
  9738. /**
  9739. * Gets if the current filter is set to filtered ESM.
  9740. */
  9741. /**
  9742. * Gets if the current filter is set to filtered ESM.
  9743. */
  9744. useBlurExponentialShadowMap: boolean;
  9745. /**
  9746. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9747. * exponential to prevent steep falloff artifacts).
  9748. */
  9749. /**
  9750. * Sets the current filter to "close ESM" (using the inverse of the
  9751. * exponential to prevent steep falloff artifacts).
  9752. */
  9753. useCloseExponentialShadowMap: boolean;
  9754. /**
  9755. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9756. * exponential to prevent steep falloff artifacts).
  9757. */
  9758. /**
  9759. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9760. * exponential to prevent steep falloff artifacts).
  9761. */
  9762. useBlurCloseExponentialShadowMap: boolean;
  9763. /**
  9764. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9765. */
  9766. /**
  9767. * Sets the current filter to "PCF" (percentage closer filtering).
  9768. */
  9769. usePercentageCloserFiltering: boolean;
  9770. private _filteringQuality;
  9771. /**
  9772. * Gets the PCF or PCSS Quality.
  9773. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9774. */
  9775. /**
  9776. * Sets the PCF or PCSS Quality.
  9777. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9778. */
  9779. filteringQuality: number;
  9780. /**
  9781. * Gets if the current filter is set to "PCSS" (contact hardening).
  9782. */
  9783. /**
  9784. * Sets the current filter to "PCSS" (contact hardening).
  9785. */
  9786. useContactHardeningShadow: boolean;
  9787. private _contactHardeningLightSizeUVRatio;
  9788. /**
  9789. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9790. * Using a ratio helps keeping shape stability independently of the map size.
  9791. *
  9792. * It does not account for the light projection as it was having too much
  9793. * instability during the light setup or during light position changes.
  9794. *
  9795. * Only valid if useContactHardeningShadow is true.
  9796. */
  9797. /**
  9798. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9799. * Using a ratio helps keeping shape stability independently of the map size.
  9800. *
  9801. * It does not account for the light projection as it was having too much
  9802. * instability during the light setup or during light position changes.
  9803. *
  9804. * Only valid if useContactHardeningShadow is true.
  9805. */
  9806. contactHardeningLightSizeUVRatio: number;
  9807. private _darkness;
  9808. /** Gets or sets the actual darkness of a shadow */
  9809. darkness: number;
  9810. /**
  9811. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9812. * 0 means strongest and 1 would means no shadow.
  9813. * @returns the darkness.
  9814. */
  9815. getDarkness(): number;
  9816. /**
  9817. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9818. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9819. * @returns the shadow generator allowing fluent coding.
  9820. */
  9821. setDarkness(darkness: number): ShadowGenerator;
  9822. private _transparencyShadow;
  9823. /** Gets or sets the ability to have transparent shadow */
  9824. transparencyShadow: boolean;
  9825. /**
  9826. * Sets the ability to have transparent shadow (boolean).
  9827. * @param transparent True if transparent else False
  9828. * @returns the shadow generator allowing fluent coding
  9829. */
  9830. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9831. private _shadowMap;
  9832. private _shadowMap2;
  9833. /**
  9834. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9835. * @returns The render target texture if present otherwise, null
  9836. */
  9837. getShadowMap(): Nullable<RenderTargetTexture>;
  9838. /**
  9839. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9840. * @returns The render target texture if the shadow map is present otherwise, null
  9841. */
  9842. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9843. /**
  9844. * Gets the class name of that object
  9845. * @returns "ShadowGenerator"
  9846. */
  9847. getClassName(): string;
  9848. /**
  9849. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9850. * @param mesh Mesh to add
  9851. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9852. * @returns the Shadow Generator itself
  9853. */
  9854. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9855. /**
  9856. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9857. * @param mesh Mesh to remove
  9858. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9859. * @returns the Shadow Generator itself
  9860. */
  9861. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9862. /**
  9863. * Controls the extent to which the shadows fade out at the edge of the frustum
  9864. * Used only by directionals and spots
  9865. */
  9866. frustumEdgeFalloff: number;
  9867. private _light;
  9868. /**
  9869. * Returns the associated light object.
  9870. * @returns the light generating the shadow
  9871. */
  9872. getLight(): IShadowLight;
  9873. /**
  9874. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9875. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9876. * It might on the other hand introduce peter panning.
  9877. */
  9878. forceBackFacesOnly: boolean;
  9879. private _scene;
  9880. private _lightDirection;
  9881. private _effect;
  9882. private _viewMatrix;
  9883. private _projectionMatrix;
  9884. private _transformMatrix;
  9885. private _cachedPosition;
  9886. private _cachedDirection;
  9887. private _cachedDefines;
  9888. private _currentRenderID;
  9889. private _boxBlurPostprocess;
  9890. private _kernelBlurXPostprocess;
  9891. private _kernelBlurYPostprocess;
  9892. private _blurPostProcesses;
  9893. private _mapSize;
  9894. private _currentFaceIndex;
  9895. private _currentFaceIndexCache;
  9896. private _textureType;
  9897. private _defaultTextureMatrix;
  9898. private _storedUniqueId;
  9899. /** @hidden */
  9900. static _SceneComponentInitialization: (scene: Scene) => void;
  9901. /**
  9902. * Creates a ShadowGenerator object.
  9903. * A ShadowGenerator is the required tool to use the shadows.
  9904. * Each light casting shadows needs to use its own ShadowGenerator.
  9905. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9906. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9907. * @param light The light object generating the shadows.
  9908. * @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.
  9909. */
  9910. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9911. private _initializeGenerator;
  9912. private _initializeShadowMap;
  9913. private _initializeBlurRTTAndPostProcesses;
  9914. private _renderForShadowMap;
  9915. private _renderSubMeshForShadowMap;
  9916. private _applyFilterValues;
  9917. /**
  9918. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9919. * @param onCompiled Callback triggered at the and of the effects compilation
  9920. * @param options Sets of optional options forcing the compilation with different modes
  9921. */
  9922. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9923. useInstances: boolean;
  9924. }>): void;
  9925. /**
  9926. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9927. * @param options Sets of optional options forcing the compilation with different modes
  9928. * @returns A promise that resolves when the compilation completes
  9929. */
  9930. forceCompilationAsync(options?: Partial<{
  9931. useInstances: boolean;
  9932. }>): Promise<void>;
  9933. /**
  9934. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9935. * @param subMesh The submesh we want to render in the shadow map
  9936. * @param useInstances Defines wether will draw in the map using instances
  9937. * @returns true if ready otherwise, false
  9938. */
  9939. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9940. /**
  9941. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9942. * @param defines Defines of the material we want to update
  9943. * @param lightIndex Index of the light in the enabled light list of the material
  9944. */
  9945. prepareDefines(defines: any, lightIndex: number): void;
  9946. /**
  9947. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9948. * defined in the generator but impacting the effect).
  9949. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9950. * @param effect The effect we are binfing the information for
  9951. */
  9952. bindShadowLight(lightIndex: string, effect: Effect): void;
  9953. /**
  9954. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9955. * (eq to shadow prjection matrix * light transform matrix)
  9956. * @returns The transform matrix used to create the shadow map
  9957. */
  9958. getTransformMatrix(): Matrix;
  9959. /**
  9960. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9961. * Cube and 2D textures for instance.
  9962. */
  9963. recreateShadowMap(): void;
  9964. private _disposeBlurPostProcesses;
  9965. private _disposeRTTandPostProcesses;
  9966. /**
  9967. * Disposes the ShadowGenerator.
  9968. * Returns nothing.
  9969. */
  9970. dispose(): void;
  9971. /**
  9972. * Serializes the shadow generator setup to a json object.
  9973. * @returns The serialized JSON object
  9974. */
  9975. serialize(): any;
  9976. /**
  9977. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9978. * @param parsedShadowGenerator The JSON object to parse
  9979. * @param scene The scene to create the shadow map for
  9980. * @returns The parsed shadow generator
  9981. */
  9982. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9983. }
  9984. }
  9985. declare module "babylonjs/Lights/light" {
  9986. import { Nullable } from "babylonjs/types";
  9987. import { Scene } from "babylonjs/scene";
  9988. import { Vector3 } from "babylonjs/Maths/math.vector";
  9989. import { Color3 } from "babylonjs/Maths/math.color";
  9990. import { Node } from "babylonjs/node";
  9991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9992. import { Effect } from "babylonjs/Materials/effect";
  9993. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9994. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9995. /**
  9996. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9997. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9998. * 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.
  9999. */
  10000. export abstract class Light extends Node {
  10001. /**
  10002. * Falloff Default: light is falling off following the material specification:
  10003. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10004. */
  10005. static readonly FALLOFF_DEFAULT: number;
  10006. /**
  10007. * Falloff Physical: light is falling off following the inverse squared distance law.
  10008. */
  10009. static readonly FALLOFF_PHYSICAL: number;
  10010. /**
  10011. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10012. * to enhance interoperability with other engines.
  10013. */
  10014. static readonly FALLOFF_GLTF: number;
  10015. /**
  10016. * Falloff Standard: light is falling off like in the standard material
  10017. * to enhance interoperability with other materials.
  10018. */
  10019. static readonly FALLOFF_STANDARD: number;
  10020. /**
  10021. * If every light affecting the material is in this lightmapMode,
  10022. * material.lightmapTexture adds or multiplies
  10023. * (depends on material.useLightmapAsShadowmap)
  10024. * after every other light calculations.
  10025. */
  10026. static readonly LIGHTMAP_DEFAULT: number;
  10027. /**
  10028. * material.lightmapTexture as only diffuse lighting from this light
  10029. * adds only specular lighting from this light
  10030. * adds dynamic shadows
  10031. */
  10032. static readonly LIGHTMAP_SPECULAR: number;
  10033. /**
  10034. * material.lightmapTexture as only lighting
  10035. * no light calculation from this light
  10036. * only adds dynamic shadows from this light
  10037. */
  10038. static readonly LIGHTMAP_SHADOWSONLY: number;
  10039. /**
  10040. * Each light type uses the default quantity according to its type:
  10041. * point/spot lights use luminous intensity
  10042. * directional lights use illuminance
  10043. */
  10044. static readonly INTENSITYMODE_AUTOMATIC: number;
  10045. /**
  10046. * lumen (lm)
  10047. */
  10048. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10049. /**
  10050. * candela (lm/sr)
  10051. */
  10052. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10053. /**
  10054. * lux (lm/m^2)
  10055. */
  10056. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10057. /**
  10058. * nit (cd/m^2)
  10059. */
  10060. static readonly INTENSITYMODE_LUMINANCE: number;
  10061. /**
  10062. * Light type const id of the point light.
  10063. */
  10064. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10065. /**
  10066. * Light type const id of the directional light.
  10067. */
  10068. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10069. /**
  10070. * Light type const id of the spot light.
  10071. */
  10072. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10073. /**
  10074. * Light type const id of the hemispheric light.
  10075. */
  10076. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10077. /**
  10078. * Diffuse gives the basic color to an object.
  10079. */
  10080. diffuse: Color3;
  10081. /**
  10082. * Specular produces a highlight color on an object.
  10083. * Note: This is note affecting PBR materials.
  10084. */
  10085. specular: Color3;
  10086. /**
  10087. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10088. * falling off base on range or angle.
  10089. * This can be set to any values in Light.FALLOFF_x.
  10090. *
  10091. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10092. * other types of materials.
  10093. */
  10094. falloffType: number;
  10095. /**
  10096. * Strength of the light.
  10097. * Note: By default it is define in the framework own unit.
  10098. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10099. */
  10100. intensity: number;
  10101. private _range;
  10102. protected _inverseSquaredRange: number;
  10103. /**
  10104. * Defines how far from the source the light is impacting in scene units.
  10105. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10106. */
  10107. /**
  10108. * Defines how far from the source the light is impacting in scene units.
  10109. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10110. */
  10111. range: number;
  10112. /**
  10113. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10114. * of light.
  10115. */
  10116. private _photometricScale;
  10117. private _intensityMode;
  10118. /**
  10119. * Gets the photometric scale used to interpret the intensity.
  10120. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10121. */
  10122. /**
  10123. * Sets the photometric scale used to interpret the intensity.
  10124. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10125. */
  10126. intensityMode: number;
  10127. private _radius;
  10128. /**
  10129. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10130. */
  10131. /**
  10132. * sets the light radius used by PBR Materials to simulate soft area lights.
  10133. */
  10134. radius: number;
  10135. private _renderPriority;
  10136. /**
  10137. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10138. * exceeding the number allowed of the materials.
  10139. */
  10140. renderPriority: number;
  10141. private _shadowEnabled;
  10142. /**
  10143. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10144. * the current shadow generator.
  10145. */
  10146. /**
  10147. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10148. * the current shadow generator.
  10149. */
  10150. shadowEnabled: boolean;
  10151. private _includedOnlyMeshes;
  10152. /**
  10153. * Gets the only meshes impacted by this light.
  10154. */
  10155. /**
  10156. * Sets the only meshes impacted by this light.
  10157. */
  10158. includedOnlyMeshes: AbstractMesh[];
  10159. private _excludedMeshes;
  10160. /**
  10161. * Gets the meshes not impacted by this light.
  10162. */
  10163. /**
  10164. * Sets the meshes not impacted by this light.
  10165. */
  10166. excludedMeshes: AbstractMesh[];
  10167. private _excludeWithLayerMask;
  10168. /**
  10169. * Gets the layer id use to find what meshes are not impacted by the light.
  10170. * Inactive if 0
  10171. */
  10172. /**
  10173. * Sets the layer id use to find what meshes are not impacted by the light.
  10174. * Inactive if 0
  10175. */
  10176. excludeWithLayerMask: number;
  10177. private _includeOnlyWithLayerMask;
  10178. /**
  10179. * Gets the layer id use to find what meshes are impacted by the light.
  10180. * Inactive if 0
  10181. */
  10182. /**
  10183. * Sets the layer id use to find what meshes are impacted by the light.
  10184. * Inactive if 0
  10185. */
  10186. includeOnlyWithLayerMask: number;
  10187. private _lightmapMode;
  10188. /**
  10189. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10190. */
  10191. /**
  10192. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10193. */
  10194. lightmapMode: number;
  10195. /**
  10196. * Shadow generator associted to the light.
  10197. * @hidden Internal use only.
  10198. */
  10199. _shadowGenerator: Nullable<IShadowGenerator>;
  10200. /**
  10201. * @hidden Internal use only.
  10202. */
  10203. _excludedMeshesIds: string[];
  10204. /**
  10205. * @hidden Internal use only.
  10206. */
  10207. _includedOnlyMeshesIds: string[];
  10208. /**
  10209. * The current light unifom buffer.
  10210. * @hidden Internal use only.
  10211. */
  10212. _uniformBuffer: UniformBuffer;
  10213. /** @hidden */
  10214. _renderId: number;
  10215. /**
  10216. * Creates a Light object in the scene.
  10217. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10218. * @param name The firendly name of the light
  10219. * @param scene The scene the light belongs too
  10220. */
  10221. constructor(name: string, scene: Scene);
  10222. protected abstract _buildUniformLayout(): void;
  10223. /**
  10224. * Sets the passed Effect "effect" with the Light information.
  10225. * @param effect The effect to update
  10226. * @param lightIndex The index of the light in the effect to update
  10227. * @returns The light
  10228. */
  10229. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10230. /**
  10231. * Sets the passed Effect "effect" with the Light textures.
  10232. * @param effect The effect to update
  10233. * @param lightIndex The index of the light in the effect to update
  10234. * @returns The light
  10235. */
  10236. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10237. /**
  10238. * Binds the lights information from the scene to the effect for the given mesh.
  10239. * @param lightIndex Light index
  10240. * @param scene The scene where the light belongs to
  10241. * @param effect The effect we are binding the data to
  10242. * @param useSpecular Defines if specular is supported
  10243. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10244. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10245. */
  10246. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  10247. /**
  10248. * Sets the passed Effect "effect" with the Light information.
  10249. * @param effect The effect to update
  10250. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10251. * @returns The light
  10252. */
  10253. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10254. /**
  10255. * Returns the string "Light".
  10256. * @returns the class name
  10257. */
  10258. getClassName(): string;
  10259. /** @hidden */
  10260. readonly _isLight: boolean;
  10261. /**
  10262. * Converts the light information to a readable string for debug purpose.
  10263. * @param fullDetails Supports for multiple levels of logging within scene loading
  10264. * @returns the human readable light info
  10265. */
  10266. toString(fullDetails?: boolean): string;
  10267. /** @hidden */
  10268. protected _syncParentEnabledState(): void;
  10269. /**
  10270. * Set the enabled state of this node.
  10271. * @param value - the new enabled state
  10272. */
  10273. setEnabled(value: boolean): void;
  10274. /**
  10275. * Returns the Light associated shadow generator if any.
  10276. * @return the associated shadow generator.
  10277. */
  10278. getShadowGenerator(): Nullable<IShadowGenerator>;
  10279. /**
  10280. * Returns a Vector3, the absolute light position in the World.
  10281. * @returns the world space position of the light
  10282. */
  10283. getAbsolutePosition(): Vector3;
  10284. /**
  10285. * Specifies if the light will affect the passed mesh.
  10286. * @param mesh The mesh to test against the light
  10287. * @return true the mesh is affected otherwise, false.
  10288. */
  10289. canAffectMesh(mesh: AbstractMesh): boolean;
  10290. /**
  10291. * Sort function to order lights for rendering.
  10292. * @param a First Light object to compare to second.
  10293. * @param b Second Light object to compare first.
  10294. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10295. */
  10296. static CompareLightsPriority(a: Light, b: Light): number;
  10297. /**
  10298. * Releases resources associated with this node.
  10299. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10300. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10301. */
  10302. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10303. /**
  10304. * Returns the light type ID (integer).
  10305. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10306. */
  10307. getTypeID(): number;
  10308. /**
  10309. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10310. * @returns the scaled intensity in intensity mode unit
  10311. */
  10312. getScaledIntensity(): number;
  10313. /**
  10314. * Returns a new Light object, named "name", from the current one.
  10315. * @param name The name of the cloned light
  10316. * @returns the new created light
  10317. */
  10318. clone(name: string): Nullable<Light>;
  10319. /**
  10320. * Serializes the current light into a Serialization object.
  10321. * @returns the serialized object.
  10322. */
  10323. serialize(): any;
  10324. /**
  10325. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10326. * This new light is named "name" and added to the passed scene.
  10327. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10328. * @param name The friendly name of the light
  10329. * @param scene The scene the new light will belong to
  10330. * @returns the constructor function
  10331. */
  10332. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10333. /**
  10334. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10335. * @param parsedLight The JSON representation of the light
  10336. * @param scene The scene to create the parsed light in
  10337. * @returns the created light after parsing
  10338. */
  10339. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10340. private _hookArrayForExcluded;
  10341. private _hookArrayForIncludedOnly;
  10342. private _resyncMeshes;
  10343. /**
  10344. * Forces the meshes to update their light related information in their rendering used effects
  10345. * @hidden Internal Use Only
  10346. */
  10347. _markMeshesAsLightDirty(): void;
  10348. /**
  10349. * Recomputes the cached photometric scale if needed.
  10350. */
  10351. private _computePhotometricScale;
  10352. /**
  10353. * Returns the Photometric Scale according to the light type and intensity mode.
  10354. */
  10355. private _getPhotometricScale;
  10356. /**
  10357. * Reorder the light in the scene according to their defined priority.
  10358. * @hidden Internal Use Only
  10359. */
  10360. _reorderLightsInScene(): void;
  10361. /**
  10362. * Prepares the list of defines specific to the light type.
  10363. * @param defines the list of defines
  10364. * @param lightIndex defines the index of the light for the effect
  10365. */
  10366. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10367. }
  10368. }
  10369. declare module "babylonjs/Actions/action" {
  10370. import { Observable } from "babylonjs/Misc/observable";
  10371. import { Condition } from "babylonjs/Actions/condition";
  10372. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10373. import { ActionManager } from "babylonjs/Actions/actionManager";
  10374. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10375. /**
  10376. * Interface used to define Action
  10377. */
  10378. export interface IAction {
  10379. /**
  10380. * Trigger for the action
  10381. */
  10382. trigger: number;
  10383. /** Options of the trigger */
  10384. triggerOptions: any;
  10385. /**
  10386. * Gets the trigger parameters
  10387. * @returns the trigger parameters
  10388. */
  10389. getTriggerParameter(): any;
  10390. /**
  10391. * Internal only - executes current action event
  10392. * @hidden
  10393. */
  10394. _executeCurrent(evt?: ActionEvent): void;
  10395. /**
  10396. * Serialize placeholder for child classes
  10397. * @param parent of child
  10398. * @returns the serialized object
  10399. */
  10400. serialize(parent: any): any;
  10401. /**
  10402. * Internal only
  10403. * @hidden
  10404. */
  10405. _prepare(): void;
  10406. /**
  10407. * Internal only - manager for action
  10408. * @hidden
  10409. */
  10410. _actionManager: AbstractActionManager;
  10411. /**
  10412. * Adds action to chain of actions, may be a DoNothingAction
  10413. * @param action defines the next action to execute
  10414. * @returns The action passed in
  10415. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10416. */
  10417. then(action: IAction): IAction;
  10418. }
  10419. /**
  10420. * The action to be carried out following a trigger
  10421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10422. */
  10423. export class Action implements IAction {
  10424. /** the trigger, with or without parameters, for the action */
  10425. triggerOptions: any;
  10426. /**
  10427. * Trigger for the action
  10428. */
  10429. trigger: number;
  10430. /**
  10431. * Internal only - manager for action
  10432. * @hidden
  10433. */
  10434. _actionManager: ActionManager;
  10435. private _nextActiveAction;
  10436. private _child;
  10437. private _condition?;
  10438. private _triggerParameter;
  10439. /**
  10440. * An event triggered prior to action being executed.
  10441. */
  10442. onBeforeExecuteObservable: Observable<Action>;
  10443. /**
  10444. * Creates a new Action
  10445. * @param triggerOptions the trigger, with or without parameters, for the action
  10446. * @param condition an optional determinant of action
  10447. */
  10448. constructor(
  10449. /** the trigger, with or without parameters, for the action */
  10450. triggerOptions: any, condition?: Condition);
  10451. /**
  10452. * Internal only
  10453. * @hidden
  10454. */
  10455. _prepare(): void;
  10456. /**
  10457. * Gets the trigger parameters
  10458. * @returns the trigger parameters
  10459. */
  10460. getTriggerParameter(): any;
  10461. /**
  10462. * Internal only - executes current action event
  10463. * @hidden
  10464. */
  10465. _executeCurrent(evt?: ActionEvent): void;
  10466. /**
  10467. * Execute placeholder for child classes
  10468. * @param evt optional action event
  10469. */
  10470. execute(evt?: ActionEvent): void;
  10471. /**
  10472. * Skips to next active action
  10473. */
  10474. skipToNextActiveAction(): void;
  10475. /**
  10476. * Adds action to chain of actions, may be a DoNothingAction
  10477. * @param action defines the next action to execute
  10478. * @returns The action passed in
  10479. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10480. */
  10481. then(action: Action): Action;
  10482. /**
  10483. * Internal only
  10484. * @hidden
  10485. */
  10486. _getProperty(propertyPath: string): string;
  10487. /**
  10488. * Internal only
  10489. * @hidden
  10490. */
  10491. _getEffectiveTarget(target: any, propertyPath: string): any;
  10492. /**
  10493. * Serialize placeholder for child classes
  10494. * @param parent of child
  10495. * @returns the serialized object
  10496. */
  10497. serialize(parent: any): any;
  10498. /**
  10499. * Internal only called by serialize
  10500. * @hidden
  10501. */
  10502. protected _serialize(serializedAction: any, parent?: any): any;
  10503. /**
  10504. * Internal only
  10505. * @hidden
  10506. */
  10507. static _SerializeValueAsString: (value: any) => string;
  10508. /**
  10509. * Internal only
  10510. * @hidden
  10511. */
  10512. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10513. name: string;
  10514. targetType: string;
  10515. value: string;
  10516. };
  10517. }
  10518. }
  10519. declare module "babylonjs/Actions/condition" {
  10520. import { ActionManager } from "babylonjs/Actions/actionManager";
  10521. /**
  10522. * A Condition applied to an Action
  10523. */
  10524. export class Condition {
  10525. /**
  10526. * Internal only - manager for action
  10527. * @hidden
  10528. */
  10529. _actionManager: ActionManager;
  10530. /**
  10531. * Internal only
  10532. * @hidden
  10533. */
  10534. _evaluationId: number;
  10535. /**
  10536. * Internal only
  10537. * @hidden
  10538. */
  10539. _currentResult: boolean;
  10540. /**
  10541. * Creates a new Condition
  10542. * @param actionManager the manager of the action the condition is applied to
  10543. */
  10544. constructor(actionManager: ActionManager);
  10545. /**
  10546. * Check if the current condition is valid
  10547. * @returns a boolean
  10548. */
  10549. isValid(): boolean;
  10550. /**
  10551. * Internal only
  10552. * @hidden
  10553. */
  10554. _getProperty(propertyPath: string): string;
  10555. /**
  10556. * Internal only
  10557. * @hidden
  10558. */
  10559. _getEffectiveTarget(target: any, propertyPath: string): any;
  10560. /**
  10561. * Serialize placeholder for child classes
  10562. * @returns the serialized object
  10563. */
  10564. serialize(): any;
  10565. /**
  10566. * Internal only
  10567. * @hidden
  10568. */
  10569. protected _serialize(serializedCondition: any): any;
  10570. }
  10571. /**
  10572. * Defines specific conditional operators as extensions of Condition
  10573. */
  10574. export class ValueCondition extends Condition {
  10575. /** path to specify the property of the target the conditional operator uses */
  10576. propertyPath: string;
  10577. /** the value compared by the conditional operator against the current value of the property */
  10578. value: any;
  10579. /** the conditional operator, default ValueCondition.IsEqual */
  10580. operator: number;
  10581. /**
  10582. * Internal only
  10583. * @hidden
  10584. */
  10585. private static _IsEqual;
  10586. /**
  10587. * Internal only
  10588. * @hidden
  10589. */
  10590. private static _IsDifferent;
  10591. /**
  10592. * Internal only
  10593. * @hidden
  10594. */
  10595. private static _IsGreater;
  10596. /**
  10597. * Internal only
  10598. * @hidden
  10599. */
  10600. private static _IsLesser;
  10601. /**
  10602. * returns the number for IsEqual
  10603. */
  10604. static readonly IsEqual: number;
  10605. /**
  10606. * Returns the number for IsDifferent
  10607. */
  10608. static readonly IsDifferent: number;
  10609. /**
  10610. * Returns the number for IsGreater
  10611. */
  10612. static readonly IsGreater: number;
  10613. /**
  10614. * Returns the number for IsLesser
  10615. */
  10616. static readonly IsLesser: number;
  10617. /**
  10618. * Internal only The action manager for the condition
  10619. * @hidden
  10620. */
  10621. _actionManager: ActionManager;
  10622. /**
  10623. * Internal only
  10624. * @hidden
  10625. */
  10626. private _target;
  10627. /**
  10628. * Internal only
  10629. * @hidden
  10630. */
  10631. private _effectiveTarget;
  10632. /**
  10633. * Internal only
  10634. * @hidden
  10635. */
  10636. private _property;
  10637. /**
  10638. * Creates a new ValueCondition
  10639. * @param actionManager manager for the action the condition applies to
  10640. * @param target for the action
  10641. * @param propertyPath path to specify the property of the target the conditional operator uses
  10642. * @param value the value compared by the conditional operator against the current value of the property
  10643. * @param operator the conditional operator, default ValueCondition.IsEqual
  10644. */
  10645. constructor(actionManager: ActionManager, target: any,
  10646. /** path to specify the property of the target the conditional operator uses */
  10647. propertyPath: string,
  10648. /** the value compared by the conditional operator against the current value of the property */
  10649. value: any,
  10650. /** the conditional operator, default ValueCondition.IsEqual */
  10651. operator?: number);
  10652. /**
  10653. * Compares the given value with the property value for the specified conditional operator
  10654. * @returns the result of the comparison
  10655. */
  10656. isValid(): boolean;
  10657. /**
  10658. * Serialize the ValueCondition into a JSON compatible object
  10659. * @returns serialization object
  10660. */
  10661. serialize(): any;
  10662. /**
  10663. * Gets the name of the conditional operator for the ValueCondition
  10664. * @param operator the conditional operator
  10665. * @returns the name
  10666. */
  10667. static GetOperatorName(operator: number): string;
  10668. }
  10669. /**
  10670. * Defines a predicate condition as an extension of Condition
  10671. */
  10672. export class PredicateCondition extends Condition {
  10673. /** defines the predicate function used to validate the condition */
  10674. predicate: () => boolean;
  10675. /**
  10676. * Internal only - manager for action
  10677. * @hidden
  10678. */
  10679. _actionManager: ActionManager;
  10680. /**
  10681. * Creates a new PredicateCondition
  10682. * @param actionManager manager for the action the condition applies to
  10683. * @param predicate defines the predicate function used to validate the condition
  10684. */
  10685. constructor(actionManager: ActionManager,
  10686. /** defines the predicate function used to validate the condition */
  10687. predicate: () => boolean);
  10688. /**
  10689. * @returns the validity of the predicate condition
  10690. */
  10691. isValid(): boolean;
  10692. }
  10693. /**
  10694. * Defines a state condition as an extension of Condition
  10695. */
  10696. export class StateCondition extends Condition {
  10697. /** Value to compare with target state */
  10698. value: string;
  10699. /**
  10700. * Internal only - manager for action
  10701. * @hidden
  10702. */
  10703. _actionManager: ActionManager;
  10704. /**
  10705. * Internal only
  10706. * @hidden
  10707. */
  10708. private _target;
  10709. /**
  10710. * Creates a new StateCondition
  10711. * @param actionManager manager for the action the condition applies to
  10712. * @param target of the condition
  10713. * @param value to compare with target state
  10714. */
  10715. constructor(actionManager: ActionManager, target: any,
  10716. /** Value to compare with target state */
  10717. value: string);
  10718. /**
  10719. * Gets a boolean indicating if the current condition is met
  10720. * @returns the validity of the state
  10721. */
  10722. isValid(): boolean;
  10723. /**
  10724. * Serialize the StateCondition into a JSON compatible object
  10725. * @returns serialization object
  10726. */
  10727. serialize(): any;
  10728. }
  10729. }
  10730. declare module "babylonjs/Actions/directActions" {
  10731. import { Action } from "babylonjs/Actions/action";
  10732. import { Condition } from "babylonjs/Actions/condition";
  10733. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10734. /**
  10735. * This defines an action responsible to toggle a boolean once triggered.
  10736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10737. */
  10738. export class SwitchBooleanAction extends Action {
  10739. /**
  10740. * The path to the boolean property in the target object
  10741. */
  10742. propertyPath: string;
  10743. private _target;
  10744. private _effectiveTarget;
  10745. private _property;
  10746. /**
  10747. * Instantiate the action
  10748. * @param triggerOptions defines the trigger options
  10749. * @param target defines the object containing the boolean
  10750. * @param propertyPath defines the path to the boolean property in the target object
  10751. * @param condition defines the trigger related conditions
  10752. */
  10753. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10754. /** @hidden */
  10755. _prepare(): void;
  10756. /**
  10757. * Execute the action toggle the boolean value.
  10758. */
  10759. execute(): void;
  10760. /**
  10761. * Serializes the actions and its related information.
  10762. * @param parent defines the object to serialize in
  10763. * @returns the serialized object
  10764. */
  10765. serialize(parent: any): any;
  10766. }
  10767. /**
  10768. * This defines an action responsible to set a the state field of the target
  10769. * to a desired value once triggered.
  10770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10771. */
  10772. export class SetStateAction extends Action {
  10773. /**
  10774. * The value to store in the state field.
  10775. */
  10776. value: string;
  10777. private _target;
  10778. /**
  10779. * Instantiate the action
  10780. * @param triggerOptions defines the trigger options
  10781. * @param target defines the object containing the state property
  10782. * @param value defines the value to store in the state field
  10783. * @param condition defines the trigger related conditions
  10784. */
  10785. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10786. /**
  10787. * Execute the action and store the value on the target state property.
  10788. */
  10789. execute(): void;
  10790. /**
  10791. * Serializes the actions and its related information.
  10792. * @param parent defines the object to serialize in
  10793. * @returns the serialized object
  10794. */
  10795. serialize(parent: any): any;
  10796. }
  10797. /**
  10798. * This defines an action responsible to set a property of the target
  10799. * to a desired value once triggered.
  10800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10801. */
  10802. export class SetValueAction extends Action {
  10803. /**
  10804. * The path of the property to set in the target.
  10805. */
  10806. propertyPath: string;
  10807. /**
  10808. * The value to set in the property
  10809. */
  10810. value: any;
  10811. private _target;
  10812. private _effectiveTarget;
  10813. private _property;
  10814. /**
  10815. * Instantiate the action
  10816. * @param triggerOptions defines the trigger options
  10817. * @param target defines the object containing the property
  10818. * @param propertyPath defines the path of the property to set in the target
  10819. * @param value defines the value to set in the property
  10820. * @param condition defines the trigger related conditions
  10821. */
  10822. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10823. /** @hidden */
  10824. _prepare(): void;
  10825. /**
  10826. * Execute the action and set the targetted property to the desired value.
  10827. */
  10828. execute(): void;
  10829. /**
  10830. * Serializes the actions and its related information.
  10831. * @param parent defines the object to serialize in
  10832. * @returns the serialized object
  10833. */
  10834. serialize(parent: any): any;
  10835. }
  10836. /**
  10837. * This defines an action responsible to increment the target value
  10838. * to a desired value once triggered.
  10839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10840. */
  10841. export class IncrementValueAction extends Action {
  10842. /**
  10843. * The path of the property to increment in the target.
  10844. */
  10845. propertyPath: string;
  10846. /**
  10847. * The value we should increment the property by.
  10848. */
  10849. value: any;
  10850. private _target;
  10851. private _effectiveTarget;
  10852. private _property;
  10853. /**
  10854. * Instantiate the action
  10855. * @param triggerOptions defines the trigger options
  10856. * @param target defines the object containing the property
  10857. * @param propertyPath defines the path of the property to increment in the target
  10858. * @param value defines the value value we should increment the property by
  10859. * @param condition defines the trigger related conditions
  10860. */
  10861. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10862. /** @hidden */
  10863. _prepare(): void;
  10864. /**
  10865. * Execute the action and increment the target of the value amount.
  10866. */
  10867. execute(): void;
  10868. /**
  10869. * Serializes the actions and its related information.
  10870. * @param parent defines the object to serialize in
  10871. * @returns the serialized object
  10872. */
  10873. serialize(parent: any): any;
  10874. }
  10875. /**
  10876. * This defines an action responsible to start an animation once triggered.
  10877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10878. */
  10879. export class PlayAnimationAction extends Action {
  10880. /**
  10881. * Where the animation should start (animation frame)
  10882. */
  10883. from: number;
  10884. /**
  10885. * Where the animation should stop (animation frame)
  10886. */
  10887. to: number;
  10888. /**
  10889. * Define if the animation should loop or stop after the first play.
  10890. */
  10891. loop?: boolean;
  10892. private _target;
  10893. /**
  10894. * Instantiate the action
  10895. * @param triggerOptions defines the trigger options
  10896. * @param target defines the target animation or animation name
  10897. * @param from defines from where the animation should start (animation frame)
  10898. * @param end defines where the animation should stop (animation frame)
  10899. * @param loop defines if the animation should loop or stop after the first play
  10900. * @param condition defines the trigger related conditions
  10901. */
  10902. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10903. /** @hidden */
  10904. _prepare(): void;
  10905. /**
  10906. * Execute the action and play the animation.
  10907. */
  10908. execute(): void;
  10909. /**
  10910. * Serializes the actions and its related information.
  10911. * @param parent defines the object to serialize in
  10912. * @returns the serialized object
  10913. */
  10914. serialize(parent: any): any;
  10915. }
  10916. /**
  10917. * This defines an action responsible to stop an animation once triggered.
  10918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10919. */
  10920. export class StopAnimationAction extends Action {
  10921. private _target;
  10922. /**
  10923. * Instantiate the action
  10924. * @param triggerOptions defines the trigger options
  10925. * @param target defines the target animation or animation name
  10926. * @param condition defines the trigger related conditions
  10927. */
  10928. constructor(triggerOptions: any, target: any, condition?: Condition);
  10929. /** @hidden */
  10930. _prepare(): void;
  10931. /**
  10932. * Execute the action and stop the animation.
  10933. */
  10934. execute(): void;
  10935. /**
  10936. * Serializes the actions and its related information.
  10937. * @param parent defines the object to serialize in
  10938. * @returns the serialized object
  10939. */
  10940. serialize(parent: any): any;
  10941. }
  10942. /**
  10943. * This defines an action responsible that does nothing once triggered.
  10944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10945. */
  10946. export class DoNothingAction extends Action {
  10947. /**
  10948. * Instantiate the action
  10949. * @param triggerOptions defines the trigger options
  10950. * @param condition defines the trigger related conditions
  10951. */
  10952. constructor(triggerOptions?: any, condition?: Condition);
  10953. /**
  10954. * Execute the action and do nothing.
  10955. */
  10956. execute(): void;
  10957. /**
  10958. * Serializes the actions and its related information.
  10959. * @param parent defines the object to serialize in
  10960. * @returns the serialized object
  10961. */
  10962. serialize(parent: any): any;
  10963. }
  10964. /**
  10965. * This defines an action responsible to trigger several actions once triggered.
  10966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10967. */
  10968. export class CombineAction extends Action {
  10969. /**
  10970. * The list of aggregated animations to run.
  10971. */
  10972. children: Action[];
  10973. /**
  10974. * Instantiate the action
  10975. * @param triggerOptions defines the trigger options
  10976. * @param children defines the list of aggregated animations to run
  10977. * @param condition defines the trigger related conditions
  10978. */
  10979. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10980. /** @hidden */
  10981. _prepare(): void;
  10982. /**
  10983. * Execute the action and executes all the aggregated actions.
  10984. */
  10985. execute(evt: ActionEvent): void;
  10986. /**
  10987. * Serializes the actions and its related information.
  10988. * @param parent defines the object to serialize in
  10989. * @returns the serialized object
  10990. */
  10991. serialize(parent: any): any;
  10992. }
  10993. /**
  10994. * This defines an action responsible to run code (external event) once triggered.
  10995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10996. */
  10997. export class ExecuteCodeAction extends Action {
  10998. /**
  10999. * The callback function to run.
  11000. */
  11001. func: (evt: ActionEvent) => void;
  11002. /**
  11003. * Instantiate the action
  11004. * @param triggerOptions defines the trigger options
  11005. * @param func defines the callback function to run
  11006. * @param condition defines the trigger related conditions
  11007. */
  11008. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11009. /**
  11010. * Execute the action and run the attached code.
  11011. */
  11012. execute(evt: ActionEvent): void;
  11013. }
  11014. /**
  11015. * This defines an action responsible to set the parent property of the target once triggered.
  11016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11017. */
  11018. export class SetParentAction extends Action {
  11019. private _parent;
  11020. private _target;
  11021. /**
  11022. * Instantiate the action
  11023. * @param triggerOptions defines the trigger options
  11024. * @param target defines the target containing the parent property
  11025. * @param parent defines from where the animation should start (animation frame)
  11026. * @param condition defines the trigger related conditions
  11027. */
  11028. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11029. /** @hidden */
  11030. _prepare(): void;
  11031. /**
  11032. * Execute the action and set the parent property.
  11033. */
  11034. execute(): void;
  11035. /**
  11036. * Serializes the actions and its related information.
  11037. * @param parent defines the object to serialize in
  11038. * @returns the serialized object
  11039. */
  11040. serialize(parent: any): any;
  11041. }
  11042. }
  11043. declare module "babylonjs/Actions/actionManager" {
  11044. import { Nullable } from "babylonjs/types";
  11045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11046. import { Scene } from "babylonjs/scene";
  11047. import { IAction } from "babylonjs/Actions/action";
  11048. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11049. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11050. /**
  11051. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11052. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11054. */
  11055. export class ActionManager extends AbstractActionManager {
  11056. /**
  11057. * Nothing
  11058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11059. */
  11060. static readonly NothingTrigger: number;
  11061. /**
  11062. * On pick
  11063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11064. */
  11065. static readonly OnPickTrigger: number;
  11066. /**
  11067. * On left pick
  11068. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11069. */
  11070. static readonly OnLeftPickTrigger: number;
  11071. /**
  11072. * On right pick
  11073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11074. */
  11075. static readonly OnRightPickTrigger: number;
  11076. /**
  11077. * On center pick
  11078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11079. */
  11080. static readonly OnCenterPickTrigger: number;
  11081. /**
  11082. * On pick down
  11083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11084. */
  11085. static readonly OnPickDownTrigger: number;
  11086. /**
  11087. * On double pick
  11088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11089. */
  11090. static readonly OnDoublePickTrigger: number;
  11091. /**
  11092. * On pick up
  11093. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11094. */
  11095. static readonly OnPickUpTrigger: number;
  11096. /**
  11097. * On pick out.
  11098. * This trigger will only be raised if you also declared a OnPickDown
  11099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11100. */
  11101. static readonly OnPickOutTrigger: number;
  11102. /**
  11103. * On long press
  11104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11105. */
  11106. static readonly OnLongPressTrigger: number;
  11107. /**
  11108. * On pointer over
  11109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11110. */
  11111. static readonly OnPointerOverTrigger: number;
  11112. /**
  11113. * On pointer out
  11114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11115. */
  11116. static readonly OnPointerOutTrigger: number;
  11117. /**
  11118. * On every frame
  11119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11120. */
  11121. static readonly OnEveryFrameTrigger: number;
  11122. /**
  11123. * On intersection enter
  11124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11125. */
  11126. static readonly OnIntersectionEnterTrigger: number;
  11127. /**
  11128. * On intersection exit
  11129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11130. */
  11131. static readonly OnIntersectionExitTrigger: number;
  11132. /**
  11133. * On key down
  11134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11135. */
  11136. static readonly OnKeyDownTrigger: number;
  11137. /**
  11138. * On key up
  11139. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11140. */
  11141. static readonly OnKeyUpTrigger: number;
  11142. private _scene;
  11143. /**
  11144. * Creates a new action manager
  11145. * @param scene defines the hosting scene
  11146. */
  11147. constructor(scene: Scene);
  11148. /**
  11149. * Releases all associated resources
  11150. */
  11151. dispose(): void;
  11152. /**
  11153. * Gets hosting scene
  11154. * @returns the hosting scene
  11155. */
  11156. getScene(): Scene;
  11157. /**
  11158. * Does this action manager handles actions of any of the given triggers
  11159. * @param triggers defines the triggers to be tested
  11160. * @return a boolean indicating whether one (or more) of the triggers is handled
  11161. */
  11162. hasSpecificTriggers(triggers: number[]): boolean;
  11163. /**
  11164. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11165. * speed.
  11166. * @param triggerA defines the trigger to be tested
  11167. * @param triggerB defines the trigger to be tested
  11168. * @return a boolean indicating whether one (or more) of the triggers is handled
  11169. */
  11170. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11171. /**
  11172. * Does this action manager handles actions of a given trigger
  11173. * @param trigger defines the trigger to be tested
  11174. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11175. * @return whether the trigger is handled
  11176. */
  11177. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11178. /**
  11179. * Does this action manager has pointer triggers
  11180. */
  11181. readonly hasPointerTriggers: boolean;
  11182. /**
  11183. * Does this action manager has pick triggers
  11184. */
  11185. readonly hasPickTriggers: boolean;
  11186. /**
  11187. * Registers an action to this action manager
  11188. * @param action defines the action to be registered
  11189. * @return the action amended (prepared) after registration
  11190. */
  11191. registerAction(action: IAction): Nullable<IAction>;
  11192. /**
  11193. * Unregisters an action to this action manager
  11194. * @param action defines the action to be unregistered
  11195. * @return a boolean indicating whether the action has been unregistered
  11196. */
  11197. unregisterAction(action: IAction): Boolean;
  11198. /**
  11199. * Process a specific trigger
  11200. * @param trigger defines the trigger to process
  11201. * @param evt defines the event details to be processed
  11202. */
  11203. processTrigger(trigger: number, evt?: IActionEvent): void;
  11204. /** @hidden */
  11205. _getEffectiveTarget(target: any, propertyPath: string): any;
  11206. /** @hidden */
  11207. _getProperty(propertyPath: string): string;
  11208. /**
  11209. * Serialize this manager to a JSON object
  11210. * @param name defines the property name to store this manager
  11211. * @returns a JSON representation of this manager
  11212. */
  11213. serialize(name: string): any;
  11214. /**
  11215. * Creates a new ActionManager from a JSON data
  11216. * @param parsedActions defines the JSON data to read from
  11217. * @param object defines the hosting mesh
  11218. * @param scene defines the hosting scene
  11219. */
  11220. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11221. /**
  11222. * Get a trigger name by index
  11223. * @param trigger defines the trigger index
  11224. * @returns a trigger name
  11225. */
  11226. static GetTriggerName(trigger: number): string;
  11227. }
  11228. }
  11229. declare module "babylonjs/Culling/ray" {
  11230. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11231. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11232. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11233. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11234. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11235. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11236. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11237. import { Plane } from "babylonjs/Maths/math.plane";
  11238. /**
  11239. * Class representing a ray with position and direction
  11240. */
  11241. export class Ray {
  11242. /** origin point */
  11243. origin: Vector3;
  11244. /** direction */
  11245. direction: Vector3;
  11246. /** length of the ray */
  11247. length: number;
  11248. private static readonly TmpVector3;
  11249. private _tmpRay;
  11250. /**
  11251. * Creates a new ray
  11252. * @param origin origin point
  11253. * @param direction direction
  11254. * @param length length of the ray
  11255. */
  11256. constructor(
  11257. /** origin point */
  11258. origin: Vector3,
  11259. /** direction */
  11260. direction: Vector3,
  11261. /** length of the ray */
  11262. length?: number);
  11263. /**
  11264. * Checks if the ray intersects a box
  11265. * @param minimum bound of the box
  11266. * @param maximum bound of the box
  11267. * @param intersectionTreshold extra extend to be added to the box in all direction
  11268. * @returns if the box was hit
  11269. */
  11270. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11271. /**
  11272. * Checks if the ray intersects a box
  11273. * @param box the bounding box to check
  11274. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11275. * @returns if the box was hit
  11276. */
  11277. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11278. /**
  11279. * If the ray hits a sphere
  11280. * @param sphere the bounding sphere to check
  11281. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11282. * @returns true if it hits the sphere
  11283. */
  11284. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11285. /**
  11286. * If the ray hits a triange
  11287. * @param vertex0 triangle vertex
  11288. * @param vertex1 triangle vertex
  11289. * @param vertex2 triangle vertex
  11290. * @returns intersection information if hit
  11291. */
  11292. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11293. /**
  11294. * Checks if ray intersects a plane
  11295. * @param plane the plane to check
  11296. * @returns the distance away it was hit
  11297. */
  11298. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11299. /**
  11300. * Calculate the intercept of a ray on a given axis
  11301. * @param axis to check 'x' | 'y' | 'z'
  11302. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11303. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11304. */
  11305. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11306. /**
  11307. * Checks if ray intersects a mesh
  11308. * @param mesh the mesh to check
  11309. * @param fastCheck if only the bounding box should checked
  11310. * @returns picking info of the intersecton
  11311. */
  11312. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11313. /**
  11314. * Checks if ray intersects a mesh
  11315. * @param meshes the meshes to check
  11316. * @param fastCheck if only the bounding box should checked
  11317. * @param results array to store result in
  11318. * @returns Array of picking infos
  11319. */
  11320. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11321. private _comparePickingInfo;
  11322. private static smallnum;
  11323. private static rayl;
  11324. /**
  11325. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11326. * @param sega the first point of the segment to test the intersection against
  11327. * @param segb the second point of the segment to test the intersection against
  11328. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11329. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11330. */
  11331. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11332. /**
  11333. * Update the ray from viewport position
  11334. * @param x position
  11335. * @param y y position
  11336. * @param viewportWidth viewport width
  11337. * @param viewportHeight viewport height
  11338. * @param world world matrix
  11339. * @param view view matrix
  11340. * @param projection projection matrix
  11341. * @returns this ray updated
  11342. */
  11343. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11344. /**
  11345. * Creates a ray with origin and direction of 0,0,0
  11346. * @returns the new ray
  11347. */
  11348. static Zero(): Ray;
  11349. /**
  11350. * Creates a new ray from screen space and viewport
  11351. * @param x position
  11352. * @param y y position
  11353. * @param viewportWidth viewport width
  11354. * @param viewportHeight viewport height
  11355. * @param world world matrix
  11356. * @param view view matrix
  11357. * @param projection projection matrix
  11358. * @returns new ray
  11359. */
  11360. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11361. /**
  11362. * 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
  11363. * transformed to the given world matrix.
  11364. * @param origin The origin point
  11365. * @param end The end point
  11366. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11367. * @returns the new ray
  11368. */
  11369. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11370. /**
  11371. * Transforms a ray by a matrix
  11372. * @param ray ray to transform
  11373. * @param matrix matrix to apply
  11374. * @returns the resulting new ray
  11375. */
  11376. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11377. /**
  11378. * Transforms a ray by a matrix
  11379. * @param ray ray to transform
  11380. * @param matrix matrix to apply
  11381. * @param result ray to store result in
  11382. */
  11383. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11384. /**
  11385. * Unproject a ray from screen space to object space
  11386. * @param sourceX defines the screen space x coordinate to use
  11387. * @param sourceY defines the screen space y coordinate to use
  11388. * @param viewportWidth defines the current width of the viewport
  11389. * @param viewportHeight defines the current height of the viewport
  11390. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11391. * @param view defines the view matrix to use
  11392. * @param projection defines the projection matrix to use
  11393. */
  11394. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11395. }
  11396. /**
  11397. * Type used to define predicate used to select faces when a mesh intersection is detected
  11398. */
  11399. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11400. module "babylonjs/scene" {
  11401. interface Scene {
  11402. /** @hidden */
  11403. _tempPickingRay: Nullable<Ray>;
  11404. /** @hidden */
  11405. _cachedRayForTransform: Ray;
  11406. /** @hidden */
  11407. _pickWithRayInverseMatrix: Matrix;
  11408. /** @hidden */
  11409. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11410. /** @hidden */
  11411. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11412. }
  11413. }
  11414. }
  11415. declare module "babylonjs/sceneComponent" {
  11416. import { Scene } from "babylonjs/scene";
  11417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11418. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11419. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11420. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11421. import { Nullable } from "babylonjs/types";
  11422. import { Camera } from "babylonjs/Cameras/camera";
  11423. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11424. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11425. import { AbstractScene } from "babylonjs/abstractScene";
  11426. import { Mesh } from "babylonjs/Meshes/mesh";
  11427. /**
  11428. * Groups all the scene component constants in one place to ease maintenance.
  11429. * @hidden
  11430. */
  11431. export class SceneComponentConstants {
  11432. static readonly NAME_EFFECTLAYER: string;
  11433. static readonly NAME_LAYER: string;
  11434. static readonly NAME_LENSFLARESYSTEM: string;
  11435. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11436. static readonly NAME_PARTICLESYSTEM: string;
  11437. static readonly NAME_GAMEPAD: string;
  11438. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11439. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11440. static readonly NAME_DEPTHRENDERER: string;
  11441. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11442. static readonly NAME_SPRITE: string;
  11443. static readonly NAME_OUTLINERENDERER: string;
  11444. static readonly NAME_PROCEDURALTEXTURE: string;
  11445. static readonly NAME_SHADOWGENERATOR: string;
  11446. static readonly NAME_OCTREE: string;
  11447. static readonly NAME_PHYSICSENGINE: string;
  11448. static readonly NAME_AUDIO: string;
  11449. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11450. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11451. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11452. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11453. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11454. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11455. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11456. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11457. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11458. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11459. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11460. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11461. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11462. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11463. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11464. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11465. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11466. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11467. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11468. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11469. static readonly STEP_AFTERRENDER_AUDIO: number;
  11470. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11471. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11472. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11473. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11474. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11475. static readonly STEP_POINTERMOVE_SPRITE: number;
  11476. static readonly STEP_POINTERDOWN_SPRITE: number;
  11477. static readonly STEP_POINTERUP_SPRITE: number;
  11478. }
  11479. /**
  11480. * This represents a scene component.
  11481. *
  11482. * This is used to decouple the dependency the scene is having on the different workloads like
  11483. * layers, post processes...
  11484. */
  11485. export interface ISceneComponent {
  11486. /**
  11487. * The name of the component. Each component must have a unique name.
  11488. */
  11489. name: string;
  11490. /**
  11491. * The scene the component belongs to.
  11492. */
  11493. scene: Scene;
  11494. /**
  11495. * Register the component to one instance of a scene.
  11496. */
  11497. register(): void;
  11498. /**
  11499. * Rebuilds the elements related to this component in case of
  11500. * context lost for instance.
  11501. */
  11502. rebuild(): void;
  11503. /**
  11504. * Disposes the component and the associated ressources.
  11505. */
  11506. dispose(): void;
  11507. }
  11508. /**
  11509. * This represents a SERIALIZABLE scene component.
  11510. *
  11511. * This extends Scene Component to add Serialization methods on top.
  11512. */
  11513. export interface ISceneSerializableComponent extends ISceneComponent {
  11514. /**
  11515. * Adds all the elements from the container to the scene
  11516. * @param container the container holding the elements
  11517. */
  11518. addFromContainer(container: AbstractScene): void;
  11519. /**
  11520. * Removes all the elements in the container from the scene
  11521. * @param container contains the elements to remove
  11522. * @param dispose if the removed element should be disposed (default: false)
  11523. */
  11524. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11525. /**
  11526. * Serializes the component data to the specified json object
  11527. * @param serializationObject The object to serialize to
  11528. */
  11529. serialize(serializationObject: any): void;
  11530. }
  11531. /**
  11532. * Strong typing of a Mesh related stage step action
  11533. */
  11534. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11535. /**
  11536. * Strong typing of a Evaluate Sub Mesh related stage step action
  11537. */
  11538. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11539. /**
  11540. * Strong typing of a Active Mesh related stage step action
  11541. */
  11542. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11543. /**
  11544. * Strong typing of a Camera related stage step action
  11545. */
  11546. export type CameraStageAction = (camera: Camera) => void;
  11547. /**
  11548. * Strong typing of a Camera Frame buffer related stage step action
  11549. */
  11550. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11551. /**
  11552. * Strong typing of a Render Target related stage step action
  11553. */
  11554. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11555. /**
  11556. * Strong typing of a RenderingGroup related stage step action
  11557. */
  11558. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11559. /**
  11560. * Strong typing of a Mesh Render related stage step action
  11561. */
  11562. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11563. /**
  11564. * Strong typing of a simple stage step action
  11565. */
  11566. export type SimpleStageAction = () => void;
  11567. /**
  11568. * Strong typing of a render target action.
  11569. */
  11570. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11571. /**
  11572. * Strong typing of a pointer move action.
  11573. */
  11574. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11575. /**
  11576. * Strong typing of a pointer up/down action.
  11577. */
  11578. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11579. /**
  11580. * Representation of a stage in the scene (Basically a list of ordered steps)
  11581. * @hidden
  11582. */
  11583. export class Stage<T extends Function> extends Array<{
  11584. index: number;
  11585. component: ISceneComponent;
  11586. action: T;
  11587. }> {
  11588. /**
  11589. * Hide ctor from the rest of the world.
  11590. * @param items The items to add.
  11591. */
  11592. private constructor();
  11593. /**
  11594. * Creates a new Stage.
  11595. * @returns A new instance of a Stage
  11596. */
  11597. static Create<T extends Function>(): Stage<T>;
  11598. /**
  11599. * Registers a step in an ordered way in the targeted stage.
  11600. * @param index Defines the position to register the step in
  11601. * @param component Defines the component attached to the step
  11602. * @param action Defines the action to launch during the step
  11603. */
  11604. registerStep(index: number, component: ISceneComponent, action: T): void;
  11605. /**
  11606. * Clears all the steps from the stage.
  11607. */
  11608. clear(): void;
  11609. }
  11610. }
  11611. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11612. import { Nullable } from "babylonjs/types";
  11613. import { Observable } from "babylonjs/Misc/observable";
  11614. import { Scene } from "babylonjs/scene";
  11615. import { Sprite } from "babylonjs/Sprites/sprite";
  11616. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11617. import { Ray } from "babylonjs/Culling/ray";
  11618. import { Camera } from "babylonjs/Cameras/camera";
  11619. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11620. import { ISceneComponent } from "babylonjs/sceneComponent";
  11621. module "babylonjs/scene" {
  11622. interface Scene {
  11623. /** @hidden */
  11624. _pointerOverSprite: Nullable<Sprite>;
  11625. /** @hidden */
  11626. _pickedDownSprite: Nullable<Sprite>;
  11627. /** @hidden */
  11628. _tempSpritePickingRay: Nullable<Ray>;
  11629. /**
  11630. * All of the sprite managers added to this scene
  11631. * @see http://doc.babylonjs.com/babylon101/sprites
  11632. */
  11633. spriteManagers: Array<ISpriteManager>;
  11634. /**
  11635. * An event triggered when sprites rendering is about to start
  11636. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11637. */
  11638. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11639. /**
  11640. * An event triggered when sprites rendering is done
  11641. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11642. */
  11643. onAfterSpritesRenderingObservable: Observable<Scene>;
  11644. /** @hidden */
  11645. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11646. /** Launch a ray to try to pick a sprite in the scene
  11647. * @param x position on screen
  11648. * @param y position on screen
  11649. * @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
  11650. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11651. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11652. * @returns a PickingInfo
  11653. */
  11654. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11655. /** Use the given ray to pick a sprite in the scene
  11656. * @param ray The ray (in world space) to use to pick meshes
  11657. * @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
  11658. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11659. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11660. * @returns a PickingInfo
  11661. */
  11662. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11663. /** @hidden */
  11664. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11665. /** Launch a ray to try to pick sprites in the scene
  11666. * @param x position on screen
  11667. * @param y position on screen
  11668. * @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
  11669. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11670. * @returns a PickingInfo array
  11671. */
  11672. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11673. /** Use the given ray to pick sprites in the scene
  11674. * @param ray The ray (in world space) to use to pick meshes
  11675. * @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
  11676. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11677. * @returns a PickingInfo array
  11678. */
  11679. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11680. /**
  11681. * Force the sprite under the pointer
  11682. * @param sprite defines the sprite to use
  11683. */
  11684. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11685. /**
  11686. * Gets the sprite under the pointer
  11687. * @returns a Sprite or null if no sprite is under the pointer
  11688. */
  11689. getPointerOverSprite(): Nullable<Sprite>;
  11690. }
  11691. }
  11692. /**
  11693. * Defines the sprite scene component responsible to manage sprites
  11694. * in a given scene.
  11695. */
  11696. export class SpriteSceneComponent implements ISceneComponent {
  11697. /**
  11698. * The component name helpfull to identify the component in the list of scene components.
  11699. */
  11700. readonly name: string;
  11701. /**
  11702. * The scene the component belongs to.
  11703. */
  11704. scene: Scene;
  11705. /** @hidden */
  11706. private _spritePredicate;
  11707. /**
  11708. * Creates a new instance of the component for the given scene
  11709. * @param scene Defines the scene to register the component in
  11710. */
  11711. constructor(scene: Scene);
  11712. /**
  11713. * Registers the component in a given scene
  11714. */
  11715. register(): void;
  11716. /**
  11717. * Rebuilds the elements related to this component in case of
  11718. * context lost for instance.
  11719. */
  11720. rebuild(): void;
  11721. /**
  11722. * Disposes the component and the associated ressources.
  11723. */
  11724. dispose(): void;
  11725. private _pickSpriteButKeepRay;
  11726. private _pointerMove;
  11727. private _pointerDown;
  11728. private _pointerUp;
  11729. }
  11730. }
  11731. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11732. /** @hidden */
  11733. export var fogFragmentDeclaration: {
  11734. name: string;
  11735. shader: string;
  11736. };
  11737. }
  11738. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11739. /** @hidden */
  11740. export var fogFragment: {
  11741. name: string;
  11742. shader: string;
  11743. };
  11744. }
  11745. declare module "babylonjs/Shaders/sprites.fragment" {
  11746. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11747. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11748. /** @hidden */
  11749. export var spritesPixelShader: {
  11750. name: string;
  11751. shader: string;
  11752. };
  11753. }
  11754. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11755. /** @hidden */
  11756. export var fogVertexDeclaration: {
  11757. name: string;
  11758. shader: string;
  11759. };
  11760. }
  11761. declare module "babylonjs/Shaders/sprites.vertex" {
  11762. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11763. /** @hidden */
  11764. export var spritesVertexShader: {
  11765. name: string;
  11766. shader: string;
  11767. };
  11768. }
  11769. declare module "babylonjs/Sprites/spriteManager" {
  11770. import { IDisposable, Scene } from "babylonjs/scene";
  11771. import { Nullable } from "babylonjs/types";
  11772. import { Observable } from "babylonjs/Misc/observable";
  11773. import { Sprite } from "babylonjs/Sprites/sprite";
  11774. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11775. import { Camera } from "babylonjs/Cameras/camera";
  11776. import { Texture } from "babylonjs/Materials/Textures/texture";
  11777. import "babylonjs/Shaders/sprites.fragment";
  11778. import "babylonjs/Shaders/sprites.vertex";
  11779. import { Ray } from "babylonjs/Culling/ray";
  11780. /**
  11781. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11782. */
  11783. export interface ISpriteManager extends IDisposable {
  11784. /**
  11785. * Restricts the camera to viewing objects with the same layerMask.
  11786. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11787. */
  11788. layerMask: number;
  11789. /**
  11790. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11791. */
  11792. isPickable: boolean;
  11793. /**
  11794. * Specifies the rendering group id for this mesh (0 by default)
  11795. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11796. */
  11797. renderingGroupId: number;
  11798. /**
  11799. * Defines the list of sprites managed by the manager.
  11800. */
  11801. sprites: Array<Sprite>;
  11802. /**
  11803. * Tests the intersection of a sprite with a specific ray.
  11804. * @param ray The ray we are sending to test the collision
  11805. * @param camera The camera space we are sending rays in
  11806. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11807. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11808. * @returns picking info or null.
  11809. */
  11810. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11811. /**
  11812. * Intersects the sprites with a ray
  11813. * @param ray defines the ray to intersect with
  11814. * @param camera defines the current active camera
  11815. * @param predicate defines a predicate used to select candidate sprites
  11816. * @returns null if no hit or a PickingInfo array
  11817. */
  11818. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11819. /**
  11820. * Renders the list of sprites on screen.
  11821. */
  11822. render(): void;
  11823. }
  11824. /**
  11825. * Class used to manage multiple sprites on the same spritesheet
  11826. * @see http://doc.babylonjs.com/babylon101/sprites
  11827. */
  11828. export class SpriteManager implements ISpriteManager {
  11829. /** defines the manager's name */
  11830. name: string;
  11831. /** Gets the list of sprites */
  11832. sprites: Sprite[];
  11833. /** Gets or sets the rendering group id (0 by default) */
  11834. renderingGroupId: number;
  11835. /** Gets or sets camera layer mask */
  11836. layerMask: number;
  11837. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11838. fogEnabled: boolean;
  11839. /** Gets or sets a boolean indicating if the sprites are pickable */
  11840. isPickable: boolean;
  11841. /** Defines the default width of a cell in the spritesheet */
  11842. cellWidth: number;
  11843. /** Defines the default height of a cell in the spritesheet */
  11844. cellHeight: number;
  11845. /** Associative array from JSON sprite data file */
  11846. private _cellData;
  11847. /** Array of sprite names from JSON sprite data file */
  11848. private _spriteMap;
  11849. /** True when packed cell data from JSON file is ready*/
  11850. private _packedAndReady;
  11851. /**
  11852. * An event triggered when the manager is disposed.
  11853. */
  11854. onDisposeObservable: Observable<SpriteManager>;
  11855. private _onDisposeObserver;
  11856. /**
  11857. * Callback called when the manager is disposed
  11858. */
  11859. onDispose: () => void;
  11860. private _capacity;
  11861. private _fromPacked;
  11862. private _spriteTexture;
  11863. private _epsilon;
  11864. private _scene;
  11865. private _vertexData;
  11866. private _buffer;
  11867. private _vertexBuffers;
  11868. private _indexBuffer;
  11869. private _effectBase;
  11870. private _effectFog;
  11871. /**
  11872. * Gets or sets the spritesheet texture
  11873. */
  11874. texture: Texture;
  11875. /**
  11876. * Creates a new sprite manager
  11877. * @param name defines the manager's name
  11878. * @param imgUrl defines the sprite sheet url
  11879. * @param capacity defines the maximum allowed number of sprites
  11880. * @param cellSize defines the size of a sprite cell
  11881. * @param scene defines the hosting scene
  11882. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11883. * @param samplingMode defines the smapling mode to use with spritesheet
  11884. * @param fromPacked set to false; do not alter
  11885. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11886. */
  11887. constructor(
  11888. /** defines the manager's name */
  11889. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11890. private _makePacked;
  11891. private _appendSpriteVertex;
  11892. /**
  11893. * Intersects the sprites with a ray
  11894. * @param ray defines the ray to intersect with
  11895. * @param camera defines the current active camera
  11896. * @param predicate defines a predicate used to select candidate sprites
  11897. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11898. * @returns null if no hit or a PickingInfo
  11899. */
  11900. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11901. /**
  11902. * Intersects the sprites with a ray
  11903. * @param ray defines the ray to intersect with
  11904. * @param camera defines the current active camera
  11905. * @param predicate defines a predicate used to select candidate sprites
  11906. * @returns null if no hit or a PickingInfo array
  11907. */
  11908. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11909. /**
  11910. * Render all child sprites
  11911. */
  11912. render(): void;
  11913. /**
  11914. * Release associated resources
  11915. */
  11916. dispose(): void;
  11917. }
  11918. }
  11919. declare module "babylonjs/Sprites/sprite" {
  11920. import { Vector3 } from "babylonjs/Maths/math.vector";
  11921. import { Nullable } from "babylonjs/types";
  11922. import { ActionManager } from "babylonjs/Actions/actionManager";
  11923. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11924. import { Color4 } from "babylonjs/Maths/math.color";
  11925. /**
  11926. * Class used to represent a sprite
  11927. * @see http://doc.babylonjs.com/babylon101/sprites
  11928. */
  11929. export class Sprite {
  11930. /** defines the name */
  11931. name: string;
  11932. /** Gets or sets the current world position */
  11933. position: Vector3;
  11934. /** Gets or sets the main color */
  11935. color: Color4;
  11936. /** Gets or sets the width */
  11937. width: number;
  11938. /** Gets or sets the height */
  11939. height: number;
  11940. /** Gets or sets rotation angle */
  11941. angle: number;
  11942. /** Gets or sets the cell index in the sprite sheet */
  11943. cellIndex: number;
  11944. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11945. cellRef: string;
  11946. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11947. invertU: number;
  11948. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11949. invertV: number;
  11950. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11951. disposeWhenFinishedAnimating: boolean;
  11952. /** Gets the list of attached animations */
  11953. animations: Animation[];
  11954. /** Gets or sets a boolean indicating if the sprite can be picked */
  11955. isPickable: boolean;
  11956. /**
  11957. * Gets or sets the associated action manager
  11958. */
  11959. actionManager: Nullable<ActionManager>;
  11960. private _animationStarted;
  11961. private _loopAnimation;
  11962. private _fromIndex;
  11963. private _toIndex;
  11964. private _delay;
  11965. private _direction;
  11966. private _manager;
  11967. private _time;
  11968. private _onAnimationEnd;
  11969. /**
  11970. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11971. */
  11972. isVisible: boolean;
  11973. /**
  11974. * Gets or sets the sprite size
  11975. */
  11976. size: number;
  11977. /**
  11978. * Creates a new Sprite
  11979. * @param name defines the name
  11980. * @param manager defines the manager
  11981. */
  11982. constructor(
  11983. /** defines the name */
  11984. name: string, manager: ISpriteManager);
  11985. /**
  11986. * Starts an animation
  11987. * @param from defines the initial key
  11988. * @param to defines the end key
  11989. * @param loop defines if the animation must loop
  11990. * @param delay defines the start delay (in ms)
  11991. * @param onAnimationEnd defines a callback to call when animation ends
  11992. */
  11993. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11994. /** Stops current animation (if any) */
  11995. stopAnimation(): void;
  11996. /** @hidden */
  11997. _animate(deltaTime: number): void;
  11998. /** Release associated resources */
  11999. dispose(): void;
  12000. }
  12001. }
  12002. declare module "babylonjs/Collisions/pickingInfo" {
  12003. import { Nullable } from "babylonjs/types";
  12004. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12006. import { Sprite } from "babylonjs/Sprites/sprite";
  12007. import { Ray } from "babylonjs/Culling/ray";
  12008. /**
  12009. * Information about the result of picking within a scene
  12010. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12011. */
  12012. export class PickingInfo {
  12013. /** @hidden */
  12014. _pickingUnavailable: boolean;
  12015. /**
  12016. * If the pick collided with an object
  12017. */
  12018. hit: boolean;
  12019. /**
  12020. * Distance away where the pick collided
  12021. */
  12022. distance: number;
  12023. /**
  12024. * The location of pick collision
  12025. */
  12026. pickedPoint: Nullable<Vector3>;
  12027. /**
  12028. * The mesh corresponding the the pick collision
  12029. */
  12030. pickedMesh: Nullable<AbstractMesh>;
  12031. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12032. bu: number;
  12033. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12034. bv: number;
  12035. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12036. faceId: number;
  12037. /** Id of the the submesh that was picked */
  12038. subMeshId: number;
  12039. /** If a sprite was picked, this will be the sprite the pick collided with */
  12040. pickedSprite: Nullable<Sprite>;
  12041. /**
  12042. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12043. */
  12044. originMesh: Nullable<AbstractMesh>;
  12045. /**
  12046. * The ray that was used to perform the picking.
  12047. */
  12048. ray: Nullable<Ray>;
  12049. /**
  12050. * Gets the normal correspodning to the face the pick collided with
  12051. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12052. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12053. * @returns The normal correspodning to the face the pick collided with
  12054. */
  12055. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12056. /**
  12057. * Gets the texture coordinates of where the pick occured
  12058. * @returns the vector containing the coordnates of the texture
  12059. */
  12060. getTextureCoordinates(): Nullable<Vector2>;
  12061. }
  12062. }
  12063. declare module "babylonjs/Events/pointerEvents" {
  12064. import { Nullable } from "babylonjs/types";
  12065. import { Vector2 } from "babylonjs/Maths/math.vector";
  12066. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12067. import { Ray } from "babylonjs/Culling/ray";
  12068. /**
  12069. * Gather the list of pointer event types as constants.
  12070. */
  12071. export class PointerEventTypes {
  12072. /**
  12073. * 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.
  12074. */
  12075. static readonly POINTERDOWN: number;
  12076. /**
  12077. * The pointerup event is fired when a pointer is no longer active.
  12078. */
  12079. static readonly POINTERUP: number;
  12080. /**
  12081. * The pointermove event is fired when a pointer changes coordinates.
  12082. */
  12083. static readonly POINTERMOVE: number;
  12084. /**
  12085. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12086. */
  12087. static readonly POINTERWHEEL: number;
  12088. /**
  12089. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12090. */
  12091. static readonly POINTERPICK: number;
  12092. /**
  12093. * The pointertap event is fired when a the object has been touched and released without drag.
  12094. */
  12095. static readonly POINTERTAP: number;
  12096. /**
  12097. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12098. */
  12099. static readonly POINTERDOUBLETAP: number;
  12100. }
  12101. /**
  12102. * Base class of pointer info types.
  12103. */
  12104. export class PointerInfoBase {
  12105. /**
  12106. * Defines the type of event (PointerEventTypes)
  12107. */
  12108. type: number;
  12109. /**
  12110. * Defines the related dom event
  12111. */
  12112. event: PointerEvent | MouseWheelEvent;
  12113. /**
  12114. * Instantiates the base class of pointers info.
  12115. * @param type Defines the type of event (PointerEventTypes)
  12116. * @param event Defines the related dom event
  12117. */
  12118. constructor(
  12119. /**
  12120. * Defines the type of event (PointerEventTypes)
  12121. */
  12122. type: number,
  12123. /**
  12124. * Defines the related dom event
  12125. */
  12126. event: PointerEvent | MouseWheelEvent);
  12127. }
  12128. /**
  12129. * This class is used to store pointer related info for the onPrePointerObservable event.
  12130. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12131. */
  12132. export class PointerInfoPre extends PointerInfoBase {
  12133. /**
  12134. * Ray from a pointer if availible (eg. 6dof controller)
  12135. */
  12136. ray: Nullable<Ray>;
  12137. /**
  12138. * Defines the local position of the pointer on the canvas.
  12139. */
  12140. localPosition: Vector2;
  12141. /**
  12142. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12143. */
  12144. skipOnPointerObservable: boolean;
  12145. /**
  12146. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12147. * @param type Defines the type of event (PointerEventTypes)
  12148. * @param event Defines the related dom event
  12149. * @param localX Defines the local x coordinates of the pointer when the event occured
  12150. * @param localY Defines the local y coordinates of the pointer when the event occured
  12151. */
  12152. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12153. }
  12154. /**
  12155. * This type contains all the data related to a pointer event in Babylon.js.
  12156. * 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.
  12157. */
  12158. export class PointerInfo extends PointerInfoBase {
  12159. /**
  12160. * Defines the picking info associated to the info (if any)\
  12161. */
  12162. pickInfo: Nullable<PickingInfo>;
  12163. /**
  12164. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12165. * @param type Defines the type of event (PointerEventTypes)
  12166. * @param event Defines the related dom event
  12167. * @param pickInfo Defines the picking info associated to the info (if any)\
  12168. */
  12169. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12170. /**
  12171. * Defines the picking info associated to the info (if any)\
  12172. */
  12173. pickInfo: Nullable<PickingInfo>);
  12174. }
  12175. /**
  12176. * Data relating to a touch event on the screen.
  12177. */
  12178. export interface PointerTouch {
  12179. /**
  12180. * X coordinate of touch.
  12181. */
  12182. x: number;
  12183. /**
  12184. * Y coordinate of touch.
  12185. */
  12186. y: number;
  12187. /**
  12188. * Id of touch. Unique for each finger.
  12189. */
  12190. pointerId: number;
  12191. /**
  12192. * Event type passed from DOM.
  12193. */
  12194. type: any;
  12195. }
  12196. }
  12197. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12198. import { Observable } from "babylonjs/Misc/observable";
  12199. import { Nullable } from "babylonjs/types";
  12200. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12201. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12202. /**
  12203. * Manage the mouse inputs to control the movement of a free camera.
  12204. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12205. */
  12206. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12207. /**
  12208. * Define if touch is enabled in the mouse input
  12209. */
  12210. touchEnabled: boolean;
  12211. /**
  12212. * Defines the camera the input is attached to.
  12213. */
  12214. camera: FreeCamera;
  12215. /**
  12216. * Defines the buttons associated with the input to handle camera move.
  12217. */
  12218. buttons: number[];
  12219. /**
  12220. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12221. */
  12222. angularSensibility: number;
  12223. private _pointerInput;
  12224. private _onMouseMove;
  12225. private _observer;
  12226. private previousPosition;
  12227. /**
  12228. * Observable for when a pointer move event occurs containing the move offset
  12229. */
  12230. onPointerMovedObservable: Observable<{
  12231. offsetX: number;
  12232. offsetY: number;
  12233. }>;
  12234. /**
  12235. * @hidden
  12236. * If the camera should be rotated automatically based on pointer movement
  12237. */
  12238. _allowCameraRotation: boolean;
  12239. /**
  12240. * Manage the mouse inputs to control the movement of a free camera.
  12241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12242. * @param touchEnabled Defines if touch is enabled or not
  12243. */
  12244. constructor(
  12245. /**
  12246. * Define if touch is enabled in the mouse input
  12247. */
  12248. touchEnabled?: boolean);
  12249. /**
  12250. * Attach the input controls to a specific dom element to get the input from.
  12251. * @param element Defines the element the controls should be listened from
  12252. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12253. */
  12254. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12255. /**
  12256. * Called on JS contextmenu event.
  12257. * Override this method to provide functionality.
  12258. */
  12259. protected onContextMenu(evt: PointerEvent): void;
  12260. /**
  12261. * Detach the current controls from the specified dom element.
  12262. * @param element Defines the element to stop listening the inputs from
  12263. */
  12264. detachControl(element: Nullable<HTMLElement>): void;
  12265. /**
  12266. * Gets the class name of the current intput.
  12267. * @returns the class name
  12268. */
  12269. getClassName(): string;
  12270. /**
  12271. * Get the friendly name associated with the input class.
  12272. * @returns the input friendly name
  12273. */
  12274. getSimpleName(): string;
  12275. }
  12276. }
  12277. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12278. import { Nullable } from "babylonjs/types";
  12279. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12280. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12281. /**
  12282. * Manage the touch inputs to control the movement of a free camera.
  12283. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12284. */
  12285. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12286. /**
  12287. * Defines the camera the input is attached to.
  12288. */
  12289. camera: FreeCamera;
  12290. /**
  12291. * Defines the touch sensibility for rotation.
  12292. * The higher the faster.
  12293. */
  12294. touchAngularSensibility: number;
  12295. /**
  12296. * Defines the touch sensibility for move.
  12297. * The higher the faster.
  12298. */
  12299. touchMoveSensibility: number;
  12300. private _offsetX;
  12301. private _offsetY;
  12302. private _pointerPressed;
  12303. private _pointerInput;
  12304. private _observer;
  12305. private _onLostFocus;
  12306. /**
  12307. * Attach the input controls to a specific dom element to get the input from.
  12308. * @param element Defines the element the controls should be listened from
  12309. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12310. */
  12311. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12312. /**
  12313. * Detach the current controls from the specified dom element.
  12314. * @param element Defines the element to stop listening the inputs from
  12315. */
  12316. detachControl(element: Nullable<HTMLElement>): void;
  12317. /**
  12318. * Update the current camera state depending on the inputs that have been used this frame.
  12319. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12320. */
  12321. checkInputs(): void;
  12322. /**
  12323. * Gets the class name of the current intput.
  12324. * @returns the class name
  12325. */
  12326. getClassName(): string;
  12327. /**
  12328. * Get the friendly name associated with the input class.
  12329. * @returns the input friendly name
  12330. */
  12331. getSimpleName(): string;
  12332. }
  12333. }
  12334. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12335. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12336. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12337. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12338. import { Nullable } from "babylonjs/types";
  12339. /**
  12340. * Default Inputs manager for the FreeCamera.
  12341. * It groups all the default supported inputs for ease of use.
  12342. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12343. */
  12344. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12345. /**
  12346. * @hidden
  12347. */
  12348. _mouseInput: Nullable<FreeCameraMouseInput>;
  12349. /**
  12350. * Instantiates a new FreeCameraInputsManager.
  12351. * @param camera Defines the camera the inputs belong to
  12352. */
  12353. constructor(camera: FreeCamera);
  12354. /**
  12355. * Add keyboard input support to the input manager.
  12356. * @returns the current input manager
  12357. */
  12358. addKeyboard(): FreeCameraInputsManager;
  12359. /**
  12360. * Add mouse input support to the input manager.
  12361. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12362. * @returns the current input manager
  12363. */
  12364. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12365. /**
  12366. * Removes the mouse input support from the manager
  12367. * @returns the current input manager
  12368. */
  12369. removeMouse(): FreeCameraInputsManager;
  12370. /**
  12371. * Add touch input support to the input manager.
  12372. * @returns the current input manager
  12373. */
  12374. addTouch(): FreeCameraInputsManager;
  12375. /**
  12376. * Remove all attached input methods from a camera
  12377. */
  12378. clear(): void;
  12379. }
  12380. }
  12381. declare module "babylonjs/Cameras/freeCamera" {
  12382. import { Vector3 } from "babylonjs/Maths/math.vector";
  12383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12384. import { Scene } from "babylonjs/scene";
  12385. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12386. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12387. /**
  12388. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12389. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12390. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12391. */
  12392. export class FreeCamera extends TargetCamera {
  12393. /**
  12394. * Define the collision ellipsoid of the camera.
  12395. * This is helpful to simulate a camera body like the player body around the camera
  12396. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12397. */
  12398. ellipsoid: Vector3;
  12399. /**
  12400. * Define an offset for the position of the ellipsoid around the camera.
  12401. * This can be helpful to determine the center of the body near the gravity center of the body
  12402. * instead of its head.
  12403. */
  12404. ellipsoidOffset: Vector3;
  12405. /**
  12406. * Enable or disable collisions of the camera with the rest of the scene objects.
  12407. */
  12408. checkCollisions: boolean;
  12409. /**
  12410. * Enable or disable gravity on the camera.
  12411. */
  12412. applyGravity: boolean;
  12413. /**
  12414. * Define the input manager associated to the camera.
  12415. */
  12416. inputs: FreeCameraInputsManager;
  12417. /**
  12418. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12419. * Higher values reduce sensitivity.
  12420. */
  12421. /**
  12422. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12423. * Higher values reduce sensitivity.
  12424. */
  12425. angularSensibility: number;
  12426. /**
  12427. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12428. */
  12429. keysUp: number[];
  12430. /**
  12431. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12432. */
  12433. keysDown: number[];
  12434. /**
  12435. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12436. */
  12437. keysLeft: number[];
  12438. /**
  12439. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12440. */
  12441. keysRight: number[];
  12442. /**
  12443. * Event raised when the camera collide with a mesh in the scene.
  12444. */
  12445. onCollide: (collidedMesh: AbstractMesh) => void;
  12446. private _collider;
  12447. private _needMoveForGravity;
  12448. private _oldPosition;
  12449. private _diffPosition;
  12450. private _newPosition;
  12451. /** @hidden */
  12452. _localDirection: Vector3;
  12453. /** @hidden */
  12454. _transformedDirection: Vector3;
  12455. /**
  12456. * Instantiates a Free Camera.
  12457. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12458. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12459. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12460. * @param name Define the name of the camera in the scene
  12461. * @param position Define the start position of the camera in the scene
  12462. * @param scene Define the scene the camera belongs to
  12463. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12464. */
  12465. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12466. /**
  12467. * Attached controls to the current camera.
  12468. * @param element Defines the element the controls should be listened from
  12469. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12470. */
  12471. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12472. /**
  12473. * Detach the current controls from the camera.
  12474. * The camera will stop reacting to inputs.
  12475. * @param element Defines the element to stop listening the inputs from
  12476. */
  12477. detachControl(element: HTMLElement): void;
  12478. private _collisionMask;
  12479. /**
  12480. * Define a collision mask to limit the list of object the camera can collide with
  12481. */
  12482. collisionMask: number;
  12483. /** @hidden */
  12484. _collideWithWorld(displacement: Vector3): void;
  12485. private _onCollisionPositionChange;
  12486. /** @hidden */
  12487. _checkInputs(): void;
  12488. /** @hidden */
  12489. _decideIfNeedsToMove(): boolean;
  12490. /** @hidden */
  12491. _updatePosition(): void;
  12492. /**
  12493. * Destroy the camera and release the current resources hold by it.
  12494. */
  12495. dispose(): void;
  12496. /**
  12497. * Gets the current object class name.
  12498. * @return the class name
  12499. */
  12500. getClassName(): string;
  12501. }
  12502. }
  12503. declare module "babylonjs/Gamepads/gamepad" {
  12504. import { Observable } from "babylonjs/Misc/observable";
  12505. /**
  12506. * Represents a gamepad control stick position
  12507. */
  12508. export class StickValues {
  12509. /**
  12510. * The x component of the control stick
  12511. */
  12512. x: number;
  12513. /**
  12514. * The y component of the control stick
  12515. */
  12516. y: number;
  12517. /**
  12518. * Initializes the gamepad x and y control stick values
  12519. * @param x The x component of the gamepad control stick value
  12520. * @param y The y component of the gamepad control stick value
  12521. */
  12522. constructor(
  12523. /**
  12524. * The x component of the control stick
  12525. */
  12526. x: number,
  12527. /**
  12528. * The y component of the control stick
  12529. */
  12530. y: number);
  12531. }
  12532. /**
  12533. * An interface which manages callbacks for gamepad button changes
  12534. */
  12535. export interface GamepadButtonChanges {
  12536. /**
  12537. * Called when a gamepad has been changed
  12538. */
  12539. changed: boolean;
  12540. /**
  12541. * Called when a gamepad press event has been triggered
  12542. */
  12543. pressChanged: boolean;
  12544. /**
  12545. * Called when a touch event has been triggered
  12546. */
  12547. touchChanged: boolean;
  12548. /**
  12549. * Called when a value has changed
  12550. */
  12551. valueChanged: boolean;
  12552. }
  12553. /**
  12554. * Represents a gamepad
  12555. */
  12556. export class Gamepad {
  12557. /**
  12558. * The id of the gamepad
  12559. */
  12560. id: string;
  12561. /**
  12562. * The index of the gamepad
  12563. */
  12564. index: number;
  12565. /**
  12566. * The browser gamepad
  12567. */
  12568. browserGamepad: any;
  12569. /**
  12570. * Specifies what type of gamepad this represents
  12571. */
  12572. type: number;
  12573. private _leftStick;
  12574. private _rightStick;
  12575. /** @hidden */
  12576. _isConnected: boolean;
  12577. private _leftStickAxisX;
  12578. private _leftStickAxisY;
  12579. private _rightStickAxisX;
  12580. private _rightStickAxisY;
  12581. /**
  12582. * Triggered when the left control stick has been changed
  12583. */
  12584. private _onleftstickchanged;
  12585. /**
  12586. * Triggered when the right control stick has been changed
  12587. */
  12588. private _onrightstickchanged;
  12589. /**
  12590. * Represents a gamepad controller
  12591. */
  12592. static GAMEPAD: number;
  12593. /**
  12594. * Represents a generic controller
  12595. */
  12596. static GENERIC: number;
  12597. /**
  12598. * Represents an XBox controller
  12599. */
  12600. static XBOX: number;
  12601. /**
  12602. * Represents a pose-enabled controller
  12603. */
  12604. static POSE_ENABLED: number;
  12605. /**
  12606. * Represents an Dual Shock controller
  12607. */
  12608. static DUALSHOCK: number;
  12609. /**
  12610. * Specifies whether the left control stick should be Y-inverted
  12611. */
  12612. protected _invertLeftStickY: boolean;
  12613. /**
  12614. * Specifies if the gamepad has been connected
  12615. */
  12616. readonly isConnected: boolean;
  12617. /**
  12618. * Initializes the gamepad
  12619. * @param id The id of the gamepad
  12620. * @param index The index of the gamepad
  12621. * @param browserGamepad The browser gamepad
  12622. * @param leftStickX The x component of the left joystick
  12623. * @param leftStickY The y component of the left joystick
  12624. * @param rightStickX The x component of the right joystick
  12625. * @param rightStickY The y component of the right joystick
  12626. */
  12627. constructor(
  12628. /**
  12629. * The id of the gamepad
  12630. */
  12631. id: string,
  12632. /**
  12633. * The index of the gamepad
  12634. */
  12635. index: number,
  12636. /**
  12637. * The browser gamepad
  12638. */
  12639. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12640. /**
  12641. * Callback triggered when the left joystick has changed
  12642. * @param callback
  12643. */
  12644. onleftstickchanged(callback: (values: StickValues) => void): void;
  12645. /**
  12646. * Callback triggered when the right joystick has changed
  12647. * @param callback
  12648. */
  12649. onrightstickchanged(callback: (values: StickValues) => void): void;
  12650. /**
  12651. * Gets the left joystick
  12652. */
  12653. /**
  12654. * Sets the left joystick values
  12655. */
  12656. leftStick: StickValues;
  12657. /**
  12658. * Gets the right joystick
  12659. */
  12660. /**
  12661. * Sets the right joystick value
  12662. */
  12663. rightStick: StickValues;
  12664. /**
  12665. * Updates the gamepad joystick positions
  12666. */
  12667. update(): void;
  12668. /**
  12669. * Disposes the gamepad
  12670. */
  12671. dispose(): void;
  12672. }
  12673. /**
  12674. * Represents a generic gamepad
  12675. */
  12676. export class GenericPad extends Gamepad {
  12677. private _buttons;
  12678. private _onbuttondown;
  12679. private _onbuttonup;
  12680. /**
  12681. * Observable triggered when a button has been pressed
  12682. */
  12683. onButtonDownObservable: Observable<number>;
  12684. /**
  12685. * Observable triggered when a button has been released
  12686. */
  12687. onButtonUpObservable: Observable<number>;
  12688. /**
  12689. * Callback triggered when a button has been pressed
  12690. * @param callback Called when a button has been pressed
  12691. */
  12692. onbuttondown(callback: (buttonPressed: number) => void): void;
  12693. /**
  12694. * Callback triggered when a button has been released
  12695. * @param callback Called when a button has been released
  12696. */
  12697. onbuttonup(callback: (buttonReleased: number) => void): void;
  12698. /**
  12699. * Initializes the generic gamepad
  12700. * @param id The id of the generic gamepad
  12701. * @param index The index of the generic gamepad
  12702. * @param browserGamepad The browser gamepad
  12703. */
  12704. constructor(id: string, index: number, browserGamepad: any);
  12705. private _setButtonValue;
  12706. /**
  12707. * Updates the generic gamepad
  12708. */
  12709. update(): void;
  12710. /**
  12711. * Disposes the generic gamepad
  12712. */
  12713. dispose(): void;
  12714. }
  12715. }
  12716. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12717. import { Nullable } from "babylonjs/types";
  12718. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12719. import { Scene } from "babylonjs/scene";
  12720. module "babylonjs/Engines/engine" {
  12721. interface Engine {
  12722. /**
  12723. * Creates a raw texture
  12724. * @param data defines the data to store in the texture
  12725. * @param width defines the width of the texture
  12726. * @param height defines the height of the texture
  12727. * @param format defines the format of the data
  12728. * @param generateMipMaps defines if the engine should generate the mip levels
  12729. * @param invertY defines if data must be stored with Y axis inverted
  12730. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12731. * @param compression defines the compression used (null by default)
  12732. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12733. * @returns the raw texture inside an InternalTexture
  12734. */
  12735. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12736. /**
  12737. * Update a raw texture
  12738. * @param texture defines the texture to update
  12739. * @param data defines the data to store in the texture
  12740. * @param format defines the format of the data
  12741. * @param invertY defines if data must be stored with Y axis inverted
  12742. */
  12743. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12744. /**
  12745. * Update a raw texture
  12746. * @param texture defines the texture to update
  12747. * @param data defines the data to store in the texture
  12748. * @param format defines the format of the data
  12749. * @param invertY defines if data must be stored with Y axis inverted
  12750. * @param compression defines the compression used (null by default)
  12751. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12752. */
  12753. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12754. /**
  12755. * Creates a new raw cube texture
  12756. * @param data defines the array of data to use to create each face
  12757. * @param size defines the size of the textures
  12758. * @param format defines the format of the data
  12759. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12760. * @param generateMipMaps defines if the engine should generate the mip levels
  12761. * @param invertY defines if data must be stored with Y axis inverted
  12762. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12763. * @param compression defines the compression used (null by default)
  12764. * @returns the cube texture as an InternalTexture
  12765. */
  12766. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12767. /**
  12768. * Update a raw cube texture
  12769. * @param texture defines the texture to udpdate
  12770. * @param data defines the data to store
  12771. * @param format defines the data format
  12772. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12773. * @param invertY defines if data must be stored with Y axis inverted
  12774. */
  12775. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12776. /**
  12777. * Update a raw cube texture
  12778. * @param texture defines the texture to udpdate
  12779. * @param data defines the data to store
  12780. * @param format defines the data format
  12781. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12782. * @param invertY defines if data must be stored with Y axis inverted
  12783. * @param compression defines the compression used (null by default)
  12784. */
  12785. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12786. /**
  12787. * Update a raw cube texture
  12788. * @param texture defines the texture to udpdate
  12789. * @param data defines the data to store
  12790. * @param format defines the data format
  12791. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12792. * @param invertY defines if data must be stored with Y axis inverted
  12793. * @param compression defines the compression used (null by default)
  12794. * @param level defines which level of the texture to update
  12795. */
  12796. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12797. /**
  12798. * Creates a new raw cube texture from a specified url
  12799. * @param url defines the url where the data is located
  12800. * @param scene defines the current scene
  12801. * @param size defines the size of the textures
  12802. * @param format defines the format of the data
  12803. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12804. * @param noMipmap defines if the engine should avoid generating the mip levels
  12805. * @param callback defines a callback used to extract texture data from loaded data
  12806. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12807. * @param onLoad defines a callback called when texture is loaded
  12808. * @param onError defines a callback called if there is an error
  12809. * @returns the cube texture as an InternalTexture
  12810. */
  12811. 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;
  12812. /**
  12813. * Creates a new raw cube texture from a specified url
  12814. * @param url defines the url where the data is located
  12815. * @param scene defines the current scene
  12816. * @param size defines the size of the textures
  12817. * @param format defines the format of the data
  12818. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12819. * @param noMipmap defines if the engine should avoid generating the mip levels
  12820. * @param callback defines a callback used to extract texture data from loaded data
  12821. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12822. * @param onLoad defines a callback called when texture is loaded
  12823. * @param onError defines a callback called if there is an error
  12824. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12825. * @param invertY defines if data must be stored with Y axis inverted
  12826. * @returns the cube texture as an InternalTexture
  12827. */
  12828. 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;
  12829. /**
  12830. * Creates a new raw 3D texture
  12831. * @param data defines the data used to create the texture
  12832. * @param width defines the width of the texture
  12833. * @param height defines the height of the texture
  12834. * @param depth defines the depth of the texture
  12835. * @param format defines the format of the texture
  12836. * @param generateMipMaps defines if the engine must generate mip levels
  12837. * @param invertY defines if data must be stored with Y axis inverted
  12838. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12839. * @param compression defines the compressed used (can be null)
  12840. * @param textureType defines the compressed used (can be null)
  12841. * @returns a new raw 3D texture (stored in an InternalTexture)
  12842. */
  12843. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12844. /**
  12845. * Update a raw 3D texture
  12846. * @param texture defines the texture to update
  12847. * @param data defines the data to store
  12848. * @param format defines the data format
  12849. * @param invertY defines if data must be stored with Y axis inverted
  12850. */
  12851. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12852. /**
  12853. * Update a raw 3D texture
  12854. * @param texture defines the texture to update
  12855. * @param data defines the data to store
  12856. * @param format defines the data format
  12857. * @param invertY defines if data must be stored with Y axis inverted
  12858. * @param compression defines the used compression (can be null)
  12859. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12860. */
  12861. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12862. /**
  12863. * Creates a new raw 2D array texture
  12864. * @param data defines the data used to create the texture
  12865. * @param width defines the width of the texture
  12866. * @param height defines the height of the texture
  12867. * @param depth defines the number of layers of the texture
  12868. * @param format defines the format of the texture
  12869. * @param generateMipMaps defines if the engine must generate mip levels
  12870. * @param invertY defines if data must be stored with Y axis inverted
  12871. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12872. * @param compression defines the compressed used (can be null)
  12873. * @param textureType defines the compressed used (can be null)
  12874. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12875. */
  12876. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12877. /**
  12878. * Update a raw 2D array texture
  12879. * @param texture defines the texture to update
  12880. * @param data defines the data to store
  12881. * @param format defines the data format
  12882. * @param invertY defines if data must be stored with Y axis inverted
  12883. */
  12884. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12885. /**
  12886. * Update a raw 2D array texture
  12887. * @param texture defines the texture to update
  12888. * @param data defines the data to store
  12889. * @param format defines the data format
  12890. * @param invertY defines if data must be stored with Y axis inverted
  12891. * @param compression defines the used compression (can be null)
  12892. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12893. */
  12894. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12895. }
  12896. }
  12897. }
  12898. declare module "babylonjs/Materials/Textures/rawTexture" {
  12899. import { Scene } from "babylonjs/scene";
  12900. import { Texture } from "babylonjs/Materials/Textures/texture";
  12901. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12902. /**
  12903. * Raw texture can help creating a texture directly from an array of data.
  12904. * This can be super useful if you either get the data from an uncompressed source or
  12905. * if you wish to create your texture pixel by pixel.
  12906. */
  12907. export class RawTexture extends Texture {
  12908. /**
  12909. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12910. */
  12911. format: number;
  12912. private _engine;
  12913. /**
  12914. * Instantiates a new RawTexture.
  12915. * Raw texture can help creating a texture directly from an array of data.
  12916. * This can be super useful if you either get the data from an uncompressed source or
  12917. * if you wish to create your texture pixel by pixel.
  12918. * @param data define the array of data to use to create the texture
  12919. * @param width define the width of the texture
  12920. * @param height define the height of the texture
  12921. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12922. * @param scene define the scene the texture belongs to
  12923. * @param generateMipMaps define whether mip maps should be generated or not
  12924. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12925. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12926. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12927. */
  12928. constructor(data: ArrayBufferView, width: number, height: number,
  12929. /**
  12930. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12931. */
  12932. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12933. /**
  12934. * Updates the texture underlying data.
  12935. * @param data Define the new data of the texture
  12936. */
  12937. update(data: ArrayBufferView): void;
  12938. /**
  12939. * Creates a luminance texture from some data.
  12940. * @param data Define the texture data
  12941. * @param width Define the width of the texture
  12942. * @param height Define the height of the texture
  12943. * @param scene Define the scene the texture belongs to
  12944. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12945. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12946. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12947. * @returns the luminance texture
  12948. */
  12949. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12950. /**
  12951. * Creates a luminance alpha texture from some data.
  12952. * @param data Define the texture data
  12953. * @param width Define the width of the texture
  12954. * @param height Define the height of the texture
  12955. * @param scene Define the scene the texture belongs to
  12956. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12957. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12958. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12959. * @returns the luminance alpha texture
  12960. */
  12961. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12962. /**
  12963. * Creates an alpha texture from some data.
  12964. * @param data Define the texture data
  12965. * @param width Define the width of the texture
  12966. * @param height Define the height of the texture
  12967. * @param scene Define the scene the texture belongs to
  12968. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12969. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12970. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12971. * @returns the alpha texture
  12972. */
  12973. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12974. /**
  12975. * Creates a RGB texture from some data.
  12976. * @param data Define the texture data
  12977. * @param width Define the width of the texture
  12978. * @param height Define the height of the texture
  12979. * @param scene Define the scene the texture belongs to
  12980. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12981. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12982. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12983. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12984. * @returns the RGB alpha texture
  12985. */
  12986. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12987. /**
  12988. * Creates a RGBA texture from some data.
  12989. * @param data Define the texture data
  12990. * @param width Define the width of the texture
  12991. * @param height Define the height of the texture
  12992. * @param scene Define the scene the texture belongs to
  12993. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12994. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12995. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12996. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12997. * @returns the RGBA texture
  12998. */
  12999. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13000. /**
  13001. * Creates a R texture from some data.
  13002. * @param data Define the texture data
  13003. * @param width Define the width of the texture
  13004. * @param height Define the height of the texture
  13005. * @param scene Define the scene the texture belongs to
  13006. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13007. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13008. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13009. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13010. * @returns the R texture
  13011. */
  13012. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13013. }
  13014. }
  13015. declare module "babylonjs/Maths/math.size" {
  13016. /**
  13017. * Interface for the size containing width and height
  13018. */
  13019. export interface ISize {
  13020. /**
  13021. * Width
  13022. */
  13023. width: number;
  13024. /**
  13025. * Heighht
  13026. */
  13027. height: number;
  13028. }
  13029. /**
  13030. * Size containing widht and height
  13031. */
  13032. export class Size implements ISize {
  13033. /**
  13034. * Width
  13035. */
  13036. width: number;
  13037. /**
  13038. * Height
  13039. */
  13040. height: number;
  13041. /**
  13042. * Creates a Size object from the given width and height (floats).
  13043. * @param width width of the new size
  13044. * @param height height of the new size
  13045. */
  13046. constructor(width: number, height: number);
  13047. /**
  13048. * Returns a string with the Size width and height
  13049. * @returns a string with the Size width and height
  13050. */
  13051. toString(): string;
  13052. /**
  13053. * "Size"
  13054. * @returns the string "Size"
  13055. */
  13056. getClassName(): string;
  13057. /**
  13058. * Returns the Size hash code.
  13059. * @returns a hash code for a unique width and height
  13060. */
  13061. getHashCode(): number;
  13062. /**
  13063. * Updates the current size from the given one.
  13064. * @param src the given size
  13065. */
  13066. copyFrom(src: Size): void;
  13067. /**
  13068. * Updates in place the current Size from the given floats.
  13069. * @param width width of the new size
  13070. * @param height height of the new size
  13071. * @returns the updated Size.
  13072. */
  13073. copyFromFloats(width: number, height: number): Size;
  13074. /**
  13075. * Updates in place the current Size from the given floats.
  13076. * @param width width to set
  13077. * @param height height to set
  13078. * @returns the updated Size.
  13079. */
  13080. set(width: number, height: number): Size;
  13081. /**
  13082. * Multiplies the width and height by numbers
  13083. * @param w factor to multiple the width by
  13084. * @param h factor to multiple the height by
  13085. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13086. */
  13087. multiplyByFloats(w: number, h: number): Size;
  13088. /**
  13089. * Clones the size
  13090. * @returns a new Size copied from the given one.
  13091. */
  13092. clone(): Size;
  13093. /**
  13094. * True if the current Size and the given one width and height are strictly equal.
  13095. * @param other the other size to compare against
  13096. * @returns True if the current Size and the given one width and height are strictly equal.
  13097. */
  13098. equals(other: Size): boolean;
  13099. /**
  13100. * The surface of the Size : width * height (float).
  13101. */
  13102. readonly surface: number;
  13103. /**
  13104. * Create a new size of zero
  13105. * @returns a new Size set to (0.0, 0.0)
  13106. */
  13107. static Zero(): Size;
  13108. /**
  13109. * Sums the width and height of two sizes
  13110. * @param otherSize size to add to this size
  13111. * @returns a new Size set as the addition result of the current Size and the given one.
  13112. */
  13113. add(otherSize: Size): Size;
  13114. /**
  13115. * Subtracts the width and height of two
  13116. * @param otherSize size to subtract to this size
  13117. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13118. */
  13119. subtract(otherSize: Size): Size;
  13120. /**
  13121. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13122. * @param start starting size to lerp between
  13123. * @param end end size to lerp between
  13124. * @param amount amount to lerp between the start and end values
  13125. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13126. */
  13127. static Lerp(start: Size, end: Size, amount: number): Size;
  13128. }
  13129. }
  13130. declare module "babylonjs/Animations/runtimeAnimation" {
  13131. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13132. import { Animatable } from "babylonjs/Animations/animatable";
  13133. import { Scene } from "babylonjs/scene";
  13134. /**
  13135. * Defines a runtime animation
  13136. */
  13137. export class RuntimeAnimation {
  13138. private _events;
  13139. /**
  13140. * The current frame of the runtime animation
  13141. */
  13142. private _currentFrame;
  13143. /**
  13144. * The animation used by the runtime animation
  13145. */
  13146. private _animation;
  13147. /**
  13148. * The target of the runtime animation
  13149. */
  13150. private _target;
  13151. /**
  13152. * The initiating animatable
  13153. */
  13154. private _host;
  13155. /**
  13156. * The original value of the runtime animation
  13157. */
  13158. private _originalValue;
  13159. /**
  13160. * The original blend value of the runtime animation
  13161. */
  13162. private _originalBlendValue;
  13163. /**
  13164. * The offsets cache of the runtime animation
  13165. */
  13166. private _offsetsCache;
  13167. /**
  13168. * The high limits cache of the runtime animation
  13169. */
  13170. private _highLimitsCache;
  13171. /**
  13172. * Specifies if the runtime animation has been stopped
  13173. */
  13174. private _stopped;
  13175. /**
  13176. * The blending factor of the runtime animation
  13177. */
  13178. private _blendingFactor;
  13179. /**
  13180. * The BabylonJS scene
  13181. */
  13182. private _scene;
  13183. /**
  13184. * The current value of the runtime animation
  13185. */
  13186. private _currentValue;
  13187. /** @hidden */
  13188. _animationState: _IAnimationState;
  13189. /**
  13190. * The active target of the runtime animation
  13191. */
  13192. private _activeTargets;
  13193. private _currentActiveTarget;
  13194. private _directTarget;
  13195. /**
  13196. * The target path of the runtime animation
  13197. */
  13198. private _targetPath;
  13199. /**
  13200. * The weight of the runtime animation
  13201. */
  13202. private _weight;
  13203. /**
  13204. * The ratio offset of the runtime animation
  13205. */
  13206. private _ratioOffset;
  13207. /**
  13208. * The previous delay of the runtime animation
  13209. */
  13210. private _previousDelay;
  13211. /**
  13212. * The previous ratio of the runtime animation
  13213. */
  13214. private _previousRatio;
  13215. private _enableBlending;
  13216. private _keys;
  13217. private _minFrame;
  13218. private _maxFrame;
  13219. private _minValue;
  13220. private _maxValue;
  13221. private _targetIsArray;
  13222. /**
  13223. * Gets the current frame of the runtime animation
  13224. */
  13225. readonly currentFrame: number;
  13226. /**
  13227. * Gets the weight of the runtime animation
  13228. */
  13229. readonly weight: number;
  13230. /**
  13231. * Gets the current value of the runtime animation
  13232. */
  13233. readonly currentValue: any;
  13234. /**
  13235. * Gets the target path of the runtime animation
  13236. */
  13237. readonly targetPath: string;
  13238. /**
  13239. * Gets the actual target of the runtime animation
  13240. */
  13241. readonly target: any;
  13242. /** @hidden */
  13243. _onLoop: () => void;
  13244. /**
  13245. * Create a new RuntimeAnimation object
  13246. * @param target defines the target of the animation
  13247. * @param animation defines the source animation object
  13248. * @param scene defines the hosting scene
  13249. * @param host defines the initiating Animatable
  13250. */
  13251. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13252. private _preparePath;
  13253. /**
  13254. * Gets the animation from the runtime animation
  13255. */
  13256. readonly animation: Animation;
  13257. /**
  13258. * Resets the runtime animation to the beginning
  13259. * @param restoreOriginal defines whether to restore the target property to the original value
  13260. */
  13261. reset(restoreOriginal?: boolean): void;
  13262. /**
  13263. * Specifies if the runtime animation is stopped
  13264. * @returns Boolean specifying if the runtime animation is stopped
  13265. */
  13266. isStopped(): boolean;
  13267. /**
  13268. * Disposes of the runtime animation
  13269. */
  13270. dispose(): void;
  13271. /**
  13272. * Apply the interpolated value to the target
  13273. * @param currentValue defines the value computed by the animation
  13274. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13275. */
  13276. setValue(currentValue: any, weight: number): void;
  13277. private _getOriginalValues;
  13278. private _setValue;
  13279. /**
  13280. * Gets the loop pmode of the runtime animation
  13281. * @returns Loop Mode
  13282. */
  13283. private _getCorrectLoopMode;
  13284. /**
  13285. * Move the current animation to a given frame
  13286. * @param frame defines the frame to move to
  13287. */
  13288. goToFrame(frame: number): void;
  13289. /**
  13290. * @hidden Internal use only
  13291. */
  13292. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13293. /**
  13294. * Execute the current animation
  13295. * @param delay defines the delay to add to the current frame
  13296. * @param from defines the lower bound of the animation range
  13297. * @param to defines the upper bound of the animation range
  13298. * @param loop defines if the current animation must loop
  13299. * @param speedRatio defines the current speed ratio
  13300. * @param weight defines the weight of the animation (default is -1 so no weight)
  13301. * @param onLoop optional callback called when animation loops
  13302. * @returns a boolean indicating if the animation is running
  13303. */
  13304. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13305. }
  13306. }
  13307. declare module "babylonjs/Animations/animatable" {
  13308. import { Animation } from "babylonjs/Animations/animation";
  13309. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13310. import { Nullable } from "babylonjs/types";
  13311. import { Observable } from "babylonjs/Misc/observable";
  13312. import { Scene } from "babylonjs/scene";
  13313. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13314. import { Node } from "babylonjs/node";
  13315. /**
  13316. * Class used to store an actual running animation
  13317. */
  13318. export class Animatable {
  13319. /** defines the target object */
  13320. target: any;
  13321. /** defines the starting frame number (default is 0) */
  13322. fromFrame: number;
  13323. /** defines the ending frame number (default is 100) */
  13324. toFrame: number;
  13325. /** defines if the animation must loop (default is false) */
  13326. loopAnimation: boolean;
  13327. /** defines a callback to call when animation ends if it is not looping */
  13328. onAnimationEnd?: (() => void) | null | undefined;
  13329. /** defines a callback to call when animation loops */
  13330. onAnimationLoop?: (() => void) | null | undefined;
  13331. private _localDelayOffset;
  13332. private _pausedDelay;
  13333. private _runtimeAnimations;
  13334. private _paused;
  13335. private _scene;
  13336. private _speedRatio;
  13337. private _weight;
  13338. private _syncRoot;
  13339. /**
  13340. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13341. * This will only apply for non looping animation (default is true)
  13342. */
  13343. disposeOnEnd: boolean;
  13344. /**
  13345. * Gets a boolean indicating if the animation has started
  13346. */
  13347. animationStarted: boolean;
  13348. /**
  13349. * Observer raised when the animation ends
  13350. */
  13351. onAnimationEndObservable: Observable<Animatable>;
  13352. /**
  13353. * Observer raised when the animation loops
  13354. */
  13355. onAnimationLoopObservable: Observable<Animatable>;
  13356. /**
  13357. * Gets the root Animatable used to synchronize and normalize animations
  13358. */
  13359. readonly syncRoot: Nullable<Animatable>;
  13360. /**
  13361. * Gets the current frame of the first RuntimeAnimation
  13362. * Used to synchronize Animatables
  13363. */
  13364. readonly masterFrame: number;
  13365. /**
  13366. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13367. */
  13368. weight: number;
  13369. /**
  13370. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13371. */
  13372. speedRatio: number;
  13373. /**
  13374. * Creates a new Animatable
  13375. * @param scene defines the hosting scene
  13376. * @param target defines the target object
  13377. * @param fromFrame defines the starting frame number (default is 0)
  13378. * @param toFrame defines the ending frame number (default is 100)
  13379. * @param loopAnimation defines if the animation must loop (default is false)
  13380. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13381. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13382. * @param animations defines a group of animation to add to the new Animatable
  13383. * @param onAnimationLoop defines a callback to call when animation loops
  13384. */
  13385. constructor(scene: Scene,
  13386. /** defines the target object */
  13387. target: any,
  13388. /** defines the starting frame number (default is 0) */
  13389. fromFrame?: number,
  13390. /** defines the ending frame number (default is 100) */
  13391. toFrame?: number,
  13392. /** defines if the animation must loop (default is false) */
  13393. loopAnimation?: boolean, speedRatio?: number,
  13394. /** defines a callback to call when animation ends if it is not looping */
  13395. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13396. /** defines a callback to call when animation loops */
  13397. onAnimationLoop?: (() => void) | null | undefined);
  13398. /**
  13399. * Synchronize and normalize current Animatable with a source Animatable
  13400. * This is useful when using animation weights and when animations are not of the same length
  13401. * @param root defines the root Animatable to synchronize with
  13402. * @returns the current Animatable
  13403. */
  13404. syncWith(root: Animatable): Animatable;
  13405. /**
  13406. * Gets the list of runtime animations
  13407. * @returns an array of RuntimeAnimation
  13408. */
  13409. getAnimations(): RuntimeAnimation[];
  13410. /**
  13411. * Adds more animations to the current animatable
  13412. * @param target defines the target of the animations
  13413. * @param animations defines the new animations to add
  13414. */
  13415. appendAnimations(target: any, animations: Animation[]): void;
  13416. /**
  13417. * Gets the source animation for a specific property
  13418. * @param property defines the propertyu to look for
  13419. * @returns null or the source animation for the given property
  13420. */
  13421. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13422. /**
  13423. * Gets the runtime animation for a specific property
  13424. * @param property defines the propertyu to look for
  13425. * @returns null or the runtime animation for the given property
  13426. */
  13427. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13428. /**
  13429. * Resets the animatable to its original state
  13430. */
  13431. reset(): void;
  13432. /**
  13433. * Allows the animatable to blend with current running animations
  13434. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13435. * @param blendingSpeed defines the blending speed to use
  13436. */
  13437. enableBlending(blendingSpeed: number): void;
  13438. /**
  13439. * Disable animation blending
  13440. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13441. */
  13442. disableBlending(): void;
  13443. /**
  13444. * Jump directly to a given frame
  13445. * @param frame defines the frame to jump to
  13446. */
  13447. goToFrame(frame: number): void;
  13448. /**
  13449. * Pause the animation
  13450. */
  13451. pause(): void;
  13452. /**
  13453. * Restart the animation
  13454. */
  13455. restart(): void;
  13456. private _raiseOnAnimationEnd;
  13457. /**
  13458. * Stop and delete the current animation
  13459. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13460. * @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)
  13461. */
  13462. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13463. /**
  13464. * Wait asynchronously for the animation to end
  13465. * @returns a promise which will be fullfilled when the animation ends
  13466. */
  13467. waitAsync(): Promise<Animatable>;
  13468. /** @hidden */
  13469. _animate(delay: number): boolean;
  13470. }
  13471. module "babylonjs/scene" {
  13472. interface Scene {
  13473. /** @hidden */
  13474. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13475. /** @hidden */
  13476. _processLateAnimationBindingsForMatrices(holder: {
  13477. totalWeight: number;
  13478. animations: RuntimeAnimation[];
  13479. originalValue: Matrix;
  13480. }): any;
  13481. /** @hidden */
  13482. _processLateAnimationBindingsForQuaternions(holder: {
  13483. totalWeight: number;
  13484. animations: RuntimeAnimation[];
  13485. originalValue: Quaternion;
  13486. }, refQuaternion: Quaternion): Quaternion;
  13487. /** @hidden */
  13488. _processLateAnimationBindings(): void;
  13489. /**
  13490. * Will start the animation sequence of a given target
  13491. * @param target defines the target
  13492. * @param from defines from which frame should animation start
  13493. * @param to defines until which frame should animation run.
  13494. * @param weight defines the weight to apply to the animation (1.0 by default)
  13495. * @param loop defines if the animation loops
  13496. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13497. * @param onAnimationEnd defines the function to be executed when the animation ends
  13498. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13499. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13500. * @param onAnimationLoop defines the callback to call when an animation loops
  13501. * @returns the animatable object created for this animation
  13502. */
  13503. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13504. /**
  13505. * Will start the animation sequence of a given target
  13506. * @param target defines the target
  13507. * @param from defines from which frame should animation start
  13508. * @param to defines until which frame should animation run.
  13509. * @param loop defines if the animation loops
  13510. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13511. * @param onAnimationEnd defines the function to be executed when the animation ends
  13512. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13513. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13514. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13515. * @param onAnimationLoop defines the callback to call when an animation loops
  13516. * @returns the animatable object created for this animation
  13517. */
  13518. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13519. /**
  13520. * Will start the animation sequence of a given target and its hierarchy
  13521. * @param target defines the target
  13522. * @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.
  13523. * @param from defines from which frame should animation start
  13524. * @param to defines until which frame should animation run.
  13525. * @param loop defines if the animation loops
  13526. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13527. * @param onAnimationEnd defines the function to be executed when the animation ends
  13528. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13529. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13530. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13531. * @param onAnimationLoop defines the callback to call when an animation loops
  13532. * @returns the list of created animatables
  13533. */
  13534. 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[];
  13535. /**
  13536. * Begin a new animation on a given node
  13537. * @param target defines the target where the animation will take place
  13538. * @param animations defines the list of animations to start
  13539. * @param from defines the initial value
  13540. * @param to defines the final value
  13541. * @param loop defines if you want animation to loop (off by default)
  13542. * @param speedRatio defines the speed ratio to apply to all animations
  13543. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13544. * @param onAnimationLoop defines the callback to call when an animation loops
  13545. * @returns the list of created animatables
  13546. */
  13547. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13548. /**
  13549. * Begin a new animation on a given node and its hierarchy
  13550. * @param target defines the root node where the animation will take place
  13551. * @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.
  13552. * @param animations defines the list of animations to start
  13553. * @param from defines the initial value
  13554. * @param to defines the final value
  13555. * @param loop defines if you want animation to loop (off by default)
  13556. * @param speedRatio defines the speed ratio to apply to all animations
  13557. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13558. * @param onAnimationLoop defines the callback to call when an animation loops
  13559. * @returns the list of animatables created for all nodes
  13560. */
  13561. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13562. /**
  13563. * Gets the animatable associated with a specific target
  13564. * @param target defines the target of the animatable
  13565. * @returns the required animatable if found
  13566. */
  13567. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13568. /**
  13569. * Gets all animatables associated with a given target
  13570. * @param target defines the target to look animatables for
  13571. * @returns an array of Animatables
  13572. */
  13573. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13574. /**
  13575. * Stops and removes all animations that have been applied to the scene
  13576. */
  13577. stopAllAnimations(): void;
  13578. /**
  13579. * Gets the current delta time used by animation engine
  13580. */
  13581. deltaTime: number;
  13582. }
  13583. }
  13584. module "babylonjs/Bones/bone" {
  13585. interface Bone {
  13586. /**
  13587. * Copy an animation range from another bone
  13588. * @param source defines the source bone
  13589. * @param rangeName defines the range name to copy
  13590. * @param frameOffset defines the frame offset
  13591. * @param rescaleAsRequired defines if rescaling must be applied if required
  13592. * @param skelDimensionsRatio defines the scaling ratio
  13593. * @returns true if operation was successful
  13594. */
  13595. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13596. }
  13597. }
  13598. }
  13599. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13600. /**
  13601. * Class used to override all child animations of a given target
  13602. */
  13603. export class AnimationPropertiesOverride {
  13604. /**
  13605. * Gets or sets a value indicating if animation blending must be used
  13606. */
  13607. enableBlending: boolean;
  13608. /**
  13609. * Gets or sets the blending speed to use when enableBlending is true
  13610. */
  13611. blendingSpeed: number;
  13612. /**
  13613. * Gets or sets the default loop mode to use
  13614. */
  13615. loopMode: number;
  13616. }
  13617. }
  13618. declare module "babylonjs/Bones/skeleton" {
  13619. import { Bone } from "babylonjs/Bones/bone";
  13620. import { Observable } from "babylonjs/Misc/observable";
  13621. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13622. import { Scene } from "babylonjs/scene";
  13623. import { Nullable } from "babylonjs/types";
  13624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13625. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13626. import { Animatable } from "babylonjs/Animations/animatable";
  13627. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13628. import { Animation } from "babylonjs/Animations/animation";
  13629. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13630. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13631. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13632. /**
  13633. * Class used to handle skinning animations
  13634. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13635. */
  13636. export class Skeleton implements IAnimatable {
  13637. /** defines the skeleton name */
  13638. name: string;
  13639. /** defines the skeleton Id */
  13640. id: string;
  13641. /**
  13642. * Defines the list of child bones
  13643. */
  13644. bones: Bone[];
  13645. /**
  13646. * Defines an estimate of the dimension of the skeleton at rest
  13647. */
  13648. dimensionsAtRest: Vector3;
  13649. /**
  13650. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13651. */
  13652. needInitialSkinMatrix: boolean;
  13653. /**
  13654. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13655. */
  13656. overrideMesh: Nullable<AbstractMesh>;
  13657. /**
  13658. * Gets the list of animations attached to this skeleton
  13659. */
  13660. animations: Array<Animation>;
  13661. private _scene;
  13662. private _isDirty;
  13663. private _transformMatrices;
  13664. private _transformMatrixTexture;
  13665. private _meshesWithPoseMatrix;
  13666. private _animatables;
  13667. private _identity;
  13668. private _synchronizedWithMesh;
  13669. private _ranges;
  13670. private _lastAbsoluteTransformsUpdateId;
  13671. private _canUseTextureForBones;
  13672. private _uniqueId;
  13673. /** @hidden */
  13674. _numBonesWithLinkedTransformNode: number;
  13675. /** @hidden */
  13676. _hasWaitingData: Nullable<boolean>;
  13677. /**
  13678. * Specifies if the skeleton should be serialized
  13679. */
  13680. doNotSerialize: boolean;
  13681. private _useTextureToStoreBoneMatrices;
  13682. /**
  13683. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13684. * Please note that this option is not available if the hardware does not support it
  13685. */
  13686. useTextureToStoreBoneMatrices: boolean;
  13687. private _animationPropertiesOverride;
  13688. /**
  13689. * Gets or sets the animation properties override
  13690. */
  13691. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13692. /**
  13693. * List of inspectable custom properties (used by the Inspector)
  13694. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13695. */
  13696. inspectableCustomProperties: IInspectable[];
  13697. /**
  13698. * An observable triggered before computing the skeleton's matrices
  13699. */
  13700. onBeforeComputeObservable: Observable<Skeleton>;
  13701. /**
  13702. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13703. */
  13704. readonly isUsingTextureForMatrices: boolean;
  13705. /**
  13706. * Gets the unique ID of this skeleton
  13707. */
  13708. readonly uniqueId: number;
  13709. /**
  13710. * Creates a new skeleton
  13711. * @param name defines the skeleton name
  13712. * @param id defines the skeleton Id
  13713. * @param scene defines the hosting scene
  13714. */
  13715. constructor(
  13716. /** defines the skeleton name */
  13717. name: string,
  13718. /** defines the skeleton Id */
  13719. id: string, scene: Scene);
  13720. /**
  13721. * Gets the current object class name.
  13722. * @return the class name
  13723. */
  13724. getClassName(): string;
  13725. /**
  13726. * Returns an array containing the root bones
  13727. * @returns an array containing the root bones
  13728. */
  13729. getChildren(): Array<Bone>;
  13730. /**
  13731. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13732. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13733. * @returns a Float32Array containing matrices data
  13734. */
  13735. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13736. /**
  13737. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13738. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13739. * @returns a raw texture containing the data
  13740. */
  13741. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13742. /**
  13743. * Gets the current hosting scene
  13744. * @returns a scene object
  13745. */
  13746. getScene(): Scene;
  13747. /**
  13748. * Gets a string representing the current skeleton data
  13749. * @param fullDetails defines a boolean indicating if we want a verbose version
  13750. * @returns a string representing the current skeleton data
  13751. */
  13752. toString(fullDetails?: boolean): string;
  13753. /**
  13754. * Get bone's index searching by name
  13755. * @param name defines bone's name to search for
  13756. * @return the indice of the bone. Returns -1 if not found
  13757. */
  13758. getBoneIndexByName(name: string): number;
  13759. /**
  13760. * Creater a new animation range
  13761. * @param name defines the name of the range
  13762. * @param from defines the start key
  13763. * @param to defines the end key
  13764. */
  13765. createAnimationRange(name: string, from: number, to: number): void;
  13766. /**
  13767. * Delete a specific animation range
  13768. * @param name defines the name of the range
  13769. * @param deleteFrames defines if frames must be removed as well
  13770. */
  13771. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13772. /**
  13773. * Gets a specific animation range
  13774. * @param name defines the name of the range to look for
  13775. * @returns the requested animation range or null if not found
  13776. */
  13777. getAnimationRange(name: string): Nullable<AnimationRange>;
  13778. /**
  13779. * Gets the list of all animation ranges defined on this skeleton
  13780. * @returns an array
  13781. */
  13782. getAnimationRanges(): Nullable<AnimationRange>[];
  13783. /**
  13784. * Copy animation range from a source skeleton.
  13785. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13786. * @param source defines the source skeleton
  13787. * @param name defines the name of the range to copy
  13788. * @param rescaleAsRequired defines if rescaling must be applied if required
  13789. * @returns true if operation was successful
  13790. */
  13791. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13792. /**
  13793. * Forces the skeleton to go to rest pose
  13794. */
  13795. returnToRest(): void;
  13796. private _getHighestAnimationFrame;
  13797. /**
  13798. * Begin a specific animation range
  13799. * @param name defines the name of the range to start
  13800. * @param loop defines if looping must be turned on (false by default)
  13801. * @param speedRatio defines the speed ratio to apply (1 by default)
  13802. * @param onAnimationEnd defines a callback which will be called when animation will end
  13803. * @returns a new animatable
  13804. */
  13805. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13806. /** @hidden */
  13807. _markAsDirty(): void;
  13808. /** @hidden */
  13809. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13810. /** @hidden */
  13811. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13812. private _computeTransformMatrices;
  13813. /**
  13814. * Build all resources required to render a skeleton
  13815. */
  13816. prepare(): void;
  13817. /**
  13818. * Gets the list of animatables currently running for this skeleton
  13819. * @returns an array of animatables
  13820. */
  13821. getAnimatables(): IAnimatable[];
  13822. /**
  13823. * Clone the current skeleton
  13824. * @param name defines the name of the new skeleton
  13825. * @param id defines the id of the new skeleton
  13826. * @returns the new skeleton
  13827. */
  13828. clone(name: string, id?: string): Skeleton;
  13829. /**
  13830. * Enable animation blending for this skeleton
  13831. * @param blendingSpeed defines the blending speed to apply
  13832. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13833. */
  13834. enableBlending(blendingSpeed?: number): void;
  13835. /**
  13836. * Releases all resources associated with the current skeleton
  13837. */
  13838. dispose(): void;
  13839. /**
  13840. * Serialize the skeleton in a JSON object
  13841. * @returns a JSON object
  13842. */
  13843. serialize(): any;
  13844. /**
  13845. * Creates a new skeleton from serialized data
  13846. * @param parsedSkeleton defines the serialized data
  13847. * @param scene defines the hosting scene
  13848. * @returns a new skeleton
  13849. */
  13850. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13851. /**
  13852. * Compute all node absolute transforms
  13853. * @param forceUpdate defines if computation must be done even if cache is up to date
  13854. */
  13855. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13856. /**
  13857. * Gets the root pose matrix
  13858. * @returns a matrix
  13859. */
  13860. getPoseMatrix(): Nullable<Matrix>;
  13861. /**
  13862. * Sorts bones per internal index
  13863. */
  13864. sortBones(): void;
  13865. private _sortBones;
  13866. }
  13867. }
  13868. declare module "babylonjs/Bones/bone" {
  13869. import { Skeleton } from "babylonjs/Bones/skeleton";
  13870. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13871. import { Nullable } from "babylonjs/types";
  13872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13873. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13874. import { Node } from "babylonjs/node";
  13875. import { Space } from "babylonjs/Maths/math.axis";
  13876. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13877. /**
  13878. * Class used to store bone information
  13879. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13880. */
  13881. export class Bone extends Node {
  13882. /**
  13883. * defines the bone name
  13884. */
  13885. name: string;
  13886. private static _tmpVecs;
  13887. private static _tmpQuat;
  13888. private static _tmpMats;
  13889. /**
  13890. * Gets the list of child bones
  13891. */
  13892. children: Bone[];
  13893. /** Gets the animations associated with this bone */
  13894. animations: import("babylonjs/Animations/animation").Animation[];
  13895. /**
  13896. * Gets or sets bone length
  13897. */
  13898. length: number;
  13899. /**
  13900. * @hidden Internal only
  13901. * Set this value to map this bone to a different index in the transform matrices
  13902. * Set this value to -1 to exclude the bone from the transform matrices
  13903. */
  13904. _index: Nullable<number>;
  13905. private _skeleton;
  13906. private _localMatrix;
  13907. private _restPose;
  13908. private _baseMatrix;
  13909. private _absoluteTransform;
  13910. private _invertedAbsoluteTransform;
  13911. private _parent;
  13912. private _scalingDeterminant;
  13913. private _worldTransform;
  13914. private _localScaling;
  13915. private _localRotation;
  13916. private _localPosition;
  13917. private _needToDecompose;
  13918. private _needToCompose;
  13919. /** @hidden */
  13920. _linkedTransformNode: Nullable<TransformNode>;
  13921. /** @hidden */
  13922. _waitingTransformNodeId: Nullable<string>;
  13923. /** @hidden */
  13924. /** @hidden */
  13925. _matrix: Matrix;
  13926. /**
  13927. * Create a new bone
  13928. * @param name defines the bone name
  13929. * @param skeleton defines the parent skeleton
  13930. * @param parentBone defines the parent (can be null if the bone is the root)
  13931. * @param localMatrix defines the local matrix
  13932. * @param restPose defines the rest pose matrix
  13933. * @param baseMatrix defines the base matrix
  13934. * @param index defines index of the bone in the hiearchy
  13935. */
  13936. constructor(
  13937. /**
  13938. * defines the bone name
  13939. */
  13940. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13941. /**
  13942. * Gets the current object class name.
  13943. * @return the class name
  13944. */
  13945. getClassName(): string;
  13946. /**
  13947. * Gets the parent skeleton
  13948. * @returns a skeleton
  13949. */
  13950. getSkeleton(): Skeleton;
  13951. /**
  13952. * Gets parent bone
  13953. * @returns a bone or null if the bone is the root of the bone hierarchy
  13954. */
  13955. getParent(): Nullable<Bone>;
  13956. /**
  13957. * Returns an array containing the root bones
  13958. * @returns an array containing the root bones
  13959. */
  13960. getChildren(): Array<Bone>;
  13961. /**
  13962. * Gets the node index in matrix array generated for rendering
  13963. * @returns the node index
  13964. */
  13965. getIndex(): number;
  13966. /**
  13967. * Sets the parent bone
  13968. * @param parent defines the parent (can be null if the bone is the root)
  13969. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13970. */
  13971. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13972. /**
  13973. * Gets the local matrix
  13974. * @returns a matrix
  13975. */
  13976. getLocalMatrix(): Matrix;
  13977. /**
  13978. * Gets the base matrix (initial matrix which remains unchanged)
  13979. * @returns a matrix
  13980. */
  13981. getBaseMatrix(): Matrix;
  13982. /**
  13983. * Gets the rest pose matrix
  13984. * @returns a matrix
  13985. */
  13986. getRestPose(): Matrix;
  13987. /**
  13988. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13989. */
  13990. getWorldMatrix(): Matrix;
  13991. /**
  13992. * Sets the local matrix to rest pose matrix
  13993. */
  13994. returnToRest(): void;
  13995. /**
  13996. * Gets the inverse of the absolute transform matrix.
  13997. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13998. * @returns a matrix
  13999. */
  14000. getInvertedAbsoluteTransform(): Matrix;
  14001. /**
  14002. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14003. * @returns a matrix
  14004. */
  14005. getAbsoluteTransform(): Matrix;
  14006. /**
  14007. * Links with the given transform node.
  14008. * The local matrix of this bone is copied from the transform node every frame.
  14009. * @param transformNode defines the transform node to link to
  14010. */
  14011. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14012. /**
  14013. * Gets the node used to drive the bone's transformation
  14014. * @returns a transform node or null
  14015. */
  14016. getTransformNode(): Nullable<TransformNode>;
  14017. /** Gets or sets current position (in local space) */
  14018. position: Vector3;
  14019. /** Gets or sets current rotation (in local space) */
  14020. rotation: Vector3;
  14021. /** Gets or sets current rotation quaternion (in local space) */
  14022. rotationQuaternion: Quaternion;
  14023. /** Gets or sets current scaling (in local space) */
  14024. scaling: Vector3;
  14025. /**
  14026. * Gets the animation properties override
  14027. */
  14028. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  14029. private _decompose;
  14030. private _compose;
  14031. /**
  14032. * Update the base and local matrices
  14033. * @param matrix defines the new base or local matrix
  14034. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14035. * @param updateLocalMatrix defines if the local matrix should be updated
  14036. */
  14037. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14038. /** @hidden */
  14039. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14040. /**
  14041. * Flag the bone as dirty (Forcing it to update everything)
  14042. */
  14043. markAsDirty(): void;
  14044. /** @hidden */
  14045. _markAsDirtyAndCompose(): void;
  14046. private _markAsDirtyAndDecompose;
  14047. /**
  14048. * Translate the bone in local or world space
  14049. * @param vec The amount to translate the bone
  14050. * @param space The space that the translation is in
  14051. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14052. */
  14053. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14054. /**
  14055. * Set the postion of the bone in local or world space
  14056. * @param position The position to set the bone
  14057. * @param space The space that the position is in
  14058. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14059. */
  14060. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14061. /**
  14062. * Set the absolute position of the bone (world space)
  14063. * @param position The position to set the bone
  14064. * @param mesh The mesh that this bone is attached to
  14065. */
  14066. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14067. /**
  14068. * Scale the bone on the x, y and z axes (in local space)
  14069. * @param x The amount to scale the bone on the x axis
  14070. * @param y The amount to scale the bone on the y axis
  14071. * @param z The amount to scale the bone on the z axis
  14072. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14073. */
  14074. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14075. /**
  14076. * Set the bone scaling in local space
  14077. * @param scale defines the scaling vector
  14078. */
  14079. setScale(scale: Vector3): void;
  14080. /**
  14081. * Gets the current scaling in local space
  14082. * @returns the current scaling vector
  14083. */
  14084. getScale(): Vector3;
  14085. /**
  14086. * Gets the current scaling in local space and stores it in a target vector
  14087. * @param result defines the target vector
  14088. */
  14089. getScaleToRef(result: Vector3): void;
  14090. /**
  14091. * Set the yaw, pitch, and roll of the bone in local or world space
  14092. * @param yaw The rotation of the bone on the y axis
  14093. * @param pitch The rotation of the bone on the x axis
  14094. * @param roll The rotation of the bone on the z axis
  14095. * @param space The space that the axes of rotation are in
  14096. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14097. */
  14098. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14099. /**
  14100. * Add a rotation to the bone on an axis in local or world space
  14101. * @param axis The axis to rotate the bone on
  14102. * @param amount The amount to rotate the bone
  14103. * @param space The space that the axis is in
  14104. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14105. */
  14106. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14107. /**
  14108. * Set the rotation of the bone to a particular axis angle in local or world space
  14109. * @param axis The axis to rotate the bone on
  14110. * @param angle The angle that the bone should be rotated to
  14111. * @param space The space that the axis is in
  14112. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14113. */
  14114. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14115. /**
  14116. * Set the euler rotation of the bone in local of world space
  14117. * @param rotation The euler rotation that the bone should be set to
  14118. * @param space The space that the rotation is in
  14119. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14120. */
  14121. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14122. /**
  14123. * Set the quaternion rotation of the bone in local of world space
  14124. * @param quat The quaternion rotation that the bone should be set to
  14125. * @param space The space that the rotation is in
  14126. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14127. */
  14128. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14129. /**
  14130. * Set the rotation matrix of the bone in local of world space
  14131. * @param rotMat The rotation matrix that the bone should be set to
  14132. * @param space The space that the rotation is in
  14133. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14134. */
  14135. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14136. private _rotateWithMatrix;
  14137. private _getNegativeRotationToRef;
  14138. /**
  14139. * Get the position of the bone in local or world space
  14140. * @param space The space that the returned position is in
  14141. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14142. * @returns The position of the bone
  14143. */
  14144. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14145. /**
  14146. * Copy the position of the bone to a vector3 in local or world space
  14147. * @param space The space that the returned position is in
  14148. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14149. * @param result The vector3 to copy the position to
  14150. */
  14151. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14152. /**
  14153. * Get the absolute position of the bone (world space)
  14154. * @param mesh The mesh that this bone is attached to
  14155. * @returns The absolute position of the bone
  14156. */
  14157. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14158. /**
  14159. * Copy the absolute position of the bone (world space) to the result param
  14160. * @param mesh The mesh that this bone is attached to
  14161. * @param result The vector3 to copy the absolute position to
  14162. */
  14163. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14164. /**
  14165. * Compute the absolute transforms of this bone and its children
  14166. */
  14167. computeAbsoluteTransforms(): void;
  14168. /**
  14169. * Get the world direction from an axis that is in the local space of the bone
  14170. * @param localAxis The local direction that is used to compute the world direction
  14171. * @param mesh The mesh that this bone is attached to
  14172. * @returns The world direction
  14173. */
  14174. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14175. /**
  14176. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14177. * @param localAxis The local direction that is used to compute the world direction
  14178. * @param mesh The mesh that this bone is attached to
  14179. * @param result The vector3 that the world direction will be copied to
  14180. */
  14181. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14182. /**
  14183. * Get the euler rotation of the bone in local or world space
  14184. * @param space The space that the rotation should be in
  14185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14186. * @returns The euler rotation
  14187. */
  14188. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14189. /**
  14190. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14191. * @param space The space that the rotation should be in
  14192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14193. * @param result The vector3 that the rotation should be copied to
  14194. */
  14195. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14196. /**
  14197. * Get the quaternion rotation of the bone in either local or world space
  14198. * @param space The space that the rotation should be in
  14199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14200. * @returns The quaternion rotation
  14201. */
  14202. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14203. /**
  14204. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14205. * @param space The space that the rotation should be in
  14206. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14207. * @param result The quaternion that the rotation should be copied to
  14208. */
  14209. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14210. /**
  14211. * Get the rotation matrix of the bone in local or world space
  14212. * @param space The space that the rotation should be in
  14213. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14214. * @returns The rotation matrix
  14215. */
  14216. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14217. /**
  14218. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14219. * @param space The space that the rotation should be in
  14220. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14221. * @param result The quaternion that the rotation should be copied to
  14222. */
  14223. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14224. /**
  14225. * Get the world position of a point that is in the local space of the bone
  14226. * @param position The local position
  14227. * @param mesh The mesh that this bone is attached to
  14228. * @returns The world position
  14229. */
  14230. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14231. /**
  14232. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14233. * @param position The local position
  14234. * @param mesh The mesh that this bone is attached to
  14235. * @param result The vector3 that the world position should be copied to
  14236. */
  14237. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14238. /**
  14239. * Get the local position of a point that is in world space
  14240. * @param position The world position
  14241. * @param mesh The mesh that this bone is attached to
  14242. * @returns The local position
  14243. */
  14244. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14245. /**
  14246. * Get the local position of a point that is in world space and copy it to the result param
  14247. * @param position The world position
  14248. * @param mesh The mesh that this bone is attached to
  14249. * @param result The vector3 that the local position should be copied to
  14250. */
  14251. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14252. }
  14253. }
  14254. declare module "babylonjs/Meshes/transformNode" {
  14255. import { DeepImmutable } from "babylonjs/types";
  14256. import { Observable } from "babylonjs/Misc/observable";
  14257. import { Nullable } from "babylonjs/types";
  14258. import { Camera } from "babylonjs/Cameras/camera";
  14259. import { Scene } from "babylonjs/scene";
  14260. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14261. import { Node } from "babylonjs/node";
  14262. import { Bone } from "babylonjs/Bones/bone";
  14263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14264. import { Space } from "babylonjs/Maths/math.axis";
  14265. /**
  14266. * 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.
  14267. * @see https://doc.babylonjs.com/how_to/transformnode
  14268. */
  14269. export class TransformNode extends Node {
  14270. /**
  14271. * Object will not rotate to face the camera
  14272. */
  14273. static BILLBOARDMODE_NONE: number;
  14274. /**
  14275. * Object will rotate to face the camera but only on the x axis
  14276. */
  14277. static BILLBOARDMODE_X: number;
  14278. /**
  14279. * Object will rotate to face the camera but only on the y axis
  14280. */
  14281. static BILLBOARDMODE_Y: number;
  14282. /**
  14283. * Object will rotate to face the camera but only on the z axis
  14284. */
  14285. static BILLBOARDMODE_Z: number;
  14286. /**
  14287. * Object will rotate to face the camera
  14288. */
  14289. static BILLBOARDMODE_ALL: number;
  14290. /**
  14291. * Object will rotate to face the camera's position instead of orientation
  14292. */
  14293. static BILLBOARDMODE_USE_POSITION: number;
  14294. private _forward;
  14295. private _forwardInverted;
  14296. private _up;
  14297. private _right;
  14298. private _rightInverted;
  14299. private _position;
  14300. private _rotation;
  14301. private _rotationQuaternion;
  14302. protected _scaling: Vector3;
  14303. protected _isDirty: boolean;
  14304. private _transformToBoneReferal;
  14305. private _isAbsoluteSynced;
  14306. private _billboardMode;
  14307. /**
  14308. * Gets or sets the billboard mode. Default is 0.
  14309. *
  14310. * | Value | Type | Description |
  14311. * | --- | --- | --- |
  14312. * | 0 | BILLBOARDMODE_NONE | |
  14313. * | 1 | BILLBOARDMODE_X | |
  14314. * | 2 | BILLBOARDMODE_Y | |
  14315. * | 4 | BILLBOARDMODE_Z | |
  14316. * | 7 | BILLBOARDMODE_ALL | |
  14317. *
  14318. */
  14319. billboardMode: number;
  14320. private _preserveParentRotationForBillboard;
  14321. /**
  14322. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14323. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14324. */
  14325. preserveParentRotationForBillboard: boolean;
  14326. /**
  14327. * 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
  14328. */
  14329. scalingDeterminant: number;
  14330. private _infiniteDistance;
  14331. /**
  14332. * Gets or sets the distance of the object to max, often used by skybox
  14333. */
  14334. infiniteDistance: boolean;
  14335. /**
  14336. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14337. * By default the system will update normals to compensate
  14338. */
  14339. ignoreNonUniformScaling: boolean;
  14340. /**
  14341. * 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
  14342. */
  14343. reIntegrateRotationIntoRotationQuaternion: boolean;
  14344. /** @hidden */
  14345. _poseMatrix: Nullable<Matrix>;
  14346. /** @hidden */
  14347. _localMatrix: Matrix;
  14348. private _usePivotMatrix;
  14349. private _absolutePosition;
  14350. private _absoluteScaling;
  14351. private _absoluteRotationQuaternion;
  14352. private _pivotMatrix;
  14353. private _pivotMatrixInverse;
  14354. protected _postMultiplyPivotMatrix: boolean;
  14355. protected _isWorldMatrixFrozen: boolean;
  14356. /** @hidden */
  14357. _indexInSceneTransformNodesArray: number;
  14358. /**
  14359. * An event triggered after the world matrix is updated
  14360. */
  14361. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14362. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14363. /**
  14364. * Gets a string identifying the name of the class
  14365. * @returns "TransformNode" string
  14366. */
  14367. getClassName(): string;
  14368. /**
  14369. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14370. */
  14371. position: Vector3;
  14372. /**
  14373. * 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)).
  14374. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14375. */
  14376. rotation: Vector3;
  14377. /**
  14378. * 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)).
  14379. */
  14380. scaling: Vector3;
  14381. /**
  14382. * 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).
  14383. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14384. */
  14385. rotationQuaternion: Nullable<Quaternion>;
  14386. /**
  14387. * The forward direction of that transform in world space.
  14388. */
  14389. readonly forward: Vector3;
  14390. /**
  14391. * The up direction of that transform in world space.
  14392. */
  14393. readonly up: Vector3;
  14394. /**
  14395. * The right direction of that transform in world space.
  14396. */
  14397. readonly right: Vector3;
  14398. /**
  14399. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14400. * @param matrix the matrix to copy the pose from
  14401. * @returns this TransformNode.
  14402. */
  14403. updatePoseMatrix(matrix: Matrix): TransformNode;
  14404. /**
  14405. * Returns the mesh Pose matrix.
  14406. * @returns the pose matrix
  14407. */
  14408. getPoseMatrix(): Matrix;
  14409. /** @hidden */
  14410. _isSynchronized(): boolean;
  14411. /** @hidden */
  14412. _initCache(): void;
  14413. /**
  14414. * Flag the transform node as dirty (Forcing it to update everything)
  14415. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14416. * @returns this transform node
  14417. */
  14418. markAsDirty(property: string): TransformNode;
  14419. /**
  14420. * Returns the current mesh absolute position.
  14421. * Returns a Vector3.
  14422. */
  14423. readonly absolutePosition: Vector3;
  14424. /**
  14425. * Returns the current mesh absolute scaling.
  14426. * Returns a Vector3.
  14427. */
  14428. readonly absoluteScaling: Vector3;
  14429. /**
  14430. * Returns the current mesh absolute rotation.
  14431. * Returns a Quaternion.
  14432. */
  14433. readonly absoluteRotationQuaternion: Quaternion;
  14434. /**
  14435. * Sets a new matrix to apply before all other transformation
  14436. * @param matrix defines the transform matrix
  14437. * @returns the current TransformNode
  14438. */
  14439. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14440. /**
  14441. * Sets a new pivot matrix to the current node
  14442. * @param matrix defines the new pivot matrix to use
  14443. * @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
  14444. * @returns the current TransformNode
  14445. */
  14446. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14447. /**
  14448. * Returns the mesh pivot matrix.
  14449. * Default : Identity.
  14450. * @returns the matrix
  14451. */
  14452. getPivotMatrix(): Matrix;
  14453. /**
  14454. * Instantiate (when possible) or clone that node with its hierarchy
  14455. * @param newParent defines the new parent to use for the instance (or clone)
  14456. * @param options defines options to configure how copy is done
  14457. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14458. * @returns an instance (or a clone) of the current node with its hiearchy
  14459. */
  14460. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14461. doNotInstantiate: boolean;
  14462. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14463. /**
  14464. * Prevents the World matrix to be computed any longer
  14465. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14466. * @returns the TransformNode.
  14467. */
  14468. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14469. /**
  14470. * Allows back the World matrix computation.
  14471. * @returns the TransformNode.
  14472. */
  14473. unfreezeWorldMatrix(): this;
  14474. /**
  14475. * True if the World matrix has been frozen.
  14476. */
  14477. readonly isWorldMatrixFrozen: boolean;
  14478. /**
  14479. * Retuns the mesh absolute position in the World.
  14480. * @returns a Vector3.
  14481. */
  14482. getAbsolutePosition(): Vector3;
  14483. /**
  14484. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14485. * @param absolutePosition the absolute position to set
  14486. * @returns the TransformNode.
  14487. */
  14488. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14489. /**
  14490. * Sets the mesh position in its local space.
  14491. * @param vector3 the position to set in localspace
  14492. * @returns the TransformNode.
  14493. */
  14494. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14495. /**
  14496. * Returns the mesh position in the local space from the current World matrix values.
  14497. * @returns a new Vector3.
  14498. */
  14499. getPositionExpressedInLocalSpace(): Vector3;
  14500. /**
  14501. * Translates the mesh along the passed Vector3 in its local space.
  14502. * @param vector3 the distance to translate in localspace
  14503. * @returns the TransformNode.
  14504. */
  14505. locallyTranslate(vector3: Vector3): TransformNode;
  14506. private static _lookAtVectorCache;
  14507. /**
  14508. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14509. * @param targetPoint the position (must be in same space as current mesh) to look at
  14510. * @param yawCor optional yaw (y-axis) correction in radians
  14511. * @param pitchCor optional pitch (x-axis) correction in radians
  14512. * @param rollCor optional roll (z-axis) correction in radians
  14513. * @param space the choosen space of the target
  14514. * @returns the TransformNode.
  14515. */
  14516. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14517. /**
  14518. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14519. * This Vector3 is expressed in the World space.
  14520. * @param localAxis axis to rotate
  14521. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14522. */
  14523. getDirection(localAxis: Vector3): Vector3;
  14524. /**
  14525. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14526. * localAxis is expressed in the mesh local space.
  14527. * result is computed in the Wordl space from the mesh World matrix.
  14528. * @param localAxis axis to rotate
  14529. * @param result the resulting transformnode
  14530. * @returns this TransformNode.
  14531. */
  14532. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14533. /**
  14534. * Sets this transform node rotation to the given local axis.
  14535. * @param localAxis the axis in local space
  14536. * @param yawCor optional yaw (y-axis) correction in radians
  14537. * @param pitchCor optional pitch (x-axis) correction in radians
  14538. * @param rollCor optional roll (z-axis) correction in radians
  14539. * @returns this TransformNode
  14540. */
  14541. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14542. /**
  14543. * Sets a new pivot point to the current node
  14544. * @param point defines the new pivot point to use
  14545. * @param space defines if the point is in world or local space (local by default)
  14546. * @returns the current TransformNode
  14547. */
  14548. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14549. /**
  14550. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14551. * @returns the pivot point
  14552. */
  14553. getPivotPoint(): Vector3;
  14554. /**
  14555. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14556. * @param result the vector3 to store the result
  14557. * @returns this TransformNode.
  14558. */
  14559. getPivotPointToRef(result: Vector3): TransformNode;
  14560. /**
  14561. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14562. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14563. */
  14564. getAbsolutePivotPoint(): Vector3;
  14565. /**
  14566. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14567. * @param result vector3 to store the result
  14568. * @returns this TransformNode.
  14569. */
  14570. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14571. /**
  14572. * Defines the passed node as the parent of the current node.
  14573. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14574. * @see https://doc.babylonjs.com/how_to/parenting
  14575. * @param node the node ot set as the parent
  14576. * @returns this TransformNode.
  14577. */
  14578. setParent(node: Nullable<Node>): TransformNode;
  14579. private _nonUniformScaling;
  14580. /**
  14581. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14582. */
  14583. readonly nonUniformScaling: boolean;
  14584. /** @hidden */
  14585. _updateNonUniformScalingState(value: boolean): boolean;
  14586. /**
  14587. * Attach the current TransformNode to another TransformNode associated with a bone
  14588. * @param bone Bone affecting the TransformNode
  14589. * @param affectedTransformNode TransformNode associated with the bone
  14590. * @returns this object
  14591. */
  14592. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14593. /**
  14594. * Detach the transform node if its associated with a bone
  14595. * @returns this object
  14596. */
  14597. detachFromBone(): TransformNode;
  14598. private static _rotationAxisCache;
  14599. /**
  14600. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14601. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14602. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14603. * The passed axis is also normalized.
  14604. * @param axis the axis to rotate around
  14605. * @param amount the amount to rotate in radians
  14606. * @param space Space to rotate in (Default: local)
  14607. * @returns the TransformNode.
  14608. */
  14609. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14610. /**
  14611. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14612. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14613. * The passed axis is also normalized. .
  14614. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14615. * @param point the point to rotate around
  14616. * @param axis the axis to rotate around
  14617. * @param amount the amount to rotate in radians
  14618. * @returns the TransformNode
  14619. */
  14620. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14621. /**
  14622. * Translates the mesh along the axis vector for the passed distance in the given space.
  14623. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14624. * @param axis the axis to translate in
  14625. * @param distance the distance to translate
  14626. * @param space Space to rotate in (Default: local)
  14627. * @returns the TransformNode.
  14628. */
  14629. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14630. /**
  14631. * Adds a rotation step to the mesh current rotation.
  14632. * x, y, z are Euler angles expressed in radians.
  14633. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14634. * This means this rotation is made in the mesh local space only.
  14635. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14636. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14637. * ```javascript
  14638. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14639. * ```
  14640. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14641. * 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.
  14642. * @param x Rotation to add
  14643. * @param y Rotation to add
  14644. * @param z Rotation to add
  14645. * @returns the TransformNode.
  14646. */
  14647. addRotation(x: number, y: number, z: number): TransformNode;
  14648. /**
  14649. * @hidden
  14650. */
  14651. protected _getEffectiveParent(): Nullable<Node>;
  14652. /**
  14653. * Computes the world matrix of the node
  14654. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14655. * @returns the world matrix
  14656. */
  14657. computeWorldMatrix(force?: boolean): Matrix;
  14658. protected _afterComputeWorldMatrix(): void;
  14659. /**
  14660. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14661. * @param func callback function to add
  14662. *
  14663. * @returns the TransformNode.
  14664. */
  14665. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14666. /**
  14667. * Removes a registered callback function.
  14668. * @param func callback function to remove
  14669. * @returns the TransformNode.
  14670. */
  14671. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14672. /**
  14673. * Gets the position of the current mesh in camera space
  14674. * @param camera defines the camera to use
  14675. * @returns a position
  14676. */
  14677. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14678. /**
  14679. * Returns the distance from the mesh to the active camera
  14680. * @param camera defines the camera to use
  14681. * @returns the distance
  14682. */
  14683. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14684. /**
  14685. * Clone the current transform node
  14686. * @param name Name of the new clone
  14687. * @param newParent New parent for the clone
  14688. * @param doNotCloneChildren Do not clone children hierarchy
  14689. * @returns the new transform node
  14690. */
  14691. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14692. /**
  14693. * Serializes the objects information.
  14694. * @param currentSerializationObject defines the object to serialize in
  14695. * @returns the serialized object
  14696. */
  14697. serialize(currentSerializationObject?: any): any;
  14698. /**
  14699. * Returns a new TransformNode object parsed from the source provided.
  14700. * @param parsedTransformNode is the source.
  14701. * @param scene the scne the object belongs to
  14702. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14703. * @returns a new TransformNode object parsed from the source provided.
  14704. */
  14705. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14706. /**
  14707. * Get all child-transformNodes of this node
  14708. * @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
  14709. * @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
  14710. * @returns an array of TransformNode
  14711. */
  14712. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14713. /**
  14714. * Releases resources associated with this transform node.
  14715. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14716. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14717. */
  14718. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14719. /**
  14720. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14721. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14722. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14723. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14724. * @returns the current mesh
  14725. */
  14726. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14727. private _syncAbsoluteScalingAndRotation;
  14728. }
  14729. }
  14730. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14731. import { Observable } from "babylonjs/Misc/observable";
  14732. import { Nullable } from "babylonjs/types";
  14733. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14734. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14736. import { Ray } from "babylonjs/Culling/ray";
  14737. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14738. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14739. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14740. /**
  14741. * Defines the types of pose enabled controllers that are supported
  14742. */
  14743. export enum PoseEnabledControllerType {
  14744. /**
  14745. * HTC Vive
  14746. */
  14747. VIVE = 0,
  14748. /**
  14749. * Oculus Rift
  14750. */
  14751. OCULUS = 1,
  14752. /**
  14753. * Windows mixed reality
  14754. */
  14755. WINDOWS = 2,
  14756. /**
  14757. * Samsung gear VR
  14758. */
  14759. GEAR_VR = 3,
  14760. /**
  14761. * Google Daydream
  14762. */
  14763. DAYDREAM = 4,
  14764. /**
  14765. * Generic
  14766. */
  14767. GENERIC = 5
  14768. }
  14769. /**
  14770. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14771. */
  14772. export interface MutableGamepadButton {
  14773. /**
  14774. * Value of the button/trigger
  14775. */
  14776. value: number;
  14777. /**
  14778. * If the button/trigger is currently touched
  14779. */
  14780. touched: boolean;
  14781. /**
  14782. * If the button/trigger is currently pressed
  14783. */
  14784. pressed: boolean;
  14785. }
  14786. /**
  14787. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14788. * @hidden
  14789. */
  14790. export interface ExtendedGamepadButton extends GamepadButton {
  14791. /**
  14792. * If the button/trigger is currently pressed
  14793. */
  14794. readonly pressed: boolean;
  14795. /**
  14796. * If the button/trigger is currently touched
  14797. */
  14798. readonly touched: boolean;
  14799. /**
  14800. * Value of the button/trigger
  14801. */
  14802. readonly value: number;
  14803. }
  14804. /** @hidden */
  14805. export interface _GamePadFactory {
  14806. /**
  14807. * Returns wether or not the current gamepad can be created for this type of controller.
  14808. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14809. * @returns true if it can be created, otherwise false
  14810. */
  14811. canCreate(gamepadInfo: any): boolean;
  14812. /**
  14813. * Creates a new instance of the Gamepad.
  14814. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14815. * @returns the new gamepad instance
  14816. */
  14817. create(gamepadInfo: any): Gamepad;
  14818. }
  14819. /**
  14820. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14821. */
  14822. export class PoseEnabledControllerHelper {
  14823. /** @hidden */
  14824. static _ControllerFactories: _GamePadFactory[];
  14825. /** @hidden */
  14826. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14827. /**
  14828. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14829. * @param vrGamepad the gamepad to initialized
  14830. * @returns a vr controller of the type the gamepad identified as
  14831. */
  14832. static InitiateController(vrGamepad: any): Gamepad;
  14833. }
  14834. /**
  14835. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14836. */
  14837. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14838. /**
  14839. * If the controller is used in a webXR session
  14840. */
  14841. isXR: boolean;
  14842. private _deviceRoomPosition;
  14843. private _deviceRoomRotationQuaternion;
  14844. /**
  14845. * The device position in babylon space
  14846. */
  14847. devicePosition: Vector3;
  14848. /**
  14849. * The device rotation in babylon space
  14850. */
  14851. deviceRotationQuaternion: Quaternion;
  14852. /**
  14853. * The scale factor of the device in babylon space
  14854. */
  14855. deviceScaleFactor: number;
  14856. /**
  14857. * (Likely devicePosition should be used instead) The device position in its room space
  14858. */
  14859. position: Vector3;
  14860. /**
  14861. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14862. */
  14863. rotationQuaternion: Quaternion;
  14864. /**
  14865. * The type of controller (Eg. Windows mixed reality)
  14866. */
  14867. controllerType: PoseEnabledControllerType;
  14868. protected _calculatedPosition: Vector3;
  14869. private _calculatedRotation;
  14870. /**
  14871. * The raw pose from the device
  14872. */
  14873. rawPose: DevicePose;
  14874. private _trackPosition;
  14875. private _maxRotationDistFromHeadset;
  14876. private _draggedRoomRotation;
  14877. /**
  14878. * @hidden
  14879. */
  14880. _disableTrackPosition(fixedPosition: Vector3): void;
  14881. /**
  14882. * Internal, the mesh attached to the controller
  14883. * @hidden
  14884. */
  14885. _mesh: Nullable<AbstractMesh>;
  14886. private _poseControlledCamera;
  14887. private _leftHandSystemQuaternion;
  14888. /**
  14889. * Internal, matrix used to convert room space to babylon space
  14890. * @hidden
  14891. */
  14892. _deviceToWorld: Matrix;
  14893. /**
  14894. * Node to be used when casting a ray from the controller
  14895. * @hidden
  14896. */
  14897. _pointingPoseNode: Nullable<TransformNode>;
  14898. /**
  14899. * Name of the child mesh that can be used to cast a ray from the controller
  14900. */
  14901. static readonly POINTING_POSE: string;
  14902. /**
  14903. * Creates a new PoseEnabledController from a gamepad
  14904. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14905. */
  14906. constructor(browserGamepad: any);
  14907. private _workingMatrix;
  14908. /**
  14909. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14910. */
  14911. update(): void;
  14912. /**
  14913. * Updates only the pose device and mesh without doing any button event checking
  14914. */
  14915. protected _updatePoseAndMesh(): void;
  14916. /**
  14917. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14918. * @param poseData raw pose fromthe device
  14919. */
  14920. updateFromDevice(poseData: DevicePose): void;
  14921. /**
  14922. * @hidden
  14923. */
  14924. _meshAttachedObservable: Observable<AbstractMesh>;
  14925. /**
  14926. * Attaches a mesh to the controller
  14927. * @param mesh the mesh to be attached
  14928. */
  14929. attachToMesh(mesh: AbstractMesh): void;
  14930. /**
  14931. * Attaches the controllers mesh to a camera
  14932. * @param camera the camera the mesh should be attached to
  14933. */
  14934. attachToPoseControlledCamera(camera: TargetCamera): void;
  14935. /**
  14936. * Disposes of the controller
  14937. */
  14938. dispose(): void;
  14939. /**
  14940. * The mesh that is attached to the controller
  14941. */
  14942. readonly mesh: Nullable<AbstractMesh>;
  14943. /**
  14944. * Gets the ray of the controller in the direction the controller is pointing
  14945. * @param length the length the resulting ray should be
  14946. * @returns a ray in the direction the controller is pointing
  14947. */
  14948. getForwardRay(length?: number): Ray;
  14949. }
  14950. }
  14951. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14952. import { Observable } from "babylonjs/Misc/observable";
  14953. import { Scene } from "babylonjs/scene";
  14954. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14955. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14956. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14957. import { Nullable } from "babylonjs/types";
  14958. /**
  14959. * Defines the WebVRController object that represents controllers tracked in 3D space
  14960. */
  14961. export abstract class WebVRController extends PoseEnabledController {
  14962. /**
  14963. * Internal, the default controller model for the controller
  14964. */
  14965. protected _defaultModel: Nullable<AbstractMesh>;
  14966. /**
  14967. * Fired when the trigger state has changed
  14968. */
  14969. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14970. /**
  14971. * Fired when the main button state has changed
  14972. */
  14973. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14974. /**
  14975. * Fired when the secondary button state has changed
  14976. */
  14977. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14978. /**
  14979. * Fired when the pad state has changed
  14980. */
  14981. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14982. /**
  14983. * Fired when controllers stick values have changed
  14984. */
  14985. onPadValuesChangedObservable: Observable<StickValues>;
  14986. /**
  14987. * Array of button availible on the controller
  14988. */
  14989. protected _buttons: Array<MutableGamepadButton>;
  14990. private _onButtonStateChange;
  14991. /**
  14992. * Fired when a controller button's state has changed
  14993. * @param callback the callback containing the button that was modified
  14994. */
  14995. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14996. /**
  14997. * X and Y axis corresponding to the controllers joystick
  14998. */
  14999. pad: StickValues;
  15000. /**
  15001. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  15002. */
  15003. hand: string;
  15004. /**
  15005. * The default controller model for the controller
  15006. */
  15007. readonly defaultModel: Nullable<AbstractMesh>;
  15008. /**
  15009. * Creates a new WebVRController from a gamepad
  15010. * @param vrGamepad the gamepad that the WebVRController should be created from
  15011. */
  15012. constructor(vrGamepad: any);
  15013. /**
  15014. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  15015. */
  15016. update(): void;
  15017. /**
  15018. * Function to be called when a button is modified
  15019. */
  15020. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  15021. /**
  15022. * Loads a mesh and attaches it to the controller
  15023. * @param scene the scene the mesh should be added to
  15024. * @param meshLoaded callback for when the mesh has been loaded
  15025. */
  15026. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15027. private _setButtonValue;
  15028. private _changes;
  15029. private _checkChanges;
  15030. /**
  15031. * Disposes of th webVRCOntroller
  15032. */
  15033. dispose(): void;
  15034. }
  15035. }
  15036. declare module "babylonjs/Lights/hemisphericLight" {
  15037. import { Nullable } from "babylonjs/types";
  15038. import { Scene } from "babylonjs/scene";
  15039. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15040. import { Color3 } from "babylonjs/Maths/math.color";
  15041. import { Effect } from "babylonjs/Materials/effect";
  15042. import { Light } from "babylonjs/Lights/light";
  15043. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15044. /**
  15045. * The HemisphericLight simulates the ambient environment light,
  15046. * so the passed direction is the light reflection direction, not the incoming direction.
  15047. */
  15048. export class HemisphericLight extends Light {
  15049. /**
  15050. * The groundColor is the light in the opposite direction to the one specified during creation.
  15051. * 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.
  15052. */
  15053. groundColor: Color3;
  15054. /**
  15055. * The light reflection direction, not the incoming direction.
  15056. */
  15057. direction: Vector3;
  15058. /**
  15059. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15060. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15061. * The HemisphericLight can't cast shadows.
  15062. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15063. * @param name The friendly name of the light
  15064. * @param direction The direction of the light reflection
  15065. * @param scene The scene the light belongs to
  15066. */
  15067. constructor(name: string, direction: Vector3, scene: Scene);
  15068. protected _buildUniformLayout(): void;
  15069. /**
  15070. * Returns the string "HemisphericLight".
  15071. * @return The class name
  15072. */
  15073. getClassName(): string;
  15074. /**
  15075. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15076. * Returns the updated direction.
  15077. * @param target The target the direction should point to
  15078. * @return The computed direction
  15079. */
  15080. setDirectionToTarget(target: Vector3): Vector3;
  15081. /**
  15082. * Returns the shadow generator associated to the light.
  15083. * @returns Always null for hemispheric lights because it does not support shadows.
  15084. */
  15085. getShadowGenerator(): Nullable<IShadowGenerator>;
  15086. /**
  15087. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15088. * @param effect The effect to update
  15089. * @param lightIndex The index of the light in the effect to update
  15090. * @returns The hemispheric light
  15091. */
  15092. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15093. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15094. /**
  15095. * Computes the world matrix of the node
  15096. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15097. * @param useWasUpdatedFlag defines a reserved property
  15098. * @returns the world matrix
  15099. */
  15100. computeWorldMatrix(): Matrix;
  15101. /**
  15102. * Returns the integer 3.
  15103. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15104. */
  15105. getTypeID(): number;
  15106. /**
  15107. * Prepares the list of defines specific to the light type.
  15108. * @param defines the list of defines
  15109. * @param lightIndex defines the index of the light for the effect
  15110. */
  15111. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15112. }
  15113. }
  15114. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15115. /** @hidden */
  15116. export var vrMultiviewToSingleviewPixelShader: {
  15117. name: string;
  15118. shader: string;
  15119. };
  15120. }
  15121. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15122. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15123. import { Scene } from "babylonjs/scene";
  15124. /**
  15125. * Renders to multiple views with a single draw call
  15126. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15127. */
  15128. export class MultiviewRenderTarget extends RenderTargetTexture {
  15129. /**
  15130. * Creates a multiview render target
  15131. * @param scene scene used with the render target
  15132. * @param size the size of the render target (used for each view)
  15133. */
  15134. constructor(scene: Scene, size?: number | {
  15135. width: number;
  15136. height: number;
  15137. } | {
  15138. ratio: number;
  15139. });
  15140. /**
  15141. * @hidden
  15142. * @param faceIndex the face index, if its a cube texture
  15143. */
  15144. _bindFrameBuffer(faceIndex?: number): void;
  15145. /**
  15146. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15147. * @returns the view count
  15148. */
  15149. getViewCount(): number;
  15150. }
  15151. }
  15152. declare module "babylonjs/Maths/math.frustum" {
  15153. import { Matrix } from "babylonjs/Maths/math.vector";
  15154. import { DeepImmutable } from "babylonjs/types";
  15155. import { Plane } from "babylonjs/Maths/math.plane";
  15156. /**
  15157. * Represents a camera frustum
  15158. */
  15159. export class Frustum {
  15160. /**
  15161. * Gets the planes representing the frustum
  15162. * @param transform matrix to be applied to the returned planes
  15163. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15164. */
  15165. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15166. /**
  15167. * Gets the near frustum plane transformed by the transform matrix
  15168. * @param transform transformation matrix to be applied to the resulting frustum plane
  15169. * @param frustumPlane the resuling frustum plane
  15170. */
  15171. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15172. /**
  15173. * Gets the far frustum plane transformed by the transform matrix
  15174. * @param transform transformation matrix to be applied to the resulting frustum plane
  15175. * @param frustumPlane the resuling frustum plane
  15176. */
  15177. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15178. /**
  15179. * Gets the left frustum plane transformed by the transform matrix
  15180. * @param transform transformation matrix to be applied to the resulting frustum plane
  15181. * @param frustumPlane the resuling frustum plane
  15182. */
  15183. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15184. /**
  15185. * Gets the right frustum plane transformed by the transform matrix
  15186. * @param transform transformation matrix to be applied to the resulting frustum plane
  15187. * @param frustumPlane the resuling frustum plane
  15188. */
  15189. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15190. /**
  15191. * Gets the top frustum plane transformed by the transform matrix
  15192. * @param transform transformation matrix to be applied to the resulting frustum plane
  15193. * @param frustumPlane the resuling frustum plane
  15194. */
  15195. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15196. /**
  15197. * Gets the bottom frustum plane transformed by the transform matrix
  15198. * @param transform transformation matrix to be applied to the resulting frustum plane
  15199. * @param frustumPlane the resuling frustum plane
  15200. */
  15201. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15202. /**
  15203. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15204. * @param transform transformation matrix to be applied to the resulting frustum planes
  15205. * @param frustumPlanes the resuling frustum planes
  15206. */
  15207. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15208. }
  15209. }
  15210. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15211. import { Camera } from "babylonjs/Cameras/camera";
  15212. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15213. import { Nullable } from "babylonjs/types";
  15214. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15215. import { Matrix } from "babylonjs/Maths/math.vector";
  15216. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15217. module "babylonjs/Engines/engine" {
  15218. interface Engine {
  15219. /**
  15220. * Creates a new multiview render target
  15221. * @param width defines the width of the texture
  15222. * @param height defines the height of the texture
  15223. * @returns the created multiview texture
  15224. */
  15225. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15226. /**
  15227. * Binds a multiview framebuffer to be drawn to
  15228. * @param multiviewTexture texture to bind
  15229. */
  15230. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15231. }
  15232. }
  15233. module "babylonjs/Cameras/camera" {
  15234. interface Camera {
  15235. /**
  15236. * @hidden
  15237. * 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)
  15238. */
  15239. _useMultiviewToSingleView: boolean;
  15240. /**
  15241. * @hidden
  15242. * 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)
  15243. */
  15244. _multiviewTexture: Nullable<RenderTargetTexture>;
  15245. /**
  15246. * @hidden
  15247. * ensures the multiview texture of the camera exists and has the specified width/height
  15248. * @param width height to set on the multiview texture
  15249. * @param height width to set on the multiview texture
  15250. */
  15251. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15252. }
  15253. }
  15254. module "babylonjs/scene" {
  15255. interface Scene {
  15256. /** @hidden */
  15257. _transformMatrixR: Matrix;
  15258. /** @hidden */
  15259. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15260. /** @hidden */
  15261. _createMultiviewUbo(): void;
  15262. /** @hidden */
  15263. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15264. /** @hidden */
  15265. _renderMultiviewToSingleView(camera: Camera): void;
  15266. }
  15267. }
  15268. }
  15269. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15270. import { Camera } from "babylonjs/Cameras/camera";
  15271. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15272. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15273. import "babylonjs/Engines/Extensions/engine.multiview";
  15274. /**
  15275. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15276. * This will not be used for webXR as it supports displaying texture arrays directly
  15277. */
  15278. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15279. /**
  15280. * Initializes a VRMultiviewToSingleview
  15281. * @param name name of the post process
  15282. * @param camera camera to be applied to
  15283. * @param scaleFactor scaling factor to the size of the output texture
  15284. */
  15285. constructor(name: string, camera: Camera, scaleFactor: number);
  15286. }
  15287. }
  15288. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15289. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15290. import { Nullable } from "babylonjs/types";
  15291. import { Size } from "babylonjs/Maths/math.size";
  15292. import { Observable } from "babylonjs/Misc/observable";
  15293. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15294. /**
  15295. * Interface used to define additional presentation attributes
  15296. */
  15297. export interface IVRPresentationAttributes {
  15298. /**
  15299. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15300. */
  15301. highRefreshRate: boolean;
  15302. /**
  15303. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15304. */
  15305. foveationLevel: number;
  15306. }
  15307. module "babylonjs/Engines/engine" {
  15308. interface Engine {
  15309. /** @hidden */
  15310. _vrDisplay: any;
  15311. /** @hidden */
  15312. _vrSupported: boolean;
  15313. /** @hidden */
  15314. _oldSize: Size;
  15315. /** @hidden */
  15316. _oldHardwareScaleFactor: number;
  15317. /** @hidden */
  15318. _vrExclusivePointerMode: boolean;
  15319. /** @hidden */
  15320. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15321. /** @hidden */
  15322. _onVRDisplayPointerRestricted: () => void;
  15323. /** @hidden */
  15324. _onVRDisplayPointerUnrestricted: () => void;
  15325. /** @hidden */
  15326. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15327. /** @hidden */
  15328. _onVrDisplayDisconnect: Nullable<() => void>;
  15329. /** @hidden */
  15330. _onVrDisplayPresentChange: Nullable<() => void>;
  15331. /**
  15332. * Observable signaled when VR display mode changes
  15333. */
  15334. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15335. /**
  15336. * Observable signaled when VR request present is complete
  15337. */
  15338. onVRRequestPresentComplete: Observable<boolean>;
  15339. /**
  15340. * Observable signaled when VR request present starts
  15341. */
  15342. onVRRequestPresentStart: Observable<Engine>;
  15343. /**
  15344. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15345. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15346. */
  15347. isInVRExclusivePointerMode: boolean;
  15348. /**
  15349. * Gets a boolean indicating if a webVR device was detected
  15350. * @returns true if a webVR device was detected
  15351. */
  15352. isVRDevicePresent(): boolean;
  15353. /**
  15354. * Gets the current webVR device
  15355. * @returns the current webVR device (or null)
  15356. */
  15357. getVRDevice(): any;
  15358. /**
  15359. * Initializes a webVR display and starts listening to display change events
  15360. * The onVRDisplayChangedObservable will be notified upon these changes
  15361. * @returns A promise containing a VRDisplay and if vr is supported
  15362. */
  15363. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15364. /** @hidden */
  15365. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15366. /**
  15367. * Gets or sets the presentation attributes used to configure VR rendering
  15368. */
  15369. vrPresentationAttributes?: IVRPresentationAttributes;
  15370. /**
  15371. * Call this function to switch to webVR mode
  15372. * Will do nothing if webVR is not supported or if there is no webVR device
  15373. * @param options the webvr options provided to the camera. mainly used for multiview
  15374. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15375. */
  15376. enableVR(options: WebVROptions): void;
  15377. /** @hidden */
  15378. _onVRFullScreenTriggered(): void;
  15379. }
  15380. }
  15381. }
  15382. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15383. import { Nullable } from "babylonjs/types";
  15384. import { Observable } from "babylonjs/Misc/observable";
  15385. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15386. import { Scene } from "babylonjs/scene";
  15387. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15388. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15389. import { Node } from "babylonjs/node";
  15390. import { Ray } from "babylonjs/Culling/ray";
  15391. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15392. import "babylonjs/Engines/Extensions/engine.webVR";
  15393. /**
  15394. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15395. * IMPORTANT!! The data is right-hand data.
  15396. * @export
  15397. * @interface DevicePose
  15398. */
  15399. export interface DevicePose {
  15400. /**
  15401. * The position of the device, values in array are [x,y,z].
  15402. */
  15403. readonly position: Nullable<Float32Array>;
  15404. /**
  15405. * The linearVelocity of the device, values in array are [x,y,z].
  15406. */
  15407. readonly linearVelocity: Nullable<Float32Array>;
  15408. /**
  15409. * The linearAcceleration of the device, values in array are [x,y,z].
  15410. */
  15411. readonly linearAcceleration: Nullable<Float32Array>;
  15412. /**
  15413. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15414. */
  15415. readonly orientation: Nullable<Float32Array>;
  15416. /**
  15417. * The angularVelocity of the device, values in array are [x,y,z].
  15418. */
  15419. readonly angularVelocity: Nullable<Float32Array>;
  15420. /**
  15421. * The angularAcceleration of the device, values in array are [x,y,z].
  15422. */
  15423. readonly angularAcceleration: Nullable<Float32Array>;
  15424. }
  15425. /**
  15426. * Interface representing a pose controlled object in Babylon.
  15427. * A pose controlled object has both regular pose values as well as pose values
  15428. * from an external device such as a VR head mounted display
  15429. */
  15430. export interface PoseControlled {
  15431. /**
  15432. * The position of the object in babylon space.
  15433. */
  15434. position: Vector3;
  15435. /**
  15436. * The rotation quaternion of the object in babylon space.
  15437. */
  15438. rotationQuaternion: Quaternion;
  15439. /**
  15440. * The position of the device in babylon space.
  15441. */
  15442. devicePosition?: Vector3;
  15443. /**
  15444. * The rotation quaternion of the device in babylon space.
  15445. */
  15446. deviceRotationQuaternion: Quaternion;
  15447. /**
  15448. * The raw pose coming from the device.
  15449. */
  15450. rawPose: Nullable<DevicePose>;
  15451. /**
  15452. * The scale of the device to be used when translating from device space to babylon space.
  15453. */
  15454. deviceScaleFactor: number;
  15455. /**
  15456. * Updates the poseControlled values based on the input device pose.
  15457. * @param poseData the pose data to update the object with
  15458. */
  15459. updateFromDevice(poseData: DevicePose): void;
  15460. }
  15461. /**
  15462. * Set of options to customize the webVRCamera
  15463. */
  15464. export interface WebVROptions {
  15465. /**
  15466. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15467. */
  15468. trackPosition?: boolean;
  15469. /**
  15470. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15471. */
  15472. positionScale?: number;
  15473. /**
  15474. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15475. */
  15476. displayName?: string;
  15477. /**
  15478. * Should the native controller meshes be initialized. (default: true)
  15479. */
  15480. controllerMeshes?: boolean;
  15481. /**
  15482. * Creating a default HemiLight only on controllers. (default: true)
  15483. */
  15484. defaultLightingOnControllers?: boolean;
  15485. /**
  15486. * If you don't want to use the default VR button of the helper. (default: false)
  15487. */
  15488. useCustomVRButton?: boolean;
  15489. /**
  15490. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15491. */
  15492. customVRButton?: HTMLButtonElement;
  15493. /**
  15494. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15495. */
  15496. rayLength?: number;
  15497. /**
  15498. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15499. */
  15500. defaultHeight?: number;
  15501. /**
  15502. * If multiview should be used if availible (default: false)
  15503. */
  15504. useMultiview?: boolean;
  15505. }
  15506. /**
  15507. * This represents a WebVR camera.
  15508. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15509. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15510. */
  15511. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15512. private webVROptions;
  15513. /**
  15514. * @hidden
  15515. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15516. */
  15517. _vrDevice: any;
  15518. /**
  15519. * The rawPose of the vrDevice.
  15520. */
  15521. rawPose: Nullable<DevicePose>;
  15522. private _onVREnabled;
  15523. private _specsVersion;
  15524. private _attached;
  15525. private _frameData;
  15526. protected _descendants: Array<Node>;
  15527. private _deviceRoomPosition;
  15528. /** @hidden */
  15529. _deviceRoomRotationQuaternion: Quaternion;
  15530. private _standingMatrix;
  15531. /**
  15532. * Represents device position in babylon space.
  15533. */
  15534. devicePosition: Vector3;
  15535. /**
  15536. * Represents device rotation in babylon space.
  15537. */
  15538. deviceRotationQuaternion: Quaternion;
  15539. /**
  15540. * The scale of the device to be used when translating from device space to babylon space.
  15541. */
  15542. deviceScaleFactor: number;
  15543. private _deviceToWorld;
  15544. private _worldToDevice;
  15545. /**
  15546. * References to the webVR controllers for the vrDevice.
  15547. */
  15548. controllers: Array<WebVRController>;
  15549. /**
  15550. * Emits an event when a controller is attached.
  15551. */
  15552. onControllersAttachedObservable: Observable<WebVRController[]>;
  15553. /**
  15554. * Emits an event when a controller's mesh has been loaded;
  15555. */
  15556. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15557. /**
  15558. * Emits an event when the HMD's pose has been updated.
  15559. */
  15560. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15561. private _poseSet;
  15562. /**
  15563. * If the rig cameras be used as parent instead of this camera.
  15564. */
  15565. rigParenting: boolean;
  15566. private _lightOnControllers;
  15567. private _defaultHeight?;
  15568. /**
  15569. * Instantiates a WebVRFreeCamera.
  15570. * @param name The name of the WebVRFreeCamera
  15571. * @param position The starting anchor position for the camera
  15572. * @param scene The scene the camera belongs to
  15573. * @param webVROptions a set of customizable options for the webVRCamera
  15574. */
  15575. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15576. /**
  15577. * Gets the device distance from the ground in meters.
  15578. * @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.
  15579. */
  15580. deviceDistanceToRoomGround(): number;
  15581. /**
  15582. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15583. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15584. */
  15585. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15586. /**
  15587. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15588. * @returns A promise with a boolean set to if the standing matrix is supported.
  15589. */
  15590. useStandingMatrixAsync(): Promise<boolean>;
  15591. /**
  15592. * Disposes the camera
  15593. */
  15594. dispose(): void;
  15595. /**
  15596. * Gets a vrController by name.
  15597. * @param name The name of the controller to retreive
  15598. * @returns the controller matching the name specified or null if not found
  15599. */
  15600. getControllerByName(name: string): Nullable<WebVRController>;
  15601. private _leftController;
  15602. /**
  15603. * The controller corresponding to the users left hand.
  15604. */
  15605. readonly leftController: Nullable<WebVRController>;
  15606. private _rightController;
  15607. /**
  15608. * The controller corresponding to the users right hand.
  15609. */
  15610. readonly rightController: Nullable<WebVRController>;
  15611. /**
  15612. * Casts a ray forward from the vrCamera's gaze.
  15613. * @param length Length of the ray (default: 100)
  15614. * @returns the ray corresponding to the gaze
  15615. */
  15616. getForwardRay(length?: number): Ray;
  15617. /**
  15618. * @hidden
  15619. * Updates the camera based on device's frame data
  15620. */
  15621. _checkInputs(): void;
  15622. /**
  15623. * Updates the poseControlled values based on the input device pose.
  15624. * @param poseData Pose coming from the device
  15625. */
  15626. updateFromDevice(poseData: DevicePose): void;
  15627. private _htmlElementAttached;
  15628. private _detachIfAttached;
  15629. /**
  15630. * WebVR's attach control will start broadcasting frames to the device.
  15631. * Note that in certain browsers (chrome for example) this function must be called
  15632. * within a user-interaction callback. Example:
  15633. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15634. *
  15635. * @param element html element to attach the vrDevice to
  15636. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15637. */
  15638. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15639. /**
  15640. * Detaches the camera from the html element and disables VR
  15641. *
  15642. * @param element html element to detach from
  15643. */
  15644. detachControl(element: HTMLElement): void;
  15645. /**
  15646. * @returns the name of this class
  15647. */
  15648. getClassName(): string;
  15649. /**
  15650. * Calls resetPose on the vrDisplay
  15651. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15652. */
  15653. resetToCurrentRotation(): void;
  15654. /**
  15655. * @hidden
  15656. * Updates the rig cameras (left and right eye)
  15657. */
  15658. _updateRigCameras(): void;
  15659. private _workingVector;
  15660. private _oneVector;
  15661. private _workingMatrix;
  15662. private updateCacheCalled;
  15663. private _correctPositionIfNotTrackPosition;
  15664. /**
  15665. * @hidden
  15666. * Updates the cached values of the camera
  15667. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15668. */
  15669. _updateCache(ignoreParentClass?: boolean): void;
  15670. /**
  15671. * @hidden
  15672. * Get current device position in babylon world
  15673. */
  15674. _computeDevicePosition(): void;
  15675. /**
  15676. * Updates the current device position and rotation in the babylon world
  15677. */
  15678. update(): void;
  15679. /**
  15680. * @hidden
  15681. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15682. * @returns an identity matrix
  15683. */
  15684. _getViewMatrix(): Matrix;
  15685. private _tmpMatrix;
  15686. /**
  15687. * This function is called by the two RIG cameras.
  15688. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15689. * @hidden
  15690. */
  15691. _getWebVRViewMatrix(): Matrix;
  15692. /** @hidden */
  15693. _getWebVRProjectionMatrix(): Matrix;
  15694. private _onGamepadConnectedObserver;
  15695. private _onGamepadDisconnectedObserver;
  15696. private _updateCacheWhenTrackingDisabledObserver;
  15697. /**
  15698. * Initializes the controllers and their meshes
  15699. */
  15700. initControllers(): void;
  15701. }
  15702. }
  15703. declare module "babylonjs/PostProcesses/postProcess" {
  15704. import { Nullable } from "babylonjs/types";
  15705. import { SmartArray } from "babylonjs/Misc/smartArray";
  15706. import { Observable } from "babylonjs/Misc/observable";
  15707. import { Vector2 } from "babylonjs/Maths/math.vector";
  15708. import { Camera } from "babylonjs/Cameras/camera";
  15709. import { Effect } from "babylonjs/Materials/effect";
  15710. import "babylonjs/Shaders/postprocess.vertex";
  15711. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15712. import { Engine } from "babylonjs/Engines/engine";
  15713. import { Color4 } from "babylonjs/Maths/math.color";
  15714. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15715. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15716. /**
  15717. * Size options for a post process
  15718. */
  15719. export type PostProcessOptions = {
  15720. width: number;
  15721. height: number;
  15722. };
  15723. /**
  15724. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15725. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15726. */
  15727. export class PostProcess {
  15728. /** Name of the PostProcess. */
  15729. name: string;
  15730. /**
  15731. * Gets or sets the unique id of the post process
  15732. */
  15733. uniqueId: number;
  15734. /**
  15735. * Width of the texture to apply the post process on
  15736. */
  15737. width: number;
  15738. /**
  15739. * Height of the texture to apply the post process on
  15740. */
  15741. height: number;
  15742. /**
  15743. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15744. * @hidden
  15745. */
  15746. _outputTexture: Nullable<InternalTexture>;
  15747. /**
  15748. * Sampling mode used by the shader
  15749. * See https://doc.babylonjs.com/classes/3.1/texture
  15750. */
  15751. renderTargetSamplingMode: number;
  15752. /**
  15753. * Clear color to use when screen clearing
  15754. */
  15755. clearColor: Color4;
  15756. /**
  15757. * If the buffer needs to be cleared before applying the post process. (default: true)
  15758. * Should be set to false if shader will overwrite all previous pixels.
  15759. */
  15760. autoClear: boolean;
  15761. /**
  15762. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15763. */
  15764. alphaMode: number;
  15765. /**
  15766. * Sets the setAlphaBlendConstants of the babylon engine
  15767. */
  15768. alphaConstants: Color4;
  15769. /**
  15770. * Animations to be used for the post processing
  15771. */
  15772. animations: import("babylonjs/Animations/animation").Animation[];
  15773. /**
  15774. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15775. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15776. */
  15777. enablePixelPerfectMode: boolean;
  15778. /**
  15779. * Force the postprocess to be applied without taking in account viewport
  15780. */
  15781. forceFullscreenViewport: boolean;
  15782. /**
  15783. * List of inspectable custom properties (used by the Inspector)
  15784. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15785. */
  15786. inspectableCustomProperties: IInspectable[];
  15787. /**
  15788. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15789. *
  15790. * | Value | Type | Description |
  15791. * | ----- | ----------------------------------- | ----------- |
  15792. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15793. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15794. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15795. *
  15796. */
  15797. scaleMode: number;
  15798. /**
  15799. * Force textures to be a power of two (default: false)
  15800. */
  15801. alwaysForcePOT: boolean;
  15802. private _samples;
  15803. /**
  15804. * Number of sample textures (default: 1)
  15805. */
  15806. samples: number;
  15807. /**
  15808. * Modify the scale of the post process to be the same as the viewport (default: false)
  15809. */
  15810. adaptScaleToCurrentViewport: boolean;
  15811. private _camera;
  15812. private _scene;
  15813. private _engine;
  15814. private _options;
  15815. private _reusable;
  15816. private _textureType;
  15817. /**
  15818. * Smart array of input and output textures for the post process.
  15819. * @hidden
  15820. */
  15821. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15822. /**
  15823. * The index in _textures that corresponds to the output texture.
  15824. * @hidden
  15825. */
  15826. _currentRenderTextureInd: number;
  15827. private _effect;
  15828. private _samplers;
  15829. private _fragmentUrl;
  15830. private _vertexUrl;
  15831. private _parameters;
  15832. private _scaleRatio;
  15833. protected _indexParameters: any;
  15834. private _shareOutputWithPostProcess;
  15835. private _texelSize;
  15836. private _forcedOutputTexture;
  15837. /**
  15838. * Returns the fragment url or shader name used in the post process.
  15839. * @returns the fragment url or name in the shader store.
  15840. */
  15841. getEffectName(): string;
  15842. /**
  15843. * An event triggered when the postprocess is activated.
  15844. */
  15845. onActivateObservable: Observable<Camera>;
  15846. private _onActivateObserver;
  15847. /**
  15848. * A function that is added to the onActivateObservable
  15849. */
  15850. onActivate: Nullable<(camera: Camera) => void>;
  15851. /**
  15852. * An event triggered when the postprocess changes its size.
  15853. */
  15854. onSizeChangedObservable: Observable<PostProcess>;
  15855. private _onSizeChangedObserver;
  15856. /**
  15857. * A function that is added to the onSizeChangedObservable
  15858. */
  15859. onSizeChanged: (postProcess: PostProcess) => void;
  15860. /**
  15861. * An event triggered when the postprocess applies its effect.
  15862. */
  15863. onApplyObservable: Observable<Effect>;
  15864. private _onApplyObserver;
  15865. /**
  15866. * A function that is added to the onApplyObservable
  15867. */
  15868. onApply: (effect: Effect) => void;
  15869. /**
  15870. * An event triggered before rendering the postprocess
  15871. */
  15872. onBeforeRenderObservable: Observable<Effect>;
  15873. private _onBeforeRenderObserver;
  15874. /**
  15875. * A function that is added to the onBeforeRenderObservable
  15876. */
  15877. onBeforeRender: (effect: Effect) => void;
  15878. /**
  15879. * An event triggered after rendering the postprocess
  15880. */
  15881. onAfterRenderObservable: Observable<Effect>;
  15882. private _onAfterRenderObserver;
  15883. /**
  15884. * A function that is added to the onAfterRenderObservable
  15885. */
  15886. onAfterRender: (efect: Effect) => void;
  15887. /**
  15888. * 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
  15889. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15890. */
  15891. inputTexture: InternalTexture;
  15892. /**
  15893. * Gets the camera which post process is applied to.
  15894. * @returns The camera the post process is applied to.
  15895. */
  15896. getCamera(): Camera;
  15897. /**
  15898. * Gets the texel size of the postprocess.
  15899. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15900. */
  15901. readonly texelSize: Vector2;
  15902. /**
  15903. * Creates a new instance PostProcess
  15904. * @param name The name of the PostProcess.
  15905. * @param fragmentUrl The url of the fragment shader to be used.
  15906. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15907. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15908. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15909. * @param camera The camera to apply the render pass to.
  15910. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15911. * @param engine The engine which the post process will be applied. (default: current engine)
  15912. * @param reusable If the post process can be reused on the same frame. (default: false)
  15913. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15914. * @param textureType Type of textures used when performing the post process. (default: 0)
  15915. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15916. * @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
  15917. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15918. */
  15919. constructor(
  15920. /** Name of the PostProcess. */
  15921. 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);
  15922. /**
  15923. * Gets a string idenfifying the name of the class
  15924. * @returns "PostProcess" string
  15925. */
  15926. getClassName(): string;
  15927. /**
  15928. * Gets the engine which this post process belongs to.
  15929. * @returns The engine the post process was enabled with.
  15930. */
  15931. getEngine(): Engine;
  15932. /**
  15933. * The effect that is created when initializing the post process.
  15934. * @returns The created effect corresponding the the postprocess.
  15935. */
  15936. getEffect(): Effect;
  15937. /**
  15938. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15939. * @param postProcess The post process to share the output with.
  15940. * @returns This post process.
  15941. */
  15942. shareOutputWith(postProcess: PostProcess): PostProcess;
  15943. /**
  15944. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15945. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15946. */
  15947. useOwnOutput(): void;
  15948. /**
  15949. * Updates the effect with the current post process compile time values and recompiles the shader.
  15950. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15951. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15952. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15953. * @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
  15954. * @param onCompiled Called when the shader has been compiled.
  15955. * @param onError Called if there is an error when compiling a shader.
  15956. */
  15957. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15958. /**
  15959. * The post process is reusable if it can be used multiple times within one frame.
  15960. * @returns If the post process is reusable
  15961. */
  15962. isReusable(): boolean;
  15963. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15964. markTextureDirty(): void;
  15965. /**
  15966. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15967. * 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.
  15968. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15969. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15970. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15971. * @returns The target texture that was bound to be written to.
  15972. */
  15973. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15974. /**
  15975. * If the post process is supported.
  15976. */
  15977. readonly isSupported: boolean;
  15978. /**
  15979. * The aspect ratio of the output texture.
  15980. */
  15981. readonly aspectRatio: number;
  15982. /**
  15983. * Get a value indicating if the post-process is ready to be used
  15984. * @returns true if the post-process is ready (shader is compiled)
  15985. */
  15986. isReady(): boolean;
  15987. /**
  15988. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15989. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15990. */
  15991. apply(): Nullable<Effect>;
  15992. private _disposeTextures;
  15993. /**
  15994. * Disposes the post process.
  15995. * @param camera The camera to dispose the post process on.
  15996. */
  15997. dispose(camera?: Camera): void;
  15998. }
  15999. }
  16000. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  16001. /** @hidden */
  16002. export var kernelBlurVaryingDeclaration: {
  16003. name: string;
  16004. shader: string;
  16005. };
  16006. }
  16007. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  16008. /** @hidden */
  16009. export var kernelBlurFragment: {
  16010. name: string;
  16011. shader: string;
  16012. };
  16013. }
  16014. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  16015. /** @hidden */
  16016. export var kernelBlurFragment2: {
  16017. name: string;
  16018. shader: string;
  16019. };
  16020. }
  16021. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16022. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16023. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16024. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16025. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16026. /** @hidden */
  16027. export var kernelBlurPixelShader: {
  16028. name: string;
  16029. shader: string;
  16030. };
  16031. }
  16032. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16033. /** @hidden */
  16034. export var kernelBlurVertex: {
  16035. name: string;
  16036. shader: string;
  16037. };
  16038. }
  16039. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16040. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16041. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16042. /** @hidden */
  16043. export var kernelBlurVertexShader: {
  16044. name: string;
  16045. shader: string;
  16046. };
  16047. }
  16048. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16049. import { Vector2 } from "babylonjs/Maths/math.vector";
  16050. import { Nullable } from "babylonjs/types";
  16051. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16052. import { Camera } from "babylonjs/Cameras/camera";
  16053. import { Effect } from "babylonjs/Materials/effect";
  16054. import { Engine } from "babylonjs/Engines/engine";
  16055. import "babylonjs/Shaders/kernelBlur.fragment";
  16056. import "babylonjs/Shaders/kernelBlur.vertex";
  16057. /**
  16058. * The Blur Post Process which blurs an image based on a kernel and direction.
  16059. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16060. */
  16061. export class BlurPostProcess extends PostProcess {
  16062. /** The direction in which to blur the image. */
  16063. direction: Vector2;
  16064. private blockCompilation;
  16065. protected _kernel: number;
  16066. protected _idealKernel: number;
  16067. protected _packedFloat: boolean;
  16068. private _staticDefines;
  16069. /**
  16070. * Sets the length in pixels of the blur sample region
  16071. */
  16072. /**
  16073. * Gets the length in pixels of the blur sample region
  16074. */
  16075. kernel: number;
  16076. /**
  16077. * Sets wether or not the blur needs to unpack/repack floats
  16078. */
  16079. /**
  16080. * Gets wether or not the blur is unpacking/repacking floats
  16081. */
  16082. packedFloat: boolean;
  16083. /**
  16084. * Creates a new instance BlurPostProcess
  16085. * @param name The name of the effect.
  16086. * @param direction The direction in which to blur the image.
  16087. * @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.
  16088. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16089. * @param camera The camera to apply the render pass to.
  16090. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16091. * @param engine The engine which the post process will be applied. (default: current engine)
  16092. * @param reusable If the post process can be reused on the same frame. (default: false)
  16093. * @param textureType Type of textures used when performing the post process. (default: 0)
  16094. * @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)
  16095. */
  16096. constructor(name: string,
  16097. /** The direction in which to blur the image. */
  16098. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16099. /**
  16100. * Updates the effect with the current post process compile time values and recompiles the shader.
  16101. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16102. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16103. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16104. * @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
  16105. * @param onCompiled Called when the shader has been compiled.
  16106. * @param onError Called if there is an error when compiling a shader.
  16107. */
  16108. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16109. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16110. /**
  16111. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16112. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16113. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16114. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16115. * The gaps between physical kernels are compensated for in the weighting of the samples
  16116. * @param idealKernel Ideal blur kernel.
  16117. * @return Nearest best kernel.
  16118. */
  16119. protected _nearestBestKernel(idealKernel: number): number;
  16120. /**
  16121. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16122. * @param x The point on the Gaussian distribution to sample.
  16123. * @return the value of the Gaussian function at x.
  16124. */
  16125. protected _gaussianWeight(x: number): number;
  16126. /**
  16127. * Generates a string that can be used as a floating point number in GLSL.
  16128. * @param x Value to print.
  16129. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16130. * @return GLSL float string.
  16131. */
  16132. protected _glslFloat(x: number, decimalFigures?: number): string;
  16133. }
  16134. }
  16135. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16136. import { Scene } from "babylonjs/scene";
  16137. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16138. import { Plane } from "babylonjs/Maths/math.plane";
  16139. /**
  16140. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16141. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16142. * You can then easily use it as a reflectionTexture on a flat surface.
  16143. * In case the surface is not a plane, please consider relying on reflection probes.
  16144. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16145. */
  16146. export class MirrorTexture extends RenderTargetTexture {
  16147. private scene;
  16148. /**
  16149. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16150. * 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.
  16151. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16152. */
  16153. mirrorPlane: Plane;
  16154. /**
  16155. * Define the blur ratio used to blur the reflection if needed.
  16156. */
  16157. blurRatio: number;
  16158. /**
  16159. * Define the adaptive blur kernel used to blur the reflection if needed.
  16160. * This will autocompute the closest best match for the `blurKernel`
  16161. */
  16162. adaptiveBlurKernel: number;
  16163. /**
  16164. * Define the blur kernel used to blur the reflection if needed.
  16165. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16166. */
  16167. blurKernel: number;
  16168. /**
  16169. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16170. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16171. */
  16172. blurKernelX: number;
  16173. /**
  16174. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16175. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16176. */
  16177. blurKernelY: number;
  16178. private _autoComputeBlurKernel;
  16179. protected _onRatioRescale(): void;
  16180. private _updateGammaSpace;
  16181. private _imageProcessingConfigChangeObserver;
  16182. private _transformMatrix;
  16183. private _mirrorMatrix;
  16184. private _savedViewMatrix;
  16185. private _blurX;
  16186. private _blurY;
  16187. private _adaptiveBlurKernel;
  16188. private _blurKernelX;
  16189. private _blurKernelY;
  16190. private _blurRatio;
  16191. /**
  16192. * Instantiates a Mirror Texture.
  16193. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16194. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16195. * You can then easily use it as a reflectionTexture on a flat surface.
  16196. * In case the surface is not a plane, please consider relying on reflection probes.
  16197. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16198. * @param name
  16199. * @param size
  16200. * @param scene
  16201. * @param generateMipMaps
  16202. * @param type
  16203. * @param samplingMode
  16204. * @param generateDepthBuffer
  16205. */
  16206. constructor(name: string, size: number | {
  16207. width: number;
  16208. height: number;
  16209. } | {
  16210. ratio: number;
  16211. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16212. private _preparePostProcesses;
  16213. /**
  16214. * Clone the mirror texture.
  16215. * @returns the cloned texture
  16216. */
  16217. clone(): MirrorTexture;
  16218. /**
  16219. * Serialize the texture to a JSON representation you could use in Parse later on
  16220. * @returns the serialized JSON representation
  16221. */
  16222. serialize(): any;
  16223. /**
  16224. * Dispose the texture and release its associated resources.
  16225. */
  16226. dispose(): void;
  16227. }
  16228. }
  16229. declare module "babylonjs/Materials/Textures/texture" {
  16230. import { Observable } from "babylonjs/Misc/observable";
  16231. import { Nullable } from "babylonjs/types";
  16232. import { Matrix } from "babylonjs/Maths/math.vector";
  16233. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16234. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16235. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16236. import { Scene } from "babylonjs/scene";
  16237. /**
  16238. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16239. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16240. */
  16241. export class Texture extends BaseTexture {
  16242. /**
  16243. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16244. */
  16245. static SerializeBuffers: boolean;
  16246. /** @hidden */
  16247. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16248. /** @hidden */
  16249. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16250. /** @hidden */
  16251. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16252. /** nearest is mag = nearest and min = nearest and mip = linear */
  16253. static readonly NEAREST_SAMPLINGMODE: number;
  16254. /** nearest is mag = nearest and min = nearest and mip = linear */
  16255. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16256. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16257. static readonly BILINEAR_SAMPLINGMODE: number;
  16258. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16259. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16260. /** Trilinear is mag = linear and min = linear and mip = linear */
  16261. static readonly TRILINEAR_SAMPLINGMODE: number;
  16262. /** Trilinear is mag = linear and min = linear and mip = linear */
  16263. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16264. /** mag = nearest and min = nearest and mip = nearest */
  16265. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16266. /** mag = nearest and min = linear and mip = nearest */
  16267. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16268. /** mag = nearest and min = linear and mip = linear */
  16269. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16270. /** mag = nearest and min = linear and mip = none */
  16271. static readonly NEAREST_LINEAR: number;
  16272. /** mag = nearest and min = nearest and mip = none */
  16273. static readonly NEAREST_NEAREST: number;
  16274. /** mag = linear and min = nearest and mip = nearest */
  16275. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16276. /** mag = linear and min = nearest and mip = linear */
  16277. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16278. /** mag = linear and min = linear and mip = none */
  16279. static readonly LINEAR_LINEAR: number;
  16280. /** mag = linear and min = nearest and mip = none */
  16281. static readonly LINEAR_NEAREST: number;
  16282. /** Explicit coordinates mode */
  16283. static readonly EXPLICIT_MODE: number;
  16284. /** Spherical coordinates mode */
  16285. static readonly SPHERICAL_MODE: number;
  16286. /** Planar coordinates mode */
  16287. static readonly PLANAR_MODE: number;
  16288. /** Cubic coordinates mode */
  16289. static readonly CUBIC_MODE: number;
  16290. /** Projection coordinates mode */
  16291. static readonly PROJECTION_MODE: number;
  16292. /** Inverse Cubic coordinates mode */
  16293. static readonly SKYBOX_MODE: number;
  16294. /** Inverse Cubic coordinates mode */
  16295. static readonly INVCUBIC_MODE: number;
  16296. /** Equirectangular coordinates mode */
  16297. static readonly EQUIRECTANGULAR_MODE: number;
  16298. /** Equirectangular Fixed coordinates mode */
  16299. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16300. /** Equirectangular Fixed Mirrored coordinates mode */
  16301. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16302. /** Texture is not repeating outside of 0..1 UVs */
  16303. static readonly CLAMP_ADDRESSMODE: number;
  16304. /** Texture is repeating outside of 0..1 UVs */
  16305. static readonly WRAP_ADDRESSMODE: number;
  16306. /** Texture is repeating and mirrored */
  16307. static readonly MIRROR_ADDRESSMODE: number;
  16308. /**
  16309. * 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
  16310. */
  16311. static UseSerializedUrlIfAny: boolean;
  16312. /**
  16313. * Define the url of the texture.
  16314. */
  16315. url: Nullable<string>;
  16316. /**
  16317. * Define an offset on the texture to offset the u coordinates of the UVs
  16318. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16319. */
  16320. uOffset: number;
  16321. /**
  16322. * Define an offset on the texture to offset the v coordinates of the UVs
  16323. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16324. */
  16325. vOffset: number;
  16326. /**
  16327. * Define an offset on the texture to scale the u coordinates of the UVs
  16328. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16329. */
  16330. uScale: number;
  16331. /**
  16332. * Define an offset on the texture to scale the v coordinates of the UVs
  16333. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16334. */
  16335. vScale: number;
  16336. /**
  16337. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16338. * @see http://doc.babylonjs.com/how_to/more_materials
  16339. */
  16340. uAng: number;
  16341. /**
  16342. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16343. * @see http://doc.babylonjs.com/how_to/more_materials
  16344. */
  16345. vAng: number;
  16346. /**
  16347. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16348. * @see http://doc.babylonjs.com/how_to/more_materials
  16349. */
  16350. wAng: number;
  16351. /**
  16352. * Defines the center of rotation (U)
  16353. */
  16354. uRotationCenter: number;
  16355. /**
  16356. * Defines the center of rotation (V)
  16357. */
  16358. vRotationCenter: number;
  16359. /**
  16360. * Defines the center of rotation (W)
  16361. */
  16362. wRotationCenter: number;
  16363. /**
  16364. * Are mip maps generated for this texture or not.
  16365. */
  16366. readonly noMipmap: boolean;
  16367. /**
  16368. * List of inspectable custom properties (used by the Inspector)
  16369. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16370. */
  16371. inspectableCustomProperties: Nullable<IInspectable[]>;
  16372. private _noMipmap;
  16373. /** @hidden */
  16374. _invertY: boolean;
  16375. private _rowGenerationMatrix;
  16376. private _cachedTextureMatrix;
  16377. private _projectionModeMatrix;
  16378. private _t0;
  16379. private _t1;
  16380. private _t2;
  16381. private _cachedUOffset;
  16382. private _cachedVOffset;
  16383. private _cachedUScale;
  16384. private _cachedVScale;
  16385. private _cachedUAng;
  16386. private _cachedVAng;
  16387. private _cachedWAng;
  16388. private _cachedProjectionMatrixId;
  16389. private _cachedCoordinatesMode;
  16390. /** @hidden */
  16391. protected _initialSamplingMode: number;
  16392. /** @hidden */
  16393. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16394. private _deleteBuffer;
  16395. protected _format: Nullable<number>;
  16396. private _delayedOnLoad;
  16397. private _delayedOnError;
  16398. private _mimeType?;
  16399. /**
  16400. * Observable triggered once the texture has been loaded.
  16401. */
  16402. onLoadObservable: Observable<Texture>;
  16403. protected _isBlocking: boolean;
  16404. /**
  16405. * Is the texture preventing material to render while loading.
  16406. * If false, a default texture will be used instead of the loading one during the preparation step.
  16407. */
  16408. isBlocking: boolean;
  16409. /**
  16410. * Get the current sampling mode associated with the texture.
  16411. */
  16412. readonly samplingMode: number;
  16413. /**
  16414. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16415. */
  16416. readonly invertY: boolean;
  16417. /**
  16418. * Instantiates a new texture.
  16419. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16420. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16421. * @param url defines the url of the picture to load as a texture
  16422. * @param scene defines the scene or engine the texture will belong to
  16423. * @param noMipmap defines if the texture will require mip maps or not
  16424. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16425. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16426. * @param onLoad defines a callback triggered when the texture has been loaded
  16427. * @param onError defines a callback triggered when an error occurred during the loading session
  16428. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16429. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16430. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16431. * @param mimeType defines an optional mime type information
  16432. */
  16433. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  16434. /**
  16435. * Update the url (and optional buffer) of this texture if url was null during construction.
  16436. * @param url the url of the texture
  16437. * @param buffer the buffer of the texture (defaults to null)
  16438. * @param onLoad callback called when the texture is loaded (defaults to null)
  16439. */
  16440. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16441. /**
  16442. * Finish the loading sequence of a texture flagged as delayed load.
  16443. * @hidden
  16444. */
  16445. delayLoad(): void;
  16446. private _prepareRowForTextureGeneration;
  16447. /**
  16448. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16449. * @returns the transform matrix of the texture.
  16450. */
  16451. getTextureMatrix(uBase?: number): Matrix;
  16452. /**
  16453. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16454. * @returns The reflection texture transform
  16455. */
  16456. getReflectionTextureMatrix(): Matrix;
  16457. /**
  16458. * Clones the texture.
  16459. * @returns the cloned texture
  16460. */
  16461. clone(): Texture;
  16462. /**
  16463. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16464. * @returns The JSON representation of the texture
  16465. */
  16466. serialize(): any;
  16467. /**
  16468. * Get the current class name of the texture useful for serialization or dynamic coding.
  16469. * @returns "Texture"
  16470. */
  16471. getClassName(): string;
  16472. /**
  16473. * Dispose the texture and release its associated resources.
  16474. */
  16475. dispose(): void;
  16476. /**
  16477. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16478. * @param parsedTexture Define the JSON representation of the texture
  16479. * @param scene Define the scene the parsed texture should be instantiated in
  16480. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16481. * @returns The parsed texture if successful
  16482. */
  16483. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16484. /**
  16485. * Creates a texture from its base 64 representation.
  16486. * @param data Define the base64 payload without the data: prefix
  16487. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16488. * @param scene Define the scene the texture should belong to
  16489. * @param noMipmap Forces the texture to not create mip map information if true
  16490. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16491. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16492. * @param onLoad define a callback triggered when the texture has been loaded
  16493. * @param onError define a callback triggered when an error occurred during the loading session
  16494. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16495. * @returns the created texture
  16496. */
  16497. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16498. /**
  16499. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16500. * @param data Define the base64 payload without the data: prefix
  16501. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16502. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16503. * @param scene Define the scene the texture should belong to
  16504. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16505. * @param noMipmap Forces the texture to not create mip map information if true
  16506. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16507. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16508. * @param onLoad define a callback triggered when the texture has been loaded
  16509. * @param onError define a callback triggered when an error occurred during the loading session
  16510. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16511. * @returns the created texture
  16512. */
  16513. 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;
  16514. }
  16515. }
  16516. declare module "babylonjs/PostProcesses/postProcessManager" {
  16517. import { Nullable } from "babylonjs/types";
  16518. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16519. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16520. import { Scene } from "babylonjs/scene";
  16521. /**
  16522. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16523. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16524. */
  16525. export class PostProcessManager {
  16526. private _scene;
  16527. private _indexBuffer;
  16528. private _vertexBuffers;
  16529. /**
  16530. * Creates a new instance PostProcess
  16531. * @param scene The scene that the post process is associated with.
  16532. */
  16533. constructor(scene: Scene);
  16534. private _prepareBuffers;
  16535. private _buildIndexBuffer;
  16536. /**
  16537. * Rebuilds the vertex buffers of the manager.
  16538. * @hidden
  16539. */
  16540. _rebuild(): void;
  16541. /**
  16542. * Prepares a frame to be run through a post process.
  16543. * @param sourceTexture The input texture to the post procesess. (default: null)
  16544. * @param postProcesses An array of post processes to be run. (default: null)
  16545. * @returns True if the post processes were able to be run.
  16546. * @hidden
  16547. */
  16548. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16549. /**
  16550. * Manually render a set of post processes to a texture.
  16551. * @param postProcesses An array of post processes to be run.
  16552. * @param targetTexture The target texture to render to.
  16553. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16554. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16555. * @param lodLevel defines which lod of the texture to render to
  16556. */
  16557. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16558. /**
  16559. * Finalize the result of the output of the postprocesses.
  16560. * @param doNotPresent If true the result will not be displayed to the screen.
  16561. * @param targetTexture The target texture to render to.
  16562. * @param faceIndex The index of the face to bind the target texture to.
  16563. * @param postProcesses The array of post processes to render.
  16564. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16565. * @hidden
  16566. */
  16567. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16568. /**
  16569. * Disposes of the post process manager.
  16570. */
  16571. dispose(): void;
  16572. }
  16573. }
  16574. declare module "babylonjs/Misc/gradients" {
  16575. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16576. /** Interface used by value gradients (color, factor, ...) */
  16577. export interface IValueGradient {
  16578. /**
  16579. * Gets or sets the gradient value (between 0 and 1)
  16580. */
  16581. gradient: number;
  16582. }
  16583. /** Class used to store color4 gradient */
  16584. export class ColorGradient implements IValueGradient {
  16585. /**
  16586. * Gets or sets the gradient value (between 0 and 1)
  16587. */
  16588. gradient: number;
  16589. /**
  16590. * Gets or sets first associated color
  16591. */
  16592. color1: Color4;
  16593. /**
  16594. * Gets or sets second associated color
  16595. */
  16596. color2?: Color4;
  16597. /**
  16598. * Will get a color picked randomly between color1 and color2.
  16599. * If color2 is undefined then color1 will be used
  16600. * @param result defines the target Color4 to store the result in
  16601. */
  16602. getColorToRef(result: Color4): void;
  16603. }
  16604. /** Class used to store color 3 gradient */
  16605. export class Color3Gradient implements IValueGradient {
  16606. /**
  16607. * Gets or sets the gradient value (between 0 and 1)
  16608. */
  16609. gradient: number;
  16610. /**
  16611. * Gets or sets the associated color
  16612. */
  16613. color: Color3;
  16614. }
  16615. /** Class used to store factor gradient */
  16616. export class FactorGradient implements IValueGradient {
  16617. /**
  16618. * Gets or sets the gradient value (between 0 and 1)
  16619. */
  16620. gradient: number;
  16621. /**
  16622. * Gets or sets first associated factor
  16623. */
  16624. factor1: number;
  16625. /**
  16626. * Gets or sets second associated factor
  16627. */
  16628. factor2?: number;
  16629. /**
  16630. * Will get a number picked randomly between factor1 and factor2.
  16631. * If factor2 is undefined then factor1 will be used
  16632. * @returns the picked number
  16633. */
  16634. getFactor(): number;
  16635. }
  16636. /**
  16637. * Helper used to simplify some generic gradient tasks
  16638. */
  16639. export class GradientHelper {
  16640. /**
  16641. * Gets the current gradient from an array of IValueGradient
  16642. * @param ratio defines the current ratio to get
  16643. * @param gradients defines the array of IValueGradient
  16644. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16645. */
  16646. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16647. }
  16648. }
  16649. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16650. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16651. import { Nullable } from "babylonjs/types";
  16652. module "babylonjs/Engines/thinEngine" {
  16653. interface ThinEngine {
  16654. /**
  16655. * Creates a dynamic texture
  16656. * @param width defines the width of the texture
  16657. * @param height defines the height of the texture
  16658. * @param generateMipMaps defines if the engine should generate the mip levels
  16659. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16660. * @returns the dynamic texture inside an InternalTexture
  16661. */
  16662. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16663. /**
  16664. * Update the content of a dynamic texture
  16665. * @param texture defines the texture to update
  16666. * @param canvas defines the canvas containing the source
  16667. * @param invertY defines if data must be stored with Y axis inverted
  16668. * @param premulAlpha defines if alpha is stored as premultiplied
  16669. * @param format defines the format of the data
  16670. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16671. */
  16672. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16673. }
  16674. }
  16675. }
  16676. declare module "babylonjs/Misc/canvasGenerator" {
  16677. /**
  16678. * Helper class used to generate a canvas to manipulate images
  16679. */
  16680. export class CanvasGenerator {
  16681. /**
  16682. * Create a new canvas (or offscreen canvas depending on the context)
  16683. * @param width defines the expected width
  16684. * @param height defines the expected height
  16685. * @return a new canvas or offscreen canvas
  16686. */
  16687. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16688. }
  16689. }
  16690. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16691. import { Scene } from "babylonjs/scene";
  16692. import { Texture } from "babylonjs/Materials/Textures/texture";
  16693. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16694. /**
  16695. * A class extending Texture allowing drawing on a texture
  16696. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16697. */
  16698. export class DynamicTexture extends Texture {
  16699. private _generateMipMaps;
  16700. private _canvas;
  16701. private _context;
  16702. private _engine;
  16703. /**
  16704. * Creates a DynamicTexture
  16705. * @param name defines the name of the texture
  16706. * @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
  16707. * @param scene defines the scene where you want the texture
  16708. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16709. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16710. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16711. */
  16712. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16713. /**
  16714. * Get the current class name of the texture useful for serialization or dynamic coding.
  16715. * @returns "DynamicTexture"
  16716. */
  16717. getClassName(): string;
  16718. /**
  16719. * Gets the current state of canRescale
  16720. */
  16721. readonly canRescale: boolean;
  16722. private _recreate;
  16723. /**
  16724. * Scales the texture
  16725. * @param ratio the scale factor to apply to both width and height
  16726. */
  16727. scale(ratio: number): void;
  16728. /**
  16729. * Resizes the texture
  16730. * @param width the new width
  16731. * @param height the new height
  16732. */
  16733. scaleTo(width: number, height: number): void;
  16734. /**
  16735. * Gets the context of the canvas used by the texture
  16736. * @returns the canvas context of the dynamic texture
  16737. */
  16738. getContext(): CanvasRenderingContext2D;
  16739. /**
  16740. * Clears the texture
  16741. */
  16742. clear(): void;
  16743. /**
  16744. * Updates the texture
  16745. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16746. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16747. */
  16748. update(invertY?: boolean, premulAlpha?: boolean): void;
  16749. /**
  16750. * Draws text onto the texture
  16751. * @param text defines the text to be drawn
  16752. * @param x defines the placement of the text from the left
  16753. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16754. * @param font defines the font to be used with font-style, font-size, font-name
  16755. * @param color defines the color used for the text
  16756. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16757. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16758. * @param update defines whether texture is immediately update (default is true)
  16759. */
  16760. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16761. /**
  16762. * Clones the texture
  16763. * @returns the clone of the texture.
  16764. */
  16765. clone(): DynamicTexture;
  16766. /**
  16767. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16768. * @returns a serialized dynamic texture object
  16769. */
  16770. serialize(): any;
  16771. /** @hidden */
  16772. _rebuild(): void;
  16773. }
  16774. }
  16775. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16776. import { Scene } from "babylonjs/scene";
  16777. import { ISceneComponent } from "babylonjs/sceneComponent";
  16778. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16779. module "babylonjs/abstractScene" {
  16780. interface AbstractScene {
  16781. /**
  16782. * The list of procedural textures added to the scene
  16783. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16784. */
  16785. proceduralTextures: Array<ProceduralTexture>;
  16786. }
  16787. }
  16788. /**
  16789. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16790. * in a given scene.
  16791. */
  16792. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16793. /**
  16794. * The component name helpfull to identify the component in the list of scene components.
  16795. */
  16796. readonly name: string;
  16797. /**
  16798. * The scene the component belongs to.
  16799. */
  16800. scene: Scene;
  16801. /**
  16802. * Creates a new instance of the component for the given scene
  16803. * @param scene Defines the scene to register the component in
  16804. */
  16805. constructor(scene: Scene);
  16806. /**
  16807. * Registers the component in a given scene
  16808. */
  16809. register(): void;
  16810. /**
  16811. * Rebuilds the elements related to this component in case of
  16812. * context lost for instance.
  16813. */
  16814. rebuild(): void;
  16815. /**
  16816. * Disposes the component and the associated ressources.
  16817. */
  16818. dispose(): void;
  16819. private _beforeClear;
  16820. }
  16821. }
  16822. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16823. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16824. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16825. module "babylonjs/Engines/thinEngine" {
  16826. interface ThinEngine {
  16827. /**
  16828. * Creates a new render target cube texture
  16829. * @param size defines the size of the texture
  16830. * @param options defines the options used to create the texture
  16831. * @returns a new render target cube texture stored in an InternalTexture
  16832. */
  16833. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16834. }
  16835. }
  16836. }
  16837. declare module "babylonjs/Shaders/procedural.vertex" {
  16838. /** @hidden */
  16839. export var proceduralVertexShader: {
  16840. name: string;
  16841. shader: string;
  16842. };
  16843. }
  16844. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16845. import { Observable } from "babylonjs/Misc/observable";
  16846. import { Nullable } from "babylonjs/types";
  16847. import { Scene } from "babylonjs/scene";
  16848. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16849. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16850. import { Effect } from "babylonjs/Materials/effect";
  16851. import { Texture } from "babylonjs/Materials/Textures/texture";
  16852. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16853. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16854. import "babylonjs/Shaders/procedural.vertex";
  16855. /**
  16856. * 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.
  16857. * This is the base class of any Procedural texture and contains most of the shareable code.
  16858. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16859. */
  16860. export class ProceduralTexture extends Texture {
  16861. isCube: boolean;
  16862. /**
  16863. * Define if the texture is enabled or not (disabled texture will not render)
  16864. */
  16865. isEnabled: boolean;
  16866. /**
  16867. * Define if the texture must be cleared before rendering (default is true)
  16868. */
  16869. autoClear: boolean;
  16870. /**
  16871. * Callback called when the texture is generated
  16872. */
  16873. onGenerated: () => void;
  16874. /**
  16875. * Event raised when the texture is generated
  16876. */
  16877. onGeneratedObservable: Observable<ProceduralTexture>;
  16878. /** @hidden */
  16879. _generateMipMaps: boolean;
  16880. /** @hidden **/
  16881. _effect: Effect;
  16882. /** @hidden */
  16883. _textures: {
  16884. [key: string]: Texture;
  16885. };
  16886. private _size;
  16887. private _currentRefreshId;
  16888. private _refreshRate;
  16889. private _vertexBuffers;
  16890. private _indexBuffer;
  16891. private _uniforms;
  16892. private _samplers;
  16893. private _fragment;
  16894. private _floats;
  16895. private _ints;
  16896. private _floatsArrays;
  16897. private _colors3;
  16898. private _colors4;
  16899. private _vectors2;
  16900. private _vectors3;
  16901. private _matrices;
  16902. private _fallbackTexture;
  16903. private _fallbackTextureUsed;
  16904. private _engine;
  16905. private _cachedDefines;
  16906. private _contentUpdateId;
  16907. private _contentData;
  16908. /**
  16909. * Instantiates a new procedural texture.
  16910. * 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.
  16911. * This is the base class of any Procedural texture and contains most of the shareable code.
  16912. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16913. * @param name Define the name of the texture
  16914. * @param size Define the size of the texture to create
  16915. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16916. * @param scene Define the scene the texture belongs to
  16917. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16918. * @param generateMipMaps Define if the texture should creates mip maps or not
  16919. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16920. */
  16921. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16922. /**
  16923. * The effect that is created when initializing the post process.
  16924. * @returns The created effect corresponding the the postprocess.
  16925. */
  16926. getEffect(): Effect;
  16927. /**
  16928. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16929. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16930. */
  16931. getContent(): Nullable<ArrayBufferView>;
  16932. private _createIndexBuffer;
  16933. /** @hidden */
  16934. _rebuild(): void;
  16935. /**
  16936. * Resets the texture in order to recreate its associated resources.
  16937. * This can be called in case of context loss
  16938. */
  16939. reset(): void;
  16940. protected _getDefines(): string;
  16941. /**
  16942. * Is the texture ready to be used ? (rendered at least once)
  16943. * @returns true if ready, otherwise, false.
  16944. */
  16945. isReady(): boolean;
  16946. /**
  16947. * Resets the refresh counter of the texture and start bak from scratch.
  16948. * Could be useful to regenerate the texture if it is setup to render only once.
  16949. */
  16950. resetRefreshCounter(): void;
  16951. /**
  16952. * Set the fragment shader to use in order to render the texture.
  16953. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16954. */
  16955. setFragment(fragment: any): void;
  16956. /**
  16957. * Define the refresh rate of the texture or the rendering frequency.
  16958. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16959. */
  16960. refreshRate: number;
  16961. /** @hidden */
  16962. _shouldRender(): boolean;
  16963. /**
  16964. * Get the size the texture is rendering at.
  16965. * @returns the size (texture is always squared)
  16966. */
  16967. getRenderSize(): number;
  16968. /**
  16969. * Resize the texture to new value.
  16970. * @param size Define the new size the texture should have
  16971. * @param generateMipMaps Define whether the new texture should create mip maps
  16972. */
  16973. resize(size: number, generateMipMaps: boolean): void;
  16974. private _checkUniform;
  16975. /**
  16976. * Set a texture in the shader program used to render.
  16977. * @param name Define the name of the uniform samplers as defined in the shader
  16978. * @param texture Define the texture to bind to this sampler
  16979. * @return the texture itself allowing "fluent" like uniform updates
  16980. */
  16981. setTexture(name: string, texture: Texture): ProceduralTexture;
  16982. /**
  16983. * Set a float in the shader.
  16984. * @param name Define the name of the uniform as defined in the shader
  16985. * @param value Define the value to give to the uniform
  16986. * @return the texture itself allowing "fluent" like uniform updates
  16987. */
  16988. setFloat(name: string, value: number): ProceduralTexture;
  16989. /**
  16990. * Set a int in the shader.
  16991. * @param name Define the name of the uniform as defined in the shader
  16992. * @param value Define the value to give to the uniform
  16993. * @return the texture itself allowing "fluent" like uniform updates
  16994. */
  16995. setInt(name: string, value: number): ProceduralTexture;
  16996. /**
  16997. * Set an array of floats in the shader.
  16998. * @param name Define the name of the uniform as defined in the shader
  16999. * @param value Define the value to give to the uniform
  17000. * @return the texture itself allowing "fluent" like uniform updates
  17001. */
  17002. setFloats(name: string, value: number[]): ProceduralTexture;
  17003. /**
  17004. * Set a vec3 in the shader from a Color3.
  17005. * @param name Define the name of the uniform as defined in the shader
  17006. * @param value Define the value to give to the uniform
  17007. * @return the texture itself allowing "fluent" like uniform updates
  17008. */
  17009. setColor3(name: string, value: Color3): ProceduralTexture;
  17010. /**
  17011. * Set a vec4 in the shader from a Color4.
  17012. * @param name Define the name of the uniform as defined in the shader
  17013. * @param value Define the value to give to the uniform
  17014. * @return the texture itself allowing "fluent" like uniform updates
  17015. */
  17016. setColor4(name: string, value: Color4): ProceduralTexture;
  17017. /**
  17018. * Set a vec2 in the shader from a Vector2.
  17019. * @param name Define the name of the uniform as defined in the shader
  17020. * @param value Define the value to give to the uniform
  17021. * @return the texture itself allowing "fluent" like uniform updates
  17022. */
  17023. setVector2(name: string, value: Vector2): ProceduralTexture;
  17024. /**
  17025. * Set a vec3 in the shader from a Vector3.
  17026. * @param name Define the name of the uniform as defined in the shader
  17027. * @param value Define the value to give to the uniform
  17028. * @return the texture itself allowing "fluent" like uniform updates
  17029. */
  17030. setVector3(name: string, value: Vector3): ProceduralTexture;
  17031. /**
  17032. * Set a mat4 in the shader from a MAtrix.
  17033. * @param name Define the name of the uniform as defined in the shader
  17034. * @param value Define the value to give to the uniform
  17035. * @return the texture itself allowing "fluent" like uniform updates
  17036. */
  17037. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17038. /**
  17039. * Render the texture to its associated render target.
  17040. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17041. */
  17042. render(useCameraPostProcess?: boolean): void;
  17043. /**
  17044. * Clone the texture.
  17045. * @returns the cloned texture
  17046. */
  17047. clone(): ProceduralTexture;
  17048. /**
  17049. * Dispose the texture and release its asoociated resources.
  17050. */
  17051. dispose(): void;
  17052. }
  17053. }
  17054. declare module "babylonjs/Particles/baseParticleSystem" {
  17055. import { Nullable } from "babylonjs/types";
  17056. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17058. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17059. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17060. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17061. import { Scene } from "babylonjs/scene";
  17062. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17063. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17064. import { Texture } from "babylonjs/Materials/Textures/texture";
  17065. import { Color4 } from "babylonjs/Maths/math.color";
  17066. import { Animation } from "babylonjs/Animations/animation";
  17067. /**
  17068. * This represents the base class for particle system in Babylon.
  17069. * 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.
  17070. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17071. * @example https://doc.babylonjs.com/babylon101/particles
  17072. */
  17073. export class BaseParticleSystem {
  17074. /**
  17075. * Source color is added to the destination color without alpha affecting the result
  17076. */
  17077. static BLENDMODE_ONEONE: number;
  17078. /**
  17079. * Blend current color and particle color using particle’s alpha
  17080. */
  17081. static BLENDMODE_STANDARD: number;
  17082. /**
  17083. * Add current color and particle color multiplied by particle’s alpha
  17084. */
  17085. static BLENDMODE_ADD: number;
  17086. /**
  17087. * Multiply current color with particle color
  17088. */
  17089. static BLENDMODE_MULTIPLY: number;
  17090. /**
  17091. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17092. */
  17093. static BLENDMODE_MULTIPLYADD: number;
  17094. /**
  17095. * List of animations used by the particle system.
  17096. */
  17097. animations: Animation[];
  17098. /**
  17099. * The id of the Particle system.
  17100. */
  17101. id: string;
  17102. /**
  17103. * The friendly name of the Particle system.
  17104. */
  17105. name: string;
  17106. /**
  17107. * The rendering group used by the Particle system to chose when to render.
  17108. */
  17109. renderingGroupId: number;
  17110. /**
  17111. * The emitter represents the Mesh or position we are attaching the particle system to.
  17112. */
  17113. emitter: Nullable<AbstractMesh | Vector3>;
  17114. /**
  17115. * The maximum number of particles to emit per frame
  17116. */
  17117. emitRate: number;
  17118. /**
  17119. * If you want to launch only a few particles at once, that can be done, as well.
  17120. */
  17121. manualEmitCount: number;
  17122. /**
  17123. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17124. */
  17125. updateSpeed: number;
  17126. /**
  17127. * The amount of time the particle system is running (depends of the overall update speed).
  17128. */
  17129. targetStopDuration: number;
  17130. /**
  17131. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17132. */
  17133. disposeOnStop: boolean;
  17134. /**
  17135. * Minimum power of emitting particles.
  17136. */
  17137. minEmitPower: number;
  17138. /**
  17139. * Maximum power of emitting particles.
  17140. */
  17141. maxEmitPower: number;
  17142. /**
  17143. * Minimum life time of emitting particles.
  17144. */
  17145. minLifeTime: number;
  17146. /**
  17147. * Maximum life time of emitting particles.
  17148. */
  17149. maxLifeTime: number;
  17150. /**
  17151. * Minimum Size of emitting particles.
  17152. */
  17153. minSize: number;
  17154. /**
  17155. * Maximum Size of emitting particles.
  17156. */
  17157. maxSize: number;
  17158. /**
  17159. * Minimum scale of emitting particles on X axis.
  17160. */
  17161. minScaleX: number;
  17162. /**
  17163. * Maximum scale of emitting particles on X axis.
  17164. */
  17165. maxScaleX: number;
  17166. /**
  17167. * Minimum scale of emitting particles on Y axis.
  17168. */
  17169. minScaleY: number;
  17170. /**
  17171. * Maximum scale of emitting particles on Y axis.
  17172. */
  17173. maxScaleY: number;
  17174. /**
  17175. * Gets or sets the minimal initial rotation in radians.
  17176. */
  17177. minInitialRotation: number;
  17178. /**
  17179. * Gets or sets the maximal initial rotation in radians.
  17180. */
  17181. maxInitialRotation: number;
  17182. /**
  17183. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17184. */
  17185. minAngularSpeed: number;
  17186. /**
  17187. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17188. */
  17189. maxAngularSpeed: number;
  17190. /**
  17191. * The texture used to render each particle. (this can be a spritesheet)
  17192. */
  17193. particleTexture: Nullable<Texture>;
  17194. /**
  17195. * The layer mask we are rendering the particles through.
  17196. */
  17197. layerMask: number;
  17198. /**
  17199. * This can help using your own shader to render the particle system.
  17200. * The according effect will be created
  17201. */
  17202. customShader: any;
  17203. /**
  17204. * By default particle system starts as soon as they are created. This prevents the
  17205. * automatic start to happen and let you decide when to start emitting particles.
  17206. */
  17207. preventAutoStart: boolean;
  17208. private _noiseTexture;
  17209. /**
  17210. * Gets or sets a texture used to add random noise to particle positions
  17211. */
  17212. noiseTexture: Nullable<ProceduralTexture>;
  17213. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17214. noiseStrength: Vector3;
  17215. /**
  17216. * Callback triggered when the particle animation is ending.
  17217. */
  17218. onAnimationEnd: Nullable<() => void>;
  17219. /**
  17220. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17221. */
  17222. blendMode: number;
  17223. /**
  17224. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17225. * to override the particles.
  17226. */
  17227. forceDepthWrite: boolean;
  17228. /** 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 */
  17229. preWarmCycles: number;
  17230. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17231. preWarmStepOffset: number;
  17232. /**
  17233. * 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)
  17234. */
  17235. spriteCellChangeSpeed: number;
  17236. /**
  17237. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17238. */
  17239. startSpriteCellID: number;
  17240. /**
  17241. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17242. */
  17243. endSpriteCellID: number;
  17244. /**
  17245. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17246. */
  17247. spriteCellWidth: number;
  17248. /**
  17249. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17250. */
  17251. spriteCellHeight: number;
  17252. /**
  17253. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17254. */
  17255. spriteRandomStartCell: boolean;
  17256. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17257. translationPivot: Vector2;
  17258. /** @hidden */
  17259. protected _isAnimationSheetEnabled: boolean;
  17260. /**
  17261. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17262. */
  17263. beginAnimationOnStart: boolean;
  17264. /**
  17265. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17266. */
  17267. beginAnimationFrom: number;
  17268. /**
  17269. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17270. */
  17271. beginAnimationTo: number;
  17272. /**
  17273. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17274. */
  17275. beginAnimationLoop: boolean;
  17276. /**
  17277. * Gets or sets a world offset applied to all particles
  17278. */
  17279. worldOffset: Vector3;
  17280. /**
  17281. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17282. */
  17283. isAnimationSheetEnabled: boolean;
  17284. /**
  17285. * Get hosting scene
  17286. * @returns the scene
  17287. */
  17288. getScene(): Scene;
  17289. /**
  17290. * You can use gravity if you want to give an orientation to your particles.
  17291. */
  17292. gravity: Vector3;
  17293. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17294. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17295. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17296. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17297. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17298. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17299. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17300. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17301. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17302. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17303. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17304. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17305. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17306. /**
  17307. * Defines the delay in milliseconds before starting the system (0 by default)
  17308. */
  17309. startDelay: number;
  17310. /**
  17311. * Gets the current list of drag gradients.
  17312. * You must use addDragGradient and removeDragGradient to udpate this list
  17313. * @returns the list of drag gradients
  17314. */
  17315. getDragGradients(): Nullable<Array<FactorGradient>>;
  17316. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17317. limitVelocityDamping: number;
  17318. /**
  17319. * Gets the current list of limit velocity gradients.
  17320. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17321. * @returns the list of limit velocity gradients
  17322. */
  17323. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17324. /**
  17325. * Gets the current list of color gradients.
  17326. * You must use addColorGradient and removeColorGradient to udpate this list
  17327. * @returns the list of color gradients
  17328. */
  17329. getColorGradients(): Nullable<Array<ColorGradient>>;
  17330. /**
  17331. * Gets the current list of size gradients.
  17332. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17333. * @returns the list of size gradients
  17334. */
  17335. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17336. /**
  17337. * Gets the current list of color remap gradients.
  17338. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17339. * @returns the list of color remap gradients
  17340. */
  17341. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17342. /**
  17343. * Gets the current list of alpha remap gradients.
  17344. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17345. * @returns the list of alpha remap gradients
  17346. */
  17347. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17348. /**
  17349. * Gets the current list of life time gradients.
  17350. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17351. * @returns the list of life time gradients
  17352. */
  17353. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17354. /**
  17355. * Gets the current list of angular speed gradients.
  17356. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17357. * @returns the list of angular speed gradients
  17358. */
  17359. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17360. /**
  17361. * Gets the current list of velocity gradients.
  17362. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17363. * @returns the list of velocity gradients
  17364. */
  17365. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17366. /**
  17367. * Gets the current list of start size gradients.
  17368. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17369. * @returns the list of start size gradients
  17370. */
  17371. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17372. /**
  17373. * Gets the current list of emit rate gradients.
  17374. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17375. * @returns the list of emit rate gradients
  17376. */
  17377. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17378. /**
  17379. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17380. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17381. */
  17382. direction1: Vector3;
  17383. /**
  17384. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17385. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17386. */
  17387. direction2: Vector3;
  17388. /**
  17389. * 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.
  17390. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17391. */
  17392. minEmitBox: Vector3;
  17393. /**
  17394. * 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.
  17395. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17396. */
  17397. maxEmitBox: Vector3;
  17398. /**
  17399. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17400. */
  17401. color1: Color4;
  17402. /**
  17403. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17404. */
  17405. color2: Color4;
  17406. /**
  17407. * Color the particle will have at the end of its lifetime
  17408. */
  17409. colorDead: Color4;
  17410. /**
  17411. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17412. */
  17413. textureMask: Color4;
  17414. /**
  17415. * The particle emitter type defines the emitter used by the particle system.
  17416. * It can be for example box, sphere, or cone...
  17417. */
  17418. particleEmitterType: IParticleEmitterType;
  17419. /** @hidden */
  17420. _isSubEmitter: boolean;
  17421. /**
  17422. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17423. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17424. */
  17425. billboardMode: number;
  17426. protected _isBillboardBased: boolean;
  17427. /**
  17428. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17429. */
  17430. isBillboardBased: boolean;
  17431. /**
  17432. * The scene the particle system belongs to.
  17433. */
  17434. protected _scene: Scene;
  17435. /**
  17436. * Local cache of defines for image processing.
  17437. */
  17438. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17439. /**
  17440. * Default configuration related to image processing available in the standard Material.
  17441. */
  17442. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17443. /**
  17444. * Gets the image processing configuration used either in this material.
  17445. */
  17446. /**
  17447. * Sets the Default image processing configuration used either in the this material.
  17448. *
  17449. * If sets to null, the scene one is in use.
  17450. */
  17451. imageProcessingConfiguration: ImageProcessingConfiguration;
  17452. /**
  17453. * Attaches a new image processing configuration to the Standard Material.
  17454. * @param configuration
  17455. */
  17456. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17457. /** @hidden */
  17458. protected _reset(): void;
  17459. /** @hidden */
  17460. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17461. /**
  17462. * Instantiates a particle system.
  17463. * 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.
  17464. * @param name The name of the particle system
  17465. */
  17466. constructor(name: string);
  17467. /**
  17468. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17469. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17470. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17471. * @returns the emitter
  17472. */
  17473. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17474. /**
  17475. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17476. * @param radius The radius of the hemisphere to emit from
  17477. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17478. * @returns the emitter
  17479. */
  17480. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17481. /**
  17482. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17483. * @param radius The radius of the sphere to emit from
  17484. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17485. * @returns the emitter
  17486. */
  17487. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17488. /**
  17489. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17490. * @param radius The radius of the sphere to emit from
  17491. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17492. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17493. * @returns the emitter
  17494. */
  17495. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17496. /**
  17497. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17498. * @param radius The radius of the emission cylinder
  17499. * @param height The height of the emission cylinder
  17500. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17501. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17502. * @returns the emitter
  17503. */
  17504. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17505. /**
  17506. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17507. * @param radius The radius of the cylinder to emit from
  17508. * @param height The height of the emission cylinder
  17509. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17510. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17511. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17512. * @returns the emitter
  17513. */
  17514. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17515. /**
  17516. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17517. * @param radius The radius of the cone to emit from
  17518. * @param angle The base angle of the cone
  17519. * @returns the emitter
  17520. */
  17521. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17522. /**
  17523. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17524. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17525. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17526. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17527. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17528. * @returns the emitter
  17529. */
  17530. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17531. }
  17532. }
  17533. declare module "babylonjs/Particles/subEmitter" {
  17534. import { Scene } from "babylonjs/scene";
  17535. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17536. /**
  17537. * Type of sub emitter
  17538. */
  17539. export enum SubEmitterType {
  17540. /**
  17541. * Attached to the particle over it's lifetime
  17542. */
  17543. ATTACHED = 0,
  17544. /**
  17545. * Created when the particle dies
  17546. */
  17547. END = 1
  17548. }
  17549. /**
  17550. * Sub emitter class used to emit particles from an existing particle
  17551. */
  17552. export class SubEmitter {
  17553. /**
  17554. * the particle system to be used by the sub emitter
  17555. */
  17556. particleSystem: ParticleSystem;
  17557. /**
  17558. * Type of the submitter (Default: END)
  17559. */
  17560. type: SubEmitterType;
  17561. /**
  17562. * 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)
  17563. * Note: This only is supported when using an emitter of type Mesh
  17564. */
  17565. inheritDirection: boolean;
  17566. /**
  17567. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17568. */
  17569. inheritedVelocityAmount: number;
  17570. /**
  17571. * Creates a sub emitter
  17572. * @param particleSystem the particle system to be used by the sub emitter
  17573. */
  17574. constructor(
  17575. /**
  17576. * the particle system to be used by the sub emitter
  17577. */
  17578. particleSystem: ParticleSystem);
  17579. /**
  17580. * Clones the sub emitter
  17581. * @returns the cloned sub emitter
  17582. */
  17583. clone(): SubEmitter;
  17584. /**
  17585. * Serialize current object to a JSON object
  17586. * @returns the serialized object
  17587. */
  17588. serialize(): any;
  17589. /** @hidden */
  17590. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17591. /**
  17592. * Creates a new SubEmitter from a serialized JSON version
  17593. * @param serializationObject defines the JSON object to read from
  17594. * @param scene defines the hosting scene
  17595. * @param rootUrl defines the rootUrl for data loading
  17596. * @returns a new SubEmitter
  17597. */
  17598. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17599. /** Release associated resources */
  17600. dispose(): void;
  17601. }
  17602. }
  17603. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17604. /** @hidden */
  17605. export var clipPlaneFragmentDeclaration: {
  17606. name: string;
  17607. shader: string;
  17608. };
  17609. }
  17610. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17611. /** @hidden */
  17612. export var imageProcessingDeclaration: {
  17613. name: string;
  17614. shader: string;
  17615. };
  17616. }
  17617. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17618. /** @hidden */
  17619. export var imageProcessingFunctions: {
  17620. name: string;
  17621. shader: string;
  17622. };
  17623. }
  17624. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17625. /** @hidden */
  17626. export var clipPlaneFragment: {
  17627. name: string;
  17628. shader: string;
  17629. };
  17630. }
  17631. declare module "babylonjs/Shaders/particles.fragment" {
  17632. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17633. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17634. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17635. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17636. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17637. /** @hidden */
  17638. export var particlesPixelShader: {
  17639. name: string;
  17640. shader: string;
  17641. };
  17642. }
  17643. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17644. /** @hidden */
  17645. export var clipPlaneVertexDeclaration: {
  17646. name: string;
  17647. shader: string;
  17648. };
  17649. }
  17650. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17651. /** @hidden */
  17652. export var clipPlaneVertex: {
  17653. name: string;
  17654. shader: string;
  17655. };
  17656. }
  17657. declare module "babylonjs/Shaders/particles.vertex" {
  17658. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17659. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17660. /** @hidden */
  17661. export var particlesVertexShader: {
  17662. name: string;
  17663. shader: string;
  17664. };
  17665. }
  17666. declare module "babylonjs/Particles/particleSystem" {
  17667. import { Nullable } from "babylonjs/types";
  17668. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17669. import { Observable } from "babylonjs/Misc/observable";
  17670. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17671. import { Effect } from "babylonjs/Materials/effect";
  17672. import { Scene, IDisposable } from "babylonjs/scene";
  17673. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17674. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17675. import { Particle } from "babylonjs/Particles/particle";
  17676. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17677. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17678. import "babylonjs/Shaders/particles.fragment";
  17679. import "babylonjs/Shaders/particles.vertex";
  17680. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17681. /**
  17682. * This represents a particle system in Babylon.
  17683. * 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.
  17684. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17685. * @example https://doc.babylonjs.com/babylon101/particles
  17686. */
  17687. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17688. /**
  17689. * Billboard mode will only apply to Y axis
  17690. */
  17691. static readonly BILLBOARDMODE_Y: number;
  17692. /**
  17693. * Billboard mode will apply to all axes
  17694. */
  17695. static readonly BILLBOARDMODE_ALL: number;
  17696. /**
  17697. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17698. */
  17699. static readonly BILLBOARDMODE_STRETCHED: number;
  17700. /**
  17701. * This function can be defined to provide custom update for active particles.
  17702. * This function will be called instead of regular update (age, position, color, etc.).
  17703. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17704. */
  17705. updateFunction: (particles: Particle[]) => void;
  17706. private _emitterWorldMatrix;
  17707. /**
  17708. * This function can be defined to specify initial direction for every new particle.
  17709. * It by default use the emitterType defined function
  17710. */
  17711. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17712. /**
  17713. * This function can be defined to specify initial position for every new particle.
  17714. * It by default use the emitterType defined function
  17715. */
  17716. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17717. /**
  17718. * @hidden
  17719. */
  17720. _inheritedVelocityOffset: Vector3;
  17721. /**
  17722. * An event triggered when the system is disposed
  17723. */
  17724. onDisposeObservable: Observable<ParticleSystem>;
  17725. private _onDisposeObserver;
  17726. /**
  17727. * Sets a callback that will be triggered when the system is disposed
  17728. */
  17729. onDispose: () => void;
  17730. private _particles;
  17731. private _epsilon;
  17732. private _capacity;
  17733. private _stockParticles;
  17734. private _newPartsExcess;
  17735. private _vertexData;
  17736. private _vertexBuffer;
  17737. private _vertexBuffers;
  17738. private _spriteBuffer;
  17739. private _indexBuffer;
  17740. private _effect;
  17741. private _customEffect;
  17742. private _cachedDefines;
  17743. private _scaledColorStep;
  17744. private _colorDiff;
  17745. private _scaledDirection;
  17746. private _scaledGravity;
  17747. private _currentRenderId;
  17748. private _alive;
  17749. private _useInstancing;
  17750. private _started;
  17751. private _stopped;
  17752. private _actualFrame;
  17753. private _scaledUpdateSpeed;
  17754. private _vertexBufferSize;
  17755. /** @hidden */
  17756. _currentEmitRateGradient: Nullable<FactorGradient>;
  17757. /** @hidden */
  17758. _currentEmitRate1: number;
  17759. /** @hidden */
  17760. _currentEmitRate2: number;
  17761. /** @hidden */
  17762. _currentStartSizeGradient: Nullable<FactorGradient>;
  17763. /** @hidden */
  17764. _currentStartSize1: number;
  17765. /** @hidden */
  17766. _currentStartSize2: number;
  17767. private readonly _rawTextureWidth;
  17768. private _rampGradientsTexture;
  17769. private _useRampGradients;
  17770. /** Gets or sets a boolean indicating that ramp gradients must be used
  17771. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17772. */
  17773. useRampGradients: boolean;
  17774. /**
  17775. * 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.
  17776. * 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: [])
  17777. */
  17778. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17779. private _subEmitters;
  17780. /**
  17781. * @hidden
  17782. * If the particle systems emitter should be disposed when the particle system is disposed
  17783. */
  17784. _disposeEmitterOnDispose: boolean;
  17785. /**
  17786. * The current active Sub-systems, this property is used by the root particle system only.
  17787. */
  17788. activeSubSystems: Array<ParticleSystem>;
  17789. private _rootParticleSystem;
  17790. /**
  17791. * Gets the current list of active particles
  17792. */
  17793. readonly particles: Particle[];
  17794. /**
  17795. * Returns the string "ParticleSystem"
  17796. * @returns a string containing the class name
  17797. */
  17798. getClassName(): string;
  17799. /**
  17800. * Instantiates a particle system.
  17801. * 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.
  17802. * @param name The name of the particle system
  17803. * @param capacity The max number of particles alive at the same time
  17804. * @param scene The scene the particle system belongs to
  17805. * @param customEffect a custom effect used to change the way particles are rendered by default
  17806. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17807. * @param epsilon Offset used to render the particles
  17808. */
  17809. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17810. private _addFactorGradient;
  17811. private _removeFactorGradient;
  17812. /**
  17813. * Adds a new life time gradient
  17814. * @param gradient defines the gradient to use (between 0 and 1)
  17815. * @param factor defines the life time factor to affect to the specified gradient
  17816. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17817. * @returns the current particle system
  17818. */
  17819. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17820. /**
  17821. * Remove a specific life time gradient
  17822. * @param gradient defines the gradient to remove
  17823. * @returns the current particle system
  17824. */
  17825. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17826. /**
  17827. * Adds a new size gradient
  17828. * @param gradient defines the gradient to use (between 0 and 1)
  17829. * @param factor defines the size factor to affect to the specified gradient
  17830. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17831. * @returns the current particle system
  17832. */
  17833. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17834. /**
  17835. * Remove a specific size gradient
  17836. * @param gradient defines the gradient to remove
  17837. * @returns the current particle system
  17838. */
  17839. removeSizeGradient(gradient: number): IParticleSystem;
  17840. /**
  17841. * Adds a new color remap gradient
  17842. * @param gradient defines the gradient to use (between 0 and 1)
  17843. * @param min defines the color remap minimal range
  17844. * @param max defines the color remap maximal range
  17845. * @returns the current particle system
  17846. */
  17847. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17848. /**
  17849. * Remove a specific color remap gradient
  17850. * @param gradient defines the gradient to remove
  17851. * @returns the current particle system
  17852. */
  17853. removeColorRemapGradient(gradient: number): IParticleSystem;
  17854. /**
  17855. * Adds a new alpha remap gradient
  17856. * @param gradient defines the gradient to use (between 0 and 1)
  17857. * @param min defines the alpha remap minimal range
  17858. * @param max defines the alpha remap maximal range
  17859. * @returns the current particle system
  17860. */
  17861. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17862. /**
  17863. * Remove a specific alpha remap gradient
  17864. * @param gradient defines the gradient to remove
  17865. * @returns the current particle system
  17866. */
  17867. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17868. /**
  17869. * Adds a new angular speed gradient
  17870. * @param gradient defines the gradient to use (between 0 and 1)
  17871. * @param factor defines the angular speed to affect to the specified gradient
  17872. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17873. * @returns the current particle system
  17874. */
  17875. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17876. /**
  17877. * Remove a specific angular speed gradient
  17878. * @param gradient defines the gradient to remove
  17879. * @returns the current particle system
  17880. */
  17881. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17882. /**
  17883. * Adds a new velocity gradient
  17884. * @param gradient defines the gradient to use (between 0 and 1)
  17885. * @param factor defines the velocity to affect to the specified gradient
  17886. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17887. * @returns the current particle system
  17888. */
  17889. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17890. /**
  17891. * Remove a specific velocity gradient
  17892. * @param gradient defines the gradient to remove
  17893. * @returns the current particle system
  17894. */
  17895. removeVelocityGradient(gradient: number): IParticleSystem;
  17896. /**
  17897. * Adds a new limit velocity gradient
  17898. * @param gradient defines the gradient to use (between 0 and 1)
  17899. * @param factor defines the limit velocity value to affect to the specified gradient
  17900. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17901. * @returns the current particle system
  17902. */
  17903. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17904. /**
  17905. * Remove a specific limit velocity gradient
  17906. * @param gradient defines the gradient to remove
  17907. * @returns the current particle system
  17908. */
  17909. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17910. /**
  17911. * Adds a new drag gradient
  17912. * @param gradient defines the gradient to use (between 0 and 1)
  17913. * @param factor defines the drag value to affect to the specified gradient
  17914. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17915. * @returns the current particle system
  17916. */
  17917. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17918. /**
  17919. * Remove a specific drag gradient
  17920. * @param gradient defines the gradient to remove
  17921. * @returns the current particle system
  17922. */
  17923. removeDragGradient(gradient: number): IParticleSystem;
  17924. /**
  17925. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17926. * @param gradient defines the gradient to use (between 0 and 1)
  17927. * @param factor defines the emit rate value to affect to the specified gradient
  17928. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17929. * @returns the current particle system
  17930. */
  17931. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17932. /**
  17933. * Remove a specific emit rate gradient
  17934. * @param gradient defines the gradient to remove
  17935. * @returns the current particle system
  17936. */
  17937. removeEmitRateGradient(gradient: number): IParticleSystem;
  17938. /**
  17939. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17940. * @param gradient defines the gradient to use (between 0 and 1)
  17941. * @param factor defines the start size value to affect to the specified gradient
  17942. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17943. * @returns the current particle system
  17944. */
  17945. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17946. /**
  17947. * Remove a specific start size gradient
  17948. * @param gradient defines the gradient to remove
  17949. * @returns the current particle system
  17950. */
  17951. removeStartSizeGradient(gradient: number): IParticleSystem;
  17952. private _createRampGradientTexture;
  17953. /**
  17954. * Gets the current list of ramp gradients.
  17955. * You must use addRampGradient and removeRampGradient to udpate this list
  17956. * @returns the list of ramp gradients
  17957. */
  17958. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17959. /**
  17960. * Adds a new ramp gradient used to remap particle colors
  17961. * @param gradient defines the gradient to use (between 0 and 1)
  17962. * @param color defines the color to affect to the specified gradient
  17963. * @returns the current particle system
  17964. */
  17965. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17966. /**
  17967. * Remove a specific ramp gradient
  17968. * @param gradient defines the gradient to remove
  17969. * @returns the current particle system
  17970. */
  17971. removeRampGradient(gradient: number): ParticleSystem;
  17972. /**
  17973. * Adds a new color gradient
  17974. * @param gradient defines the gradient to use (between 0 and 1)
  17975. * @param color1 defines the color to affect to the specified gradient
  17976. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17977. * @returns this particle system
  17978. */
  17979. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17980. /**
  17981. * Remove a specific color gradient
  17982. * @param gradient defines the gradient to remove
  17983. * @returns this particle system
  17984. */
  17985. removeColorGradient(gradient: number): IParticleSystem;
  17986. private _fetchR;
  17987. protected _reset(): void;
  17988. private _resetEffect;
  17989. private _createVertexBuffers;
  17990. private _createIndexBuffer;
  17991. /**
  17992. * Gets the maximum number of particles active at the same time.
  17993. * @returns The max number of active particles.
  17994. */
  17995. getCapacity(): number;
  17996. /**
  17997. * Gets whether there are still active particles in the system.
  17998. * @returns True if it is alive, otherwise false.
  17999. */
  18000. isAlive(): boolean;
  18001. /**
  18002. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18003. * @returns True if it has been started, otherwise false.
  18004. */
  18005. isStarted(): boolean;
  18006. private _prepareSubEmitterInternalArray;
  18007. /**
  18008. * Starts the particle system and begins to emit
  18009. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  18010. */
  18011. start(delay?: number): void;
  18012. /**
  18013. * Stops the particle system.
  18014. * @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.
  18015. */
  18016. stop(stopSubEmitters?: boolean): void;
  18017. /**
  18018. * Remove all active particles
  18019. */
  18020. reset(): void;
  18021. /**
  18022. * @hidden (for internal use only)
  18023. */
  18024. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18025. /**
  18026. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18027. * Its lifetime will start back at 0.
  18028. */
  18029. recycleParticle: (particle: Particle) => void;
  18030. private _stopSubEmitters;
  18031. private _createParticle;
  18032. private _removeFromRoot;
  18033. private _emitFromParticle;
  18034. private _update;
  18035. /** @hidden */
  18036. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18037. /** @hidden */
  18038. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18039. /** @hidden */
  18040. private _getEffect;
  18041. /**
  18042. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18043. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18044. */
  18045. animate(preWarmOnly?: boolean): void;
  18046. private _appendParticleVertices;
  18047. /**
  18048. * Rebuilds the particle system.
  18049. */
  18050. rebuild(): void;
  18051. /**
  18052. * Is this system ready to be used/rendered
  18053. * @return true if the system is ready
  18054. */
  18055. isReady(): boolean;
  18056. private _render;
  18057. /**
  18058. * Renders the particle system in its current state.
  18059. * @returns the current number of particles
  18060. */
  18061. render(): number;
  18062. /**
  18063. * Disposes the particle system and free the associated resources
  18064. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18065. */
  18066. dispose(disposeTexture?: boolean): void;
  18067. /**
  18068. * Clones the particle system.
  18069. * @param name The name of the cloned object
  18070. * @param newEmitter The new emitter to use
  18071. * @returns the cloned particle system
  18072. */
  18073. clone(name: string, newEmitter: any): ParticleSystem;
  18074. /**
  18075. * Serializes the particle system to a JSON object.
  18076. * @returns the JSON object
  18077. */
  18078. serialize(): any;
  18079. /** @hidden */
  18080. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18081. /** @hidden */
  18082. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18083. /**
  18084. * Parses a JSON object to create a particle system.
  18085. * @param parsedParticleSystem The JSON object to parse
  18086. * @param scene The scene to create the particle system in
  18087. * @param rootUrl The root url to use to load external dependencies like texture
  18088. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18089. * @returns the Parsed particle system
  18090. */
  18091. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18092. }
  18093. }
  18094. declare module "babylonjs/Particles/particle" {
  18095. import { Nullable } from "babylonjs/types";
  18096. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18097. import { Color4 } from "babylonjs/Maths/math.color";
  18098. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18099. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18100. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18101. /**
  18102. * A particle represents one of the element emitted by a particle system.
  18103. * This is mainly define by its coordinates, direction, velocity and age.
  18104. */
  18105. export class Particle {
  18106. /**
  18107. * The particle system the particle belongs to.
  18108. */
  18109. particleSystem: ParticleSystem;
  18110. private static _Count;
  18111. /**
  18112. * Unique ID of the particle
  18113. */
  18114. id: number;
  18115. /**
  18116. * The world position of the particle in the scene.
  18117. */
  18118. position: Vector3;
  18119. /**
  18120. * The world direction of the particle in the scene.
  18121. */
  18122. direction: Vector3;
  18123. /**
  18124. * The color of the particle.
  18125. */
  18126. color: Color4;
  18127. /**
  18128. * The color change of the particle per step.
  18129. */
  18130. colorStep: Color4;
  18131. /**
  18132. * Defines how long will the life of the particle be.
  18133. */
  18134. lifeTime: number;
  18135. /**
  18136. * The current age of the particle.
  18137. */
  18138. age: number;
  18139. /**
  18140. * The current size of the particle.
  18141. */
  18142. size: number;
  18143. /**
  18144. * The current scale of the particle.
  18145. */
  18146. scale: Vector2;
  18147. /**
  18148. * The current angle of the particle.
  18149. */
  18150. angle: number;
  18151. /**
  18152. * Defines how fast is the angle changing.
  18153. */
  18154. angularSpeed: number;
  18155. /**
  18156. * Defines the cell index used by the particle to be rendered from a sprite.
  18157. */
  18158. cellIndex: number;
  18159. /**
  18160. * The information required to support color remapping
  18161. */
  18162. remapData: Vector4;
  18163. /** @hidden */
  18164. _randomCellOffset?: number;
  18165. /** @hidden */
  18166. _initialDirection: Nullable<Vector3>;
  18167. /** @hidden */
  18168. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18169. /** @hidden */
  18170. _initialStartSpriteCellID: number;
  18171. /** @hidden */
  18172. _initialEndSpriteCellID: number;
  18173. /** @hidden */
  18174. _currentColorGradient: Nullable<ColorGradient>;
  18175. /** @hidden */
  18176. _currentColor1: Color4;
  18177. /** @hidden */
  18178. _currentColor2: Color4;
  18179. /** @hidden */
  18180. _currentSizeGradient: Nullable<FactorGradient>;
  18181. /** @hidden */
  18182. _currentSize1: number;
  18183. /** @hidden */
  18184. _currentSize2: number;
  18185. /** @hidden */
  18186. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18187. /** @hidden */
  18188. _currentAngularSpeed1: number;
  18189. /** @hidden */
  18190. _currentAngularSpeed2: number;
  18191. /** @hidden */
  18192. _currentVelocityGradient: Nullable<FactorGradient>;
  18193. /** @hidden */
  18194. _currentVelocity1: number;
  18195. /** @hidden */
  18196. _currentVelocity2: number;
  18197. /** @hidden */
  18198. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18199. /** @hidden */
  18200. _currentLimitVelocity1: number;
  18201. /** @hidden */
  18202. _currentLimitVelocity2: number;
  18203. /** @hidden */
  18204. _currentDragGradient: Nullable<FactorGradient>;
  18205. /** @hidden */
  18206. _currentDrag1: number;
  18207. /** @hidden */
  18208. _currentDrag2: number;
  18209. /** @hidden */
  18210. _randomNoiseCoordinates1: Vector3;
  18211. /** @hidden */
  18212. _randomNoiseCoordinates2: Vector3;
  18213. /**
  18214. * Creates a new instance Particle
  18215. * @param particleSystem the particle system the particle belongs to
  18216. */
  18217. constructor(
  18218. /**
  18219. * The particle system the particle belongs to.
  18220. */
  18221. particleSystem: ParticleSystem);
  18222. private updateCellInfoFromSystem;
  18223. /**
  18224. * Defines how the sprite cell index is updated for the particle
  18225. */
  18226. updateCellIndex(): void;
  18227. /** @hidden */
  18228. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18229. /** @hidden */
  18230. _inheritParticleInfoToSubEmitters(): void;
  18231. /** @hidden */
  18232. _reset(): void;
  18233. /**
  18234. * Copy the properties of particle to another one.
  18235. * @param other the particle to copy the information to.
  18236. */
  18237. copyTo(other: Particle): void;
  18238. }
  18239. }
  18240. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18241. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18242. import { Effect } from "babylonjs/Materials/effect";
  18243. import { Particle } from "babylonjs/Particles/particle";
  18244. /**
  18245. * Particle emitter represents a volume emitting particles.
  18246. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18247. */
  18248. export interface IParticleEmitterType {
  18249. /**
  18250. * Called by the particle System when the direction is computed for the created particle.
  18251. * @param worldMatrix is the world matrix of the particle system
  18252. * @param directionToUpdate is the direction vector to update with the result
  18253. * @param particle is the particle we are computed the direction for
  18254. */
  18255. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18256. /**
  18257. * Called by the particle System when the position is computed for the created particle.
  18258. * @param worldMatrix is the world matrix of the particle system
  18259. * @param positionToUpdate is the position vector to update with the result
  18260. * @param particle is the particle we are computed the position for
  18261. */
  18262. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18263. /**
  18264. * Clones the current emitter and returns a copy of it
  18265. * @returns the new emitter
  18266. */
  18267. clone(): IParticleEmitterType;
  18268. /**
  18269. * Called by the GPUParticleSystem to setup the update shader
  18270. * @param effect defines the update shader
  18271. */
  18272. applyToShader(effect: Effect): void;
  18273. /**
  18274. * Returns a string to use to update the GPU particles update shader
  18275. * @returns the effect defines string
  18276. */
  18277. getEffectDefines(): string;
  18278. /**
  18279. * Returns a string representing the class name
  18280. * @returns a string containing the class name
  18281. */
  18282. getClassName(): string;
  18283. /**
  18284. * Serializes the particle system to a JSON object.
  18285. * @returns the JSON object
  18286. */
  18287. serialize(): any;
  18288. /**
  18289. * Parse properties from a JSON object
  18290. * @param serializationObject defines the JSON object
  18291. */
  18292. parse(serializationObject: any): void;
  18293. }
  18294. }
  18295. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18296. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18297. import { Effect } from "babylonjs/Materials/effect";
  18298. import { Particle } from "babylonjs/Particles/particle";
  18299. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18300. /**
  18301. * Particle emitter emitting particles from the inside of a box.
  18302. * It emits the particles randomly between 2 given directions.
  18303. */
  18304. export class BoxParticleEmitter implements IParticleEmitterType {
  18305. /**
  18306. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18307. */
  18308. direction1: Vector3;
  18309. /**
  18310. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18311. */
  18312. direction2: Vector3;
  18313. /**
  18314. * 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.
  18315. */
  18316. minEmitBox: Vector3;
  18317. /**
  18318. * 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.
  18319. */
  18320. maxEmitBox: Vector3;
  18321. /**
  18322. * Creates a new instance BoxParticleEmitter
  18323. */
  18324. constructor();
  18325. /**
  18326. * Called by the particle System when the direction is computed for the created particle.
  18327. * @param worldMatrix is the world matrix of the particle system
  18328. * @param directionToUpdate is the direction vector to update with the result
  18329. * @param particle is the particle we are computed the direction for
  18330. */
  18331. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18332. /**
  18333. * Called by the particle System when the position is computed for the created particle.
  18334. * @param worldMatrix is the world matrix of the particle system
  18335. * @param positionToUpdate is the position vector to update with the result
  18336. * @param particle is the particle we are computed the position for
  18337. */
  18338. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18339. /**
  18340. * Clones the current emitter and returns a copy of it
  18341. * @returns the new emitter
  18342. */
  18343. clone(): BoxParticleEmitter;
  18344. /**
  18345. * Called by the GPUParticleSystem to setup the update shader
  18346. * @param effect defines the update shader
  18347. */
  18348. applyToShader(effect: Effect): void;
  18349. /**
  18350. * Returns a string to use to update the GPU particles update shader
  18351. * @returns a string containng the defines string
  18352. */
  18353. getEffectDefines(): string;
  18354. /**
  18355. * Returns the string "BoxParticleEmitter"
  18356. * @returns a string containing the class name
  18357. */
  18358. getClassName(): string;
  18359. /**
  18360. * Serializes the particle system to a JSON object.
  18361. * @returns the JSON object
  18362. */
  18363. serialize(): any;
  18364. /**
  18365. * Parse properties from a JSON object
  18366. * @param serializationObject defines the JSON object
  18367. */
  18368. parse(serializationObject: any): void;
  18369. }
  18370. }
  18371. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18372. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18373. import { Effect } from "babylonjs/Materials/effect";
  18374. import { Particle } from "babylonjs/Particles/particle";
  18375. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18376. /**
  18377. * Particle emitter emitting particles from the inside of a cone.
  18378. * It emits the particles alongside the cone volume from the base to the particle.
  18379. * The emission direction might be randomized.
  18380. */
  18381. export class ConeParticleEmitter implements IParticleEmitterType {
  18382. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18383. directionRandomizer: number;
  18384. private _radius;
  18385. private _angle;
  18386. private _height;
  18387. /**
  18388. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18389. */
  18390. radiusRange: number;
  18391. /**
  18392. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18393. */
  18394. heightRange: number;
  18395. /**
  18396. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18397. */
  18398. emitFromSpawnPointOnly: boolean;
  18399. /**
  18400. * Gets or sets the radius of the emission cone
  18401. */
  18402. radius: number;
  18403. /**
  18404. * Gets or sets the angle of the emission cone
  18405. */
  18406. angle: number;
  18407. private _buildHeight;
  18408. /**
  18409. * Creates a new instance ConeParticleEmitter
  18410. * @param radius the radius of the emission cone (1 by default)
  18411. * @param angle the cone base angle (PI by default)
  18412. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18413. */
  18414. constructor(radius?: number, angle?: number,
  18415. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18416. directionRandomizer?: number);
  18417. /**
  18418. * Called by the particle System when the direction is computed for the created particle.
  18419. * @param worldMatrix is the world matrix of the particle system
  18420. * @param directionToUpdate is the direction vector to update with the result
  18421. * @param particle is the particle we are computed the direction for
  18422. */
  18423. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18424. /**
  18425. * Called by the particle System when the position is computed for the created particle.
  18426. * @param worldMatrix is the world matrix of the particle system
  18427. * @param positionToUpdate is the position vector to update with the result
  18428. * @param particle is the particle we are computed the position for
  18429. */
  18430. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18431. /**
  18432. * Clones the current emitter and returns a copy of it
  18433. * @returns the new emitter
  18434. */
  18435. clone(): ConeParticleEmitter;
  18436. /**
  18437. * Called by the GPUParticleSystem to setup the update shader
  18438. * @param effect defines the update shader
  18439. */
  18440. applyToShader(effect: Effect): void;
  18441. /**
  18442. * Returns a string to use to update the GPU particles update shader
  18443. * @returns a string containng the defines string
  18444. */
  18445. getEffectDefines(): string;
  18446. /**
  18447. * Returns the string "ConeParticleEmitter"
  18448. * @returns a string containing the class name
  18449. */
  18450. getClassName(): string;
  18451. /**
  18452. * Serializes the particle system to a JSON object.
  18453. * @returns the JSON object
  18454. */
  18455. serialize(): any;
  18456. /**
  18457. * Parse properties from a JSON object
  18458. * @param serializationObject defines the JSON object
  18459. */
  18460. parse(serializationObject: any): void;
  18461. }
  18462. }
  18463. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18464. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18465. import { Effect } from "babylonjs/Materials/effect";
  18466. import { Particle } from "babylonjs/Particles/particle";
  18467. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18468. /**
  18469. * Particle emitter emitting particles from the inside of a cylinder.
  18470. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18471. */
  18472. export class CylinderParticleEmitter implements IParticleEmitterType {
  18473. /**
  18474. * The radius of the emission cylinder.
  18475. */
  18476. radius: number;
  18477. /**
  18478. * The height of the emission cylinder.
  18479. */
  18480. height: number;
  18481. /**
  18482. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18483. */
  18484. radiusRange: number;
  18485. /**
  18486. * How much to randomize the particle direction [0-1].
  18487. */
  18488. directionRandomizer: number;
  18489. /**
  18490. * Creates a new instance CylinderParticleEmitter
  18491. * @param radius the radius of the emission cylinder (1 by default)
  18492. * @param height the height of the emission cylinder (1 by default)
  18493. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18494. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18495. */
  18496. constructor(
  18497. /**
  18498. * The radius of the emission cylinder.
  18499. */
  18500. radius?: number,
  18501. /**
  18502. * The height of the emission cylinder.
  18503. */
  18504. height?: number,
  18505. /**
  18506. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18507. */
  18508. radiusRange?: number,
  18509. /**
  18510. * How much to randomize the particle direction [0-1].
  18511. */
  18512. directionRandomizer?: number);
  18513. /**
  18514. * Called by the particle System when the direction is computed for the created particle.
  18515. * @param worldMatrix is the world matrix of the particle system
  18516. * @param directionToUpdate is the direction vector to update with the result
  18517. * @param particle is the particle we are computed the direction for
  18518. */
  18519. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18520. /**
  18521. * Called by the particle System when the position is computed for the created particle.
  18522. * @param worldMatrix is the world matrix of the particle system
  18523. * @param positionToUpdate is the position vector to update with the result
  18524. * @param particle is the particle we are computed the position for
  18525. */
  18526. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18527. /**
  18528. * Clones the current emitter and returns a copy of it
  18529. * @returns the new emitter
  18530. */
  18531. clone(): CylinderParticleEmitter;
  18532. /**
  18533. * Called by the GPUParticleSystem to setup the update shader
  18534. * @param effect defines the update shader
  18535. */
  18536. applyToShader(effect: Effect): void;
  18537. /**
  18538. * Returns a string to use to update the GPU particles update shader
  18539. * @returns a string containng the defines string
  18540. */
  18541. getEffectDefines(): string;
  18542. /**
  18543. * Returns the string "CylinderParticleEmitter"
  18544. * @returns a string containing the class name
  18545. */
  18546. getClassName(): string;
  18547. /**
  18548. * Serializes the particle system to a JSON object.
  18549. * @returns the JSON object
  18550. */
  18551. serialize(): any;
  18552. /**
  18553. * Parse properties from a JSON object
  18554. * @param serializationObject defines the JSON object
  18555. */
  18556. parse(serializationObject: any): void;
  18557. }
  18558. /**
  18559. * Particle emitter emitting particles from the inside of a cylinder.
  18560. * It emits the particles randomly between two vectors.
  18561. */
  18562. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18563. /**
  18564. * The min limit of the emission direction.
  18565. */
  18566. direction1: Vector3;
  18567. /**
  18568. * The max limit of the emission direction.
  18569. */
  18570. direction2: Vector3;
  18571. /**
  18572. * Creates a new instance CylinderDirectedParticleEmitter
  18573. * @param radius the radius of the emission cylinder (1 by default)
  18574. * @param height the height of the emission cylinder (1 by default)
  18575. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18576. * @param direction1 the min limit of the emission direction (up vector by default)
  18577. * @param direction2 the max limit of the emission direction (up vector by default)
  18578. */
  18579. constructor(radius?: number, height?: number, radiusRange?: number,
  18580. /**
  18581. * The min limit of the emission direction.
  18582. */
  18583. direction1?: Vector3,
  18584. /**
  18585. * The max limit of the emission direction.
  18586. */
  18587. direction2?: Vector3);
  18588. /**
  18589. * Called by the particle System when the direction is computed for the created particle.
  18590. * @param worldMatrix is the world matrix of the particle system
  18591. * @param directionToUpdate is the direction vector to update with the result
  18592. * @param particle is the particle we are computed the direction for
  18593. */
  18594. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18595. /**
  18596. * Clones the current emitter and returns a copy of it
  18597. * @returns the new emitter
  18598. */
  18599. clone(): CylinderDirectedParticleEmitter;
  18600. /**
  18601. * Called by the GPUParticleSystem to setup the update shader
  18602. * @param effect defines the update shader
  18603. */
  18604. applyToShader(effect: Effect): void;
  18605. /**
  18606. * Returns a string to use to update the GPU particles update shader
  18607. * @returns a string containng the defines string
  18608. */
  18609. getEffectDefines(): string;
  18610. /**
  18611. * Returns the string "CylinderDirectedParticleEmitter"
  18612. * @returns a string containing the class name
  18613. */
  18614. getClassName(): string;
  18615. /**
  18616. * Serializes the particle system to a JSON object.
  18617. * @returns the JSON object
  18618. */
  18619. serialize(): any;
  18620. /**
  18621. * Parse properties from a JSON object
  18622. * @param serializationObject defines the JSON object
  18623. */
  18624. parse(serializationObject: any): void;
  18625. }
  18626. }
  18627. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18628. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18629. import { Effect } from "babylonjs/Materials/effect";
  18630. import { Particle } from "babylonjs/Particles/particle";
  18631. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18632. /**
  18633. * Particle emitter emitting particles from the inside of a hemisphere.
  18634. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18635. */
  18636. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18637. /**
  18638. * The radius of the emission hemisphere.
  18639. */
  18640. radius: number;
  18641. /**
  18642. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18643. */
  18644. radiusRange: number;
  18645. /**
  18646. * How much to randomize the particle direction [0-1].
  18647. */
  18648. directionRandomizer: number;
  18649. /**
  18650. * Creates a new instance HemisphericParticleEmitter
  18651. * @param radius the radius of the emission hemisphere (1 by default)
  18652. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18653. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18654. */
  18655. constructor(
  18656. /**
  18657. * The radius of the emission hemisphere.
  18658. */
  18659. radius?: number,
  18660. /**
  18661. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18662. */
  18663. radiusRange?: number,
  18664. /**
  18665. * How much to randomize the particle direction [0-1].
  18666. */
  18667. directionRandomizer?: number);
  18668. /**
  18669. * Called by the particle System when the direction is computed for the created particle.
  18670. * @param worldMatrix is the world matrix of the particle system
  18671. * @param directionToUpdate is the direction vector to update with the result
  18672. * @param particle is the particle we are computed the direction for
  18673. */
  18674. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18675. /**
  18676. * Called by the particle System when the position is computed for the created particle.
  18677. * @param worldMatrix is the world matrix of the particle system
  18678. * @param positionToUpdate is the position vector to update with the result
  18679. * @param particle is the particle we are computed the position for
  18680. */
  18681. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18682. /**
  18683. * Clones the current emitter and returns a copy of it
  18684. * @returns the new emitter
  18685. */
  18686. clone(): HemisphericParticleEmitter;
  18687. /**
  18688. * Called by the GPUParticleSystem to setup the update shader
  18689. * @param effect defines the update shader
  18690. */
  18691. applyToShader(effect: Effect): void;
  18692. /**
  18693. * Returns a string to use to update the GPU particles update shader
  18694. * @returns a string containng the defines string
  18695. */
  18696. getEffectDefines(): string;
  18697. /**
  18698. * Returns the string "HemisphericParticleEmitter"
  18699. * @returns a string containing the class name
  18700. */
  18701. getClassName(): string;
  18702. /**
  18703. * Serializes the particle system to a JSON object.
  18704. * @returns the JSON object
  18705. */
  18706. serialize(): any;
  18707. /**
  18708. * Parse properties from a JSON object
  18709. * @param serializationObject defines the JSON object
  18710. */
  18711. parse(serializationObject: any): void;
  18712. }
  18713. }
  18714. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18715. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18716. import { Effect } from "babylonjs/Materials/effect";
  18717. import { Particle } from "babylonjs/Particles/particle";
  18718. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18719. /**
  18720. * Particle emitter emitting particles from a point.
  18721. * It emits the particles randomly between 2 given directions.
  18722. */
  18723. export class PointParticleEmitter implements IParticleEmitterType {
  18724. /**
  18725. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18726. */
  18727. direction1: Vector3;
  18728. /**
  18729. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18730. */
  18731. direction2: Vector3;
  18732. /**
  18733. * Creates a new instance PointParticleEmitter
  18734. */
  18735. constructor();
  18736. /**
  18737. * Called by the particle System when the direction is computed for the created particle.
  18738. * @param worldMatrix is the world matrix of the particle system
  18739. * @param directionToUpdate is the direction vector to update with the result
  18740. * @param particle is the particle we are computed the direction for
  18741. */
  18742. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18743. /**
  18744. * Called by the particle System when the position is computed for the created particle.
  18745. * @param worldMatrix is the world matrix of the particle system
  18746. * @param positionToUpdate is the position vector to update with the result
  18747. * @param particle is the particle we are computed the position for
  18748. */
  18749. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18750. /**
  18751. * Clones the current emitter and returns a copy of it
  18752. * @returns the new emitter
  18753. */
  18754. clone(): PointParticleEmitter;
  18755. /**
  18756. * Called by the GPUParticleSystem to setup the update shader
  18757. * @param effect defines the update shader
  18758. */
  18759. applyToShader(effect: Effect): void;
  18760. /**
  18761. * Returns a string to use to update the GPU particles update shader
  18762. * @returns a string containng the defines string
  18763. */
  18764. getEffectDefines(): string;
  18765. /**
  18766. * Returns the string "PointParticleEmitter"
  18767. * @returns a string containing the class name
  18768. */
  18769. getClassName(): string;
  18770. /**
  18771. * Serializes the particle system to a JSON object.
  18772. * @returns the JSON object
  18773. */
  18774. serialize(): any;
  18775. /**
  18776. * Parse properties from a JSON object
  18777. * @param serializationObject defines the JSON object
  18778. */
  18779. parse(serializationObject: any): void;
  18780. }
  18781. }
  18782. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18783. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18784. import { Effect } from "babylonjs/Materials/effect";
  18785. import { Particle } from "babylonjs/Particles/particle";
  18786. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18787. /**
  18788. * Particle emitter emitting particles from the inside of a sphere.
  18789. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18790. */
  18791. export class SphereParticleEmitter implements IParticleEmitterType {
  18792. /**
  18793. * The radius of the emission sphere.
  18794. */
  18795. radius: number;
  18796. /**
  18797. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18798. */
  18799. radiusRange: number;
  18800. /**
  18801. * How much to randomize the particle direction [0-1].
  18802. */
  18803. directionRandomizer: number;
  18804. /**
  18805. * Creates a new instance SphereParticleEmitter
  18806. * @param radius the radius of the emission sphere (1 by default)
  18807. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18808. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18809. */
  18810. constructor(
  18811. /**
  18812. * The radius of the emission sphere.
  18813. */
  18814. radius?: number,
  18815. /**
  18816. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18817. */
  18818. radiusRange?: number,
  18819. /**
  18820. * How much to randomize the particle direction [0-1].
  18821. */
  18822. directionRandomizer?: number);
  18823. /**
  18824. * Called by the particle System when the direction is computed for the created particle.
  18825. * @param worldMatrix is the world matrix of the particle system
  18826. * @param directionToUpdate is the direction vector to update with the result
  18827. * @param particle is the particle we are computed the direction for
  18828. */
  18829. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18830. /**
  18831. * Called by the particle System when the position is computed for the created particle.
  18832. * @param worldMatrix is the world matrix of the particle system
  18833. * @param positionToUpdate is the position vector to update with the result
  18834. * @param particle is the particle we are computed the position for
  18835. */
  18836. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18837. /**
  18838. * Clones the current emitter and returns a copy of it
  18839. * @returns the new emitter
  18840. */
  18841. clone(): SphereParticleEmitter;
  18842. /**
  18843. * Called by the GPUParticleSystem to setup the update shader
  18844. * @param effect defines the update shader
  18845. */
  18846. applyToShader(effect: Effect): void;
  18847. /**
  18848. * Returns a string to use to update the GPU particles update shader
  18849. * @returns a string containng the defines string
  18850. */
  18851. getEffectDefines(): string;
  18852. /**
  18853. * Returns the string "SphereParticleEmitter"
  18854. * @returns a string containing the class name
  18855. */
  18856. getClassName(): string;
  18857. /**
  18858. * Serializes the particle system to a JSON object.
  18859. * @returns the JSON object
  18860. */
  18861. serialize(): any;
  18862. /**
  18863. * Parse properties from a JSON object
  18864. * @param serializationObject defines the JSON object
  18865. */
  18866. parse(serializationObject: any): void;
  18867. }
  18868. /**
  18869. * Particle emitter emitting particles from the inside of a sphere.
  18870. * It emits the particles randomly between two vectors.
  18871. */
  18872. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18873. /**
  18874. * The min limit of the emission direction.
  18875. */
  18876. direction1: Vector3;
  18877. /**
  18878. * The max limit of the emission direction.
  18879. */
  18880. direction2: Vector3;
  18881. /**
  18882. * Creates a new instance SphereDirectedParticleEmitter
  18883. * @param radius the radius of the emission sphere (1 by default)
  18884. * @param direction1 the min limit of the emission direction (up vector by default)
  18885. * @param direction2 the max limit of the emission direction (up vector by default)
  18886. */
  18887. constructor(radius?: number,
  18888. /**
  18889. * The min limit of the emission direction.
  18890. */
  18891. direction1?: Vector3,
  18892. /**
  18893. * The max limit of the emission direction.
  18894. */
  18895. direction2?: Vector3);
  18896. /**
  18897. * Called by the particle System when the direction is computed for the created particle.
  18898. * @param worldMatrix is the world matrix of the particle system
  18899. * @param directionToUpdate is the direction vector to update with the result
  18900. * @param particle is the particle we are computed the direction for
  18901. */
  18902. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18903. /**
  18904. * Clones the current emitter and returns a copy of it
  18905. * @returns the new emitter
  18906. */
  18907. clone(): SphereDirectedParticleEmitter;
  18908. /**
  18909. * Called by the GPUParticleSystem to setup the update shader
  18910. * @param effect defines the update shader
  18911. */
  18912. applyToShader(effect: Effect): void;
  18913. /**
  18914. * Returns a string to use to update the GPU particles update shader
  18915. * @returns a string containng the defines string
  18916. */
  18917. getEffectDefines(): string;
  18918. /**
  18919. * Returns the string "SphereDirectedParticleEmitter"
  18920. * @returns a string containing the class name
  18921. */
  18922. getClassName(): string;
  18923. /**
  18924. * Serializes the particle system to a JSON object.
  18925. * @returns the JSON object
  18926. */
  18927. serialize(): any;
  18928. /**
  18929. * Parse properties from a JSON object
  18930. * @param serializationObject defines the JSON object
  18931. */
  18932. parse(serializationObject: any): void;
  18933. }
  18934. }
  18935. declare module "babylonjs/Particles/EmitterTypes/index" {
  18936. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18937. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18938. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18939. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18940. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18941. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18942. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18943. }
  18944. declare module "babylonjs/Particles/IParticleSystem" {
  18945. import { Nullable } from "babylonjs/types";
  18946. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18947. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18949. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18950. import { Texture } from "babylonjs/Materials/Textures/texture";
  18951. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18952. import { Scene } from "babylonjs/scene";
  18953. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18954. import { Animation } from "babylonjs/Animations/animation";
  18955. /**
  18956. * Interface representing a particle system in Babylon.js.
  18957. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18958. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18959. */
  18960. export interface IParticleSystem {
  18961. /**
  18962. * List of animations used by the particle system.
  18963. */
  18964. animations: Animation[];
  18965. /**
  18966. * The id of the Particle system.
  18967. */
  18968. id: string;
  18969. /**
  18970. * The name of the Particle system.
  18971. */
  18972. name: string;
  18973. /**
  18974. * The emitter represents the Mesh or position we are attaching the particle system to.
  18975. */
  18976. emitter: Nullable<AbstractMesh | Vector3>;
  18977. /**
  18978. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18979. */
  18980. isBillboardBased: boolean;
  18981. /**
  18982. * The rendering group used by the Particle system to chose when to render.
  18983. */
  18984. renderingGroupId: number;
  18985. /**
  18986. * The layer mask we are rendering the particles through.
  18987. */
  18988. layerMask: number;
  18989. /**
  18990. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18991. */
  18992. updateSpeed: number;
  18993. /**
  18994. * The amount of time the particle system is running (depends of the overall update speed).
  18995. */
  18996. targetStopDuration: number;
  18997. /**
  18998. * The texture used to render each particle. (this can be a spritesheet)
  18999. */
  19000. particleTexture: Nullable<Texture>;
  19001. /**
  19002. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  19003. */
  19004. blendMode: number;
  19005. /**
  19006. * Minimum life time of emitting particles.
  19007. */
  19008. minLifeTime: number;
  19009. /**
  19010. * Maximum life time of emitting particles.
  19011. */
  19012. maxLifeTime: number;
  19013. /**
  19014. * Minimum Size of emitting particles.
  19015. */
  19016. minSize: number;
  19017. /**
  19018. * Maximum Size of emitting particles.
  19019. */
  19020. maxSize: number;
  19021. /**
  19022. * Minimum scale of emitting particles on X axis.
  19023. */
  19024. minScaleX: number;
  19025. /**
  19026. * Maximum scale of emitting particles on X axis.
  19027. */
  19028. maxScaleX: number;
  19029. /**
  19030. * Minimum scale of emitting particles on Y axis.
  19031. */
  19032. minScaleY: number;
  19033. /**
  19034. * Maximum scale of emitting particles on Y axis.
  19035. */
  19036. maxScaleY: number;
  19037. /**
  19038. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19039. */
  19040. color1: Color4;
  19041. /**
  19042. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19043. */
  19044. color2: Color4;
  19045. /**
  19046. * Color the particle will have at the end of its lifetime.
  19047. */
  19048. colorDead: Color4;
  19049. /**
  19050. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19051. */
  19052. emitRate: number;
  19053. /**
  19054. * You can use gravity if you want to give an orientation to your particles.
  19055. */
  19056. gravity: Vector3;
  19057. /**
  19058. * Minimum power of emitting particles.
  19059. */
  19060. minEmitPower: number;
  19061. /**
  19062. * Maximum power of emitting particles.
  19063. */
  19064. maxEmitPower: number;
  19065. /**
  19066. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19067. */
  19068. minAngularSpeed: number;
  19069. /**
  19070. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19071. */
  19072. maxAngularSpeed: number;
  19073. /**
  19074. * Gets or sets the minimal initial rotation in radians.
  19075. */
  19076. minInitialRotation: number;
  19077. /**
  19078. * Gets or sets the maximal initial rotation in radians.
  19079. */
  19080. maxInitialRotation: number;
  19081. /**
  19082. * The particle emitter type defines the emitter used by the particle system.
  19083. * It can be for example box, sphere, or cone...
  19084. */
  19085. particleEmitterType: Nullable<IParticleEmitterType>;
  19086. /**
  19087. * Defines the delay in milliseconds before starting the system (0 by default)
  19088. */
  19089. startDelay: number;
  19090. /**
  19091. * 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
  19092. */
  19093. preWarmCycles: number;
  19094. /**
  19095. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19096. */
  19097. preWarmStepOffset: number;
  19098. /**
  19099. * 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)
  19100. */
  19101. spriteCellChangeSpeed: number;
  19102. /**
  19103. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19104. */
  19105. startSpriteCellID: number;
  19106. /**
  19107. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19108. */
  19109. endSpriteCellID: number;
  19110. /**
  19111. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19112. */
  19113. spriteCellWidth: number;
  19114. /**
  19115. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19116. */
  19117. spriteCellHeight: number;
  19118. /**
  19119. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19120. */
  19121. spriteRandomStartCell: boolean;
  19122. /**
  19123. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19124. */
  19125. isAnimationSheetEnabled: boolean;
  19126. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19127. translationPivot: Vector2;
  19128. /**
  19129. * Gets or sets a texture used to add random noise to particle positions
  19130. */
  19131. noiseTexture: Nullable<BaseTexture>;
  19132. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19133. noiseStrength: Vector3;
  19134. /**
  19135. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19136. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19137. */
  19138. billboardMode: number;
  19139. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19140. limitVelocityDamping: number;
  19141. /**
  19142. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19143. */
  19144. beginAnimationOnStart: boolean;
  19145. /**
  19146. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19147. */
  19148. beginAnimationFrom: number;
  19149. /**
  19150. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19151. */
  19152. beginAnimationTo: number;
  19153. /**
  19154. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19155. */
  19156. beginAnimationLoop: boolean;
  19157. /**
  19158. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19159. */
  19160. disposeOnStop: boolean;
  19161. /**
  19162. * Gets the maximum number of particles active at the same time.
  19163. * @returns The max number of active particles.
  19164. */
  19165. getCapacity(): number;
  19166. /**
  19167. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19168. * @returns True if it has been started, otherwise false.
  19169. */
  19170. isStarted(): boolean;
  19171. /**
  19172. * Animates the particle system for this frame.
  19173. */
  19174. animate(): void;
  19175. /**
  19176. * Renders the particle system in its current state.
  19177. * @returns the current number of particles
  19178. */
  19179. render(): number;
  19180. /**
  19181. * Dispose the particle system and frees its associated resources.
  19182. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19183. */
  19184. dispose(disposeTexture?: boolean): void;
  19185. /**
  19186. * Clones the particle system.
  19187. * @param name The name of the cloned object
  19188. * @param newEmitter The new emitter to use
  19189. * @returns the cloned particle system
  19190. */
  19191. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19192. /**
  19193. * Serializes the particle system to a JSON object.
  19194. * @returns the JSON object
  19195. */
  19196. serialize(): any;
  19197. /**
  19198. * Rebuild the particle system
  19199. */
  19200. rebuild(): void;
  19201. /**
  19202. * Starts the particle system and begins to emit
  19203. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19204. */
  19205. start(delay?: number): void;
  19206. /**
  19207. * Stops the particle system.
  19208. */
  19209. stop(): void;
  19210. /**
  19211. * Remove all active particles
  19212. */
  19213. reset(): void;
  19214. /**
  19215. * Is this system ready to be used/rendered
  19216. * @return true if the system is ready
  19217. */
  19218. isReady(): boolean;
  19219. /**
  19220. * Adds a new color gradient
  19221. * @param gradient defines the gradient to use (between 0 and 1)
  19222. * @param color1 defines the color to affect to the specified gradient
  19223. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19224. * @returns the current particle system
  19225. */
  19226. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19227. /**
  19228. * Remove a specific color gradient
  19229. * @param gradient defines the gradient to remove
  19230. * @returns the current particle system
  19231. */
  19232. removeColorGradient(gradient: number): IParticleSystem;
  19233. /**
  19234. * Adds a new size gradient
  19235. * @param gradient defines the gradient to use (between 0 and 1)
  19236. * @param factor defines the size factor to affect to the specified gradient
  19237. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19238. * @returns the current particle system
  19239. */
  19240. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19241. /**
  19242. * Remove a specific size gradient
  19243. * @param gradient defines the gradient to remove
  19244. * @returns the current particle system
  19245. */
  19246. removeSizeGradient(gradient: number): IParticleSystem;
  19247. /**
  19248. * Gets the current list of color gradients.
  19249. * You must use addColorGradient and removeColorGradient to udpate this list
  19250. * @returns the list of color gradients
  19251. */
  19252. getColorGradients(): Nullable<Array<ColorGradient>>;
  19253. /**
  19254. * Gets the current list of size gradients.
  19255. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19256. * @returns the list of size gradients
  19257. */
  19258. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19259. /**
  19260. * Gets the current list of angular speed gradients.
  19261. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19262. * @returns the list of angular speed gradients
  19263. */
  19264. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19265. /**
  19266. * Adds a new angular speed gradient
  19267. * @param gradient defines the gradient to use (between 0 and 1)
  19268. * @param factor defines the angular speed to affect to the specified gradient
  19269. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19270. * @returns the current particle system
  19271. */
  19272. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19273. /**
  19274. * Remove a specific angular speed gradient
  19275. * @param gradient defines the gradient to remove
  19276. * @returns the current particle system
  19277. */
  19278. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19279. /**
  19280. * Gets the current list of velocity gradients.
  19281. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19282. * @returns the list of velocity gradients
  19283. */
  19284. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19285. /**
  19286. * Adds a new velocity gradient
  19287. * @param gradient defines the gradient to use (between 0 and 1)
  19288. * @param factor defines the velocity to affect to the specified gradient
  19289. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19290. * @returns the current particle system
  19291. */
  19292. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19293. /**
  19294. * Remove a specific velocity gradient
  19295. * @param gradient defines the gradient to remove
  19296. * @returns the current particle system
  19297. */
  19298. removeVelocityGradient(gradient: number): IParticleSystem;
  19299. /**
  19300. * Gets the current list of limit velocity gradients.
  19301. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19302. * @returns the list of limit velocity gradients
  19303. */
  19304. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19305. /**
  19306. * Adds a new limit velocity gradient
  19307. * @param gradient defines the gradient to use (between 0 and 1)
  19308. * @param factor defines the limit velocity to affect to the specified gradient
  19309. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19310. * @returns the current particle system
  19311. */
  19312. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19313. /**
  19314. * Remove a specific limit velocity gradient
  19315. * @param gradient defines the gradient to remove
  19316. * @returns the current particle system
  19317. */
  19318. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19319. /**
  19320. * Adds a new drag gradient
  19321. * @param gradient defines the gradient to use (between 0 and 1)
  19322. * @param factor defines the drag to affect to the specified gradient
  19323. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19324. * @returns the current particle system
  19325. */
  19326. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19327. /**
  19328. * Remove a specific drag gradient
  19329. * @param gradient defines the gradient to remove
  19330. * @returns the current particle system
  19331. */
  19332. removeDragGradient(gradient: number): IParticleSystem;
  19333. /**
  19334. * Gets the current list of drag gradients.
  19335. * You must use addDragGradient and removeDragGradient to udpate this list
  19336. * @returns the list of drag gradients
  19337. */
  19338. getDragGradients(): Nullable<Array<FactorGradient>>;
  19339. /**
  19340. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19341. * @param gradient defines the gradient to use (between 0 and 1)
  19342. * @param factor defines the emit rate to affect to the specified gradient
  19343. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19344. * @returns the current particle system
  19345. */
  19346. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19347. /**
  19348. * Remove a specific emit rate gradient
  19349. * @param gradient defines the gradient to remove
  19350. * @returns the current particle system
  19351. */
  19352. removeEmitRateGradient(gradient: number): IParticleSystem;
  19353. /**
  19354. * Gets the current list of emit rate gradients.
  19355. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19356. * @returns the list of emit rate gradients
  19357. */
  19358. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19359. /**
  19360. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19361. * @param gradient defines the gradient to use (between 0 and 1)
  19362. * @param factor defines the start size to affect to the specified gradient
  19363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19364. * @returns the current particle system
  19365. */
  19366. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19367. /**
  19368. * Remove a specific start size gradient
  19369. * @param gradient defines the gradient to remove
  19370. * @returns the current particle system
  19371. */
  19372. removeStartSizeGradient(gradient: number): IParticleSystem;
  19373. /**
  19374. * Gets the current list of start size gradients.
  19375. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19376. * @returns the list of start size gradients
  19377. */
  19378. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19379. /**
  19380. * Adds a new life time gradient
  19381. * @param gradient defines the gradient to use (between 0 and 1)
  19382. * @param factor defines the life time factor to affect to the specified gradient
  19383. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19384. * @returns the current particle system
  19385. */
  19386. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19387. /**
  19388. * Remove a specific life time gradient
  19389. * @param gradient defines the gradient to remove
  19390. * @returns the current particle system
  19391. */
  19392. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19393. /**
  19394. * Gets the current list of life time gradients.
  19395. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19396. * @returns the list of life time gradients
  19397. */
  19398. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19399. /**
  19400. * Gets the current list of color gradients.
  19401. * You must use addColorGradient and removeColorGradient to udpate this list
  19402. * @returns the list of color gradients
  19403. */
  19404. getColorGradients(): Nullable<Array<ColorGradient>>;
  19405. /**
  19406. * Adds a new ramp gradient used to remap particle colors
  19407. * @param gradient defines the gradient to use (between 0 and 1)
  19408. * @param color defines the color to affect to the specified gradient
  19409. * @returns the current particle system
  19410. */
  19411. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19412. /**
  19413. * Gets the current list of ramp gradients.
  19414. * You must use addRampGradient and removeRampGradient to udpate this list
  19415. * @returns the list of ramp gradients
  19416. */
  19417. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19418. /** Gets or sets a boolean indicating that ramp gradients must be used
  19419. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19420. */
  19421. useRampGradients: boolean;
  19422. /**
  19423. * Adds a new color remap gradient
  19424. * @param gradient defines the gradient to use (between 0 and 1)
  19425. * @param min defines the color remap minimal range
  19426. * @param max defines the color remap maximal range
  19427. * @returns the current particle system
  19428. */
  19429. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19430. /**
  19431. * Gets the current list of color remap gradients.
  19432. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19433. * @returns the list of color remap gradients
  19434. */
  19435. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19436. /**
  19437. * Adds a new alpha remap gradient
  19438. * @param gradient defines the gradient to use (between 0 and 1)
  19439. * @param min defines the alpha remap minimal range
  19440. * @param max defines the alpha remap maximal range
  19441. * @returns the current particle system
  19442. */
  19443. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19444. /**
  19445. * Gets the current list of alpha remap gradients.
  19446. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19447. * @returns the list of alpha remap gradients
  19448. */
  19449. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19450. /**
  19451. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19452. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19453. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19454. * @returns the emitter
  19455. */
  19456. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19457. /**
  19458. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19459. * @param radius The radius of the hemisphere to emit from
  19460. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19461. * @returns the emitter
  19462. */
  19463. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19464. /**
  19465. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19466. * @param radius The radius of the sphere to emit from
  19467. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19468. * @returns the emitter
  19469. */
  19470. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19471. /**
  19472. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19473. * @param radius The radius of the sphere to emit from
  19474. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19475. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19476. * @returns the emitter
  19477. */
  19478. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19479. /**
  19480. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19481. * @param radius The radius of the emission cylinder
  19482. * @param height The height of the emission cylinder
  19483. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19484. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19485. * @returns the emitter
  19486. */
  19487. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19488. /**
  19489. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19490. * @param radius The radius of the cylinder to emit from
  19491. * @param height The height of the emission cylinder
  19492. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19493. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19494. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19495. * @returns the emitter
  19496. */
  19497. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19498. /**
  19499. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19500. * @param radius The radius of the cone to emit from
  19501. * @param angle The base angle of the cone
  19502. * @returns the emitter
  19503. */
  19504. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19505. /**
  19506. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19507. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19508. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19509. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19510. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19511. * @returns the emitter
  19512. */
  19513. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19514. /**
  19515. * Get hosting scene
  19516. * @returns the scene
  19517. */
  19518. getScene(): Scene;
  19519. }
  19520. }
  19521. declare module "babylonjs/Meshes/instancedMesh" {
  19522. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19523. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19524. import { Camera } from "babylonjs/Cameras/camera";
  19525. import { Node } from "babylonjs/node";
  19526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19527. import { Mesh } from "babylonjs/Meshes/mesh";
  19528. import { Material } from "babylonjs/Materials/material";
  19529. import { Skeleton } from "babylonjs/Bones/skeleton";
  19530. import { Light } from "babylonjs/Lights/light";
  19531. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19532. /**
  19533. * Creates an instance based on a source mesh.
  19534. */
  19535. export class InstancedMesh extends AbstractMesh {
  19536. private _sourceMesh;
  19537. private _currentLOD;
  19538. /** @hidden */
  19539. _indexInSourceMeshInstanceArray: number;
  19540. constructor(name: string, source: Mesh);
  19541. /**
  19542. * Returns the string "InstancedMesh".
  19543. */
  19544. getClassName(): string;
  19545. /** Gets the list of lights affecting that mesh */
  19546. readonly lightSources: Light[];
  19547. _resyncLightSources(): void;
  19548. _resyncLightSource(light: Light): void;
  19549. _removeLightSource(light: Light, dispose: boolean): void;
  19550. /**
  19551. * If the source mesh receives shadows
  19552. */
  19553. readonly receiveShadows: boolean;
  19554. /**
  19555. * The material of the source mesh
  19556. */
  19557. readonly material: Nullable<Material>;
  19558. /**
  19559. * Visibility of the source mesh
  19560. */
  19561. readonly visibility: number;
  19562. /**
  19563. * Skeleton of the source mesh
  19564. */
  19565. readonly skeleton: Nullable<Skeleton>;
  19566. /**
  19567. * Rendering ground id of the source mesh
  19568. */
  19569. renderingGroupId: number;
  19570. /**
  19571. * Returns the total number of vertices (integer).
  19572. */
  19573. getTotalVertices(): number;
  19574. /**
  19575. * Returns a positive integer : the total number of indices in this mesh geometry.
  19576. * @returns the numner of indices or zero if the mesh has no geometry.
  19577. */
  19578. getTotalIndices(): number;
  19579. /**
  19580. * The source mesh of the instance
  19581. */
  19582. readonly sourceMesh: Mesh;
  19583. /**
  19584. * Is this node ready to be used/rendered
  19585. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19586. * @return {boolean} is it ready
  19587. */
  19588. isReady(completeCheck?: boolean): boolean;
  19589. /**
  19590. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19591. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19592. * @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.
  19593. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19594. */
  19595. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19596. /**
  19597. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19598. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19599. * The `data` are either a numeric array either a Float32Array.
  19600. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19601. * 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).
  19602. * Note that a new underlying VertexBuffer object is created each call.
  19603. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19604. *
  19605. * Possible `kind` values :
  19606. * - VertexBuffer.PositionKind
  19607. * - VertexBuffer.UVKind
  19608. * - VertexBuffer.UV2Kind
  19609. * - VertexBuffer.UV3Kind
  19610. * - VertexBuffer.UV4Kind
  19611. * - VertexBuffer.UV5Kind
  19612. * - VertexBuffer.UV6Kind
  19613. * - VertexBuffer.ColorKind
  19614. * - VertexBuffer.MatricesIndicesKind
  19615. * - VertexBuffer.MatricesIndicesExtraKind
  19616. * - VertexBuffer.MatricesWeightsKind
  19617. * - VertexBuffer.MatricesWeightsExtraKind
  19618. *
  19619. * Returns the Mesh.
  19620. */
  19621. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19622. /**
  19623. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19624. * If the mesh has no geometry, it is simply returned as it is.
  19625. * The `data` are either a numeric array either a Float32Array.
  19626. * No new underlying VertexBuffer object is created.
  19627. * 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.
  19628. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19629. *
  19630. * Possible `kind` values :
  19631. * - VertexBuffer.PositionKind
  19632. * - VertexBuffer.UVKind
  19633. * - VertexBuffer.UV2Kind
  19634. * - VertexBuffer.UV3Kind
  19635. * - VertexBuffer.UV4Kind
  19636. * - VertexBuffer.UV5Kind
  19637. * - VertexBuffer.UV6Kind
  19638. * - VertexBuffer.ColorKind
  19639. * - VertexBuffer.MatricesIndicesKind
  19640. * - VertexBuffer.MatricesIndicesExtraKind
  19641. * - VertexBuffer.MatricesWeightsKind
  19642. * - VertexBuffer.MatricesWeightsExtraKind
  19643. *
  19644. * Returns the Mesh.
  19645. */
  19646. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19647. /**
  19648. * Sets the mesh indices.
  19649. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19650. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19651. * This method creates a new index buffer each call.
  19652. * Returns the Mesh.
  19653. */
  19654. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19655. /**
  19656. * Boolean : True if the mesh owns the requested kind of data.
  19657. */
  19658. isVerticesDataPresent(kind: string): boolean;
  19659. /**
  19660. * Returns an array of indices (IndicesArray).
  19661. */
  19662. getIndices(): Nullable<IndicesArray>;
  19663. readonly _positions: Nullable<Vector3[]>;
  19664. /**
  19665. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19666. * This means the mesh underlying bounding box and sphere are recomputed.
  19667. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19668. * @returns the current mesh
  19669. */
  19670. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19671. /** @hidden */
  19672. _preActivate(): InstancedMesh;
  19673. /** @hidden */
  19674. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19675. /** @hidden */
  19676. _postActivate(): void;
  19677. getWorldMatrix(): Matrix;
  19678. readonly isAnInstance: boolean;
  19679. /**
  19680. * Returns the current associated LOD AbstractMesh.
  19681. */
  19682. getLOD(camera: Camera): AbstractMesh;
  19683. /** @hidden */
  19684. _syncSubMeshes(): InstancedMesh;
  19685. /** @hidden */
  19686. _generatePointsArray(): boolean;
  19687. /**
  19688. * Creates a new InstancedMesh from the current mesh.
  19689. * - name (string) : the cloned mesh name
  19690. * - newParent (optional Node) : the optional Node to parent the clone to.
  19691. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19692. *
  19693. * Returns the clone.
  19694. */
  19695. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19696. /**
  19697. * Disposes the InstancedMesh.
  19698. * Returns nothing.
  19699. */
  19700. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19701. }
  19702. module "babylonjs/Meshes/mesh" {
  19703. interface Mesh {
  19704. /**
  19705. * Register a custom buffer that will be instanced
  19706. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19707. * @param kind defines the buffer kind
  19708. * @param stride defines the stride in floats
  19709. */
  19710. registerInstancedBuffer(kind: string, stride: number): void;
  19711. /** @hidden */
  19712. _userInstancedBuffersStorage: {
  19713. data: {
  19714. [key: string]: Float32Array;
  19715. };
  19716. sizes: {
  19717. [key: string]: number;
  19718. };
  19719. vertexBuffers: {
  19720. [key: string]: Nullable<VertexBuffer>;
  19721. };
  19722. strides: {
  19723. [key: string]: number;
  19724. };
  19725. };
  19726. }
  19727. }
  19728. module "babylonjs/Meshes/abstractMesh" {
  19729. interface AbstractMesh {
  19730. /**
  19731. * Object used to store instanced buffers defined by user
  19732. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19733. */
  19734. instancedBuffers: {
  19735. [key: string]: any;
  19736. };
  19737. }
  19738. }
  19739. }
  19740. declare module "babylonjs/Materials/shaderMaterial" {
  19741. import { Scene } from "babylonjs/scene";
  19742. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19744. import { Mesh } from "babylonjs/Meshes/mesh";
  19745. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19746. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19747. import { Texture } from "babylonjs/Materials/Textures/texture";
  19748. import { Material } from "babylonjs/Materials/material";
  19749. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19750. /**
  19751. * Defines the options associated with the creation of a shader material.
  19752. */
  19753. export interface IShaderMaterialOptions {
  19754. /**
  19755. * Does the material work in alpha blend mode
  19756. */
  19757. needAlphaBlending: boolean;
  19758. /**
  19759. * Does the material work in alpha test mode
  19760. */
  19761. needAlphaTesting: boolean;
  19762. /**
  19763. * The list of attribute names used in the shader
  19764. */
  19765. attributes: string[];
  19766. /**
  19767. * The list of unifrom names used in the shader
  19768. */
  19769. uniforms: string[];
  19770. /**
  19771. * The list of UBO names used in the shader
  19772. */
  19773. uniformBuffers: string[];
  19774. /**
  19775. * The list of sampler names used in the shader
  19776. */
  19777. samplers: string[];
  19778. /**
  19779. * The list of defines used in the shader
  19780. */
  19781. defines: string[];
  19782. }
  19783. /**
  19784. * 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.
  19785. *
  19786. * This returned material effects how the mesh will look based on the code in the shaders.
  19787. *
  19788. * @see http://doc.babylonjs.com/how_to/shader_material
  19789. */
  19790. export class ShaderMaterial extends Material {
  19791. private _shaderPath;
  19792. private _options;
  19793. private _textures;
  19794. private _textureArrays;
  19795. private _floats;
  19796. private _ints;
  19797. private _floatsArrays;
  19798. private _colors3;
  19799. private _colors3Arrays;
  19800. private _colors4;
  19801. private _colors4Arrays;
  19802. private _vectors2;
  19803. private _vectors3;
  19804. private _vectors4;
  19805. private _matrices;
  19806. private _matrixArrays;
  19807. private _matrices3x3;
  19808. private _matrices2x2;
  19809. private _vectors2Arrays;
  19810. private _vectors3Arrays;
  19811. private _vectors4Arrays;
  19812. private _cachedWorldViewMatrix;
  19813. private _cachedWorldViewProjectionMatrix;
  19814. private _renderId;
  19815. private _multiview;
  19816. /**
  19817. * Instantiate a new shader material.
  19818. * 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.
  19819. * This returned material effects how the mesh will look based on the code in the shaders.
  19820. * @see http://doc.babylonjs.com/how_to/shader_material
  19821. * @param name Define the name of the material in the scene
  19822. * @param scene Define the scene the material belongs to
  19823. * @param shaderPath Defines the route to the shader code in one of three ways:
  19824. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19825. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19826. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19827. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19828. * @param options Define the options used to create the shader
  19829. */
  19830. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19831. /**
  19832. * Gets the shader path used to define the shader code
  19833. * It can be modified to trigger a new compilation
  19834. */
  19835. /**
  19836. * Sets the shader path used to define the shader code
  19837. * It can be modified to trigger a new compilation
  19838. */
  19839. shaderPath: any;
  19840. /**
  19841. * Gets the options used to compile the shader.
  19842. * They can be modified to trigger a new compilation
  19843. */
  19844. readonly options: IShaderMaterialOptions;
  19845. /**
  19846. * Gets the current class name of the material e.g. "ShaderMaterial"
  19847. * Mainly use in serialization.
  19848. * @returns the class name
  19849. */
  19850. getClassName(): string;
  19851. /**
  19852. * Specifies if the material will require alpha blending
  19853. * @returns a boolean specifying if alpha blending is needed
  19854. */
  19855. needAlphaBlending(): boolean;
  19856. /**
  19857. * Specifies if this material should be rendered in alpha test mode
  19858. * @returns a boolean specifying if an alpha test is needed.
  19859. */
  19860. needAlphaTesting(): boolean;
  19861. private _checkUniform;
  19862. /**
  19863. * Set a texture in the shader.
  19864. * @param name Define the name of the uniform samplers as defined in the shader
  19865. * @param texture Define the texture to bind to this sampler
  19866. * @return the material itself allowing "fluent" like uniform updates
  19867. */
  19868. setTexture(name: string, texture: Texture): ShaderMaterial;
  19869. /**
  19870. * Set a texture array in the shader.
  19871. * @param name Define the name of the uniform sampler array as defined in the shader
  19872. * @param textures Define the list of textures to bind to this sampler
  19873. * @return the material itself allowing "fluent" like uniform updates
  19874. */
  19875. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19876. /**
  19877. * Set a float in the shader.
  19878. * @param name Define the name of the uniform as defined in the shader
  19879. * @param value Define the value to give to the uniform
  19880. * @return the material itself allowing "fluent" like uniform updates
  19881. */
  19882. setFloat(name: string, value: number): ShaderMaterial;
  19883. /**
  19884. * Set a int in the shader.
  19885. * @param name Define the name of the uniform as defined in the shader
  19886. * @param value Define the value to give to the uniform
  19887. * @return the material itself allowing "fluent" like uniform updates
  19888. */
  19889. setInt(name: string, value: number): ShaderMaterial;
  19890. /**
  19891. * Set an array of floats in the shader.
  19892. * @param name Define the name of the uniform as defined in the shader
  19893. * @param value Define the value to give to the uniform
  19894. * @return the material itself allowing "fluent" like uniform updates
  19895. */
  19896. setFloats(name: string, value: number[]): ShaderMaterial;
  19897. /**
  19898. * Set a vec3 in the shader from a Color3.
  19899. * @param name Define the name of the uniform as defined in the shader
  19900. * @param value Define the value to give to the uniform
  19901. * @return the material itself allowing "fluent" like uniform updates
  19902. */
  19903. setColor3(name: string, value: Color3): ShaderMaterial;
  19904. /**
  19905. * Set a vec3 array in the shader from a Color3 array.
  19906. * @param name Define the name of the uniform as defined in the shader
  19907. * @param value Define the value to give to the uniform
  19908. * @return the material itself allowing "fluent" like uniform updates
  19909. */
  19910. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19911. /**
  19912. * Set a vec4 in the shader from a Color4.
  19913. * @param name Define the name of the uniform as defined in the shader
  19914. * @param value Define the value to give to the uniform
  19915. * @return the material itself allowing "fluent" like uniform updates
  19916. */
  19917. setColor4(name: string, value: Color4): ShaderMaterial;
  19918. /**
  19919. * Set a vec4 array in the shader from a Color4 array.
  19920. * @param name Define the name of the uniform as defined in the shader
  19921. * @param value Define the value to give to the uniform
  19922. * @return the material itself allowing "fluent" like uniform updates
  19923. */
  19924. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19925. /**
  19926. * Set a vec2 in the shader from a Vector2.
  19927. * @param name Define the name of the uniform as defined in the shader
  19928. * @param value Define the value to give to the uniform
  19929. * @return the material itself allowing "fluent" like uniform updates
  19930. */
  19931. setVector2(name: string, value: Vector2): ShaderMaterial;
  19932. /**
  19933. * Set a vec3 in the shader from a Vector3.
  19934. * @param name Define the name of the uniform as defined in the shader
  19935. * @param value Define the value to give to the uniform
  19936. * @return the material itself allowing "fluent" like uniform updates
  19937. */
  19938. setVector3(name: string, value: Vector3): ShaderMaterial;
  19939. /**
  19940. * Set a vec4 in the shader from a Vector4.
  19941. * @param name Define the name of the uniform as defined in the shader
  19942. * @param value Define the value to give to the uniform
  19943. * @return the material itself allowing "fluent" like uniform updates
  19944. */
  19945. setVector4(name: string, value: Vector4): ShaderMaterial;
  19946. /**
  19947. * Set a mat4 in the shader from a Matrix.
  19948. * @param name Define the name of the uniform as defined in the shader
  19949. * @param value Define the value to give to the uniform
  19950. * @return the material itself allowing "fluent" like uniform updates
  19951. */
  19952. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19953. /**
  19954. * Set a float32Array in the shader from a matrix array.
  19955. * @param name Define the name of the uniform as defined in the shader
  19956. * @param value Define the value to give to the uniform
  19957. * @return the material itself allowing "fluent" like uniform updates
  19958. */
  19959. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19960. /**
  19961. * Set a mat3 in the shader from a Float32Array.
  19962. * @param name Define the name of the uniform as defined in the shader
  19963. * @param value Define the value to give to the uniform
  19964. * @return the material itself allowing "fluent" like uniform updates
  19965. */
  19966. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19967. /**
  19968. * Set a mat2 in the shader from a Float32Array.
  19969. * @param name Define the name of the uniform as defined in the shader
  19970. * @param value Define the value to give to the uniform
  19971. * @return the material itself allowing "fluent" like uniform updates
  19972. */
  19973. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19974. /**
  19975. * Set a vec2 array in the shader from a number array.
  19976. * @param name Define the name of the uniform as defined in the shader
  19977. * @param value Define the value to give to the uniform
  19978. * @return the material itself allowing "fluent" like uniform updates
  19979. */
  19980. setArray2(name: string, value: number[]): ShaderMaterial;
  19981. /**
  19982. * Set a vec3 array in the shader from a number array.
  19983. * @param name Define the name of the uniform as defined in the shader
  19984. * @param value Define the value to give to the uniform
  19985. * @return the material itself allowing "fluent" like uniform updates
  19986. */
  19987. setArray3(name: string, value: number[]): ShaderMaterial;
  19988. /**
  19989. * Set a vec4 array in the shader from a number array.
  19990. * @param name Define the name of the uniform as defined in the shader
  19991. * @param value Define the value to give to the uniform
  19992. * @return the material itself allowing "fluent" like uniform updates
  19993. */
  19994. setArray4(name: string, value: number[]): ShaderMaterial;
  19995. private _checkCache;
  19996. /**
  19997. * Specifies that the submesh is ready to be used
  19998. * @param mesh defines the mesh to check
  19999. * @param subMesh defines which submesh to check
  20000. * @param useInstances specifies that instances should be used
  20001. * @returns a boolean indicating that the submesh is ready or not
  20002. */
  20003. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20004. /**
  20005. * Checks if the material is ready to render the requested mesh
  20006. * @param mesh Define the mesh to render
  20007. * @param useInstances Define whether or not the material is used with instances
  20008. * @returns true if ready, otherwise false
  20009. */
  20010. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20011. /**
  20012. * Binds the world matrix to the material
  20013. * @param world defines the world transformation matrix
  20014. */
  20015. bindOnlyWorldMatrix(world: Matrix): void;
  20016. /**
  20017. * Binds the material to the mesh
  20018. * @param world defines the world transformation matrix
  20019. * @param mesh defines the mesh to bind the material to
  20020. */
  20021. bind(world: Matrix, mesh?: Mesh): void;
  20022. /**
  20023. * Gets the active textures from the material
  20024. * @returns an array of textures
  20025. */
  20026. getActiveTextures(): BaseTexture[];
  20027. /**
  20028. * Specifies if the material uses a texture
  20029. * @param texture defines the texture to check against the material
  20030. * @returns a boolean specifying if the material uses the texture
  20031. */
  20032. hasTexture(texture: BaseTexture): boolean;
  20033. /**
  20034. * Makes a duplicate of the material, and gives it a new name
  20035. * @param name defines the new name for the duplicated material
  20036. * @returns the cloned material
  20037. */
  20038. clone(name: string): ShaderMaterial;
  20039. /**
  20040. * Disposes the material
  20041. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20042. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20043. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20044. */
  20045. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20046. /**
  20047. * Serializes this material in a JSON representation
  20048. * @returns the serialized material object
  20049. */
  20050. serialize(): any;
  20051. /**
  20052. * Creates a shader material from parsed shader material data
  20053. * @param source defines the JSON represnetation of the material
  20054. * @param scene defines the hosting scene
  20055. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20056. * @returns a new material
  20057. */
  20058. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20059. }
  20060. }
  20061. declare module "babylonjs/Shaders/color.fragment" {
  20062. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20063. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20064. /** @hidden */
  20065. export var colorPixelShader: {
  20066. name: string;
  20067. shader: string;
  20068. };
  20069. }
  20070. declare module "babylonjs/Shaders/color.vertex" {
  20071. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20072. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20073. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20074. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20075. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20076. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20077. /** @hidden */
  20078. export var colorVertexShader: {
  20079. name: string;
  20080. shader: string;
  20081. };
  20082. }
  20083. declare module "babylonjs/Meshes/linesMesh" {
  20084. import { Nullable } from "babylonjs/types";
  20085. import { Scene } from "babylonjs/scene";
  20086. import { Color3 } from "babylonjs/Maths/math.color";
  20087. import { Node } from "babylonjs/node";
  20088. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20089. import { Mesh } from "babylonjs/Meshes/mesh";
  20090. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20091. import { Effect } from "babylonjs/Materials/effect";
  20092. import { Material } from "babylonjs/Materials/material";
  20093. import "babylonjs/Shaders/color.fragment";
  20094. import "babylonjs/Shaders/color.vertex";
  20095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20096. /**
  20097. * Line mesh
  20098. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20099. */
  20100. export class LinesMesh extends Mesh {
  20101. /**
  20102. * If vertex color should be applied to the mesh
  20103. */
  20104. readonly useVertexColor?: boolean | undefined;
  20105. /**
  20106. * If vertex alpha should be applied to the mesh
  20107. */
  20108. readonly useVertexAlpha?: boolean | undefined;
  20109. /**
  20110. * Color of the line (Default: White)
  20111. */
  20112. color: Color3;
  20113. /**
  20114. * Alpha of the line (Default: 1)
  20115. */
  20116. alpha: number;
  20117. /**
  20118. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20119. * This margin is expressed in world space coordinates, so its value may vary.
  20120. * Default value is 0.1
  20121. */
  20122. intersectionThreshold: number;
  20123. private _colorShader;
  20124. private color4;
  20125. /**
  20126. * Creates a new LinesMesh
  20127. * @param name defines the name
  20128. * @param scene defines the hosting scene
  20129. * @param parent defines the parent mesh if any
  20130. * @param source defines the optional source LinesMesh used to clone data from
  20131. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20132. * When false, achieved by calling a clone(), also passing False.
  20133. * This will make creation of children, recursive.
  20134. * @param useVertexColor defines if this LinesMesh supports vertex color
  20135. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20136. */
  20137. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20138. /**
  20139. * If vertex color should be applied to the mesh
  20140. */
  20141. useVertexColor?: boolean | undefined,
  20142. /**
  20143. * If vertex alpha should be applied to the mesh
  20144. */
  20145. useVertexAlpha?: boolean | undefined);
  20146. private _addClipPlaneDefine;
  20147. private _removeClipPlaneDefine;
  20148. isReady(): boolean;
  20149. /**
  20150. * Returns the string "LineMesh"
  20151. */
  20152. getClassName(): string;
  20153. /**
  20154. * @hidden
  20155. */
  20156. /**
  20157. * @hidden
  20158. */
  20159. material: Material;
  20160. /**
  20161. * @hidden
  20162. */
  20163. readonly checkCollisions: boolean;
  20164. /** @hidden */
  20165. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20166. /** @hidden */
  20167. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20168. /**
  20169. * Disposes of the line mesh
  20170. * @param doNotRecurse If children should be disposed
  20171. */
  20172. dispose(doNotRecurse?: boolean): void;
  20173. /**
  20174. * Returns a new LineMesh object cloned from the current one.
  20175. */
  20176. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20177. /**
  20178. * Creates a new InstancedLinesMesh object from the mesh model.
  20179. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20180. * @param name defines the name of the new instance
  20181. * @returns a new InstancedLinesMesh
  20182. */
  20183. createInstance(name: string): InstancedLinesMesh;
  20184. }
  20185. /**
  20186. * Creates an instance based on a source LinesMesh
  20187. */
  20188. export class InstancedLinesMesh extends InstancedMesh {
  20189. /**
  20190. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20191. * This margin is expressed in world space coordinates, so its value may vary.
  20192. * Initilized with the intersectionThreshold value of the source LinesMesh
  20193. */
  20194. intersectionThreshold: number;
  20195. constructor(name: string, source: LinesMesh);
  20196. /**
  20197. * Returns the string "InstancedLinesMesh".
  20198. */
  20199. getClassName(): string;
  20200. }
  20201. }
  20202. declare module "babylonjs/Shaders/line.fragment" {
  20203. /** @hidden */
  20204. export var linePixelShader: {
  20205. name: string;
  20206. shader: string;
  20207. };
  20208. }
  20209. declare module "babylonjs/Shaders/line.vertex" {
  20210. /** @hidden */
  20211. export var lineVertexShader: {
  20212. name: string;
  20213. shader: string;
  20214. };
  20215. }
  20216. declare module "babylonjs/Rendering/edgesRenderer" {
  20217. import { Nullable } from "babylonjs/types";
  20218. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20220. import { Vector3 } from "babylonjs/Maths/math.vector";
  20221. import { IDisposable } from "babylonjs/scene";
  20222. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20223. import "babylonjs/Shaders/line.fragment";
  20224. import "babylonjs/Shaders/line.vertex";
  20225. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20226. module "babylonjs/Meshes/abstractMesh" {
  20227. interface AbstractMesh {
  20228. /**
  20229. * Gets the edgesRenderer associated with the mesh
  20230. */
  20231. edgesRenderer: Nullable<EdgesRenderer>;
  20232. }
  20233. }
  20234. module "babylonjs/Meshes/linesMesh" {
  20235. interface LinesMesh {
  20236. /**
  20237. * Enables the edge rendering mode on the mesh.
  20238. * This mode makes the mesh edges visible
  20239. * @param epsilon defines the maximal distance between two angles to detect a face
  20240. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20241. * @returns the currentAbstractMesh
  20242. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20243. */
  20244. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20245. }
  20246. }
  20247. module "babylonjs/Meshes/linesMesh" {
  20248. interface InstancedLinesMesh {
  20249. /**
  20250. * Enables the edge rendering mode on the mesh.
  20251. * This mode makes the mesh edges visible
  20252. * @param epsilon defines the maximal distance between two angles to detect a face
  20253. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20254. * @returns the current InstancedLinesMesh
  20255. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20256. */
  20257. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20258. }
  20259. }
  20260. /**
  20261. * Defines the minimum contract an Edges renderer should follow.
  20262. */
  20263. export interface IEdgesRenderer extends IDisposable {
  20264. /**
  20265. * Gets or sets a boolean indicating if the edgesRenderer is active
  20266. */
  20267. isEnabled: boolean;
  20268. /**
  20269. * Renders the edges of the attached mesh,
  20270. */
  20271. render(): void;
  20272. /**
  20273. * Checks wether or not the edges renderer is ready to render.
  20274. * @return true if ready, otherwise false.
  20275. */
  20276. isReady(): boolean;
  20277. }
  20278. /**
  20279. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20280. */
  20281. export class EdgesRenderer implements IEdgesRenderer {
  20282. /**
  20283. * Define the size of the edges with an orthographic camera
  20284. */
  20285. edgesWidthScalerForOrthographic: number;
  20286. /**
  20287. * Define the size of the edges with a perspective camera
  20288. */
  20289. edgesWidthScalerForPerspective: number;
  20290. protected _source: AbstractMesh;
  20291. protected _linesPositions: number[];
  20292. protected _linesNormals: number[];
  20293. protected _linesIndices: number[];
  20294. protected _epsilon: number;
  20295. protected _indicesCount: number;
  20296. protected _lineShader: ShaderMaterial;
  20297. protected _ib: DataBuffer;
  20298. protected _buffers: {
  20299. [key: string]: Nullable<VertexBuffer>;
  20300. };
  20301. protected _checkVerticesInsteadOfIndices: boolean;
  20302. private _meshRebuildObserver;
  20303. private _meshDisposeObserver;
  20304. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20305. isEnabled: boolean;
  20306. /**
  20307. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20308. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20309. * @param source Mesh used to create edges
  20310. * @param epsilon sum of angles in adjacency to check for edge
  20311. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20312. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20313. */
  20314. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20315. protected _prepareRessources(): void;
  20316. /** @hidden */
  20317. _rebuild(): void;
  20318. /**
  20319. * Releases the required resources for the edges renderer
  20320. */
  20321. dispose(): void;
  20322. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20323. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20324. /**
  20325. * Checks if the pair of p0 and p1 is en edge
  20326. * @param faceIndex
  20327. * @param edge
  20328. * @param faceNormals
  20329. * @param p0
  20330. * @param p1
  20331. * @private
  20332. */
  20333. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20334. /**
  20335. * push line into the position, normal and index buffer
  20336. * @protected
  20337. */
  20338. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20339. /**
  20340. * Generates lines edges from adjacencjes
  20341. * @private
  20342. */
  20343. _generateEdgesLines(): void;
  20344. /**
  20345. * Checks wether or not the edges renderer is ready to render.
  20346. * @return true if ready, otherwise false.
  20347. */
  20348. isReady(): boolean;
  20349. /**
  20350. * Renders the edges of the attached mesh,
  20351. */
  20352. render(): void;
  20353. }
  20354. /**
  20355. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20356. */
  20357. export class LineEdgesRenderer extends EdgesRenderer {
  20358. /**
  20359. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20360. * @param source LineMesh used to generate edges
  20361. * @param epsilon not important (specified angle for edge detection)
  20362. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20363. */
  20364. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20365. /**
  20366. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20367. */
  20368. _generateEdgesLines(): void;
  20369. }
  20370. }
  20371. declare module "babylonjs/Rendering/renderingGroup" {
  20372. import { SmartArray } from "babylonjs/Misc/smartArray";
  20373. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20375. import { Nullable } from "babylonjs/types";
  20376. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20377. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20378. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20379. import { Material } from "babylonjs/Materials/material";
  20380. import { Scene } from "babylonjs/scene";
  20381. /**
  20382. * This represents the object necessary to create a rendering group.
  20383. * This is exclusively used and created by the rendering manager.
  20384. * To modify the behavior, you use the available helpers in your scene or meshes.
  20385. * @hidden
  20386. */
  20387. export class RenderingGroup {
  20388. index: number;
  20389. private static _zeroVector;
  20390. private _scene;
  20391. private _opaqueSubMeshes;
  20392. private _transparentSubMeshes;
  20393. private _alphaTestSubMeshes;
  20394. private _depthOnlySubMeshes;
  20395. private _particleSystems;
  20396. private _spriteManagers;
  20397. private _opaqueSortCompareFn;
  20398. private _alphaTestSortCompareFn;
  20399. private _transparentSortCompareFn;
  20400. private _renderOpaque;
  20401. private _renderAlphaTest;
  20402. private _renderTransparent;
  20403. /** @hidden */
  20404. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20405. onBeforeTransparentRendering: () => void;
  20406. /**
  20407. * Set the opaque sort comparison function.
  20408. * If null the sub meshes will be render in the order they were created
  20409. */
  20410. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20411. /**
  20412. * Set the alpha test sort comparison function.
  20413. * If null the sub meshes will be render in the order they were created
  20414. */
  20415. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20416. /**
  20417. * Set the transparent sort comparison function.
  20418. * If null the sub meshes will be render in the order they were created
  20419. */
  20420. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20421. /**
  20422. * Creates a new rendering group.
  20423. * @param index The rendering group index
  20424. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20425. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20426. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20427. */
  20428. 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>);
  20429. /**
  20430. * Render all the sub meshes contained in the group.
  20431. * @param customRenderFunction Used to override the default render behaviour of the group.
  20432. * @returns true if rendered some submeshes.
  20433. */
  20434. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20435. /**
  20436. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20437. * @param subMeshes The submeshes to render
  20438. */
  20439. private renderOpaqueSorted;
  20440. /**
  20441. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20442. * @param subMeshes The submeshes to render
  20443. */
  20444. private renderAlphaTestSorted;
  20445. /**
  20446. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20447. * @param subMeshes The submeshes to render
  20448. */
  20449. private renderTransparentSorted;
  20450. /**
  20451. * Renders the submeshes in a specified order.
  20452. * @param subMeshes The submeshes to sort before render
  20453. * @param sortCompareFn The comparison function use to sort
  20454. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20455. * @param transparent Specifies to activate blending if true
  20456. */
  20457. private static renderSorted;
  20458. /**
  20459. * Renders the submeshes in the order they were dispatched (no sort applied).
  20460. * @param subMeshes The submeshes to render
  20461. */
  20462. private static renderUnsorted;
  20463. /**
  20464. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20465. * are rendered back to front if in the same alpha index.
  20466. *
  20467. * @param a The first submesh
  20468. * @param b The second submesh
  20469. * @returns The result of the comparison
  20470. */
  20471. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20472. /**
  20473. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20474. * are rendered back to front.
  20475. *
  20476. * @param a The first submesh
  20477. * @param b The second submesh
  20478. * @returns The result of the comparison
  20479. */
  20480. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20481. /**
  20482. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20483. * are rendered front to back (prevent overdraw).
  20484. *
  20485. * @param a The first submesh
  20486. * @param b The second submesh
  20487. * @returns The result of the comparison
  20488. */
  20489. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20490. /**
  20491. * Resets the different lists of submeshes to prepare a new frame.
  20492. */
  20493. prepare(): void;
  20494. dispose(): void;
  20495. /**
  20496. * Inserts the submesh in its correct queue depending on its material.
  20497. * @param subMesh The submesh to dispatch
  20498. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20499. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20500. */
  20501. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20502. dispatchSprites(spriteManager: ISpriteManager): void;
  20503. dispatchParticles(particleSystem: IParticleSystem): void;
  20504. private _renderParticles;
  20505. private _renderSprites;
  20506. }
  20507. }
  20508. declare module "babylonjs/Rendering/renderingManager" {
  20509. import { Nullable } from "babylonjs/types";
  20510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20511. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20512. import { SmartArray } from "babylonjs/Misc/smartArray";
  20513. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20514. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20515. import { Material } from "babylonjs/Materials/material";
  20516. import { Scene } from "babylonjs/scene";
  20517. import { Camera } from "babylonjs/Cameras/camera";
  20518. /**
  20519. * Interface describing the different options available in the rendering manager
  20520. * regarding Auto Clear between groups.
  20521. */
  20522. export interface IRenderingManagerAutoClearSetup {
  20523. /**
  20524. * Defines whether or not autoclear is enable.
  20525. */
  20526. autoClear: boolean;
  20527. /**
  20528. * Defines whether or not to autoclear the depth buffer.
  20529. */
  20530. depth: boolean;
  20531. /**
  20532. * Defines whether or not to autoclear the stencil buffer.
  20533. */
  20534. stencil: boolean;
  20535. }
  20536. /**
  20537. * This class is used by the onRenderingGroupObservable
  20538. */
  20539. export class RenderingGroupInfo {
  20540. /**
  20541. * The Scene that being rendered
  20542. */
  20543. scene: Scene;
  20544. /**
  20545. * The camera currently used for the rendering pass
  20546. */
  20547. camera: Nullable<Camera>;
  20548. /**
  20549. * The ID of the renderingGroup being processed
  20550. */
  20551. renderingGroupId: number;
  20552. }
  20553. /**
  20554. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20555. * It is enable to manage the different groups as well as the different necessary sort functions.
  20556. * This should not be used directly aside of the few static configurations
  20557. */
  20558. export class RenderingManager {
  20559. /**
  20560. * The max id used for rendering groups (not included)
  20561. */
  20562. static MAX_RENDERINGGROUPS: number;
  20563. /**
  20564. * The min id used for rendering groups (included)
  20565. */
  20566. static MIN_RENDERINGGROUPS: number;
  20567. /**
  20568. * Used to globally prevent autoclearing scenes.
  20569. */
  20570. static AUTOCLEAR: boolean;
  20571. /**
  20572. * @hidden
  20573. */
  20574. _useSceneAutoClearSetup: boolean;
  20575. private _scene;
  20576. private _renderingGroups;
  20577. private _depthStencilBufferAlreadyCleaned;
  20578. private _autoClearDepthStencil;
  20579. private _customOpaqueSortCompareFn;
  20580. private _customAlphaTestSortCompareFn;
  20581. private _customTransparentSortCompareFn;
  20582. private _renderingGroupInfo;
  20583. /**
  20584. * Instantiates a new rendering group for a particular scene
  20585. * @param scene Defines the scene the groups belongs to
  20586. */
  20587. constructor(scene: Scene);
  20588. private _clearDepthStencilBuffer;
  20589. /**
  20590. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20591. * @hidden
  20592. */
  20593. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20594. /**
  20595. * Resets the different information of the group to prepare a new frame
  20596. * @hidden
  20597. */
  20598. reset(): void;
  20599. /**
  20600. * Dispose and release the group and its associated resources.
  20601. * @hidden
  20602. */
  20603. dispose(): void;
  20604. /**
  20605. * Clear the info related to rendering groups preventing retention points during dispose.
  20606. */
  20607. freeRenderingGroups(): void;
  20608. private _prepareRenderingGroup;
  20609. /**
  20610. * Add a sprite manager to the rendering manager in order to render it this frame.
  20611. * @param spriteManager Define the sprite manager to render
  20612. */
  20613. dispatchSprites(spriteManager: ISpriteManager): void;
  20614. /**
  20615. * Add a particle system to the rendering manager in order to render it this frame.
  20616. * @param particleSystem Define the particle system to render
  20617. */
  20618. dispatchParticles(particleSystem: IParticleSystem): void;
  20619. /**
  20620. * Add a submesh to the manager in order to render it this frame
  20621. * @param subMesh The submesh to dispatch
  20622. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20623. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20624. */
  20625. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20626. /**
  20627. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20628. * This allowed control for front to back rendering or reversly depending of the special needs.
  20629. *
  20630. * @param renderingGroupId The rendering group id corresponding to its index
  20631. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20632. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20633. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20634. */
  20635. 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;
  20636. /**
  20637. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20638. *
  20639. * @param renderingGroupId The rendering group id corresponding to its index
  20640. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20641. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20642. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20643. */
  20644. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20645. /**
  20646. * Gets the current auto clear configuration for one rendering group of the rendering
  20647. * manager.
  20648. * @param index the rendering group index to get the information for
  20649. * @returns The auto clear setup for the requested rendering group
  20650. */
  20651. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20652. }
  20653. }
  20654. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20655. import { Observable } from "babylonjs/Misc/observable";
  20656. import { SmartArray } from "babylonjs/Misc/smartArray";
  20657. import { Nullable } from "babylonjs/types";
  20658. import { Camera } from "babylonjs/Cameras/camera";
  20659. import { Scene } from "babylonjs/scene";
  20660. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20661. import { Color4 } from "babylonjs/Maths/math.color";
  20662. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20664. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20665. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20666. import { Texture } from "babylonjs/Materials/Textures/texture";
  20667. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20668. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20669. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20670. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20671. import { Engine } from "babylonjs/Engines/engine";
  20672. /**
  20673. * This Helps creating a texture that will be created from a camera in your scene.
  20674. * It is basically a dynamic texture that could be used to create special effects for instance.
  20675. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20676. */
  20677. export class RenderTargetTexture extends Texture {
  20678. isCube: boolean;
  20679. /**
  20680. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20681. */
  20682. static readonly REFRESHRATE_RENDER_ONCE: number;
  20683. /**
  20684. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20685. */
  20686. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20687. /**
  20688. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20689. * the central point of your effect and can save a lot of performances.
  20690. */
  20691. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20692. /**
  20693. * Use this predicate to dynamically define the list of mesh you want to render.
  20694. * If set, the renderList property will be overwritten.
  20695. */
  20696. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20697. private _renderList;
  20698. /**
  20699. * Use this list to define the list of mesh you want to render.
  20700. */
  20701. renderList: Nullable<Array<AbstractMesh>>;
  20702. private _hookArray;
  20703. /**
  20704. * Define if particles should be rendered in your texture.
  20705. */
  20706. renderParticles: boolean;
  20707. /**
  20708. * Define if sprites should be rendered in your texture.
  20709. */
  20710. renderSprites: boolean;
  20711. /**
  20712. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20713. */
  20714. coordinatesMode: number;
  20715. /**
  20716. * Define the camera used to render the texture.
  20717. */
  20718. activeCamera: Nullable<Camera>;
  20719. /**
  20720. * Override the render function of the texture with your own one.
  20721. */
  20722. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20723. /**
  20724. * Define if camera post processes should be use while rendering the texture.
  20725. */
  20726. useCameraPostProcesses: boolean;
  20727. /**
  20728. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20729. */
  20730. ignoreCameraViewport: boolean;
  20731. private _postProcessManager;
  20732. private _postProcesses;
  20733. private _resizeObserver;
  20734. /**
  20735. * An event triggered when the texture is unbind.
  20736. */
  20737. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20738. /**
  20739. * An event triggered when the texture is unbind.
  20740. */
  20741. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20742. private _onAfterUnbindObserver;
  20743. /**
  20744. * Set a after unbind callback in the texture.
  20745. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20746. */
  20747. onAfterUnbind: () => void;
  20748. /**
  20749. * An event triggered before rendering the texture
  20750. */
  20751. onBeforeRenderObservable: Observable<number>;
  20752. private _onBeforeRenderObserver;
  20753. /**
  20754. * Set a before render callback in the texture.
  20755. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20756. */
  20757. onBeforeRender: (faceIndex: number) => void;
  20758. /**
  20759. * An event triggered after rendering the texture
  20760. */
  20761. onAfterRenderObservable: Observable<number>;
  20762. private _onAfterRenderObserver;
  20763. /**
  20764. * Set a after render callback in the texture.
  20765. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20766. */
  20767. onAfterRender: (faceIndex: number) => void;
  20768. /**
  20769. * An event triggered after the texture clear
  20770. */
  20771. onClearObservable: Observable<Engine>;
  20772. private _onClearObserver;
  20773. /**
  20774. * Set a clear callback in the texture.
  20775. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20776. */
  20777. onClear: (Engine: Engine) => void;
  20778. /**
  20779. * An event triggered when the texture is resized.
  20780. */
  20781. onResizeObservable: Observable<RenderTargetTexture>;
  20782. /**
  20783. * Define the clear color of the Render Target if it should be different from the scene.
  20784. */
  20785. clearColor: Color4;
  20786. protected _size: number | {
  20787. width: number;
  20788. height: number;
  20789. };
  20790. protected _initialSizeParameter: number | {
  20791. width: number;
  20792. height: number;
  20793. } | {
  20794. ratio: number;
  20795. };
  20796. protected _sizeRatio: Nullable<number>;
  20797. /** @hidden */
  20798. _generateMipMaps: boolean;
  20799. protected _renderingManager: RenderingManager;
  20800. /** @hidden */
  20801. _waitingRenderList: string[];
  20802. protected _doNotChangeAspectRatio: boolean;
  20803. protected _currentRefreshId: number;
  20804. protected _refreshRate: number;
  20805. protected _textureMatrix: Matrix;
  20806. protected _samples: number;
  20807. protected _renderTargetOptions: RenderTargetCreationOptions;
  20808. /**
  20809. * Gets render target creation options that were used.
  20810. */
  20811. readonly renderTargetOptions: RenderTargetCreationOptions;
  20812. protected _engine: Engine;
  20813. protected _onRatioRescale(): void;
  20814. /**
  20815. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20816. * It must define where the camera used to render the texture is set
  20817. */
  20818. boundingBoxPosition: Vector3;
  20819. private _boundingBoxSize;
  20820. /**
  20821. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20822. * When defined, the cubemap will switch to local mode
  20823. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20824. * @example https://www.babylonjs-playground.com/#RNASML
  20825. */
  20826. boundingBoxSize: Vector3;
  20827. /**
  20828. * In case the RTT has been created with a depth texture, get the associated
  20829. * depth texture.
  20830. * Otherwise, return null.
  20831. */
  20832. depthStencilTexture: Nullable<InternalTexture>;
  20833. /**
  20834. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20835. * or used a shadow, depth texture...
  20836. * @param name The friendly name of the texture
  20837. * @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)
  20838. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20839. * @param generateMipMaps True if mip maps need to be generated after render.
  20840. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20841. * @param type The type of the buffer in the RTT (int, half float, float...)
  20842. * @param isCube True if a cube texture needs to be created
  20843. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20844. * @param generateDepthBuffer True to generate a depth buffer
  20845. * @param generateStencilBuffer True to generate a stencil buffer
  20846. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20847. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20848. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20849. */
  20850. constructor(name: string, size: number | {
  20851. width: number;
  20852. height: number;
  20853. } | {
  20854. ratio: number;
  20855. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20856. /**
  20857. * Creates a depth stencil texture.
  20858. * This is only available in WebGL 2 or with the depth texture extension available.
  20859. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20860. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20861. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20862. */
  20863. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20864. private _processSizeParameter;
  20865. /**
  20866. * Define the number of samples to use in case of MSAA.
  20867. * It defaults to one meaning no MSAA has been enabled.
  20868. */
  20869. samples: number;
  20870. /**
  20871. * Resets the refresh counter of the texture and start bak from scratch.
  20872. * Could be useful to regenerate the texture if it is setup to render only once.
  20873. */
  20874. resetRefreshCounter(): void;
  20875. /**
  20876. * Define the refresh rate of the texture or the rendering frequency.
  20877. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20878. */
  20879. refreshRate: number;
  20880. /**
  20881. * Adds a post process to the render target rendering passes.
  20882. * @param postProcess define the post process to add
  20883. */
  20884. addPostProcess(postProcess: PostProcess): void;
  20885. /**
  20886. * Clear all the post processes attached to the render target
  20887. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20888. */
  20889. clearPostProcesses(dispose?: boolean): void;
  20890. /**
  20891. * Remove one of the post process from the list of attached post processes to the texture
  20892. * @param postProcess define the post process to remove from the list
  20893. */
  20894. removePostProcess(postProcess: PostProcess): void;
  20895. /** @hidden */
  20896. _shouldRender(): boolean;
  20897. /**
  20898. * Gets the actual render size of the texture.
  20899. * @returns the width of the render size
  20900. */
  20901. getRenderSize(): number;
  20902. /**
  20903. * Gets the actual render width of the texture.
  20904. * @returns the width of the render size
  20905. */
  20906. getRenderWidth(): number;
  20907. /**
  20908. * Gets the actual render height of the texture.
  20909. * @returns the height of the render size
  20910. */
  20911. getRenderHeight(): number;
  20912. /**
  20913. * Get if the texture can be rescaled or not.
  20914. */
  20915. readonly canRescale: boolean;
  20916. /**
  20917. * Resize the texture using a ratio.
  20918. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20919. */
  20920. scale(ratio: number): void;
  20921. /**
  20922. * Get the texture reflection matrix used to rotate/transform the reflection.
  20923. * @returns the reflection matrix
  20924. */
  20925. getReflectionTextureMatrix(): Matrix;
  20926. /**
  20927. * Resize the texture to a new desired size.
  20928. * Be carrefull as it will recreate all the data in the new texture.
  20929. * @param size Define the new size. It can be:
  20930. * - a number for squared texture,
  20931. * - an object containing { width: number, height: number }
  20932. * - or an object containing a ratio { ratio: number }
  20933. */
  20934. resize(size: number | {
  20935. width: number;
  20936. height: number;
  20937. } | {
  20938. ratio: number;
  20939. }): void;
  20940. /**
  20941. * Renders all the objects from the render list into the texture.
  20942. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20943. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20944. */
  20945. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20946. private _bestReflectionRenderTargetDimension;
  20947. /**
  20948. * @hidden
  20949. * @param faceIndex face index to bind to if this is a cubetexture
  20950. */
  20951. _bindFrameBuffer(faceIndex?: number): void;
  20952. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20953. private renderToTarget;
  20954. /**
  20955. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20956. * This allowed control for front to back rendering or reversly depending of the special needs.
  20957. *
  20958. * @param renderingGroupId The rendering group id corresponding to its index
  20959. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20960. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20961. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20962. */
  20963. 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;
  20964. /**
  20965. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20966. *
  20967. * @param renderingGroupId The rendering group id corresponding to its index
  20968. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20969. */
  20970. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20971. /**
  20972. * Clones the texture.
  20973. * @returns the cloned texture
  20974. */
  20975. clone(): RenderTargetTexture;
  20976. /**
  20977. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20978. * @returns The JSON representation of the texture
  20979. */
  20980. serialize(): any;
  20981. /**
  20982. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20983. */
  20984. disposeFramebufferObjects(): void;
  20985. /**
  20986. * Dispose the texture and release its associated resources.
  20987. */
  20988. dispose(): void;
  20989. /** @hidden */
  20990. _rebuild(): void;
  20991. /**
  20992. * Clear the info related to rendering groups preventing retention point in material dispose.
  20993. */
  20994. freeRenderingGroups(): void;
  20995. /**
  20996. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20997. * @returns the view count
  20998. */
  20999. getViewCount(): number;
  21000. }
  21001. }
  21002. declare module "babylonjs/Materials/material" {
  21003. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21004. import { SmartArray } from "babylonjs/Misc/smartArray";
  21005. import { Observable } from "babylonjs/Misc/observable";
  21006. import { Nullable } from "babylonjs/types";
  21007. import { Scene } from "babylonjs/scene";
  21008. import { Matrix } from "babylonjs/Maths/math.vector";
  21009. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21011. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21012. import { Effect } from "babylonjs/Materials/effect";
  21013. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21014. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21015. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21016. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21017. import { Mesh } from "babylonjs/Meshes/mesh";
  21018. import { Animation } from "babylonjs/Animations/animation";
  21019. /**
  21020. * Options for compiling materials.
  21021. */
  21022. export interface IMaterialCompilationOptions {
  21023. /**
  21024. * Defines whether clip planes are enabled.
  21025. */
  21026. clipPlane: boolean;
  21027. /**
  21028. * Defines whether instances are enabled.
  21029. */
  21030. useInstances: boolean;
  21031. }
  21032. /**
  21033. * Base class for the main features of a material in Babylon.js
  21034. */
  21035. export class Material implements IAnimatable {
  21036. /**
  21037. * Returns the triangle fill mode
  21038. */
  21039. static readonly TriangleFillMode: number;
  21040. /**
  21041. * Returns the wireframe mode
  21042. */
  21043. static readonly WireFrameFillMode: number;
  21044. /**
  21045. * Returns the point fill mode
  21046. */
  21047. static readonly PointFillMode: number;
  21048. /**
  21049. * Returns the point list draw mode
  21050. */
  21051. static readonly PointListDrawMode: number;
  21052. /**
  21053. * Returns the line list draw mode
  21054. */
  21055. static readonly LineListDrawMode: number;
  21056. /**
  21057. * Returns the line loop draw mode
  21058. */
  21059. static readonly LineLoopDrawMode: number;
  21060. /**
  21061. * Returns the line strip draw mode
  21062. */
  21063. static readonly LineStripDrawMode: number;
  21064. /**
  21065. * Returns the triangle strip draw mode
  21066. */
  21067. static readonly TriangleStripDrawMode: number;
  21068. /**
  21069. * Returns the triangle fan draw mode
  21070. */
  21071. static readonly TriangleFanDrawMode: number;
  21072. /**
  21073. * Stores the clock-wise side orientation
  21074. */
  21075. static readonly ClockWiseSideOrientation: number;
  21076. /**
  21077. * Stores the counter clock-wise side orientation
  21078. */
  21079. static readonly CounterClockWiseSideOrientation: number;
  21080. /**
  21081. * The dirty texture flag value
  21082. */
  21083. static readonly TextureDirtyFlag: number;
  21084. /**
  21085. * The dirty light flag value
  21086. */
  21087. static readonly LightDirtyFlag: number;
  21088. /**
  21089. * The dirty fresnel flag value
  21090. */
  21091. static readonly FresnelDirtyFlag: number;
  21092. /**
  21093. * The dirty attribute flag value
  21094. */
  21095. static readonly AttributesDirtyFlag: number;
  21096. /**
  21097. * The dirty misc flag value
  21098. */
  21099. static readonly MiscDirtyFlag: number;
  21100. /**
  21101. * The all dirty flag value
  21102. */
  21103. static readonly AllDirtyFlag: number;
  21104. /**
  21105. * The ID of the material
  21106. */
  21107. id: string;
  21108. /**
  21109. * Gets or sets the unique id of the material
  21110. */
  21111. uniqueId: number;
  21112. /**
  21113. * The name of the material
  21114. */
  21115. name: string;
  21116. /**
  21117. * Gets or sets user defined metadata
  21118. */
  21119. metadata: any;
  21120. /**
  21121. * For internal use only. Please do not use.
  21122. */
  21123. reservedDataStore: any;
  21124. /**
  21125. * Specifies if the ready state should be checked on each call
  21126. */
  21127. checkReadyOnEveryCall: boolean;
  21128. /**
  21129. * Specifies if the ready state should be checked once
  21130. */
  21131. checkReadyOnlyOnce: boolean;
  21132. /**
  21133. * The state of the material
  21134. */
  21135. state: string;
  21136. /**
  21137. * The alpha value of the material
  21138. */
  21139. protected _alpha: number;
  21140. /**
  21141. * List of inspectable custom properties (used by the Inspector)
  21142. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21143. */
  21144. inspectableCustomProperties: IInspectable[];
  21145. /**
  21146. * Sets the alpha value of the material
  21147. */
  21148. /**
  21149. * Gets the alpha value of the material
  21150. */
  21151. alpha: number;
  21152. /**
  21153. * Specifies if back face culling is enabled
  21154. */
  21155. protected _backFaceCulling: boolean;
  21156. /**
  21157. * Sets the back-face culling state
  21158. */
  21159. /**
  21160. * Gets the back-face culling state
  21161. */
  21162. backFaceCulling: boolean;
  21163. /**
  21164. * Stores the value for side orientation
  21165. */
  21166. sideOrientation: number;
  21167. /**
  21168. * Callback triggered when the material is compiled
  21169. */
  21170. onCompiled: Nullable<(effect: Effect) => void>;
  21171. /**
  21172. * Callback triggered when an error occurs
  21173. */
  21174. onError: Nullable<(effect: Effect, errors: string) => void>;
  21175. /**
  21176. * Callback triggered to get the render target textures
  21177. */
  21178. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21179. /**
  21180. * Gets a boolean indicating that current material needs to register RTT
  21181. */
  21182. readonly hasRenderTargetTextures: boolean;
  21183. /**
  21184. * Specifies if the material should be serialized
  21185. */
  21186. doNotSerialize: boolean;
  21187. /**
  21188. * @hidden
  21189. */
  21190. _storeEffectOnSubMeshes: boolean;
  21191. /**
  21192. * Stores the animations for the material
  21193. */
  21194. animations: Nullable<Array<Animation>>;
  21195. /**
  21196. * An event triggered when the material is disposed
  21197. */
  21198. onDisposeObservable: Observable<Material>;
  21199. /**
  21200. * An observer which watches for dispose events
  21201. */
  21202. private _onDisposeObserver;
  21203. private _onUnBindObservable;
  21204. /**
  21205. * Called during a dispose event
  21206. */
  21207. onDispose: () => void;
  21208. private _onBindObservable;
  21209. /**
  21210. * An event triggered when the material is bound
  21211. */
  21212. readonly onBindObservable: Observable<AbstractMesh>;
  21213. /**
  21214. * An observer which watches for bind events
  21215. */
  21216. private _onBindObserver;
  21217. /**
  21218. * Called during a bind event
  21219. */
  21220. onBind: (Mesh: AbstractMesh) => void;
  21221. /**
  21222. * An event triggered when the material is unbound
  21223. */
  21224. readonly onUnBindObservable: Observable<Material>;
  21225. /**
  21226. * Stores the value of the alpha mode
  21227. */
  21228. private _alphaMode;
  21229. /**
  21230. * Sets the value of the alpha mode.
  21231. *
  21232. * | Value | Type | Description |
  21233. * | --- | --- | --- |
  21234. * | 0 | ALPHA_DISABLE | |
  21235. * | 1 | ALPHA_ADD | |
  21236. * | 2 | ALPHA_COMBINE | |
  21237. * | 3 | ALPHA_SUBTRACT | |
  21238. * | 4 | ALPHA_MULTIPLY | |
  21239. * | 5 | ALPHA_MAXIMIZED | |
  21240. * | 6 | ALPHA_ONEONE | |
  21241. * | 7 | ALPHA_PREMULTIPLIED | |
  21242. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21243. * | 9 | ALPHA_INTERPOLATE | |
  21244. * | 10 | ALPHA_SCREENMODE | |
  21245. *
  21246. */
  21247. /**
  21248. * Gets the value of the alpha mode
  21249. */
  21250. alphaMode: number;
  21251. /**
  21252. * Stores the state of the need depth pre-pass value
  21253. */
  21254. private _needDepthPrePass;
  21255. /**
  21256. * Sets the need depth pre-pass value
  21257. */
  21258. /**
  21259. * Gets the depth pre-pass value
  21260. */
  21261. needDepthPrePass: boolean;
  21262. /**
  21263. * Specifies if depth writing should be disabled
  21264. */
  21265. disableDepthWrite: boolean;
  21266. /**
  21267. * Specifies if depth writing should be forced
  21268. */
  21269. forceDepthWrite: boolean;
  21270. /**
  21271. * Specifies the depth function that should be used. 0 means the default engine function
  21272. */
  21273. depthFunction: number;
  21274. /**
  21275. * Specifies if there should be a separate pass for culling
  21276. */
  21277. separateCullingPass: boolean;
  21278. /**
  21279. * Stores the state specifing if fog should be enabled
  21280. */
  21281. private _fogEnabled;
  21282. /**
  21283. * Sets the state for enabling fog
  21284. */
  21285. /**
  21286. * Gets the value of the fog enabled state
  21287. */
  21288. fogEnabled: boolean;
  21289. /**
  21290. * Stores the size of points
  21291. */
  21292. pointSize: number;
  21293. /**
  21294. * Stores the z offset value
  21295. */
  21296. zOffset: number;
  21297. /**
  21298. * Gets a value specifying if wireframe mode is enabled
  21299. */
  21300. /**
  21301. * Sets the state of wireframe mode
  21302. */
  21303. wireframe: boolean;
  21304. /**
  21305. * Gets the value specifying if point clouds are enabled
  21306. */
  21307. /**
  21308. * Sets the state of point cloud mode
  21309. */
  21310. pointsCloud: boolean;
  21311. /**
  21312. * Gets the material fill mode
  21313. */
  21314. /**
  21315. * Sets the material fill mode
  21316. */
  21317. fillMode: number;
  21318. /**
  21319. * @hidden
  21320. * Stores the effects for the material
  21321. */
  21322. _effect: Nullable<Effect>;
  21323. /**
  21324. * @hidden
  21325. * Specifies if the material was previously ready
  21326. */
  21327. _wasPreviouslyReady: boolean;
  21328. /**
  21329. * Specifies if uniform buffers should be used
  21330. */
  21331. private _useUBO;
  21332. /**
  21333. * Stores a reference to the scene
  21334. */
  21335. private _scene;
  21336. /**
  21337. * Stores the fill mode state
  21338. */
  21339. private _fillMode;
  21340. /**
  21341. * Specifies if the depth write state should be cached
  21342. */
  21343. private _cachedDepthWriteState;
  21344. /**
  21345. * Specifies if the depth function state should be cached
  21346. */
  21347. private _cachedDepthFunctionState;
  21348. /**
  21349. * Stores the uniform buffer
  21350. */
  21351. protected _uniformBuffer: UniformBuffer;
  21352. /** @hidden */
  21353. _indexInSceneMaterialArray: number;
  21354. /** @hidden */
  21355. meshMap: Nullable<{
  21356. [id: string]: AbstractMesh | undefined;
  21357. }>;
  21358. /**
  21359. * Creates a material instance
  21360. * @param name defines the name of the material
  21361. * @param scene defines the scene to reference
  21362. * @param doNotAdd specifies if the material should be added to the scene
  21363. */
  21364. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21365. /**
  21366. * Returns a string representation of the current material
  21367. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21368. * @returns a string with material information
  21369. */
  21370. toString(fullDetails?: boolean): string;
  21371. /**
  21372. * Gets the class name of the material
  21373. * @returns a string with the class name of the material
  21374. */
  21375. getClassName(): string;
  21376. /**
  21377. * Specifies if updates for the material been locked
  21378. */
  21379. readonly isFrozen: boolean;
  21380. /**
  21381. * Locks updates for the material
  21382. */
  21383. freeze(): void;
  21384. /**
  21385. * Unlocks updates for the material
  21386. */
  21387. unfreeze(): void;
  21388. /**
  21389. * Specifies if the material is ready to be used
  21390. * @param mesh defines the mesh to check
  21391. * @param useInstances specifies if instances should be used
  21392. * @returns a boolean indicating if the material is ready to be used
  21393. */
  21394. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21395. /**
  21396. * Specifies that the submesh is ready to be used
  21397. * @param mesh defines the mesh to check
  21398. * @param subMesh defines which submesh to check
  21399. * @param useInstances specifies that instances should be used
  21400. * @returns a boolean indicating that the submesh is ready or not
  21401. */
  21402. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21403. /**
  21404. * Returns the material effect
  21405. * @returns the effect associated with the material
  21406. */
  21407. getEffect(): Nullable<Effect>;
  21408. /**
  21409. * Returns the current scene
  21410. * @returns a Scene
  21411. */
  21412. getScene(): Scene;
  21413. /**
  21414. * Specifies if the material will require alpha blending
  21415. * @returns a boolean specifying if alpha blending is needed
  21416. */
  21417. needAlphaBlending(): boolean;
  21418. /**
  21419. * Specifies if the mesh will require alpha blending
  21420. * @param mesh defines the mesh to check
  21421. * @returns a boolean specifying if alpha blending is needed for the mesh
  21422. */
  21423. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21424. /**
  21425. * Specifies if this material should be rendered in alpha test mode
  21426. * @returns a boolean specifying if an alpha test is needed.
  21427. */
  21428. needAlphaTesting(): boolean;
  21429. /**
  21430. * Gets the texture used for the alpha test
  21431. * @returns the texture to use for alpha testing
  21432. */
  21433. getAlphaTestTexture(): Nullable<BaseTexture>;
  21434. /**
  21435. * Marks the material to indicate that it needs to be re-calculated
  21436. */
  21437. markDirty(): void;
  21438. /** @hidden */
  21439. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21440. /**
  21441. * Binds the material to the mesh
  21442. * @param world defines the world transformation matrix
  21443. * @param mesh defines the mesh to bind the material to
  21444. */
  21445. bind(world: Matrix, mesh?: Mesh): void;
  21446. /**
  21447. * Binds the submesh to the material
  21448. * @param world defines the world transformation matrix
  21449. * @param mesh defines the mesh containing the submesh
  21450. * @param subMesh defines the submesh to bind the material to
  21451. */
  21452. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21453. /**
  21454. * Binds the world matrix to the material
  21455. * @param world defines the world transformation matrix
  21456. */
  21457. bindOnlyWorldMatrix(world: Matrix): void;
  21458. /**
  21459. * Binds the scene's uniform buffer to the effect.
  21460. * @param effect defines the effect to bind to the scene uniform buffer
  21461. * @param sceneUbo defines the uniform buffer storing scene data
  21462. */
  21463. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21464. /**
  21465. * Binds the view matrix to the effect
  21466. * @param effect defines the effect to bind the view matrix to
  21467. */
  21468. bindView(effect: Effect): void;
  21469. /**
  21470. * Binds the view projection matrix to the effect
  21471. * @param effect defines the effect to bind the view projection matrix to
  21472. */
  21473. bindViewProjection(effect: Effect): void;
  21474. /**
  21475. * Specifies if material alpha testing should be turned on for the mesh
  21476. * @param mesh defines the mesh to check
  21477. */
  21478. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21479. /**
  21480. * Processes to execute after binding the material to a mesh
  21481. * @param mesh defines the rendered mesh
  21482. */
  21483. protected _afterBind(mesh?: Mesh): void;
  21484. /**
  21485. * Unbinds the material from the mesh
  21486. */
  21487. unbind(): void;
  21488. /**
  21489. * Gets the active textures from the material
  21490. * @returns an array of textures
  21491. */
  21492. getActiveTextures(): BaseTexture[];
  21493. /**
  21494. * Specifies if the material uses a texture
  21495. * @param texture defines the texture to check against the material
  21496. * @returns a boolean specifying if the material uses the texture
  21497. */
  21498. hasTexture(texture: BaseTexture): boolean;
  21499. /**
  21500. * Makes a duplicate of the material, and gives it a new name
  21501. * @param name defines the new name for the duplicated material
  21502. * @returns the cloned material
  21503. */
  21504. clone(name: string): Nullable<Material>;
  21505. /**
  21506. * Gets the meshes bound to the material
  21507. * @returns an array of meshes bound to the material
  21508. */
  21509. getBindedMeshes(): AbstractMesh[];
  21510. /**
  21511. * Force shader compilation
  21512. * @param mesh defines the mesh associated with this material
  21513. * @param onCompiled defines a function to execute once the material is compiled
  21514. * @param options defines the options to configure the compilation
  21515. * @param onError defines a function to execute if the material fails compiling
  21516. */
  21517. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21518. /**
  21519. * Force shader compilation
  21520. * @param mesh defines the mesh that will use this material
  21521. * @param options defines additional options for compiling the shaders
  21522. * @returns a promise that resolves when the compilation completes
  21523. */
  21524. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21525. private static readonly _AllDirtyCallBack;
  21526. private static readonly _ImageProcessingDirtyCallBack;
  21527. private static readonly _TextureDirtyCallBack;
  21528. private static readonly _FresnelDirtyCallBack;
  21529. private static readonly _MiscDirtyCallBack;
  21530. private static readonly _LightsDirtyCallBack;
  21531. private static readonly _AttributeDirtyCallBack;
  21532. private static _FresnelAndMiscDirtyCallBack;
  21533. private static _TextureAndMiscDirtyCallBack;
  21534. private static readonly _DirtyCallbackArray;
  21535. private static readonly _RunDirtyCallBacks;
  21536. /**
  21537. * Marks a define in the material to indicate that it needs to be re-computed
  21538. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21539. */
  21540. markAsDirty(flag: number): void;
  21541. /**
  21542. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21543. * @param func defines a function which checks material defines against the submeshes
  21544. */
  21545. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21546. /**
  21547. * Indicates that we need to re-calculated for all submeshes
  21548. */
  21549. protected _markAllSubMeshesAsAllDirty(): void;
  21550. /**
  21551. * Indicates that image processing needs to be re-calculated for all submeshes
  21552. */
  21553. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21554. /**
  21555. * Indicates that textures need to be re-calculated for all submeshes
  21556. */
  21557. protected _markAllSubMeshesAsTexturesDirty(): void;
  21558. /**
  21559. * Indicates that fresnel needs to be re-calculated for all submeshes
  21560. */
  21561. protected _markAllSubMeshesAsFresnelDirty(): void;
  21562. /**
  21563. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21564. */
  21565. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21566. /**
  21567. * Indicates that lights need to be re-calculated for all submeshes
  21568. */
  21569. protected _markAllSubMeshesAsLightsDirty(): void;
  21570. /**
  21571. * Indicates that attributes need to be re-calculated for all submeshes
  21572. */
  21573. protected _markAllSubMeshesAsAttributesDirty(): void;
  21574. /**
  21575. * Indicates that misc needs to be re-calculated for all submeshes
  21576. */
  21577. protected _markAllSubMeshesAsMiscDirty(): void;
  21578. /**
  21579. * Indicates that textures and misc need to be re-calculated for all submeshes
  21580. */
  21581. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21582. /**
  21583. * Disposes the material
  21584. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21585. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21586. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21587. */
  21588. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21589. /** @hidden */
  21590. private releaseVertexArrayObject;
  21591. /**
  21592. * Serializes this material
  21593. * @returns the serialized material object
  21594. */
  21595. serialize(): any;
  21596. /**
  21597. * Creates a material from parsed material data
  21598. * @param parsedMaterial defines parsed material data
  21599. * @param scene defines the hosting scene
  21600. * @param rootUrl defines the root URL to use to load textures
  21601. * @returns a new material
  21602. */
  21603. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21604. }
  21605. }
  21606. declare module "babylonjs/Materials/multiMaterial" {
  21607. import { Nullable } from "babylonjs/types";
  21608. import { Scene } from "babylonjs/scene";
  21609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21610. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21611. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21612. import { Material } from "babylonjs/Materials/material";
  21613. /**
  21614. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21615. * separate meshes. This can be use to improve performances.
  21616. * @see http://doc.babylonjs.com/how_to/multi_materials
  21617. */
  21618. export class MultiMaterial extends Material {
  21619. private _subMaterials;
  21620. /**
  21621. * Gets or Sets the list of Materials used within the multi material.
  21622. * They need to be ordered according to the submeshes order in the associated mesh
  21623. */
  21624. subMaterials: Nullable<Material>[];
  21625. /**
  21626. * Function used to align with Node.getChildren()
  21627. * @returns the list of Materials used within the multi material
  21628. */
  21629. getChildren(): Nullable<Material>[];
  21630. /**
  21631. * Instantiates a new Multi Material
  21632. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21633. * separate meshes. This can be use to improve performances.
  21634. * @see http://doc.babylonjs.com/how_to/multi_materials
  21635. * @param name Define the name in the scene
  21636. * @param scene Define the scene the material belongs to
  21637. */
  21638. constructor(name: string, scene: Scene);
  21639. private _hookArray;
  21640. /**
  21641. * Get one of the submaterial by its index in the submaterials array
  21642. * @param index The index to look the sub material at
  21643. * @returns The Material if the index has been defined
  21644. */
  21645. getSubMaterial(index: number): Nullable<Material>;
  21646. /**
  21647. * Get the list of active textures for the whole sub materials list.
  21648. * @returns All the textures that will be used during the rendering
  21649. */
  21650. getActiveTextures(): BaseTexture[];
  21651. /**
  21652. * Gets the current class name of the material e.g. "MultiMaterial"
  21653. * Mainly use in serialization.
  21654. * @returns the class name
  21655. */
  21656. getClassName(): string;
  21657. /**
  21658. * Checks if the material is ready to render the requested sub mesh
  21659. * @param mesh Define the mesh the submesh belongs to
  21660. * @param subMesh Define the sub mesh to look readyness for
  21661. * @param useInstances Define whether or not the material is used with instances
  21662. * @returns true if ready, otherwise false
  21663. */
  21664. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21665. /**
  21666. * Clones the current material and its related sub materials
  21667. * @param name Define the name of the newly cloned material
  21668. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21669. * @returns the cloned material
  21670. */
  21671. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21672. /**
  21673. * Serializes the materials into a JSON representation.
  21674. * @returns the JSON representation
  21675. */
  21676. serialize(): any;
  21677. /**
  21678. * Dispose the material and release its associated resources
  21679. * @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)
  21680. * @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)
  21681. * @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)
  21682. */
  21683. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21684. /**
  21685. * Creates a MultiMaterial from parsed MultiMaterial data.
  21686. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21687. * @param scene defines the hosting scene
  21688. * @returns a new MultiMaterial
  21689. */
  21690. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21691. }
  21692. }
  21693. declare module "babylonjs/Meshes/subMesh" {
  21694. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21695. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21696. import { Engine } from "babylonjs/Engines/engine";
  21697. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21698. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21699. import { Effect } from "babylonjs/Materials/effect";
  21700. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21701. import { Plane } from "babylonjs/Maths/math.plane";
  21702. import { Collider } from "babylonjs/Collisions/collider";
  21703. import { Material } from "babylonjs/Materials/material";
  21704. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21706. import { Mesh } from "babylonjs/Meshes/mesh";
  21707. import { Ray } from "babylonjs/Culling/ray";
  21708. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21709. /**
  21710. * Base class for submeshes
  21711. */
  21712. export class BaseSubMesh {
  21713. /** @hidden */
  21714. _materialDefines: Nullable<MaterialDefines>;
  21715. /** @hidden */
  21716. _materialEffect: Nullable<Effect>;
  21717. /**
  21718. * Gets material defines used by the effect associated to the sub mesh
  21719. */
  21720. /**
  21721. * Sets material defines used by the effect associated to the sub mesh
  21722. */
  21723. materialDefines: Nullable<MaterialDefines>;
  21724. /**
  21725. * Gets associated effect
  21726. */
  21727. readonly effect: Nullable<Effect>;
  21728. /**
  21729. * Sets associated effect (effect used to render this submesh)
  21730. * @param effect defines the effect to associate with
  21731. * @param defines defines the set of defines used to compile this effect
  21732. */
  21733. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21734. }
  21735. /**
  21736. * Defines a subdivision inside a mesh
  21737. */
  21738. export class SubMesh extends BaseSubMesh implements ICullable {
  21739. /** the material index to use */
  21740. materialIndex: number;
  21741. /** vertex index start */
  21742. verticesStart: number;
  21743. /** vertices count */
  21744. verticesCount: number;
  21745. /** index start */
  21746. indexStart: number;
  21747. /** indices count */
  21748. indexCount: number;
  21749. /** @hidden */
  21750. _linesIndexCount: number;
  21751. private _mesh;
  21752. private _renderingMesh;
  21753. private _boundingInfo;
  21754. private _linesIndexBuffer;
  21755. /** @hidden */
  21756. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21757. /** @hidden */
  21758. _trianglePlanes: Plane[];
  21759. /** @hidden */
  21760. _lastColliderTransformMatrix: Nullable<Matrix>;
  21761. /** @hidden */
  21762. _renderId: number;
  21763. /** @hidden */
  21764. _alphaIndex: number;
  21765. /** @hidden */
  21766. _distanceToCamera: number;
  21767. /** @hidden */
  21768. _id: number;
  21769. private _currentMaterial;
  21770. /**
  21771. * Add a new submesh to a mesh
  21772. * @param materialIndex defines the material index to use
  21773. * @param verticesStart defines vertex index start
  21774. * @param verticesCount defines vertices count
  21775. * @param indexStart defines index start
  21776. * @param indexCount defines indices count
  21777. * @param mesh defines the parent mesh
  21778. * @param renderingMesh defines an optional rendering mesh
  21779. * @param createBoundingBox defines if bounding box should be created for this submesh
  21780. * @returns the new submesh
  21781. */
  21782. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21783. /**
  21784. * Creates a new submesh
  21785. * @param materialIndex defines the material index to use
  21786. * @param verticesStart defines vertex index start
  21787. * @param verticesCount defines vertices count
  21788. * @param indexStart defines index start
  21789. * @param indexCount defines indices count
  21790. * @param mesh defines the parent mesh
  21791. * @param renderingMesh defines an optional rendering mesh
  21792. * @param createBoundingBox defines if bounding box should be created for this submesh
  21793. */
  21794. constructor(
  21795. /** the material index to use */
  21796. materialIndex: number,
  21797. /** vertex index start */
  21798. verticesStart: number,
  21799. /** vertices count */
  21800. verticesCount: number,
  21801. /** index start */
  21802. indexStart: number,
  21803. /** indices count */
  21804. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21805. /**
  21806. * Returns true if this submesh covers the entire parent mesh
  21807. * @ignorenaming
  21808. */
  21809. readonly IsGlobal: boolean;
  21810. /**
  21811. * Returns the submesh BoudingInfo object
  21812. * @returns current bounding info (or mesh's one if the submesh is global)
  21813. */
  21814. getBoundingInfo(): BoundingInfo;
  21815. /**
  21816. * Sets the submesh BoundingInfo
  21817. * @param boundingInfo defines the new bounding info to use
  21818. * @returns the SubMesh
  21819. */
  21820. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21821. /**
  21822. * Returns the mesh of the current submesh
  21823. * @return the parent mesh
  21824. */
  21825. getMesh(): AbstractMesh;
  21826. /**
  21827. * Returns the rendering mesh of the submesh
  21828. * @returns the rendering mesh (could be different from parent mesh)
  21829. */
  21830. getRenderingMesh(): Mesh;
  21831. /**
  21832. * Returns the submesh material
  21833. * @returns null or the current material
  21834. */
  21835. getMaterial(): Nullable<Material>;
  21836. /**
  21837. * Sets a new updated BoundingInfo object to the submesh
  21838. * @param data defines an optional position array to use to determine the bounding info
  21839. * @returns the SubMesh
  21840. */
  21841. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21842. /** @hidden */
  21843. _checkCollision(collider: Collider): boolean;
  21844. /**
  21845. * Updates the submesh BoundingInfo
  21846. * @param world defines the world matrix to use to update the bounding info
  21847. * @returns the submesh
  21848. */
  21849. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21850. /**
  21851. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21852. * @param frustumPlanes defines the frustum planes
  21853. * @returns true if the submesh is intersecting with the frustum
  21854. */
  21855. isInFrustum(frustumPlanes: Plane[]): boolean;
  21856. /**
  21857. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21858. * @param frustumPlanes defines the frustum planes
  21859. * @returns true if the submesh is inside the frustum
  21860. */
  21861. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21862. /**
  21863. * Renders the submesh
  21864. * @param enableAlphaMode defines if alpha needs to be used
  21865. * @returns the submesh
  21866. */
  21867. render(enableAlphaMode: boolean): SubMesh;
  21868. /**
  21869. * @hidden
  21870. */
  21871. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21872. /**
  21873. * Checks if the submesh intersects with a ray
  21874. * @param ray defines the ray to test
  21875. * @returns true is the passed ray intersects the submesh bounding box
  21876. */
  21877. canIntersects(ray: Ray): boolean;
  21878. /**
  21879. * Intersects current submesh with a ray
  21880. * @param ray defines the ray to test
  21881. * @param positions defines mesh's positions array
  21882. * @param indices defines mesh's indices array
  21883. * @param fastCheck defines if only bounding info should be used
  21884. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21885. * @returns intersection info or null if no intersection
  21886. */
  21887. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21888. /** @hidden */
  21889. private _intersectLines;
  21890. /** @hidden */
  21891. private _intersectUnIndexedLines;
  21892. /** @hidden */
  21893. private _intersectTriangles;
  21894. /** @hidden */
  21895. private _intersectUnIndexedTriangles;
  21896. /** @hidden */
  21897. _rebuild(): void;
  21898. /**
  21899. * Creates a new submesh from the passed mesh
  21900. * @param newMesh defines the new hosting mesh
  21901. * @param newRenderingMesh defines an optional rendering mesh
  21902. * @returns the new submesh
  21903. */
  21904. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21905. /**
  21906. * Release associated resources
  21907. */
  21908. dispose(): void;
  21909. /**
  21910. * Gets the class name
  21911. * @returns the string "SubMesh".
  21912. */
  21913. getClassName(): string;
  21914. /**
  21915. * Creates a new submesh from indices data
  21916. * @param materialIndex the index of the main mesh material
  21917. * @param startIndex the index where to start the copy in the mesh indices array
  21918. * @param indexCount the number of indices to copy then from the startIndex
  21919. * @param mesh the main mesh to create the submesh from
  21920. * @param renderingMesh the optional rendering mesh
  21921. * @returns a new submesh
  21922. */
  21923. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21924. }
  21925. }
  21926. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21927. /**
  21928. * Class used to represent data loading progression
  21929. */
  21930. export class SceneLoaderFlags {
  21931. private static _ForceFullSceneLoadingForIncremental;
  21932. private static _ShowLoadingScreen;
  21933. private static _CleanBoneMatrixWeights;
  21934. private static _loggingLevel;
  21935. /**
  21936. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21937. */
  21938. static ForceFullSceneLoadingForIncremental: boolean;
  21939. /**
  21940. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21941. */
  21942. static ShowLoadingScreen: boolean;
  21943. /**
  21944. * Defines the current logging level (while loading the scene)
  21945. * @ignorenaming
  21946. */
  21947. static loggingLevel: number;
  21948. /**
  21949. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21950. */
  21951. static CleanBoneMatrixWeights: boolean;
  21952. }
  21953. }
  21954. declare module "babylonjs/Meshes/geometry" {
  21955. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21956. import { Scene } from "babylonjs/scene";
  21957. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21958. import { Engine } from "babylonjs/Engines/engine";
  21959. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21960. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21961. import { Effect } from "babylonjs/Materials/effect";
  21962. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21963. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21964. import { Mesh } from "babylonjs/Meshes/mesh";
  21965. /**
  21966. * Class used to store geometry data (vertex buffers + index buffer)
  21967. */
  21968. export class Geometry implements IGetSetVerticesData {
  21969. /**
  21970. * Gets or sets the ID of the geometry
  21971. */
  21972. id: string;
  21973. /**
  21974. * Gets or sets the unique ID of the geometry
  21975. */
  21976. uniqueId: number;
  21977. /**
  21978. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21979. */
  21980. delayLoadState: number;
  21981. /**
  21982. * Gets the file containing the data to load when running in delay load state
  21983. */
  21984. delayLoadingFile: Nullable<string>;
  21985. /**
  21986. * Callback called when the geometry is updated
  21987. */
  21988. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21989. private _scene;
  21990. private _engine;
  21991. private _meshes;
  21992. private _totalVertices;
  21993. /** @hidden */
  21994. _indices: IndicesArray;
  21995. /** @hidden */
  21996. _vertexBuffers: {
  21997. [key: string]: VertexBuffer;
  21998. };
  21999. private _isDisposed;
  22000. private _extend;
  22001. private _boundingBias;
  22002. /** @hidden */
  22003. _delayInfo: Array<string>;
  22004. private _indexBuffer;
  22005. private _indexBufferIsUpdatable;
  22006. /** @hidden */
  22007. _boundingInfo: Nullable<BoundingInfo>;
  22008. /** @hidden */
  22009. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22010. /** @hidden */
  22011. _softwareSkinningFrameId: number;
  22012. private _vertexArrayObjects;
  22013. private _updatable;
  22014. /** @hidden */
  22015. _positions: Nullable<Vector3[]>;
  22016. /**
  22017. * 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
  22018. */
  22019. /**
  22020. * 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
  22021. */
  22022. boundingBias: Vector2;
  22023. /**
  22024. * Static function used to attach a new empty geometry to a mesh
  22025. * @param mesh defines the mesh to attach the geometry to
  22026. * @returns the new Geometry
  22027. */
  22028. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22029. /**
  22030. * Creates a new geometry
  22031. * @param id defines the unique ID
  22032. * @param scene defines the hosting scene
  22033. * @param vertexData defines the VertexData used to get geometry data
  22034. * @param updatable defines if geometry must be updatable (false by default)
  22035. * @param mesh defines the mesh that will be associated with the geometry
  22036. */
  22037. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22038. /**
  22039. * Gets the current extend of the geometry
  22040. */
  22041. readonly extend: {
  22042. minimum: Vector3;
  22043. maximum: Vector3;
  22044. };
  22045. /**
  22046. * Gets the hosting scene
  22047. * @returns the hosting Scene
  22048. */
  22049. getScene(): Scene;
  22050. /**
  22051. * Gets the hosting engine
  22052. * @returns the hosting Engine
  22053. */
  22054. getEngine(): Engine;
  22055. /**
  22056. * Defines if the geometry is ready to use
  22057. * @returns true if the geometry is ready to be used
  22058. */
  22059. isReady(): boolean;
  22060. /**
  22061. * Gets a value indicating that the geometry should not be serialized
  22062. */
  22063. readonly doNotSerialize: boolean;
  22064. /** @hidden */
  22065. _rebuild(): void;
  22066. /**
  22067. * Affects all geometry data in one call
  22068. * @param vertexData defines the geometry data
  22069. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22070. */
  22071. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22072. /**
  22073. * Set specific vertex data
  22074. * @param kind defines the data kind (Position, normal, etc...)
  22075. * @param data defines the vertex data to use
  22076. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22077. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22078. */
  22079. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22080. /**
  22081. * Removes a specific vertex data
  22082. * @param kind defines the data kind (Position, normal, etc...)
  22083. */
  22084. removeVerticesData(kind: string): void;
  22085. /**
  22086. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22087. * @param buffer defines the vertex buffer to use
  22088. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22089. */
  22090. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22091. /**
  22092. * Update a specific vertex buffer
  22093. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22094. * It will do nothing if the buffer is not updatable
  22095. * @param kind defines the data kind (Position, normal, etc...)
  22096. * @param data defines the data to use
  22097. * @param offset defines the offset in the target buffer where to store the data
  22098. * @param useBytes set to true if the offset is in bytes
  22099. */
  22100. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22101. /**
  22102. * Update a specific vertex buffer
  22103. * This function will create a new buffer if the current one is not updatable
  22104. * @param kind defines the data kind (Position, normal, etc...)
  22105. * @param data defines the data to use
  22106. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22107. */
  22108. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22109. private _updateBoundingInfo;
  22110. /** @hidden */
  22111. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22112. /**
  22113. * Gets total number of vertices
  22114. * @returns the total number of vertices
  22115. */
  22116. getTotalVertices(): number;
  22117. /**
  22118. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22119. * @param kind defines the data kind (Position, normal, etc...)
  22120. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22121. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22122. * @returns a float array containing vertex data
  22123. */
  22124. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22125. /**
  22126. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22127. * @param kind defines the data kind (Position, normal, etc...)
  22128. * @returns true if the vertex buffer with the specified kind is updatable
  22129. */
  22130. isVertexBufferUpdatable(kind: string): boolean;
  22131. /**
  22132. * Gets a specific vertex buffer
  22133. * @param kind defines the data kind (Position, normal, etc...)
  22134. * @returns a VertexBuffer
  22135. */
  22136. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22137. /**
  22138. * Returns all vertex buffers
  22139. * @return an object holding all vertex buffers indexed by kind
  22140. */
  22141. getVertexBuffers(): Nullable<{
  22142. [key: string]: VertexBuffer;
  22143. }>;
  22144. /**
  22145. * Gets a boolean indicating if specific vertex buffer is present
  22146. * @param kind defines the data kind (Position, normal, etc...)
  22147. * @returns true if data is present
  22148. */
  22149. isVerticesDataPresent(kind: string): boolean;
  22150. /**
  22151. * Gets a list of all attached data kinds (Position, normal, etc...)
  22152. * @returns a list of string containing all kinds
  22153. */
  22154. getVerticesDataKinds(): string[];
  22155. /**
  22156. * Update index buffer
  22157. * @param indices defines the indices to store in the index buffer
  22158. * @param offset defines the offset in the target buffer where to store the data
  22159. * @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)
  22160. */
  22161. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22162. /**
  22163. * Creates a new index buffer
  22164. * @param indices defines the indices to store in the index buffer
  22165. * @param totalVertices defines the total number of vertices (could be null)
  22166. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22167. */
  22168. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22169. /**
  22170. * Return the total number of indices
  22171. * @returns the total number of indices
  22172. */
  22173. getTotalIndices(): number;
  22174. /**
  22175. * Gets the index buffer array
  22176. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22177. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22178. * @returns the index buffer array
  22179. */
  22180. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22181. /**
  22182. * Gets the index buffer
  22183. * @return the index buffer
  22184. */
  22185. getIndexBuffer(): Nullable<DataBuffer>;
  22186. /** @hidden */
  22187. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22188. /**
  22189. * Release the associated resources for a specific mesh
  22190. * @param mesh defines the source mesh
  22191. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22192. */
  22193. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22194. /**
  22195. * Apply current geometry to a given mesh
  22196. * @param mesh defines the mesh to apply geometry to
  22197. */
  22198. applyToMesh(mesh: Mesh): void;
  22199. private _updateExtend;
  22200. private _applyToMesh;
  22201. private notifyUpdate;
  22202. /**
  22203. * Load the geometry if it was flagged as delay loaded
  22204. * @param scene defines the hosting scene
  22205. * @param onLoaded defines a callback called when the geometry is loaded
  22206. */
  22207. load(scene: Scene, onLoaded?: () => void): void;
  22208. private _queueLoad;
  22209. /**
  22210. * Invert the geometry to move from a right handed system to a left handed one.
  22211. */
  22212. toLeftHanded(): void;
  22213. /** @hidden */
  22214. _resetPointsArrayCache(): void;
  22215. /** @hidden */
  22216. _generatePointsArray(): boolean;
  22217. /**
  22218. * Gets a value indicating if the geometry is disposed
  22219. * @returns true if the geometry was disposed
  22220. */
  22221. isDisposed(): boolean;
  22222. private _disposeVertexArrayObjects;
  22223. /**
  22224. * Free all associated resources
  22225. */
  22226. dispose(): void;
  22227. /**
  22228. * Clone the current geometry into a new geometry
  22229. * @param id defines the unique ID of the new geometry
  22230. * @returns a new geometry object
  22231. */
  22232. copy(id: string): Geometry;
  22233. /**
  22234. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22235. * @return a JSON representation of the current geometry data (without the vertices data)
  22236. */
  22237. serialize(): any;
  22238. private toNumberArray;
  22239. /**
  22240. * Serialize all vertices data into a JSON oject
  22241. * @returns a JSON representation of the current geometry data
  22242. */
  22243. serializeVerticeData(): any;
  22244. /**
  22245. * Extracts a clone of a mesh geometry
  22246. * @param mesh defines the source mesh
  22247. * @param id defines the unique ID of the new geometry object
  22248. * @returns the new geometry object
  22249. */
  22250. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22251. /**
  22252. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22253. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22254. * Be aware Math.random() could cause collisions, but:
  22255. * "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"
  22256. * @returns a string containing a new GUID
  22257. */
  22258. static RandomId(): string;
  22259. /** @hidden */
  22260. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22261. private static _CleanMatricesWeights;
  22262. /**
  22263. * Create a new geometry from persisted data (Using .babylon file format)
  22264. * @param parsedVertexData defines the persisted data
  22265. * @param scene defines the hosting scene
  22266. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22267. * @returns the new geometry object
  22268. */
  22269. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22270. }
  22271. }
  22272. declare module "babylonjs/Meshes/mesh.vertexData" {
  22273. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22274. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22275. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22276. import { Geometry } from "babylonjs/Meshes/geometry";
  22277. import { Mesh } from "babylonjs/Meshes/mesh";
  22278. /**
  22279. * Define an interface for all classes that will get and set the data on vertices
  22280. */
  22281. export interface IGetSetVerticesData {
  22282. /**
  22283. * Gets a boolean indicating if specific vertex data is present
  22284. * @param kind defines the vertex data kind to use
  22285. * @returns true is data kind is present
  22286. */
  22287. isVerticesDataPresent(kind: string): boolean;
  22288. /**
  22289. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22290. * @param kind defines the data kind (Position, normal, etc...)
  22291. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22292. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22293. * @returns a float array containing vertex data
  22294. */
  22295. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22296. /**
  22297. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22298. * @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.
  22299. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22300. * @returns the indices array or an empty array if the mesh has no geometry
  22301. */
  22302. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22303. /**
  22304. * Set specific vertex data
  22305. * @param kind defines the data kind (Position, normal, etc...)
  22306. * @param data defines the vertex data to use
  22307. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22308. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22309. */
  22310. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22311. /**
  22312. * Update a specific associated vertex buffer
  22313. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22314. * - VertexBuffer.PositionKind
  22315. * - VertexBuffer.UVKind
  22316. * - VertexBuffer.UV2Kind
  22317. * - VertexBuffer.UV3Kind
  22318. * - VertexBuffer.UV4Kind
  22319. * - VertexBuffer.UV5Kind
  22320. * - VertexBuffer.UV6Kind
  22321. * - VertexBuffer.ColorKind
  22322. * - VertexBuffer.MatricesIndicesKind
  22323. * - VertexBuffer.MatricesIndicesExtraKind
  22324. * - VertexBuffer.MatricesWeightsKind
  22325. * - VertexBuffer.MatricesWeightsExtraKind
  22326. * @param data defines the data source
  22327. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22328. * @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)
  22329. */
  22330. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22331. /**
  22332. * Creates a new index buffer
  22333. * @param indices defines the indices to store in the index buffer
  22334. * @param totalVertices defines the total number of vertices (could be null)
  22335. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22336. */
  22337. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22338. }
  22339. /**
  22340. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22341. */
  22342. export class VertexData {
  22343. /**
  22344. * Mesh side orientation : usually the external or front surface
  22345. */
  22346. static readonly FRONTSIDE: number;
  22347. /**
  22348. * Mesh side orientation : usually the internal or back surface
  22349. */
  22350. static readonly BACKSIDE: number;
  22351. /**
  22352. * Mesh side orientation : both internal and external or front and back surfaces
  22353. */
  22354. static readonly DOUBLESIDE: number;
  22355. /**
  22356. * Mesh side orientation : by default, `FRONTSIDE`
  22357. */
  22358. static readonly DEFAULTSIDE: number;
  22359. /**
  22360. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22361. */
  22362. positions: Nullable<FloatArray>;
  22363. /**
  22364. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22365. */
  22366. normals: Nullable<FloatArray>;
  22367. /**
  22368. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22369. */
  22370. tangents: Nullable<FloatArray>;
  22371. /**
  22372. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22373. */
  22374. uvs: Nullable<FloatArray>;
  22375. /**
  22376. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22377. */
  22378. uvs2: Nullable<FloatArray>;
  22379. /**
  22380. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22381. */
  22382. uvs3: Nullable<FloatArray>;
  22383. /**
  22384. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22385. */
  22386. uvs4: Nullable<FloatArray>;
  22387. /**
  22388. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22389. */
  22390. uvs5: Nullable<FloatArray>;
  22391. /**
  22392. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22393. */
  22394. uvs6: Nullable<FloatArray>;
  22395. /**
  22396. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22397. */
  22398. colors: Nullable<FloatArray>;
  22399. /**
  22400. * 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).
  22401. */
  22402. matricesIndices: Nullable<FloatArray>;
  22403. /**
  22404. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22405. */
  22406. matricesWeights: Nullable<FloatArray>;
  22407. /**
  22408. * An array extending the number of possible indices
  22409. */
  22410. matricesIndicesExtra: Nullable<FloatArray>;
  22411. /**
  22412. * An array extending the number of possible weights when the number of indices is extended
  22413. */
  22414. matricesWeightsExtra: Nullable<FloatArray>;
  22415. /**
  22416. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22417. */
  22418. indices: Nullable<IndicesArray>;
  22419. /**
  22420. * Uses the passed data array to set the set the values for the specified kind of data
  22421. * @param data a linear array of floating numbers
  22422. * @param kind the type of data that is being set, eg positions, colors etc
  22423. */
  22424. set(data: FloatArray, kind: string): void;
  22425. /**
  22426. * Associates the vertexData to the passed Mesh.
  22427. * Sets it as updatable or not (default `false`)
  22428. * @param mesh the mesh the vertexData is applied to
  22429. * @param updatable when used and having the value true allows new data to update the vertexData
  22430. * @returns the VertexData
  22431. */
  22432. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22433. /**
  22434. * Associates the vertexData to the passed Geometry.
  22435. * Sets it as updatable or not (default `false`)
  22436. * @param geometry the geometry the vertexData is applied to
  22437. * @param updatable when used and having the value true allows new data to update the vertexData
  22438. * @returns VertexData
  22439. */
  22440. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22441. /**
  22442. * Updates the associated mesh
  22443. * @param mesh the mesh to be updated
  22444. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22445. * @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
  22446. * @returns VertexData
  22447. */
  22448. updateMesh(mesh: Mesh): VertexData;
  22449. /**
  22450. * Updates the associated geometry
  22451. * @param geometry the geometry to be updated
  22452. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22453. * @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
  22454. * @returns VertexData.
  22455. */
  22456. updateGeometry(geometry: Geometry): VertexData;
  22457. private _applyTo;
  22458. private _update;
  22459. /**
  22460. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22461. * @param matrix the transforming matrix
  22462. * @returns the VertexData
  22463. */
  22464. transform(matrix: Matrix): VertexData;
  22465. /**
  22466. * Merges the passed VertexData into the current one
  22467. * @param other the VertexData to be merged into the current one
  22468. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22469. * @returns the modified VertexData
  22470. */
  22471. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22472. private _mergeElement;
  22473. private _validate;
  22474. /**
  22475. * Serializes the VertexData
  22476. * @returns a serialized object
  22477. */
  22478. serialize(): any;
  22479. /**
  22480. * Extracts the vertexData from a mesh
  22481. * @param mesh the mesh from which to extract the VertexData
  22482. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22483. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22484. * @returns the object VertexData associated to the passed mesh
  22485. */
  22486. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22487. /**
  22488. * Extracts the vertexData from the geometry
  22489. * @param geometry the geometry from which to extract the VertexData
  22490. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22491. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22492. * @returns the object VertexData associated to the passed mesh
  22493. */
  22494. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22495. private static _ExtractFrom;
  22496. /**
  22497. * Creates the VertexData for a Ribbon
  22498. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22499. * * pathArray array of paths, each of which an array of successive Vector3
  22500. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22501. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22502. * * 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
  22503. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22504. * * 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)
  22505. * * 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)
  22506. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22507. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22508. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22509. * @returns the VertexData of the ribbon
  22510. */
  22511. static CreateRibbon(options: {
  22512. pathArray: Vector3[][];
  22513. closeArray?: boolean;
  22514. closePath?: boolean;
  22515. offset?: number;
  22516. sideOrientation?: number;
  22517. frontUVs?: Vector4;
  22518. backUVs?: Vector4;
  22519. invertUV?: boolean;
  22520. uvs?: Vector2[];
  22521. colors?: Color4[];
  22522. }): VertexData;
  22523. /**
  22524. * Creates the VertexData for a box
  22525. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22526. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22527. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22528. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22529. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22530. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22531. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22532. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22533. * * 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)
  22534. * * 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)
  22535. * @returns the VertexData of the box
  22536. */
  22537. static CreateBox(options: {
  22538. size?: number;
  22539. width?: number;
  22540. height?: number;
  22541. depth?: number;
  22542. faceUV?: Vector4[];
  22543. faceColors?: Color4[];
  22544. sideOrientation?: number;
  22545. frontUVs?: Vector4;
  22546. backUVs?: Vector4;
  22547. }): VertexData;
  22548. /**
  22549. * Creates the VertexData for a tiled box
  22550. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22551. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22552. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22553. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22554. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22555. * @returns the VertexData of the box
  22556. */
  22557. static CreateTiledBox(options: {
  22558. pattern?: number;
  22559. width?: number;
  22560. height?: number;
  22561. depth?: number;
  22562. tileSize?: number;
  22563. tileWidth?: number;
  22564. tileHeight?: number;
  22565. alignHorizontal?: number;
  22566. alignVertical?: number;
  22567. faceUV?: Vector4[];
  22568. faceColors?: Color4[];
  22569. sideOrientation?: number;
  22570. }): VertexData;
  22571. /**
  22572. * Creates the VertexData for a tiled plane
  22573. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22574. * * pattern a limited pattern arrangement depending on the number
  22575. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22576. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22577. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22578. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22579. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22580. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22581. * @returns the VertexData of the tiled plane
  22582. */
  22583. static CreateTiledPlane(options: {
  22584. pattern?: number;
  22585. tileSize?: number;
  22586. tileWidth?: number;
  22587. tileHeight?: number;
  22588. size?: number;
  22589. width?: number;
  22590. height?: number;
  22591. alignHorizontal?: number;
  22592. alignVertical?: number;
  22593. sideOrientation?: number;
  22594. frontUVs?: Vector4;
  22595. backUVs?: Vector4;
  22596. }): VertexData;
  22597. /**
  22598. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22599. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22600. * * segments sets the number of horizontal strips optional, default 32
  22601. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22602. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22603. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22604. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22605. * * 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
  22606. * * 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
  22607. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22608. * * 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)
  22609. * * 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)
  22610. * @returns the VertexData of the ellipsoid
  22611. */
  22612. static CreateSphere(options: {
  22613. segments?: number;
  22614. diameter?: number;
  22615. diameterX?: number;
  22616. diameterY?: number;
  22617. diameterZ?: number;
  22618. arc?: number;
  22619. slice?: number;
  22620. sideOrientation?: number;
  22621. frontUVs?: Vector4;
  22622. backUVs?: Vector4;
  22623. }): VertexData;
  22624. /**
  22625. * Creates the VertexData for a cylinder, cone or prism
  22626. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22627. * * height sets the height (y direction) of the cylinder, optional, default 2
  22628. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22629. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22630. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22631. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22632. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22633. * * 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
  22634. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22635. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22636. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22637. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22638. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22639. * * 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)
  22640. * * 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)
  22641. * @returns the VertexData of the cylinder, cone or prism
  22642. */
  22643. static CreateCylinder(options: {
  22644. height?: number;
  22645. diameterTop?: number;
  22646. diameterBottom?: number;
  22647. diameter?: number;
  22648. tessellation?: number;
  22649. subdivisions?: number;
  22650. arc?: number;
  22651. faceColors?: Color4[];
  22652. faceUV?: Vector4[];
  22653. hasRings?: boolean;
  22654. enclose?: boolean;
  22655. sideOrientation?: number;
  22656. frontUVs?: Vector4;
  22657. backUVs?: Vector4;
  22658. }): VertexData;
  22659. /**
  22660. * Creates the VertexData for a torus
  22661. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22662. * * diameter the diameter of the torus, optional default 1
  22663. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22664. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22665. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22666. * * 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)
  22667. * * 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)
  22668. * @returns the VertexData of the torus
  22669. */
  22670. static CreateTorus(options: {
  22671. diameter?: number;
  22672. thickness?: number;
  22673. tessellation?: number;
  22674. sideOrientation?: number;
  22675. frontUVs?: Vector4;
  22676. backUVs?: Vector4;
  22677. }): VertexData;
  22678. /**
  22679. * Creates the VertexData of the LineSystem
  22680. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22681. * - lines an array of lines, each line being an array of successive Vector3
  22682. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22683. * @returns the VertexData of the LineSystem
  22684. */
  22685. static CreateLineSystem(options: {
  22686. lines: Vector3[][];
  22687. colors?: Nullable<Color4[][]>;
  22688. }): VertexData;
  22689. /**
  22690. * Create the VertexData for a DashedLines
  22691. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22692. * - points an array successive Vector3
  22693. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22694. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22695. * - dashNb the intended total number of dashes, optional, default 200
  22696. * @returns the VertexData for the DashedLines
  22697. */
  22698. static CreateDashedLines(options: {
  22699. points: Vector3[];
  22700. dashSize?: number;
  22701. gapSize?: number;
  22702. dashNb?: number;
  22703. }): VertexData;
  22704. /**
  22705. * Creates the VertexData for a Ground
  22706. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22707. * - width the width (x direction) of the ground, optional, default 1
  22708. * - height the height (z direction) of the ground, optional, default 1
  22709. * - subdivisions the number of subdivisions per side, optional, default 1
  22710. * @returns the VertexData of the Ground
  22711. */
  22712. static CreateGround(options: {
  22713. width?: number;
  22714. height?: number;
  22715. subdivisions?: number;
  22716. subdivisionsX?: number;
  22717. subdivisionsY?: number;
  22718. }): VertexData;
  22719. /**
  22720. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22721. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22722. * * xmin the ground minimum X coordinate, optional, default -1
  22723. * * zmin the ground minimum Z coordinate, optional, default -1
  22724. * * xmax the ground maximum X coordinate, optional, default 1
  22725. * * zmax the ground maximum Z coordinate, optional, default 1
  22726. * * 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}
  22727. * * 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}
  22728. * @returns the VertexData of the TiledGround
  22729. */
  22730. static CreateTiledGround(options: {
  22731. xmin: number;
  22732. zmin: number;
  22733. xmax: number;
  22734. zmax: number;
  22735. subdivisions?: {
  22736. w: number;
  22737. h: number;
  22738. };
  22739. precision?: {
  22740. w: number;
  22741. h: number;
  22742. };
  22743. }): VertexData;
  22744. /**
  22745. * Creates the VertexData of the Ground designed from a heightmap
  22746. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22747. * * width the width (x direction) of the ground
  22748. * * height the height (z direction) of the ground
  22749. * * subdivisions the number of subdivisions per side
  22750. * * minHeight the minimum altitude on the ground, optional, default 0
  22751. * * maxHeight the maximum altitude on the ground, optional default 1
  22752. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22753. * * buffer the array holding the image color data
  22754. * * bufferWidth the width of image
  22755. * * bufferHeight the height of image
  22756. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22757. * @returns the VertexData of the Ground designed from a heightmap
  22758. */
  22759. static CreateGroundFromHeightMap(options: {
  22760. width: number;
  22761. height: number;
  22762. subdivisions: number;
  22763. minHeight: number;
  22764. maxHeight: number;
  22765. colorFilter: Color3;
  22766. buffer: Uint8Array;
  22767. bufferWidth: number;
  22768. bufferHeight: number;
  22769. alphaFilter: number;
  22770. }): VertexData;
  22771. /**
  22772. * Creates the VertexData for a Plane
  22773. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22774. * * size sets the width and height of the plane to the value of size, optional default 1
  22775. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22776. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22777. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22778. * * 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)
  22779. * * 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)
  22780. * @returns the VertexData of the box
  22781. */
  22782. static CreatePlane(options: {
  22783. size?: number;
  22784. width?: number;
  22785. height?: number;
  22786. sideOrientation?: number;
  22787. frontUVs?: Vector4;
  22788. backUVs?: Vector4;
  22789. }): VertexData;
  22790. /**
  22791. * Creates the VertexData of the Disc or regular Polygon
  22792. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22793. * * radius the radius of the disc, optional default 0.5
  22794. * * tessellation the number of polygon sides, optional, default 64
  22795. * * 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
  22796. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22797. * * 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)
  22798. * * 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)
  22799. * @returns the VertexData of the box
  22800. */
  22801. static CreateDisc(options: {
  22802. radius?: number;
  22803. tessellation?: number;
  22804. arc?: number;
  22805. sideOrientation?: number;
  22806. frontUVs?: Vector4;
  22807. backUVs?: Vector4;
  22808. }): VertexData;
  22809. /**
  22810. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22811. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22812. * @param polygon a mesh built from polygonTriangulation.build()
  22813. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22814. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22815. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22816. * @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)
  22817. * @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)
  22818. * @returns the VertexData of the Polygon
  22819. */
  22820. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22821. /**
  22822. * Creates the VertexData of the IcoSphere
  22823. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22824. * * radius the radius of the IcoSphere, optional default 1
  22825. * * radiusX allows stretching in the x direction, optional, default radius
  22826. * * radiusY allows stretching in the y direction, optional, default radius
  22827. * * radiusZ allows stretching in the z direction, optional, default radius
  22828. * * flat when true creates a flat shaded mesh, optional, default true
  22829. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22830. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22831. * * 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)
  22832. * * 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)
  22833. * @returns the VertexData of the IcoSphere
  22834. */
  22835. static CreateIcoSphere(options: {
  22836. radius?: number;
  22837. radiusX?: number;
  22838. radiusY?: number;
  22839. radiusZ?: number;
  22840. flat?: boolean;
  22841. subdivisions?: number;
  22842. sideOrientation?: number;
  22843. frontUVs?: Vector4;
  22844. backUVs?: Vector4;
  22845. }): VertexData;
  22846. /**
  22847. * Creates the VertexData for a Polyhedron
  22848. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22849. * * type provided types are:
  22850. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22851. * * 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)
  22852. * * size the size of the IcoSphere, optional default 1
  22853. * * sizeX allows stretching in the x direction, optional, default size
  22854. * * sizeY allows stretching in the y direction, optional, default size
  22855. * * sizeZ allows stretching in the z direction, optional, default size
  22856. * * 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
  22857. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22858. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22859. * * flat when true creates a flat shaded mesh, optional, default true
  22860. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22861. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22862. * * 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)
  22863. * * 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)
  22864. * @returns the VertexData of the Polyhedron
  22865. */
  22866. static CreatePolyhedron(options: {
  22867. type?: number;
  22868. size?: number;
  22869. sizeX?: number;
  22870. sizeY?: number;
  22871. sizeZ?: number;
  22872. custom?: any;
  22873. faceUV?: Vector4[];
  22874. faceColors?: Color4[];
  22875. flat?: boolean;
  22876. sideOrientation?: number;
  22877. frontUVs?: Vector4;
  22878. backUVs?: Vector4;
  22879. }): VertexData;
  22880. /**
  22881. * Creates the VertexData for a TorusKnot
  22882. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22883. * * radius the radius of the torus knot, optional, default 2
  22884. * * tube the thickness of the tube, optional, default 0.5
  22885. * * radialSegments the number of sides on each tube segments, optional, default 32
  22886. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22887. * * p the number of windings around the z axis, optional, default 2
  22888. * * q the number of windings around the x axis, optional, default 3
  22889. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22890. * * 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)
  22891. * * 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)
  22892. * @returns the VertexData of the Torus Knot
  22893. */
  22894. static CreateTorusKnot(options: {
  22895. radius?: number;
  22896. tube?: number;
  22897. radialSegments?: number;
  22898. tubularSegments?: number;
  22899. p?: number;
  22900. q?: number;
  22901. sideOrientation?: number;
  22902. frontUVs?: Vector4;
  22903. backUVs?: Vector4;
  22904. }): VertexData;
  22905. /**
  22906. * Compute normals for given positions and indices
  22907. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22908. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22909. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22910. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22911. * * facetNormals : optional array of facet normals (vector3)
  22912. * * facetPositions : optional array of facet positions (vector3)
  22913. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22914. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22915. * * bInfo : optional bounding info, required for facetPartitioning computation
  22916. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22917. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22918. * * useRightHandedSystem: optional boolean to for right handed system computation
  22919. * * depthSort : optional boolean to enable the facet depth sort computation
  22920. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22921. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22922. */
  22923. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22924. facetNormals?: any;
  22925. facetPositions?: any;
  22926. facetPartitioning?: any;
  22927. ratio?: number;
  22928. bInfo?: any;
  22929. bbSize?: Vector3;
  22930. subDiv?: any;
  22931. useRightHandedSystem?: boolean;
  22932. depthSort?: boolean;
  22933. distanceTo?: Vector3;
  22934. depthSortedFacets?: any;
  22935. }): void;
  22936. /** @hidden */
  22937. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22938. /**
  22939. * Applies VertexData created from the imported parameters to the geometry
  22940. * @param parsedVertexData the parsed data from an imported file
  22941. * @param geometry the geometry to apply the VertexData to
  22942. */
  22943. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22944. }
  22945. }
  22946. declare module "babylonjs/Morph/morphTarget" {
  22947. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22948. import { Observable } from "babylonjs/Misc/observable";
  22949. import { Nullable, FloatArray } from "babylonjs/types";
  22950. import { Scene } from "babylonjs/scene";
  22951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22952. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22953. /**
  22954. * Defines a target to use with MorphTargetManager
  22955. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22956. */
  22957. export class MorphTarget implements IAnimatable {
  22958. /** defines the name of the target */
  22959. name: string;
  22960. /**
  22961. * Gets or sets the list of animations
  22962. */
  22963. animations: import("babylonjs/Animations/animation").Animation[];
  22964. private _scene;
  22965. private _positions;
  22966. private _normals;
  22967. private _tangents;
  22968. private _uvs;
  22969. private _influence;
  22970. private _uniqueId;
  22971. /**
  22972. * Observable raised when the influence changes
  22973. */
  22974. onInfluenceChanged: Observable<boolean>;
  22975. /** @hidden */
  22976. _onDataLayoutChanged: Observable<void>;
  22977. /**
  22978. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22979. */
  22980. influence: number;
  22981. /**
  22982. * Gets or sets the id of the morph Target
  22983. */
  22984. id: string;
  22985. private _animationPropertiesOverride;
  22986. /**
  22987. * Gets or sets the animation properties override
  22988. */
  22989. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22990. /**
  22991. * Creates a new MorphTarget
  22992. * @param name defines the name of the target
  22993. * @param influence defines the influence to use
  22994. * @param scene defines the scene the morphtarget belongs to
  22995. */
  22996. constructor(
  22997. /** defines the name of the target */
  22998. name: string, influence?: number, scene?: Nullable<Scene>);
  22999. /**
  23000. * Gets the unique ID of this manager
  23001. */
  23002. readonly uniqueId: number;
  23003. /**
  23004. * Gets a boolean defining if the target contains position data
  23005. */
  23006. readonly hasPositions: boolean;
  23007. /**
  23008. * Gets a boolean defining if the target contains normal data
  23009. */
  23010. readonly hasNormals: boolean;
  23011. /**
  23012. * Gets a boolean defining if the target contains tangent data
  23013. */
  23014. readonly hasTangents: boolean;
  23015. /**
  23016. * Gets a boolean defining if the target contains texture coordinates data
  23017. */
  23018. readonly hasUVs: boolean;
  23019. /**
  23020. * Affects position data to this target
  23021. * @param data defines the position data to use
  23022. */
  23023. setPositions(data: Nullable<FloatArray>): void;
  23024. /**
  23025. * Gets the position data stored in this target
  23026. * @returns a FloatArray containing the position data (or null if not present)
  23027. */
  23028. getPositions(): Nullable<FloatArray>;
  23029. /**
  23030. * Affects normal data to this target
  23031. * @param data defines the normal data to use
  23032. */
  23033. setNormals(data: Nullable<FloatArray>): void;
  23034. /**
  23035. * Gets the normal data stored in this target
  23036. * @returns a FloatArray containing the normal data (or null if not present)
  23037. */
  23038. getNormals(): Nullable<FloatArray>;
  23039. /**
  23040. * Affects tangent data to this target
  23041. * @param data defines the tangent data to use
  23042. */
  23043. setTangents(data: Nullable<FloatArray>): void;
  23044. /**
  23045. * Gets the tangent data stored in this target
  23046. * @returns a FloatArray containing the tangent data (or null if not present)
  23047. */
  23048. getTangents(): Nullable<FloatArray>;
  23049. /**
  23050. * Affects texture coordinates data to this target
  23051. * @param data defines the texture coordinates data to use
  23052. */
  23053. setUVs(data: Nullable<FloatArray>): void;
  23054. /**
  23055. * Gets the texture coordinates data stored in this target
  23056. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23057. */
  23058. getUVs(): Nullable<FloatArray>;
  23059. /**
  23060. * Clone the current target
  23061. * @returns a new MorphTarget
  23062. */
  23063. clone(): MorphTarget;
  23064. /**
  23065. * Serializes the current target into a Serialization object
  23066. * @returns the serialized object
  23067. */
  23068. serialize(): any;
  23069. /**
  23070. * Returns the string "MorphTarget"
  23071. * @returns "MorphTarget"
  23072. */
  23073. getClassName(): string;
  23074. /**
  23075. * Creates a new target from serialized data
  23076. * @param serializationObject defines the serialized data to use
  23077. * @returns a new MorphTarget
  23078. */
  23079. static Parse(serializationObject: any): MorphTarget;
  23080. /**
  23081. * Creates a MorphTarget from mesh data
  23082. * @param mesh defines the source mesh
  23083. * @param name defines the name to use for the new target
  23084. * @param influence defines the influence to attach to the target
  23085. * @returns a new MorphTarget
  23086. */
  23087. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23088. }
  23089. }
  23090. declare module "babylonjs/Morph/morphTargetManager" {
  23091. import { Nullable } from "babylonjs/types";
  23092. import { Scene } from "babylonjs/scene";
  23093. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23094. /**
  23095. * This class is used to deform meshes using morphing between different targets
  23096. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23097. */
  23098. export class MorphTargetManager {
  23099. private _targets;
  23100. private _targetInfluenceChangedObservers;
  23101. private _targetDataLayoutChangedObservers;
  23102. private _activeTargets;
  23103. private _scene;
  23104. private _influences;
  23105. private _supportsNormals;
  23106. private _supportsTangents;
  23107. private _supportsUVs;
  23108. private _vertexCount;
  23109. private _uniqueId;
  23110. private _tempInfluences;
  23111. /**
  23112. * Gets or sets a boolean indicating if normals must be morphed
  23113. */
  23114. enableNormalMorphing: boolean;
  23115. /**
  23116. * Gets or sets a boolean indicating if tangents must be morphed
  23117. */
  23118. enableTangentMorphing: boolean;
  23119. /**
  23120. * Gets or sets a boolean indicating if UV must be morphed
  23121. */
  23122. enableUVMorphing: boolean;
  23123. /**
  23124. * Creates a new MorphTargetManager
  23125. * @param scene defines the current scene
  23126. */
  23127. constructor(scene?: Nullable<Scene>);
  23128. /**
  23129. * Gets the unique ID of this manager
  23130. */
  23131. readonly uniqueId: number;
  23132. /**
  23133. * Gets the number of vertices handled by this manager
  23134. */
  23135. readonly vertexCount: number;
  23136. /**
  23137. * Gets a boolean indicating if this manager supports morphing of normals
  23138. */
  23139. readonly supportsNormals: boolean;
  23140. /**
  23141. * Gets a boolean indicating if this manager supports morphing of tangents
  23142. */
  23143. readonly supportsTangents: boolean;
  23144. /**
  23145. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23146. */
  23147. readonly supportsUVs: boolean;
  23148. /**
  23149. * Gets the number of targets stored in this manager
  23150. */
  23151. readonly numTargets: number;
  23152. /**
  23153. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23154. */
  23155. readonly numInfluencers: number;
  23156. /**
  23157. * Gets the list of influences (one per target)
  23158. */
  23159. readonly influences: Float32Array;
  23160. /**
  23161. * Gets the active target at specified index. An active target is a target with an influence > 0
  23162. * @param index defines the index to check
  23163. * @returns the requested target
  23164. */
  23165. getActiveTarget(index: number): MorphTarget;
  23166. /**
  23167. * Gets the target at specified index
  23168. * @param index defines the index to check
  23169. * @returns the requested target
  23170. */
  23171. getTarget(index: number): MorphTarget;
  23172. /**
  23173. * Add a new target to this manager
  23174. * @param target defines the target to add
  23175. */
  23176. addTarget(target: MorphTarget): void;
  23177. /**
  23178. * Removes a target from the manager
  23179. * @param target defines the target to remove
  23180. */
  23181. removeTarget(target: MorphTarget): void;
  23182. /**
  23183. * Clone the current manager
  23184. * @returns a new MorphTargetManager
  23185. */
  23186. clone(): MorphTargetManager;
  23187. /**
  23188. * Serializes the current manager into a Serialization object
  23189. * @returns the serialized object
  23190. */
  23191. serialize(): any;
  23192. private _syncActiveTargets;
  23193. /**
  23194. * Syncrhonize the targets with all the meshes using this morph target manager
  23195. */
  23196. synchronize(): void;
  23197. /**
  23198. * Creates a new MorphTargetManager from serialized data
  23199. * @param serializationObject defines the serialized data
  23200. * @param scene defines the hosting scene
  23201. * @returns the new MorphTargetManager
  23202. */
  23203. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23204. }
  23205. }
  23206. declare module "babylonjs/Meshes/meshLODLevel" {
  23207. import { Mesh } from "babylonjs/Meshes/mesh";
  23208. import { Nullable } from "babylonjs/types";
  23209. /**
  23210. * Class used to represent a specific level of detail of a mesh
  23211. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23212. */
  23213. export class MeshLODLevel {
  23214. /** Defines the distance where this level should start being displayed */
  23215. distance: number;
  23216. /** Defines the mesh to use to render this level */
  23217. mesh: Nullable<Mesh>;
  23218. /**
  23219. * Creates a new LOD level
  23220. * @param distance defines the distance where this level should star being displayed
  23221. * @param mesh defines the mesh to use to render this level
  23222. */
  23223. constructor(
  23224. /** Defines the distance where this level should start being displayed */
  23225. distance: number,
  23226. /** Defines the mesh to use to render this level */
  23227. mesh: Nullable<Mesh>);
  23228. }
  23229. }
  23230. declare module "babylonjs/Meshes/groundMesh" {
  23231. import { Scene } from "babylonjs/scene";
  23232. import { Vector3 } from "babylonjs/Maths/math.vector";
  23233. import { Mesh } from "babylonjs/Meshes/mesh";
  23234. /**
  23235. * Mesh representing the gorund
  23236. */
  23237. export class GroundMesh extends Mesh {
  23238. /** If octree should be generated */
  23239. generateOctree: boolean;
  23240. private _heightQuads;
  23241. /** @hidden */
  23242. _subdivisionsX: number;
  23243. /** @hidden */
  23244. _subdivisionsY: number;
  23245. /** @hidden */
  23246. _width: number;
  23247. /** @hidden */
  23248. _height: number;
  23249. /** @hidden */
  23250. _minX: number;
  23251. /** @hidden */
  23252. _maxX: number;
  23253. /** @hidden */
  23254. _minZ: number;
  23255. /** @hidden */
  23256. _maxZ: number;
  23257. constructor(name: string, scene: Scene);
  23258. /**
  23259. * "GroundMesh"
  23260. * @returns "GroundMesh"
  23261. */
  23262. getClassName(): string;
  23263. /**
  23264. * The minimum of x and y subdivisions
  23265. */
  23266. readonly subdivisions: number;
  23267. /**
  23268. * X subdivisions
  23269. */
  23270. readonly subdivisionsX: number;
  23271. /**
  23272. * Y subdivisions
  23273. */
  23274. readonly subdivisionsY: number;
  23275. /**
  23276. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23277. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23278. * @param chunksCount the number of subdivisions for x and y
  23279. * @param octreeBlocksSize (Default: 32)
  23280. */
  23281. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23282. /**
  23283. * Returns a height (y) value in the Worl system :
  23284. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23285. * @param x x coordinate
  23286. * @param z z coordinate
  23287. * @returns the ground y position if (x, z) are outside the ground surface.
  23288. */
  23289. getHeightAtCoordinates(x: number, z: number): number;
  23290. /**
  23291. * Returns a normalized vector (Vector3) orthogonal to the ground
  23292. * at the ground coordinates (x, z) expressed in the World system.
  23293. * @param x x coordinate
  23294. * @param z z coordinate
  23295. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23296. */
  23297. getNormalAtCoordinates(x: number, z: number): Vector3;
  23298. /**
  23299. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23300. * at the ground coordinates (x, z) expressed in the World system.
  23301. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23302. * @param x x coordinate
  23303. * @param z z coordinate
  23304. * @param ref vector to store the result
  23305. * @returns the GroundMesh.
  23306. */
  23307. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23308. /**
  23309. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23310. * if the ground has been updated.
  23311. * This can be used in the render loop.
  23312. * @returns the GroundMesh.
  23313. */
  23314. updateCoordinateHeights(): GroundMesh;
  23315. private _getFacetAt;
  23316. private _initHeightQuads;
  23317. private _computeHeightQuads;
  23318. /**
  23319. * Serializes this ground mesh
  23320. * @param serializationObject object to write serialization to
  23321. */
  23322. serialize(serializationObject: any): void;
  23323. /**
  23324. * Parses a serialized ground mesh
  23325. * @param parsedMesh the serialized mesh
  23326. * @param scene the scene to create the ground mesh in
  23327. * @returns the created ground mesh
  23328. */
  23329. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23330. }
  23331. }
  23332. declare module "babylonjs/Physics/physicsJoint" {
  23333. import { Vector3 } from "babylonjs/Maths/math.vector";
  23334. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23335. /**
  23336. * Interface for Physics-Joint data
  23337. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23338. */
  23339. export interface PhysicsJointData {
  23340. /**
  23341. * The main pivot of the joint
  23342. */
  23343. mainPivot?: Vector3;
  23344. /**
  23345. * The connected pivot of the joint
  23346. */
  23347. connectedPivot?: Vector3;
  23348. /**
  23349. * The main axis of the joint
  23350. */
  23351. mainAxis?: Vector3;
  23352. /**
  23353. * The connected axis of the joint
  23354. */
  23355. connectedAxis?: Vector3;
  23356. /**
  23357. * The collision of the joint
  23358. */
  23359. collision?: boolean;
  23360. /**
  23361. * Native Oimo/Cannon/Energy data
  23362. */
  23363. nativeParams?: any;
  23364. }
  23365. /**
  23366. * This is a holder class for the physics joint created by the physics plugin
  23367. * It holds a set of functions to control the underlying joint
  23368. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23369. */
  23370. export class PhysicsJoint {
  23371. /**
  23372. * The type of the physics joint
  23373. */
  23374. type: number;
  23375. /**
  23376. * The data for the physics joint
  23377. */
  23378. jointData: PhysicsJointData;
  23379. private _physicsJoint;
  23380. protected _physicsPlugin: IPhysicsEnginePlugin;
  23381. /**
  23382. * Initializes the physics joint
  23383. * @param type The type of the physics joint
  23384. * @param jointData The data for the physics joint
  23385. */
  23386. constructor(
  23387. /**
  23388. * The type of the physics joint
  23389. */
  23390. type: number,
  23391. /**
  23392. * The data for the physics joint
  23393. */
  23394. jointData: PhysicsJointData);
  23395. /**
  23396. * Gets the physics joint
  23397. */
  23398. /**
  23399. * Sets the physics joint
  23400. */
  23401. physicsJoint: any;
  23402. /**
  23403. * Sets the physics plugin
  23404. */
  23405. physicsPlugin: IPhysicsEnginePlugin;
  23406. /**
  23407. * Execute a function that is physics-plugin specific.
  23408. * @param {Function} func the function that will be executed.
  23409. * It accepts two parameters: the physics world and the physics joint
  23410. */
  23411. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23412. /**
  23413. * Distance-Joint type
  23414. */
  23415. static DistanceJoint: number;
  23416. /**
  23417. * Hinge-Joint type
  23418. */
  23419. static HingeJoint: number;
  23420. /**
  23421. * Ball-and-Socket joint type
  23422. */
  23423. static BallAndSocketJoint: number;
  23424. /**
  23425. * Wheel-Joint type
  23426. */
  23427. static WheelJoint: number;
  23428. /**
  23429. * Slider-Joint type
  23430. */
  23431. static SliderJoint: number;
  23432. /**
  23433. * Prismatic-Joint type
  23434. */
  23435. static PrismaticJoint: number;
  23436. /**
  23437. * Universal-Joint type
  23438. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23439. */
  23440. static UniversalJoint: number;
  23441. /**
  23442. * Hinge-Joint 2 type
  23443. */
  23444. static Hinge2Joint: number;
  23445. /**
  23446. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23447. */
  23448. static PointToPointJoint: number;
  23449. /**
  23450. * Spring-Joint type
  23451. */
  23452. static SpringJoint: number;
  23453. /**
  23454. * Lock-Joint type
  23455. */
  23456. static LockJoint: number;
  23457. }
  23458. /**
  23459. * A class representing a physics distance joint
  23460. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23461. */
  23462. export class DistanceJoint extends PhysicsJoint {
  23463. /**
  23464. *
  23465. * @param jointData The data for the Distance-Joint
  23466. */
  23467. constructor(jointData: DistanceJointData);
  23468. /**
  23469. * Update the predefined distance.
  23470. * @param maxDistance The maximum preferred distance
  23471. * @param minDistance The minimum preferred distance
  23472. */
  23473. updateDistance(maxDistance: number, minDistance?: number): void;
  23474. }
  23475. /**
  23476. * Represents a Motor-Enabled Joint
  23477. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23478. */
  23479. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23480. /**
  23481. * Initializes the Motor-Enabled Joint
  23482. * @param type The type of the joint
  23483. * @param jointData The physica joint data for the joint
  23484. */
  23485. constructor(type: number, jointData: PhysicsJointData);
  23486. /**
  23487. * Set the motor values.
  23488. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23489. * @param force the force to apply
  23490. * @param maxForce max force for this motor.
  23491. */
  23492. setMotor(force?: number, maxForce?: number): void;
  23493. /**
  23494. * Set the motor's limits.
  23495. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23496. * @param upperLimit The upper limit of the motor
  23497. * @param lowerLimit The lower limit of the motor
  23498. */
  23499. setLimit(upperLimit: number, lowerLimit?: number): void;
  23500. }
  23501. /**
  23502. * This class represents a single physics Hinge-Joint
  23503. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23504. */
  23505. export class HingeJoint extends MotorEnabledJoint {
  23506. /**
  23507. * Initializes the Hinge-Joint
  23508. * @param jointData The joint data for the Hinge-Joint
  23509. */
  23510. constructor(jointData: PhysicsJointData);
  23511. /**
  23512. * Set the motor values.
  23513. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23514. * @param {number} force the force to apply
  23515. * @param {number} maxForce max force for this motor.
  23516. */
  23517. setMotor(force?: number, maxForce?: number): void;
  23518. /**
  23519. * Set the motor's limits.
  23520. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23521. * @param upperLimit The upper limit of the motor
  23522. * @param lowerLimit The lower limit of the motor
  23523. */
  23524. setLimit(upperLimit: number, lowerLimit?: number): void;
  23525. }
  23526. /**
  23527. * This class represents a dual hinge physics joint (same as wheel joint)
  23528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23529. */
  23530. export class Hinge2Joint extends MotorEnabledJoint {
  23531. /**
  23532. * Initializes the Hinge2-Joint
  23533. * @param jointData The joint data for the Hinge2-Joint
  23534. */
  23535. constructor(jointData: PhysicsJointData);
  23536. /**
  23537. * Set the motor values.
  23538. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23539. * @param {number} targetSpeed the speed the motor is to reach
  23540. * @param {number} maxForce max force for this motor.
  23541. * @param {motorIndex} the motor's index, 0 or 1.
  23542. */
  23543. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23544. /**
  23545. * Set the motor limits.
  23546. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23547. * @param {number} upperLimit the upper limit
  23548. * @param {number} lowerLimit lower limit
  23549. * @param {motorIndex} the motor's index, 0 or 1.
  23550. */
  23551. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23552. }
  23553. /**
  23554. * Interface for a motor enabled joint
  23555. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23556. */
  23557. export interface IMotorEnabledJoint {
  23558. /**
  23559. * Physics joint
  23560. */
  23561. physicsJoint: any;
  23562. /**
  23563. * Sets the motor of the motor-enabled joint
  23564. * @param force The force of the motor
  23565. * @param maxForce The maximum force of the motor
  23566. * @param motorIndex The index of the motor
  23567. */
  23568. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23569. /**
  23570. * Sets the limit of the motor
  23571. * @param upperLimit The upper limit of the motor
  23572. * @param lowerLimit The lower limit of the motor
  23573. * @param motorIndex The index of the motor
  23574. */
  23575. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23576. }
  23577. /**
  23578. * Joint data for a Distance-Joint
  23579. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23580. */
  23581. export interface DistanceJointData extends PhysicsJointData {
  23582. /**
  23583. * Max distance the 2 joint objects can be apart
  23584. */
  23585. maxDistance: number;
  23586. }
  23587. /**
  23588. * Joint data from a spring joint
  23589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23590. */
  23591. export interface SpringJointData extends PhysicsJointData {
  23592. /**
  23593. * Length of the spring
  23594. */
  23595. length: number;
  23596. /**
  23597. * Stiffness of the spring
  23598. */
  23599. stiffness: number;
  23600. /**
  23601. * Damping of the spring
  23602. */
  23603. damping: number;
  23604. /** this callback will be called when applying the force to the impostors. */
  23605. forceApplicationCallback: () => void;
  23606. }
  23607. }
  23608. declare module "babylonjs/Physics/physicsRaycastResult" {
  23609. import { Vector3 } from "babylonjs/Maths/math.vector";
  23610. /**
  23611. * Holds the data for the raycast result
  23612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23613. */
  23614. export class PhysicsRaycastResult {
  23615. private _hasHit;
  23616. private _hitDistance;
  23617. private _hitNormalWorld;
  23618. private _hitPointWorld;
  23619. private _rayFromWorld;
  23620. private _rayToWorld;
  23621. /**
  23622. * Gets if there was a hit
  23623. */
  23624. readonly hasHit: boolean;
  23625. /**
  23626. * Gets the distance from the hit
  23627. */
  23628. readonly hitDistance: number;
  23629. /**
  23630. * Gets the hit normal/direction in the world
  23631. */
  23632. readonly hitNormalWorld: Vector3;
  23633. /**
  23634. * Gets the hit point in the world
  23635. */
  23636. readonly hitPointWorld: Vector3;
  23637. /**
  23638. * Gets the ray "start point" of the ray in the world
  23639. */
  23640. readonly rayFromWorld: Vector3;
  23641. /**
  23642. * Gets the ray "end point" of the ray in the world
  23643. */
  23644. readonly rayToWorld: Vector3;
  23645. /**
  23646. * Sets the hit data (normal & point in world space)
  23647. * @param hitNormalWorld defines the normal in world space
  23648. * @param hitPointWorld defines the point in world space
  23649. */
  23650. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23651. /**
  23652. * Sets the distance from the start point to the hit point
  23653. * @param distance
  23654. */
  23655. setHitDistance(distance: number): void;
  23656. /**
  23657. * Calculates the distance manually
  23658. */
  23659. calculateHitDistance(): void;
  23660. /**
  23661. * Resets all the values to default
  23662. * @param from The from point on world space
  23663. * @param to The to point on world space
  23664. */
  23665. reset(from?: Vector3, to?: Vector3): void;
  23666. }
  23667. /**
  23668. * Interface for the size containing width and height
  23669. */
  23670. interface IXYZ {
  23671. /**
  23672. * X
  23673. */
  23674. x: number;
  23675. /**
  23676. * Y
  23677. */
  23678. y: number;
  23679. /**
  23680. * Z
  23681. */
  23682. z: number;
  23683. }
  23684. }
  23685. declare module "babylonjs/Physics/IPhysicsEngine" {
  23686. import { Nullable } from "babylonjs/types";
  23687. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23688. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23689. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23690. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23691. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23692. /**
  23693. * Interface used to describe a physics joint
  23694. */
  23695. export interface PhysicsImpostorJoint {
  23696. /** Defines the main impostor to which the joint is linked */
  23697. mainImpostor: PhysicsImpostor;
  23698. /** Defines the impostor that is connected to the main impostor using this joint */
  23699. connectedImpostor: PhysicsImpostor;
  23700. /** Defines the joint itself */
  23701. joint: PhysicsJoint;
  23702. }
  23703. /** @hidden */
  23704. export interface IPhysicsEnginePlugin {
  23705. world: any;
  23706. name: string;
  23707. setGravity(gravity: Vector3): void;
  23708. setTimeStep(timeStep: number): void;
  23709. getTimeStep(): number;
  23710. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23711. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23712. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23713. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23714. removePhysicsBody(impostor: PhysicsImpostor): void;
  23715. generateJoint(joint: PhysicsImpostorJoint): void;
  23716. removeJoint(joint: PhysicsImpostorJoint): void;
  23717. isSupported(): boolean;
  23718. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23719. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23720. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23721. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23722. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23723. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23724. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23725. getBodyMass(impostor: PhysicsImpostor): number;
  23726. getBodyFriction(impostor: PhysicsImpostor): number;
  23727. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23728. getBodyRestitution(impostor: PhysicsImpostor): number;
  23729. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23730. getBodyPressure?(impostor: PhysicsImpostor): number;
  23731. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23732. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23733. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23734. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23735. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23736. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23737. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23738. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23739. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23740. sleepBody(impostor: PhysicsImpostor): void;
  23741. wakeUpBody(impostor: PhysicsImpostor): void;
  23742. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23743. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23744. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23745. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23746. getRadius(impostor: PhysicsImpostor): number;
  23747. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23748. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23749. dispose(): void;
  23750. }
  23751. /**
  23752. * Interface used to define a physics engine
  23753. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23754. */
  23755. export interface IPhysicsEngine {
  23756. /**
  23757. * Gets the gravity vector used by the simulation
  23758. */
  23759. gravity: Vector3;
  23760. /**
  23761. * Sets the gravity vector used by the simulation
  23762. * @param gravity defines the gravity vector to use
  23763. */
  23764. setGravity(gravity: Vector3): void;
  23765. /**
  23766. * Set the time step of the physics engine.
  23767. * Default is 1/60.
  23768. * To slow it down, enter 1/600 for example.
  23769. * To speed it up, 1/30
  23770. * @param newTimeStep the new timestep to apply to this world.
  23771. */
  23772. setTimeStep(newTimeStep: number): void;
  23773. /**
  23774. * Get the time step of the physics engine.
  23775. * @returns the current time step
  23776. */
  23777. getTimeStep(): number;
  23778. /**
  23779. * Set the sub time step of the physics engine.
  23780. * Default is 0 meaning there is no sub steps
  23781. * To increase physics resolution precision, set a small value (like 1 ms)
  23782. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23783. */
  23784. setSubTimeStep(subTimeStep: number): void;
  23785. /**
  23786. * Get the sub time step of the physics engine.
  23787. * @returns the current sub time step
  23788. */
  23789. getSubTimeStep(): number;
  23790. /**
  23791. * Release all resources
  23792. */
  23793. dispose(): void;
  23794. /**
  23795. * Gets the name of the current physics plugin
  23796. * @returns the name of the plugin
  23797. */
  23798. getPhysicsPluginName(): string;
  23799. /**
  23800. * Adding a new impostor for the impostor tracking.
  23801. * This will be done by the impostor itself.
  23802. * @param impostor the impostor to add
  23803. */
  23804. addImpostor(impostor: PhysicsImpostor): void;
  23805. /**
  23806. * Remove an impostor from the engine.
  23807. * This impostor and its mesh will not longer be updated by the physics engine.
  23808. * @param impostor the impostor to remove
  23809. */
  23810. removeImpostor(impostor: PhysicsImpostor): void;
  23811. /**
  23812. * Add a joint to the physics engine
  23813. * @param mainImpostor defines the main impostor to which the joint is added.
  23814. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23815. * @param joint defines the joint that will connect both impostors.
  23816. */
  23817. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23818. /**
  23819. * Removes a joint from the simulation
  23820. * @param mainImpostor defines the impostor used with the joint
  23821. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23822. * @param joint defines the joint to remove
  23823. */
  23824. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23825. /**
  23826. * Gets the current plugin used to run the simulation
  23827. * @returns current plugin
  23828. */
  23829. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23830. /**
  23831. * Gets the list of physic impostors
  23832. * @returns an array of PhysicsImpostor
  23833. */
  23834. getImpostors(): Array<PhysicsImpostor>;
  23835. /**
  23836. * Gets the impostor for a physics enabled object
  23837. * @param object defines the object impersonated by the impostor
  23838. * @returns the PhysicsImpostor or null if not found
  23839. */
  23840. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23841. /**
  23842. * Gets the impostor for a physics body object
  23843. * @param body defines physics body used by the impostor
  23844. * @returns the PhysicsImpostor or null if not found
  23845. */
  23846. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23847. /**
  23848. * Does a raycast in the physics world
  23849. * @param from when should the ray start?
  23850. * @param to when should the ray end?
  23851. * @returns PhysicsRaycastResult
  23852. */
  23853. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23854. /**
  23855. * Called by the scene. No need to call it.
  23856. * @param delta defines the timespam between frames
  23857. */
  23858. _step(delta: number): void;
  23859. }
  23860. }
  23861. declare module "babylonjs/Physics/physicsImpostor" {
  23862. import { Nullable, IndicesArray } from "babylonjs/types";
  23863. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23864. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23866. import { Scene } from "babylonjs/scene";
  23867. import { Bone } from "babylonjs/Bones/bone";
  23868. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23869. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23870. import { Space } from "babylonjs/Maths/math.axis";
  23871. /**
  23872. * The interface for the physics imposter parameters
  23873. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23874. */
  23875. export interface PhysicsImpostorParameters {
  23876. /**
  23877. * The mass of the physics imposter
  23878. */
  23879. mass: number;
  23880. /**
  23881. * The friction of the physics imposter
  23882. */
  23883. friction?: number;
  23884. /**
  23885. * The coefficient of restitution of the physics imposter
  23886. */
  23887. restitution?: number;
  23888. /**
  23889. * The native options of the physics imposter
  23890. */
  23891. nativeOptions?: any;
  23892. /**
  23893. * Specifies if the parent should be ignored
  23894. */
  23895. ignoreParent?: boolean;
  23896. /**
  23897. * Specifies if bi-directional transformations should be disabled
  23898. */
  23899. disableBidirectionalTransformation?: boolean;
  23900. /**
  23901. * The pressure inside the physics imposter, soft object only
  23902. */
  23903. pressure?: number;
  23904. /**
  23905. * The stiffness the physics imposter, soft object only
  23906. */
  23907. stiffness?: number;
  23908. /**
  23909. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23910. */
  23911. velocityIterations?: number;
  23912. /**
  23913. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23914. */
  23915. positionIterations?: number;
  23916. /**
  23917. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23918. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23919. * Add to fix multiple points
  23920. */
  23921. fixedPoints?: number;
  23922. /**
  23923. * The collision margin around a soft object
  23924. */
  23925. margin?: number;
  23926. /**
  23927. * The collision margin around a soft object
  23928. */
  23929. damping?: number;
  23930. /**
  23931. * The path for a rope based on an extrusion
  23932. */
  23933. path?: any;
  23934. /**
  23935. * The shape of an extrusion used for a rope based on an extrusion
  23936. */
  23937. shape?: any;
  23938. }
  23939. /**
  23940. * Interface for a physics-enabled object
  23941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23942. */
  23943. export interface IPhysicsEnabledObject {
  23944. /**
  23945. * The position of the physics-enabled object
  23946. */
  23947. position: Vector3;
  23948. /**
  23949. * The rotation of the physics-enabled object
  23950. */
  23951. rotationQuaternion: Nullable<Quaternion>;
  23952. /**
  23953. * The scale of the physics-enabled object
  23954. */
  23955. scaling: Vector3;
  23956. /**
  23957. * The rotation of the physics-enabled object
  23958. */
  23959. rotation?: Vector3;
  23960. /**
  23961. * The parent of the physics-enabled object
  23962. */
  23963. parent?: any;
  23964. /**
  23965. * The bounding info of the physics-enabled object
  23966. * @returns The bounding info of the physics-enabled object
  23967. */
  23968. getBoundingInfo(): BoundingInfo;
  23969. /**
  23970. * Computes the world matrix
  23971. * @param force Specifies if the world matrix should be computed by force
  23972. * @returns A world matrix
  23973. */
  23974. computeWorldMatrix(force: boolean): Matrix;
  23975. /**
  23976. * Gets the world matrix
  23977. * @returns A world matrix
  23978. */
  23979. getWorldMatrix?(): Matrix;
  23980. /**
  23981. * Gets the child meshes
  23982. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23983. * @returns An array of abstract meshes
  23984. */
  23985. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23986. /**
  23987. * Gets the vertex data
  23988. * @param kind The type of vertex data
  23989. * @returns A nullable array of numbers, or a float32 array
  23990. */
  23991. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23992. /**
  23993. * Gets the indices from the mesh
  23994. * @returns A nullable array of index arrays
  23995. */
  23996. getIndices?(): Nullable<IndicesArray>;
  23997. /**
  23998. * Gets the scene from the mesh
  23999. * @returns the indices array or null
  24000. */
  24001. getScene?(): Scene;
  24002. /**
  24003. * Gets the absolute position from the mesh
  24004. * @returns the absolute position
  24005. */
  24006. getAbsolutePosition(): Vector3;
  24007. /**
  24008. * Gets the absolute pivot point from the mesh
  24009. * @returns the absolute pivot point
  24010. */
  24011. getAbsolutePivotPoint(): Vector3;
  24012. /**
  24013. * Rotates the mesh
  24014. * @param axis The axis of rotation
  24015. * @param amount The amount of rotation
  24016. * @param space The space of the rotation
  24017. * @returns The rotation transform node
  24018. */
  24019. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24020. /**
  24021. * Translates the mesh
  24022. * @param axis The axis of translation
  24023. * @param distance The distance of translation
  24024. * @param space The space of the translation
  24025. * @returns The transform node
  24026. */
  24027. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24028. /**
  24029. * Sets the absolute position of the mesh
  24030. * @param absolutePosition The absolute position of the mesh
  24031. * @returns The transform node
  24032. */
  24033. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24034. /**
  24035. * Gets the class name of the mesh
  24036. * @returns The class name
  24037. */
  24038. getClassName(): string;
  24039. }
  24040. /**
  24041. * Represents a physics imposter
  24042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24043. */
  24044. export class PhysicsImpostor {
  24045. /**
  24046. * The physics-enabled object used as the physics imposter
  24047. */
  24048. object: IPhysicsEnabledObject;
  24049. /**
  24050. * The type of the physics imposter
  24051. */
  24052. type: number;
  24053. private _options;
  24054. private _scene?;
  24055. /**
  24056. * The default object size of the imposter
  24057. */
  24058. static DEFAULT_OBJECT_SIZE: Vector3;
  24059. /**
  24060. * The identity quaternion of the imposter
  24061. */
  24062. static IDENTITY_QUATERNION: Quaternion;
  24063. /** @hidden */
  24064. _pluginData: any;
  24065. private _physicsEngine;
  24066. private _physicsBody;
  24067. private _bodyUpdateRequired;
  24068. private _onBeforePhysicsStepCallbacks;
  24069. private _onAfterPhysicsStepCallbacks;
  24070. /** @hidden */
  24071. _onPhysicsCollideCallbacks: Array<{
  24072. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24073. otherImpostors: Array<PhysicsImpostor>;
  24074. }>;
  24075. private _deltaPosition;
  24076. private _deltaRotation;
  24077. private _deltaRotationConjugated;
  24078. /** @hidden */
  24079. _isFromLine: boolean;
  24080. private _parent;
  24081. private _isDisposed;
  24082. private static _tmpVecs;
  24083. private static _tmpQuat;
  24084. /**
  24085. * Specifies if the physics imposter is disposed
  24086. */
  24087. readonly isDisposed: boolean;
  24088. /**
  24089. * Gets the mass of the physics imposter
  24090. */
  24091. mass: number;
  24092. /**
  24093. * Gets the coefficient of friction
  24094. */
  24095. /**
  24096. * Sets the coefficient of friction
  24097. */
  24098. friction: number;
  24099. /**
  24100. * Gets the coefficient of restitution
  24101. */
  24102. /**
  24103. * Sets the coefficient of restitution
  24104. */
  24105. restitution: number;
  24106. /**
  24107. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24108. */
  24109. /**
  24110. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24111. */
  24112. pressure: number;
  24113. /**
  24114. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24115. */
  24116. /**
  24117. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24118. */
  24119. stiffness: number;
  24120. /**
  24121. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24122. */
  24123. /**
  24124. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24125. */
  24126. velocityIterations: number;
  24127. /**
  24128. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24129. */
  24130. /**
  24131. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24132. */
  24133. positionIterations: number;
  24134. /**
  24135. * The unique id of the physics imposter
  24136. * set by the physics engine when adding this impostor to the array
  24137. */
  24138. uniqueId: number;
  24139. /**
  24140. * @hidden
  24141. */
  24142. soft: boolean;
  24143. /**
  24144. * @hidden
  24145. */
  24146. segments: number;
  24147. private _joints;
  24148. /**
  24149. * Initializes the physics imposter
  24150. * @param object The physics-enabled object used as the physics imposter
  24151. * @param type The type of the physics imposter
  24152. * @param _options The options for the physics imposter
  24153. * @param _scene The Babylon scene
  24154. */
  24155. constructor(
  24156. /**
  24157. * The physics-enabled object used as the physics imposter
  24158. */
  24159. object: IPhysicsEnabledObject,
  24160. /**
  24161. * The type of the physics imposter
  24162. */
  24163. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24164. /**
  24165. * This function will completly initialize this impostor.
  24166. * It will create a new body - but only if this mesh has no parent.
  24167. * If it has, this impostor will not be used other than to define the impostor
  24168. * of the child mesh.
  24169. * @hidden
  24170. */
  24171. _init(): void;
  24172. private _getPhysicsParent;
  24173. /**
  24174. * Should a new body be generated.
  24175. * @returns boolean specifying if body initialization is required
  24176. */
  24177. isBodyInitRequired(): boolean;
  24178. /**
  24179. * Sets the updated scaling
  24180. * @param updated Specifies if the scaling is updated
  24181. */
  24182. setScalingUpdated(): void;
  24183. /**
  24184. * Force a regeneration of this or the parent's impostor's body.
  24185. * Use under cautious - This will remove all joints already implemented.
  24186. */
  24187. forceUpdate(): void;
  24188. /**
  24189. * Gets the body that holds this impostor. Either its own, or its parent.
  24190. */
  24191. /**
  24192. * Set the physics body. Used mainly by the physics engine/plugin
  24193. */
  24194. physicsBody: any;
  24195. /**
  24196. * Get the parent of the physics imposter
  24197. * @returns Physics imposter or null
  24198. */
  24199. /**
  24200. * Sets the parent of the physics imposter
  24201. */
  24202. parent: Nullable<PhysicsImpostor>;
  24203. /**
  24204. * Resets the update flags
  24205. */
  24206. resetUpdateFlags(): void;
  24207. /**
  24208. * Gets the object extend size
  24209. * @returns the object extend size
  24210. */
  24211. getObjectExtendSize(): Vector3;
  24212. /**
  24213. * Gets the object center
  24214. * @returns The object center
  24215. */
  24216. getObjectCenter(): Vector3;
  24217. /**
  24218. * Get a specific parametes from the options parameter
  24219. * @param paramName The object parameter name
  24220. * @returns The object parameter
  24221. */
  24222. getParam(paramName: string): any;
  24223. /**
  24224. * Sets a specific parameter in the options given to the physics plugin
  24225. * @param paramName The parameter name
  24226. * @param value The value of the parameter
  24227. */
  24228. setParam(paramName: string, value: number): void;
  24229. /**
  24230. * Specifically change the body's mass option. Won't recreate the physics body object
  24231. * @param mass The mass of the physics imposter
  24232. */
  24233. setMass(mass: number): void;
  24234. /**
  24235. * Gets the linear velocity
  24236. * @returns linear velocity or null
  24237. */
  24238. getLinearVelocity(): Nullable<Vector3>;
  24239. /**
  24240. * Sets the linear velocity
  24241. * @param velocity linear velocity or null
  24242. */
  24243. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24244. /**
  24245. * Gets the angular velocity
  24246. * @returns angular velocity or null
  24247. */
  24248. getAngularVelocity(): Nullable<Vector3>;
  24249. /**
  24250. * Sets the angular velocity
  24251. * @param velocity The velocity or null
  24252. */
  24253. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24254. /**
  24255. * Execute a function with the physics plugin native code
  24256. * Provide a function the will have two variables - the world object and the physics body object
  24257. * @param func The function to execute with the physics plugin native code
  24258. */
  24259. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24260. /**
  24261. * Register a function that will be executed before the physics world is stepping forward
  24262. * @param func The function to execute before the physics world is stepped forward
  24263. */
  24264. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24265. /**
  24266. * Unregister a function that will be executed before the physics world is stepping forward
  24267. * @param func The function to execute before the physics world is stepped forward
  24268. */
  24269. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24270. /**
  24271. * Register a function that will be executed after the physics step
  24272. * @param func The function to execute after physics step
  24273. */
  24274. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24275. /**
  24276. * Unregisters a function that will be executed after the physics step
  24277. * @param func The function to execute after physics step
  24278. */
  24279. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24280. /**
  24281. * register a function that will be executed when this impostor collides against a different body
  24282. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24283. * @param func Callback that is executed on collision
  24284. */
  24285. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24286. /**
  24287. * Unregisters the physics imposter on contact
  24288. * @param collideAgainst The physics object to collide against
  24289. * @param func Callback to execute on collision
  24290. */
  24291. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24292. private _tmpQuat;
  24293. private _tmpQuat2;
  24294. /**
  24295. * Get the parent rotation
  24296. * @returns The parent rotation
  24297. */
  24298. getParentsRotation(): Quaternion;
  24299. /**
  24300. * this function is executed by the physics engine.
  24301. */
  24302. beforeStep: () => void;
  24303. /**
  24304. * this function is executed by the physics engine
  24305. */
  24306. afterStep: () => void;
  24307. /**
  24308. * Legacy collision detection event support
  24309. */
  24310. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24311. /**
  24312. * event and body object due to cannon's event-based architecture.
  24313. */
  24314. onCollide: (e: {
  24315. body: any;
  24316. }) => void;
  24317. /**
  24318. * Apply a force
  24319. * @param force The force to apply
  24320. * @param contactPoint The contact point for the force
  24321. * @returns The physics imposter
  24322. */
  24323. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24324. /**
  24325. * Apply an impulse
  24326. * @param force The impulse force
  24327. * @param contactPoint The contact point for the impulse force
  24328. * @returns The physics imposter
  24329. */
  24330. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24331. /**
  24332. * A help function to create a joint
  24333. * @param otherImpostor A physics imposter used to create a joint
  24334. * @param jointType The type of joint
  24335. * @param jointData The data for the joint
  24336. * @returns The physics imposter
  24337. */
  24338. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24339. /**
  24340. * Add a joint to this impostor with a different impostor
  24341. * @param otherImpostor A physics imposter used to add a joint
  24342. * @param joint The joint to add
  24343. * @returns The physics imposter
  24344. */
  24345. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24346. /**
  24347. * Add an anchor to a cloth impostor
  24348. * @param otherImpostor rigid impostor to anchor to
  24349. * @param width ratio across width from 0 to 1
  24350. * @param height ratio up height from 0 to 1
  24351. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24352. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24353. * @returns impostor the soft imposter
  24354. */
  24355. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24356. /**
  24357. * Add a hook to a rope impostor
  24358. * @param otherImpostor rigid impostor to anchor to
  24359. * @param length ratio across rope from 0 to 1
  24360. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24361. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24362. * @returns impostor the rope imposter
  24363. */
  24364. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24365. /**
  24366. * Will keep this body still, in a sleep mode.
  24367. * @returns the physics imposter
  24368. */
  24369. sleep(): PhysicsImpostor;
  24370. /**
  24371. * Wake the body up.
  24372. * @returns The physics imposter
  24373. */
  24374. wakeUp(): PhysicsImpostor;
  24375. /**
  24376. * Clones the physics imposter
  24377. * @param newObject The physics imposter clones to this physics-enabled object
  24378. * @returns A nullable physics imposter
  24379. */
  24380. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24381. /**
  24382. * Disposes the physics imposter
  24383. */
  24384. dispose(): void;
  24385. /**
  24386. * Sets the delta position
  24387. * @param position The delta position amount
  24388. */
  24389. setDeltaPosition(position: Vector3): void;
  24390. /**
  24391. * Sets the delta rotation
  24392. * @param rotation The delta rotation amount
  24393. */
  24394. setDeltaRotation(rotation: Quaternion): void;
  24395. /**
  24396. * Gets the box size of the physics imposter and stores the result in the input parameter
  24397. * @param result Stores the box size
  24398. * @returns The physics imposter
  24399. */
  24400. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24401. /**
  24402. * Gets the radius of the physics imposter
  24403. * @returns Radius of the physics imposter
  24404. */
  24405. getRadius(): number;
  24406. /**
  24407. * Sync a bone with this impostor
  24408. * @param bone The bone to sync to the impostor.
  24409. * @param boneMesh The mesh that the bone is influencing.
  24410. * @param jointPivot The pivot of the joint / bone in local space.
  24411. * @param distToJoint Optional distance from the impostor to the joint.
  24412. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24413. */
  24414. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24415. /**
  24416. * Sync impostor to a bone
  24417. * @param bone The bone that the impostor will be synced to.
  24418. * @param boneMesh The mesh that the bone is influencing.
  24419. * @param jointPivot The pivot of the joint / bone in local space.
  24420. * @param distToJoint Optional distance from the impostor to the joint.
  24421. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24422. * @param boneAxis Optional vector3 axis the bone is aligned with
  24423. */
  24424. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24425. /**
  24426. * No-Imposter type
  24427. */
  24428. static NoImpostor: number;
  24429. /**
  24430. * Sphere-Imposter type
  24431. */
  24432. static SphereImpostor: number;
  24433. /**
  24434. * Box-Imposter type
  24435. */
  24436. static BoxImpostor: number;
  24437. /**
  24438. * Plane-Imposter type
  24439. */
  24440. static PlaneImpostor: number;
  24441. /**
  24442. * Mesh-imposter type
  24443. */
  24444. static MeshImpostor: number;
  24445. /**
  24446. * Capsule-Impostor type (Ammo.js plugin only)
  24447. */
  24448. static CapsuleImpostor: number;
  24449. /**
  24450. * Cylinder-Imposter type
  24451. */
  24452. static CylinderImpostor: number;
  24453. /**
  24454. * Particle-Imposter type
  24455. */
  24456. static ParticleImpostor: number;
  24457. /**
  24458. * Heightmap-Imposter type
  24459. */
  24460. static HeightmapImpostor: number;
  24461. /**
  24462. * ConvexHull-Impostor type (Ammo.js plugin only)
  24463. */
  24464. static ConvexHullImpostor: number;
  24465. /**
  24466. * Custom-Imposter type (Ammo.js plugin only)
  24467. */
  24468. static CustomImpostor: number;
  24469. /**
  24470. * Rope-Imposter type
  24471. */
  24472. static RopeImpostor: number;
  24473. /**
  24474. * Cloth-Imposter type
  24475. */
  24476. static ClothImpostor: number;
  24477. /**
  24478. * Softbody-Imposter type
  24479. */
  24480. static SoftbodyImpostor: number;
  24481. }
  24482. }
  24483. declare module "babylonjs/Meshes/mesh" {
  24484. import { Observable } from "babylonjs/Misc/observable";
  24485. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24486. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24487. import { Camera } from "babylonjs/Cameras/camera";
  24488. import { Scene } from "babylonjs/scene";
  24489. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24490. import { Color4 } from "babylonjs/Maths/math.color";
  24491. import { Engine } from "babylonjs/Engines/engine";
  24492. import { Node } from "babylonjs/node";
  24493. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24494. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24495. import { Buffer } from "babylonjs/Meshes/buffer";
  24496. import { Geometry } from "babylonjs/Meshes/geometry";
  24497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24498. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24499. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24500. import { Effect } from "babylonjs/Materials/effect";
  24501. import { Material } from "babylonjs/Materials/material";
  24502. import { Skeleton } from "babylonjs/Bones/skeleton";
  24503. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24504. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24505. import { Path3D } from "babylonjs/Maths/math.path";
  24506. import { Plane } from "babylonjs/Maths/math.plane";
  24507. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24508. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24509. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24510. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24511. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24512. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24513. /**
  24514. * @hidden
  24515. **/
  24516. export class _CreationDataStorage {
  24517. closePath?: boolean;
  24518. closeArray?: boolean;
  24519. idx: number[];
  24520. dashSize: number;
  24521. gapSize: number;
  24522. path3D: Path3D;
  24523. pathArray: Vector3[][];
  24524. arc: number;
  24525. radius: number;
  24526. cap: number;
  24527. tessellation: number;
  24528. }
  24529. /**
  24530. * @hidden
  24531. **/
  24532. class _InstanceDataStorage {
  24533. visibleInstances: any;
  24534. batchCache: _InstancesBatch;
  24535. instancesBufferSize: number;
  24536. instancesBuffer: Nullable<Buffer>;
  24537. instancesData: Float32Array;
  24538. overridenInstanceCount: number;
  24539. isFrozen: boolean;
  24540. previousBatch: Nullable<_InstancesBatch>;
  24541. hardwareInstancedRendering: boolean;
  24542. sideOrientation: number;
  24543. manualUpdate: boolean;
  24544. }
  24545. /**
  24546. * @hidden
  24547. **/
  24548. export class _InstancesBatch {
  24549. mustReturn: boolean;
  24550. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24551. renderSelf: boolean[];
  24552. hardwareInstancedRendering: boolean[];
  24553. }
  24554. /**
  24555. * Class used to represent renderable models
  24556. */
  24557. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24558. /**
  24559. * Mesh side orientation : usually the external or front surface
  24560. */
  24561. static readonly FRONTSIDE: number;
  24562. /**
  24563. * Mesh side orientation : usually the internal or back surface
  24564. */
  24565. static readonly BACKSIDE: number;
  24566. /**
  24567. * Mesh side orientation : both internal and external or front and back surfaces
  24568. */
  24569. static readonly DOUBLESIDE: number;
  24570. /**
  24571. * Mesh side orientation : by default, `FRONTSIDE`
  24572. */
  24573. static readonly DEFAULTSIDE: number;
  24574. /**
  24575. * Mesh cap setting : no cap
  24576. */
  24577. static readonly NO_CAP: number;
  24578. /**
  24579. * Mesh cap setting : one cap at the beginning of the mesh
  24580. */
  24581. static readonly CAP_START: number;
  24582. /**
  24583. * Mesh cap setting : one cap at the end of the mesh
  24584. */
  24585. static readonly CAP_END: number;
  24586. /**
  24587. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24588. */
  24589. static readonly CAP_ALL: number;
  24590. /**
  24591. * Mesh pattern setting : no flip or rotate
  24592. */
  24593. static readonly NO_FLIP: number;
  24594. /**
  24595. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24596. */
  24597. static readonly FLIP_TILE: number;
  24598. /**
  24599. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24600. */
  24601. static readonly ROTATE_TILE: number;
  24602. /**
  24603. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24604. */
  24605. static readonly FLIP_ROW: number;
  24606. /**
  24607. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24608. */
  24609. static readonly ROTATE_ROW: number;
  24610. /**
  24611. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24612. */
  24613. static readonly FLIP_N_ROTATE_TILE: number;
  24614. /**
  24615. * Mesh pattern setting : rotate pattern and rotate
  24616. */
  24617. static readonly FLIP_N_ROTATE_ROW: number;
  24618. /**
  24619. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24620. */
  24621. static readonly CENTER: number;
  24622. /**
  24623. * Mesh tile positioning : part tiles on left
  24624. */
  24625. static readonly LEFT: number;
  24626. /**
  24627. * Mesh tile positioning : part tiles on right
  24628. */
  24629. static readonly RIGHT: number;
  24630. /**
  24631. * Mesh tile positioning : part tiles on top
  24632. */
  24633. static readonly TOP: number;
  24634. /**
  24635. * Mesh tile positioning : part tiles on bottom
  24636. */
  24637. static readonly BOTTOM: number;
  24638. /**
  24639. * Gets the default side orientation.
  24640. * @param orientation the orientation to value to attempt to get
  24641. * @returns the default orientation
  24642. * @hidden
  24643. */
  24644. static _GetDefaultSideOrientation(orientation?: number): number;
  24645. private _internalMeshDataInfo;
  24646. /**
  24647. * An event triggered before rendering the mesh
  24648. */
  24649. readonly onBeforeRenderObservable: Observable<Mesh>;
  24650. /**
  24651. * An event triggered before binding the mesh
  24652. */
  24653. readonly onBeforeBindObservable: Observable<Mesh>;
  24654. /**
  24655. * An event triggered after rendering the mesh
  24656. */
  24657. readonly onAfterRenderObservable: Observable<Mesh>;
  24658. /**
  24659. * An event triggered before drawing the mesh
  24660. */
  24661. readonly onBeforeDrawObservable: Observable<Mesh>;
  24662. private _onBeforeDrawObserver;
  24663. /**
  24664. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24665. */
  24666. onBeforeDraw: () => void;
  24667. readonly hasInstances: boolean;
  24668. /**
  24669. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24670. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24671. */
  24672. delayLoadState: number;
  24673. /**
  24674. * Gets the list of instances created from this mesh
  24675. * it is not supposed to be modified manually.
  24676. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24677. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24678. */
  24679. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24680. /**
  24681. * Gets the file containing delay loading data for this mesh
  24682. */
  24683. delayLoadingFile: string;
  24684. /** @hidden */
  24685. _binaryInfo: any;
  24686. /**
  24687. * User defined function used to change how LOD level selection is done
  24688. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24689. */
  24690. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24691. /**
  24692. * Gets or sets the morph target manager
  24693. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24694. */
  24695. morphTargetManager: Nullable<MorphTargetManager>;
  24696. /** @hidden */
  24697. _creationDataStorage: Nullable<_CreationDataStorage>;
  24698. /** @hidden */
  24699. _geometry: Nullable<Geometry>;
  24700. /** @hidden */
  24701. _delayInfo: Array<string>;
  24702. /** @hidden */
  24703. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24704. /** @hidden */
  24705. _instanceDataStorage: _InstanceDataStorage;
  24706. private _effectiveMaterial;
  24707. /** @hidden */
  24708. _shouldGenerateFlatShading: boolean;
  24709. /** @hidden */
  24710. _originalBuilderSideOrientation: number;
  24711. /**
  24712. * Use this property to change the original side orientation defined at construction time
  24713. */
  24714. overrideMaterialSideOrientation: Nullable<number>;
  24715. /**
  24716. * Gets the source mesh (the one used to clone this one from)
  24717. */
  24718. readonly source: Nullable<Mesh>;
  24719. /**
  24720. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24721. */
  24722. isUnIndexed: boolean;
  24723. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24724. readonly worldMatrixInstancedBuffer: Float32Array;
  24725. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24726. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  24727. /**
  24728. * @constructor
  24729. * @param name The value used by scene.getMeshByName() to do a lookup.
  24730. * @param scene The scene to add this mesh to.
  24731. * @param parent The parent of this mesh, if it has one
  24732. * @param source An optional Mesh from which geometry is shared, cloned.
  24733. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24734. * When false, achieved by calling a clone(), also passing False.
  24735. * This will make creation of children, recursive.
  24736. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24737. */
  24738. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24739. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24740. doNotInstantiate: boolean;
  24741. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24742. /**
  24743. * Gets the class name
  24744. * @returns the string "Mesh".
  24745. */
  24746. getClassName(): string;
  24747. /** @hidden */
  24748. readonly _isMesh: boolean;
  24749. /**
  24750. * Returns a description of this mesh
  24751. * @param fullDetails define if full details about this mesh must be used
  24752. * @returns a descriptive string representing this mesh
  24753. */
  24754. toString(fullDetails?: boolean): string;
  24755. /** @hidden */
  24756. _unBindEffect(): void;
  24757. /**
  24758. * Gets a boolean indicating if this mesh has LOD
  24759. */
  24760. readonly hasLODLevels: boolean;
  24761. /**
  24762. * Gets the list of MeshLODLevel associated with the current mesh
  24763. * @returns an array of MeshLODLevel
  24764. */
  24765. getLODLevels(): MeshLODLevel[];
  24766. private _sortLODLevels;
  24767. /**
  24768. * Add a mesh as LOD level triggered at the given distance.
  24769. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24770. * @param distance The distance from the center of the object to show this level
  24771. * @param mesh The mesh to be added as LOD level (can be null)
  24772. * @return This mesh (for chaining)
  24773. */
  24774. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24775. /**
  24776. * Returns the LOD level mesh at the passed distance or null if not found.
  24777. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24778. * @param distance The distance from the center of the object to show this level
  24779. * @returns a Mesh or `null`
  24780. */
  24781. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24782. /**
  24783. * Remove a mesh from the LOD array
  24784. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24785. * @param mesh defines the mesh to be removed
  24786. * @return This mesh (for chaining)
  24787. */
  24788. removeLODLevel(mesh: Mesh): Mesh;
  24789. /**
  24790. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24791. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24792. * @param camera defines the camera to use to compute distance
  24793. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24794. * @return This mesh (for chaining)
  24795. */
  24796. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24797. /**
  24798. * Gets the mesh internal Geometry object
  24799. */
  24800. readonly geometry: Nullable<Geometry>;
  24801. /**
  24802. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24803. * @returns the total number of vertices
  24804. */
  24805. getTotalVertices(): number;
  24806. /**
  24807. * Returns the content of an associated vertex buffer
  24808. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24809. * - VertexBuffer.PositionKind
  24810. * - VertexBuffer.UVKind
  24811. * - VertexBuffer.UV2Kind
  24812. * - VertexBuffer.UV3Kind
  24813. * - VertexBuffer.UV4Kind
  24814. * - VertexBuffer.UV5Kind
  24815. * - VertexBuffer.UV6Kind
  24816. * - VertexBuffer.ColorKind
  24817. * - VertexBuffer.MatricesIndicesKind
  24818. * - VertexBuffer.MatricesIndicesExtraKind
  24819. * - VertexBuffer.MatricesWeightsKind
  24820. * - VertexBuffer.MatricesWeightsExtraKind
  24821. * @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
  24822. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24823. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24824. */
  24825. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24826. /**
  24827. * Returns the mesh VertexBuffer object from the requested `kind`
  24828. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24829. * - VertexBuffer.PositionKind
  24830. * - VertexBuffer.NormalKind
  24831. * - VertexBuffer.UVKind
  24832. * - VertexBuffer.UV2Kind
  24833. * - VertexBuffer.UV3Kind
  24834. * - VertexBuffer.UV4Kind
  24835. * - VertexBuffer.UV5Kind
  24836. * - VertexBuffer.UV6Kind
  24837. * - VertexBuffer.ColorKind
  24838. * - VertexBuffer.MatricesIndicesKind
  24839. * - VertexBuffer.MatricesIndicesExtraKind
  24840. * - VertexBuffer.MatricesWeightsKind
  24841. * - VertexBuffer.MatricesWeightsExtraKind
  24842. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24843. */
  24844. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24845. /**
  24846. * Tests if a specific vertex buffer is associated with this mesh
  24847. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24848. * - VertexBuffer.PositionKind
  24849. * - VertexBuffer.NormalKind
  24850. * - VertexBuffer.UVKind
  24851. * - VertexBuffer.UV2Kind
  24852. * - VertexBuffer.UV3Kind
  24853. * - VertexBuffer.UV4Kind
  24854. * - VertexBuffer.UV5Kind
  24855. * - VertexBuffer.UV6Kind
  24856. * - VertexBuffer.ColorKind
  24857. * - VertexBuffer.MatricesIndicesKind
  24858. * - VertexBuffer.MatricesIndicesExtraKind
  24859. * - VertexBuffer.MatricesWeightsKind
  24860. * - VertexBuffer.MatricesWeightsExtraKind
  24861. * @returns a boolean
  24862. */
  24863. isVerticesDataPresent(kind: string): boolean;
  24864. /**
  24865. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24866. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24867. * - VertexBuffer.PositionKind
  24868. * - VertexBuffer.UVKind
  24869. * - VertexBuffer.UV2Kind
  24870. * - VertexBuffer.UV3Kind
  24871. * - VertexBuffer.UV4Kind
  24872. * - VertexBuffer.UV5Kind
  24873. * - VertexBuffer.UV6Kind
  24874. * - VertexBuffer.ColorKind
  24875. * - VertexBuffer.MatricesIndicesKind
  24876. * - VertexBuffer.MatricesIndicesExtraKind
  24877. * - VertexBuffer.MatricesWeightsKind
  24878. * - VertexBuffer.MatricesWeightsExtraKind
  24879. * @returns a boolean
  24880. */
  24881. isVertexBufferUpdatable(kind: string): boolean;
  24882. /**
  24883. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24884. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24885. * - VertexBuffer.PositionKind
  24886. * - VertexBuffer.NormalKind
  24887. * - VertexBuffer.UVKind
  24888. * - VertexBuffer.UV2Kind
  24889. * - VertexBuffer.UV3Kind
  24890. * - VertexBuffer.UV4Kind
  24891. * - VertexBuffer.UV5Kind
  24892. * - VertexBuffer.UV6Kind
  24893. * - VertexBuffer.ColorKind
  24894. * - VertexBuffer.MatricesIndicesKind
  24895. * - VertexBuffer.MatricesIndicesExtraKind
  24896. * - VertexBuffer.MatricesWeightsKind
  24897. * - VertexBuffer.MatricesWeightsExtraKind
  24898. * @returns an array of strings
  24899. */
  24900. getVerticesDataKinds(): string[];
  24901. /**
  24902. * Returns a positive integer : the total number of indices in this mesh geometry.
  24903. * @returns the numner of indices or zero if the mesh has no geometry.
  24904. */
  24905. getTotalIndices(): number;
  24906. /**
  24907. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24908. * @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.
  24909. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24910. * @returns the indices array or an empty array if the mesh has no geometry
  24911. */
  24912. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24913. readonly isBlocked: boolean;
  24914. /**
  24915. * Determine if the current mesh is ready to be rendered
  24916. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24917. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24918. * @returns true if all associated assets are ready (material, textures, shaders)
  24919. */
  24920. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24921. /**
  24922. * 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.
  24923. */
  24924. readonly areNormalsFrozen: boolean;
  24925. /**
  24926. * 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.
  24927. * @returns the current mesh
  24928. */
  24929. freezeNormals(): Mesh;
  24930. /**
  24931. * 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
  24932. * @returns the current mesh
  24933. */
  24934. unfreezeNormals(): Mesh;
  24935. /**
  24936. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24937. */
  24938. overridenInstanceCount: number;
  24939. /** @hidden */
  24940. _preActivate(): Mesh;
  24941. /** @hidden */
  24942. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24943. /** @hidden */
  24944. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24945. /**
  24946. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24947. * This means the mesh underlying bounding box and sphere are recomputed.
  24948. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24949. * @returns the current mesh
  24950. */
  24951. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24952. /** @hidden */
  24953. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24954. /**
  24955. * This function will subdivide the mesh into multiple submeshes
  24956. * @param count defines the expected number of submeshes
  24957. */
  24958. subdivide(count: number): void;
  24959. /**
  24960. * Copy a FloatArray into a specific associated vertex buffer
  24961. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24962. * - VertexBuffer.PositionKind
  24963. * - VertexBuffer.UVKind
  24964. * - VertexBuffer.UV2Kind
  24965. * - VertexBuffer.UV3Kind
  24966. * - VertexBuffer.UV4Kind
  24967. * - VertexBuffer.UV5Kind
  24968. * - VertexBuffer.UV6Kind
  24969. * - VertexBuffer.ColorKind
  24970. * - VertexBuffer.MatricesIndicesKind
  24971. * - VertexBuffer.MatricesIndicesExtraKind
  24972. * - VertexBuffer.MatricesWeightsKind
  24973. * - VertexBuffer.MatricesWeightsExtraKind
  24974. * @param data defines the data source
  24975. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24976. * @param stride defines the data stride size (can be null)
  24977. * @returns the current mesh
  24978. */
  24979. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24980. /**
  24981. * Delete a vertex buffer associated with this mesh
  24982. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24983. * - VertexBuffer.PositionKind
  24984. * - VertexBuffer.UVKind
  24985. * - VertexBuffer.UV2Kind
  24986. * - VertexBuffer.UV3Kind
  24987. * - VertexBuffer.UV4Kind
  24988. * - VertexBuffer.UV5Kind
  24989. * - VertexBuffer.UV6Kind
  24990. * - VertexBuffer.ColorKind
  24991. * - VertexBuffer.MatricesIndicesKind
  24992. * - VertexBuffer.MatricesIndicesExtraKind
  24993. * - VertexBuffer.MatricesWeightsKind
  24994. * - VertexBuffer.MatricesWeightsExtraKind
  24995. */
  24996. removeVerticesData(kind: string): void;
  24997. /**
  24998. * Flags an associated vertex buffer as updatable
  24999. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25000. * - VertexBuffer.PositionKind
  25001. * - VertexBuffer.UVKind
  25002. * - VertexBuffer.UV2Kind
  25003. * - VertexBuffer.UV3Kind
  25004. * - VertexBuffer.UV4Kind
  25005. * - VertexBuffer.UV5Kind
  25006. * - VertexBuffer.UV6Kind
  25007. * - VertexBuffer.ColorKind
  25008. * - VertexBuffer.MatricesIndicesKind
  25009. * - VertexBuffer.MatricesIndicesExtraKind
  25010. * - VertexBuffer.MatricesWeightsKind
  25011. * - VertexBuffer.MatricesWeightsExtraKind
  25012. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25013. */
  25014. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25015. /**
  25016. * Sets the mesh global Vertex Buffer
  25017. * @param buffer defines the buffer to use
  25018. * @returns the current mesh
  25019. */
  25020. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25021. /**
  25022. * Update a specific associated vertex buffer
  25023. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25024. * - VertexBuffer.PositionKind
  25025. * - VertexBuffer.UVKind
  25026. * - VertexBuffer.UV2Kind
  25027. * - VertexBuffer.UV3Kind
  25028. * - VertexBuffer.UV4Kind
  25029. * - VertexBuffer.UV5Kind
  25030. * - VertexBuffer.UV6Kind
  25031. * - VertexBuffer.ColorKind
  25032. * - VertexBuffer.MatricesIndicesKind
  25033. * - VertexBuffer.MatricesIndicesExtraKind
  25034. * - VertexBuffer.MatricesWeightsKind
  25035. * - VertexBuffer.MatricesWeightsExtraKind
  25036. * @param data defines the data source
  25037. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25038. * @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)
  25039. * @returns the current mesh
  25040. */
  25041. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25042. /**
  25043. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25044. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25045. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25046. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25047. * @returns the current mesh
  25048. */
  25049. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25050. /**
  25051. * Creates a un-shared specific occurence of the geometry for the mesh.
  25052. * @returns the current mesh
  25053. */
  25054. makeGeometryUnique(): Mesh;
  25055. /**
  25056. * Set the index buffer of this mesh
  25057. * @param indices defines the source data
  25058. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25059. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25060. * @returns the current mesh
  25061. */
  25062. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25063. /**
  25064. * Update the current index buffer
  25065. * @param indices defines the source data
  25066. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25067. * @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)
  25068. * @returns the current mesh
  25069. */
  25070. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25071. /**
  25072. * Invert the geometry to move from a right handed system to a left handed one.
  25073. * @returns the current mesh
  25074. */
  25075. toLeftHanded(): Mesh;
  25076. /** @hidden */
  25077. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25078. /** @hidden */
  25079. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25080. /**
  25081. * Registers for this mesh a javascript function called just before the rendering process
  25082. * @param func defines the function to call before rendering this mesh
  25083. * @returns the current mesh
  25084. */
  25085. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25086. /**
  25087. * Disposes a previously registered javascript function called before the rendering
  25088. * @param func defines the function to remove
  25089. * @returns the current mesh
  25090. */
  25091. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25092. /**
  25093. * Registers for this mesh a javascript function called just after the rendering is complete
  25094. * @param func defines the function to call after rendering this mesh
  25095. * @returns the current mesh
  25096. */
  25097. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25098. /**
  25099. * Disposes a previously registered javascript function called after the rendering.
  25100. * @param func defines the function to remove
  25101. * @returns the current mesh
  25102. */
  25103. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25104. /** @hidden */
  25105. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25106. /** @hidden */
  25107. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25108. /** @hidden */
  25109. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25110. /** @hidden */
  25111. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25112. /** @hidden */
  25113. _rebuild(): void;
  25114. /** @hidden */
  25115. _freeze(): void;
  25116. /** @hidden */
  25117. _unFreeze(): void;
  25118. /**
  25119. * 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
  25120. * @param subMesh defines the subMesh to render
  25121. * @param enableAlphaMode defines if alpha mode can be changed
  25122. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25123. * @returns the current mesh
  25124. */
  25125. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25126. private _onBeforeDraw;
  25127. /**
  25128. * Renormalize the mesh and patch it up if there are no weights
  25129. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25130. * However in the case of zero weights then we set just a single influence to 1.
  25131. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25132. */
  25133. cleanMatrixWeights(): void;
  25134. private normalizeSkinFourWeights;
  25135. private normalizeSkinWeightsAndExtra;
  25136. /**
  25137. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25138. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25139. * the user know there was an issue with importing the mesh
  25140. * @returns a validation object with skinned, valid and report string
  25141. */
  25142. validateSkinning(): {
  25143. skinned: boolean;
  25144. valid: boolean;
  25145. report: string;
  25146. };
  25147. /** @hidden */
  25148. _checkDelayState(): Mesh;
  25149. private _queueLoad;
  25150. /**
  25151. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25152. * A mesh is in the frustum if its bounding box intersects the frustum
  25153. * @param frustumPlanes defines the frustum to test
  25154. * @returns true if the mesh is in the frustum planes
  25155. */
  25156. isInFrustum(frustumPlanes: Plane[]): boolean;
  25157. /**
  25158. * Sets the mesh material by the material or multiMaterial `id` property
  25159. * @param id is a string identifying the material or the multiMaterial
  25160. * @returns the current mesh
  25161. */
  25162. setMaterialByID(id: string): Mesh;
  25163. /**
  25164. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25165. * @returns an array of IAnimatable
  25166. */
  25167. getAnimatables(): IAnimatable[];
  25168. /**
  25169. * Modifies the mesh geometry according to the passed transformation matrix.
  25170. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25171. * The mesh normals are modified using the same transformation.
  25172. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25173. * @param transform defines the transform matrix to use
  25174. * @see http://doc.babylonjs.com/resources/baking_transformations
  25175. * @returns the current mesh
  25176. */
  25177. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25178. /**
  25179. * Modifies the mesh geometry according to its own current World Matrix.
  25180. * The mesh World Matrix is then reset.
  25181. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25182. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25183. * @see http://doc.babylonjs.com/resources/baking_transformations
  25184. * @returns the current mesh
  25185. */
  25186. bakeCurrentTransformIntoVertices(): Mesh;
  25187. /** @hidden */
  25188. readonly _positions: Nullable<Vector3[]>;
  25189. /** @hidden */
  25190. _resetPointsArrayCache(): Mesh;
  25191. /** @hidden */
  25192. _generatePointsArray(): boolean;
  25193. /**
  25194. * Returns a new Mesh object generated from the current mesh properties.
  25195. * This method must not get confused with createInstance()
  25196. * @param name is a string, the name given to the new mesh
  25197. * @param newParent can be any Node object (default `null`)
  25198. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25199. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25200. * @returns a new mesh
  25201. */
  25202. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25203. /**
  25204. * Releases resources associated with this mesh.
  25205. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25206. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25207. */
  25208. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25209. /** @hidden */
  25210. _disposeInstanceSpecificData(): void;
  25211. /**
  25212. * Modifies the mesh geometry according to a displacement map.
  25213. * 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.
  25214. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25215. * @param url is a string, the URL from the image file is to be downloaded.
  25216. * @param minHeight is the lower limit of the displacement.
  25217. * @param maxHeight is the upper limit of the displacement.
  25218. * @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.
  25219. * @param uvOffset is an optional vector2 used to offset UV.
  25220. * @param uvScale is an optional vector2 used to scale UV.
  25221. * @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.
  25222. * @returns the Mesh.
  25223. */
  25224. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25225. /**
  25226. * Modifies the mesh geometry according to a displacementMap buffer.
  25227. * 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.
  25228. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25229. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25230. * @param heightMapWidth is the width of the buffer image.
  25231. * @param heightMapHeight is the height of the buffer image.
  25232. * @param minHeight is the lower limit of the displacement.
  25233. * @param maxHeight is the upper limit of the displacement.
  25234. * @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.
  25235. * @param uvOffset is an optional vector2 used to offset UV.
  25236. * @param uvScale is an optional vector2 used to scale UV.
  25237. * @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.
  25238. * @returns the Mesh.
  25239. */
  25240. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25241. /**
  25242. * Modify the mesh to get a flat shading rendering.
  25243. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25244. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25245. * @returns current mesh
  25246. */
  25247. convertToFlatShadedMesh(): Mesh;
  25248. /**
  25249. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25250. * In other words, more vertices, no more indices and a single bigger VBO.
  25251. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25252. * @returns current mesh
  25253. */
  25254. convertToUnIndexedMesh(): Mesh;
  25255. /**
  25256. * Inverses facet orientations.
  25257. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25258. * @param flipNormals will also inverts the normals
  25259. * @returns current mesh
  25260. */
  25261. flipFaces(flipNormals?: boolean): Mesh;
  25262. /**
  25263. * Increase the number of facets and hence vertices in a mesh
  25264. * Vertex normals are interpolated from existing vertex normals
  25265. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25266. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25267. */
  25268. increaseVertices(numberPerEdge: number): void;
  25269. /**
  25270. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25271. * This will undo any application of covertToFlatShadedMesh
  25272. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25273. */
  25274. forceSharedVertices(): void;
  25275. /** @hidden */
  25276. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25277. /** @hidden */
  25278. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25279. /**
  25280. * Creates a new InstancedMesh object from the mesh model.
  25281. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25282. * @param name defines the name of the new instance
  25283. * @returns a new InstancedMesh
  25284. */
  25285. createInstance(name: string): InstancedMesh;
  25286. /**
  25287. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25288. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25289. * @returns the current mesh
  25290. */
  25291. synchronizeInstances(): Mesh;
  25292. /**
  25293. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25294. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25295. * This should be used together with the simplification to avoid disappearing triangles.
  25296. * @param successCallback an optional success callback to be called after the optimization finished.
  25297. * @returns the current mesh
  25298. */
  25299. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25300. /**
  25301. * Serialize current mesh
  25302. * @param serializationObject defines the object which will receive the serialization data
  25303. */
  25304. serialize(serializationObject: any): void;
  25305. /** @hidden */
  25306. _syncGeometryWithMorphTargetManager(): void;
  25307. /** @hidden */
  25308. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25309. /**
  25310. * Returns a new Mesh object parsed from the source provided.
  25311. * @param parsedMesh is the source
  25312. * @param scene defines the hosting scene
  25313. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25314. * @returns a new Mesh
  25315. */
  25316. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25317. /**
  25318. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25319. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25320. * @param name defines the name of the mesh to create
  25321. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25322. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25323. * @param closePath creates a seam between the first and the last points of each path of the path array
  25324. * @param offset is taken in account only if the `pathArray` is containing a single path
  25325. * @param scene defines the hosting scene
  25326. * @param updatable defines if the mesh must be flagged as updatable
  25327. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25328. * @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)
  25329. * @returns a new Mesh
  25330. */
  25331. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25332. /**
  25333. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25334. * @param name defines the name of the mesh to create
  25335. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25336. * @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
  25337. * @param scene defines the hosting scene
  25338. * @param updatable defines if the mesh must be flagged as updatable
  25339. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25340. * @returns a new Mesh
  25341. */
  25342. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25343. /**
  25344. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25345. * @param name defines the name of the mesh to create
  25346. * @param size sets the size (float) of each box side (default 1)
  25347. * @param scene defines the hosting scene
  25348. * @param updatable defines if the mesh must be flagged as updatable
  25349. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25350. * @returns a new Mesh
  25351. */
  25352. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25353. /**
  25354. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25355. * @param name defines the name of the mesh to create
  25356. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25357. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25358. * @param scene defines the hosting scene
  25359. * @param updatable defines if the mesh must be flagged as updatable
  25360. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25361. * @returns a new Mesh
  25362. */
  25363. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25364. /**
  25365. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25366. * @param name defines the name of the mesh to create
  25367. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25368. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25369. * @param scene defines the hosting scene
  25370. * @returns a new Mesh
  25371. */
  25372. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25373. /**
  25374. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25375. * @param name defines the name of the mesh to create
  25376. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25377. * @param diameterTop set the top cap diameter (floats, default 1)
  25378. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25379. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25380. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25381. * @param scene defines the hosting scene
  25382. * @param updatable defines if the mesh must be flagged as updatable
  25383. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25384. * @returns a new Mesh
  25385. */
  25386. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25387. /**
  25388. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25389. * @param name defines the name of the mesh to create
  25390. * @param diameter sets the diameter size (float) of the torus (default 1)
  25391. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25392. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25393. * @param scene defines the hosting scene
  25394. * @param updatable defines if the mesh must be flagged as updatable
  25395. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25396. * @returns a new Mesh
  25397. */
  25398. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25399. /**
  25400. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25401. * @param name defines the name of the mesh to create
  25402. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25403. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25404. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25405. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25406. * @param p the number of windings on X axis (positive integers, default 2)
  25407. * @param q the number of windings on Y axis (positive integers, default 3)
  25408. * @param scene defines the hosting scene
  25409. * @param updatable defines if the mesh must be flagged as updatable
  25410. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25411. * @returns a new Mesh
  25412. */
  25413. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25414. /**
  25415. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25416. * @param name defines the name of the mesh to create
  25417. * @param points is an array successive Vector3
  25418. * @param scene defines the hosting scene
  25419. * @param updatable defines if the mesh must be flagged as updatable
  25420. * @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).
  25421. * @returns a new Mesh
  25422. */
  25423. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25424. /**
  25425. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25426. * @param name defines the name of the mesh to create
  25427. * @param points is an array successive Vector3
  25428. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25429. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25430. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25431. * @param scene defines the hosting scene
  25432. * @param updatable defines if the mesh must be flagged as updatable
  25433. * @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)
  25434. * @returns a new Mesh
  25435. */
  25436. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25437. /**
  25438. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25439. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25440. * 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.
  25441. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25442. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25443. * Remember you can only change the shape positions, not their number when updating a polygon.
  25444. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25445. * @param name defines the name of the mesh to create
  25446. * @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
  25447. * @param scene defines the hosting scene
  25448. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25449. * @param updatable defines if the mesh must be flagged as updatable
  25450. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25451. * @param earcutInjection can be used to inject your own earcut reference
  25452. * @returns a new Mesh
  25453. */
  25454. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25455. /**
  25456. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25457. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25458. * @param name defines the name of the mesh to create
  25459. * @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
  25460. * @param depth defines the height of extrusion
  25461. * @param scene defines the hosting scene
  25462. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25463. * @param updatable defines if the mesh must be flagged as updatable
  25464. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25465. * @param earcutInjection can be used to inject your own earcut reference
  25466. * @returns a new Mesh
  25467. */
  25468. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25469. /**
  25470. * Creates an extruded shape mesh.
  25471. * 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
  25472. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25473. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25474. * @param name defines the name of the mesh to create
  25475. * @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
  25476. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25477. * @param scale is the value to scale the shape
  25478. * @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
  25479. * @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
  25480. * @param scene defines the hosting scene
  25481. * @param updatable defines if the mesh must be flagged as updatable
  25482. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25483. * @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)
  25484. * @returns a new Mesh
  25485. */
  25486. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25487. /**
  25488. * Creates an custom extruded shape mesh.
  25489. * The custom extrusion is a parametric shape.
  25490. * It has no predefined shape. Its final shape will depend on the input parameters.
  25491. * Please consider using the same method from the MeshBuilder class instead
  25492. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25493. * @param name defines the name of the mesh to create
  25494. * @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
  25495. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25496. * @param scaleFunction is a custom Javascript function called on each path point
  25497. * @param rotationFunction is a custom Javascript function called on each path point
  25498. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25499. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25500. * @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
  25501. * @param scene defines the hosting scene
  25502. * @param updatable defines if the mesh must be flagged as updatable
  25503. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25504. * @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)
  25505. * @returns a new Mesh
  25506. */
  25507. 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;
  25508. /**
  25509. * Creates lathe mesh.
  25510. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25511. * Please consider using the same method from the MeshBuilder class instead
  25512. * @param name defines the name of the mesh to create
  25513. * @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
  25514. * @param radius is the radius value of the lathe
  25515. * @param tessellation is the side number of the lathe.
  25516. * @param scene defines the hosting scene
  25517. * @param updatable defines if the mesh must be flagged as updatable
  25518. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25519. * @returns a new Mesh
  25520. */
  25521. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25522. /**
  25523. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25524. * @param name defines the name of the mesh to create
  25525. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25526. * @param scene defines the hosting scene
  25527. * @param updatable defines if the mesh must be flagged as updatable
  25528. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25529. * @returns a new Mesh
  25530. */
  25531. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25532. /**
  25533. * Creates a ground mesh.
  25534. * Please consider using the same method from the MeshBuilder class instead
  25535. * @param name defines the name of the mesh to create
  25536. * @param width set the width of the ground
  25537. * @param height set the height of the ground
  25538. * @param subdivisions sets the number of subdivisions per side
  25539. * @param scene defines the hosting scene
  25540. * @param updatable defines if the mesh must be flagged as updatable
  25541. * @returns a new Mesh
  25542. */
  25543. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25544. /**
  25545. * Creates a tiled ground mesh.
  25546. * Please consider using the same method from the MeshBuilder class instead
  25547. * @param name defines the name of the mesh to create
  25548. * @param xmin set the ground minimum X coordinate
  25549. * @param zmin set the ground minimum Y coordinate
  25550. * @param xmax set the ground maximum X coordinate
  25551. * @param zmax set the ground maximum Z coordinate
  25552. * @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
  25553. * @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
  25554. * @param scene defines the hosting scene
  25555. * @param updatable defines if the mesh must be flagged as updatable
  25556. * @returns a new Mesh
  25557. */
  25558. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25559. w: number;
  25560. h: number;
  25561. }, precision: {
  25562. w: number;
  25563. h: number;
  25564. }, scene: Scene, updatable?: boolean): Mesh;
  25565. /**
  25566. * Creates a ground mesh from a height map.
  25567. * Please consider using the same method from the MeshBuilder class instead
  25568. * @see http://doc.babylonjs.com/babylon101/height_map
  25569. * @param name defines the name of the mesh to create
  25570. * @param url sets the URL of the height map image resource
  25571. * @param width set the ground width size
  25572. * @param height set the ground height size
  25573. * @param subdivisions sets the number of subdivision per side
  25574. * @param minHeight is the minimum altitude on the ground
  25575. * @param maxHeight is the maximum altitude on the ground
  25576. * @param scene defines the hosting scene
  25577. * @param updatable defines if the mesh must be flagged as updatable
  25578. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25579. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25580. * @returns a new Mesh
  25581. */
  25582. 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;
  25583. /**
  25584. * Creates a tube mesh.
  25585. * The tube is a parametric shape.
  25586. * It has no predefined shape. Its final shape will depend on the input parameters.
  25587. * Please consider using the same method from the MeshBuilder class instead
  25588. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25589. * @param name defines the name of the mesh to create
  25590. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25591. * @param radius sets the tube radius size
  25592. * @param tessellation is the number of sides on the tubular surface
  25593. * @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
  25594. * @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
  25595. * @param scene defines the hosting scene
  25596. * @param updatable defines if the mesh must be flagged as updatable
  25597. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25598. * @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)
  25599. * @returns a new Mesh
  25600. */
  25601. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25602. (i: number, distance: number): number;
  25603. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25604. /**
  25605. * Creates a polyhedron mesh.
  25606. * Please consider using the same method from the MeshBuilder class instead.
  25607. * * 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
  25608. * * The parameter `size` (positive float, default 1) sets the polygon size
  25609. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25610. * * 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`
  25611. * * 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
  25612. * * 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)`)
  25613. * * 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
  25614. * * 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
  25615. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25616. * * If you create a double-sided mesh, you can choose what parts of 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
  25617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25618. * @param name defines the name of the mesh to create
  25619. * @param options defines the options used to create the mesh
  25620. * @param scene defines the hosting scene
  25621. * @returns a new Mesh
  25622. */
  25623. static CreatePolyhedron(name: string, options: {
  25624. type?: number;
  25625. size?: number;
  25626. sizeX?: number;
  25627. sizeY?: number;
  25628. sizeZ?: number;
  25629. custom?: any;
  25630. faceUV?: Vector4[];
  25631. faceColors?: Color4[];
  25632. updatable?: boolean;
  25633. sideOrientation?: number;
  25634. }, scene: Scene): Mesh;
  25635. /**
  25636. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25637. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25638. * * 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`)
  25639. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25640. * * 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
  25641. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25642. * * If you create a double-sided mesh, you can choose what parts of 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
  25643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25644. * @param name defines the name of the mesh
  25645. * @param options defines the options used to create the mesh
  25646. * @param scene defines the hosting scene
  25647. * @returns a new Mesh
  25648. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25649. */
  25650. static CreateIcoSphere(name: string, options: {
  25651. radius?: number;
  25652. flat?: boolean;
  25653. subdivisions?: number;
  25654. sideOrientation?: number;
  25655. updatable?: boolean;
  25656. }, scene: Scene): Mesh;
  25657. /**
  25658. * Creates a decal mesh.
  25659. * Please consider using the same method from the MeshBuilder class instead.
  25660. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25661. * @param name defines the name of the mesh
  25662. * @param sourceMesh defines the mesh receiving the decal
  25663. * @param position sets the position of the decal in world coordinates
  25664. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25665. * @param size sets the decal scaling
  25666. * @param angle sets the angle to rotate the decal
  25667. * @returns a new Mesh
  25668. */
  25669. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25670. /**
  25671. * Prepare internal position array for software CPU skinning
  25672. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25673. */
  25674. setPositionsForCPUSkinning(): Float32Array;
  25675. /**
  25676. * Prepare internal normal array for software CPU skinning
  25677. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25678. */
  25679. setNormalsForCPUSkinning(): Float32Array;
  25680. /**
  25681. * Updates the vertex buffer by applying transformation from the bones
  25682. * @param skeleton defines the skeleton to apply to current mesh
  25683. * @returns the current mesh
  25684. */
  25685. applySkeleton(skeleton: Skeleton): Mesh;
  25686. /**
  25687. * 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
  25688. * @param meshes defines the list of meshes to scan
  25689. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25690. */
  25691. static MinMax(meshes: AbstractMesh[]): {
  25692. min: Vector3;
  25693. max: Vector3;
  25694. };
  25695. /**
  25696. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25697. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25698. * @returns a vector3
  25699. */
  25700. static Center(meshesOrMinMaxVector: {
  25701. min: Vector3;
  25702. max: Vector3;
  25703. } | AbstractMesh[]): Vector3;
  25704. /**
  25705. * Merge the array of meshes into a single mesh for performance reasons.
  25706. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25707. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25708. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25709. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25710. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25711. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25712. * @returns a new mesh
  25713. */
  25714. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25715. /** @hidden */
  25716. addInstance(instance: InstancedMesh): void;
  25717. /** @hidden */
  25718. removeInstance(instance: InstancedMesh): void;
  25719. }
  25720. }
  25721. declare module "babylonjs/Cameras/camera" {
  25722. import { SmartArray } from "babylonjs/Misc/smartArray";
  25723. import { Observable } from "babylonjs/Misc/observable";
  25724. import { Nullable } from "babylonjs/types";
  25725. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25726. import { Scene } from "babylonjs/scene";
  25727. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25728. import { Node } from "babylonjs/node";
  25729. import { Mesh } from "babylonjs/Meshes/mesh";
  25730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25731. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25732. import { Viewport } from "babylonjs/Maths/math.viewport";
  25733. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25734. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25735. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25736. import { Ray } from "babylonjs/Culling/ray";
  25737. /**
  25738. * This is the base class of all the camera used in the application.
  25739. * @see http://doc.babylonjs.com/features/cameras
  25740. */
  25741. export class Camera extends Node {
  25742. /** @hidden */
  25743. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25744. /**
  25745. * This is the default projection mode used by the cameras.
  25746. * It helps recreating a feeling of perspective and better appreciate depth.
  25747. * This is the best way to simulate real life cameras.
  25748. */
  25749. static readonly PERSPECTIVE_CAMERA: number;
  25750. /**
  25751. * This helps creating camera with an orthographic mode.
  25752. * 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.
  25753. */
  25754. static readonly ORTHOGRAPHIC_CAMERA: number;
  25755. /**
  25756. * This is the default FOV mode for perspective cameras.
  25757. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25758. */
  25759. static readonly FOVMODE_VERTICAL_FIXED: number;
  25760. /**
  25761. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25762. */
  25763. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25764. /**
  25765. * This specifies ther is no need for a camera rig.
  25766. * Basically only one eye is rendered corresponding to the camera.
  25767. */
  25768. static readonly RIG_MODE_NONE: number;
  25769. /**
  25770. * Simulates a camera Rig with one blue eye and one red eye.
  25771. * This can be use with 3d blue and red glasses.
  25772. */
  25773. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25774. /**
  25775. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25776. */
  25777. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25778. /**
  25779. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25780. */
  25781. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25782. /**
  25783. * Defines that both eyes of the camera will be rendered over under each other.
  25784. */
  25785. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25786. /**
  25787. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25788. */
  25789. static readonly RIG_MODE_VR: number;
  25790. /**
  25791. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25792. */
  25793. static readonly RIG_MODE_WEBVR: number;
  25794. /**
  25795. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25796. */
  25797. static readonly RIG_MODE_CUSTOM: number;
  25798. /**
  25799. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25800. */
  25801. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25802. /**
  25803. * Define the input manager associated with the camera.
  25804. */
  25805. inputs: CameraInputsManager<Camera>;
  25806. /** @hidden */
  25807. _position: Vector3;
  25808. /**
  25809. * Define the current local position of the camera in the scene
  25810. */
  25811. position: Vector3;
  25812. /**
  25813. * The vector the camera should consider as up.
  25814. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25815. */
  25816. upVector: Vector3;
  25817. /**
  25818. * Define the current limit on the left side for an orthographic camera
  25819. * In scene unit
  25820. */
  25821. orthoLeft: Nullable<number>;
  25822. /**
  25823. * Define the current limit on the right side for an orthographic camera
  25824. * In scene unit
  25825. */
  25826. orthoRight: Nullable<number>;
  25827. /**
  25828. * Define the current limit on the bottom side for an orthographic camera
  25829. * In scene unit
  25830. */
  25831. orthoBottom: Nullable<number>;
  25832. /**
  25833. * Define the current limit on the top side for an orthographic camera
  25834. * In scene unit
  25835. */
  25836. orthoTop: Nullable<number>;
  25837. /**
  25838. * Field Of View is set in Radians. (default is 0.8)
  25839. */
  25840. fov: number;
  25841. /**
  25842. * Define the minimum distance the camera can see from.
  25843. * This is important to note that the depth buffer are not infinite and the closer it starts
  25844. * the more your scene might encounter depth fighting issue.
  25845. */
  25846. minZ: number;
  25847. /**
  25848. * Define the maximum distance the camera can see to.
  25849. * This is important to note that the depth buffer are not infinite and the further it end
  25850. * the more your scene might encounter depth fighting issue.
  25851. */
  25852. maxZ: number;
  25853. /**
  25854. * Define the default inertia of the camera.
  25855. * This helps giving a smooth feeling to the camera movement.
  25856. */
  25857. inertia: number;
  25858. /**
  25859. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25860. */
  25861. mode: number;
  25862. /**
  25863. * Define wether the camera is intermediate.
  25864. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25865. */
  25866. isIntermediate: boolean;
  25867. /**
  25868. * Define the viewport of the camera.
  25869. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25870. */
  25871. viewport: Viewport;
  25872. /**
  25873. * Restricts the camera to viewing objects with the same layerMask.
  25874. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25875. */
  25876. layerMask: number;
  25877. /**
  25878. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25879. */
  25880. fovMode: number;
  25881. /**
  25882. * Rig mode of the camera.
  25883. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25884. * This is normally controlled byt the camera themselves as internal use.
  25885. */
  25886. cameraRigMode: number;
  25887. /**
  25888. * Defines the distance between both "eyes" in case of a RIG
  25889. */
  25890. interaxialDistance: number;
  25891. /**
  25892. * Defines if stereoscopic rendering is done side by side or over under.
  25893. */
  25894. isStereoscopicSideBySide: boolean;
  25895. /**
  25896. * 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
  25897. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25898. * else in the scene. (Eg. security camera)
  25899. *
  25900. * 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)
  25901. */
  25902. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25903. /**
  25904. * When set, the camera will render to this render target instead of the default canvas
  25905. *
  25906. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25907. */
  25908. outputRenderTarget: Nullable<RenderTargetTexture>;
  25909. /**
  25910. * Observable triggered when the camera view matrix has changed.
  25911. */
  25912. onViewMatrixChangedObservable: Observable<Camera>;
  25913. /**
  25914. * Observable triggered when the camera Projection matrix has changed.
  25915. */
  25916. onProjectionMatrixChangedObservable: Observable<Camera>;
  25917. /**
  25918. * Observable triggered when the inputs have been processed.
  25919. */
  25920. onAfterCheckInputsObservable: Observable<Camera>;
  25921. /**
  25922. * Observable triggered when reset has been called and applied to the camera.
  25923. */
  25924. onRestoreStateObservable: Observable<Camera>;
  25925. /** @hidden */
  25926. _cameraRigParams: any;
  25927. /** @hidden */
  25928. _rigCameras: Camera[];
  25929. /** @hidden */
  25930. _rigPostProcess: Nullable<PostProcess>;
  25931. protected _webvrViewMatrix: Matrix;
  25932. /** @hidden */
  25933. _skipRendering: boolean;
  25934. /** @hidden */
  25935. _projectionMatrix: Matrix;
  25936. /** @hidden */
  25937. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25938. /** @hidden */
  25939. _activeMeshes: SmartArray<AbstractMesh>;
  25940. protected _globalPosition: Vector3;
  25941. /** @hidden */
  25942. _computedViewMatrix: Matrix;
  25943. private _doNotComputeProjectionMatrix;
  25944. private _transformMatrix;
  25945. private _frustumPlanes;
  25946. private _refreshFrustumPlanes;
  25947. private _storedFov;
  25948. private _stateStored;
  25949. /**
  25950. * Instantiates a new camera object.
  25951. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25952. * @see http://doc.babylonjs.com/features/cameras
  25953. * @param name Defines the name of the camera in the scene
  25954. * @param position Defines the position of the camera
  25955. * @param scene Defines the scene the camera belongs too
  25956. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25957. */
  25958. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25959. /**
  25960. * Store current camera state (fov, position, etc..)
  25961. * @returns the camera
  25962. */
  25963. storeState(): Camera;
  25964. /**
  25965. * Restores the camera state values if it has been stored. You must call storeState() first
  25966. */
  25967. protected _restoreStateValues(): boolean;
  25968. /**
  25969. * Restored camera state. You must call storeState() first.
  25970. * @returns true if restored and false otherwise
  25971. */
  25972. restoreState(): boolean;
  25973. /**
  25974. * Gets the class name of the camera.
  25975. * @returns the class name
  25976. */
  25977. getClassName(): string;
  25978. /** @hidden */
  25979. readonly _isCamera: boolean;
  25980. /**
  25981. * Gets a string representation of the camera useful for debug purpose.
  25982. * @param fullDetails Defines that a more verboe level of logging is required
  25983. * @returns the string representation
  25984. */
  25985. toString(fullDetails?: boolean): string;
  25986. /**
  25987. * Gets the current world space position of the camera.
  25988. */
  25989. readonly globalPosition: Vector3;
  25990. /**
  25991. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25992. * @returns the active meshe list
  25993. */
  25994. getActiveMeshes(): SmartArray<AbstractMesh>;
  25995. /**
  25996. * Check wether a mesh is part of the current active mesh list of the camera
  25997. * @param mesh Defines the mesh to check
  25998. * @returns true if active, false otherwise
  25999. */
  26000. isActiveMesh(mesh: Mesh): boolean;
  26001. /**
  26002. * Is this camera ready to be used/rendered
  26003. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26004. * @return true if the camera is ready
  26005. */
  26006. isReady(completeCheck?: boolean): boolean;
  26007. /** @hidden */
  26008. _initCache(): void;
  26009. /** @hidden */
  26010. _updateCache(ignoreParentClass?: boolean): void;
  26011. /** @hidden */
  26012. _isSynchronized(): boolean;
  26013. /** @hidden */
  26014. _isSynchronizedViewMatrix(): boolean;
  26015. /** @hidden */
  26016. _isSynchronizedProjectionMatrix(): boolean;
  26017. /**
  26018. * Attach the input controls to a specific dom element to get the input from.
  26019. * @param element Defines the element the controls should be listened from
  26020. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26021. */
  26022. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26023. /**
  26024. * Detach the current controls from the specified dom element.
  26025. * @param element Defines the element to stop listening the inputs from
  26026. */
  26027. detachControl(element: HTMLElement): void;
  26028. /**
  26029. * Update the camera state according to the different inputs gathered during the frame.
  26030. */
  26031. update(): void;
  26032. /** @hidden */
  26033. _checkInputs(): void;
  26034. /** @hidden */
  26035. readonly rigCameras: Camera[];
  26036. /**
  26037. * Gets the post process used by the rig cameras
  26038. */
  26039. readonly rigPostProcess: Nullable<PostProcess>;
  26040. /**
  26041. * Internal, gets the first post proces.
  26042. * @returns the first post process to be run on this camera.
  26043. */
  26044. _getFirstPostProcess(): Nullable<PostProcess>;
  26045. private _cascadePostProcessesToRigCams;
  26046. /**
  26047. * Attach a post process to the camera.
  26048. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26049. * @param postProcess The post process to attach to the camera
  26050. * @param insertAt The position of the post process in case several of them are in use in the scene
  26051. * @returns the position the post process has been inserted at
  26052. */
  26053. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26054. /**
  26055. * Detach a post process to the camera.
  26056. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26057. * @param postProcess The post process to detach from the camera
  26058. */
  26059. detachPostProcess(postProcess: PostProcess): void;
  26060. /**
  26061. * Gets the current world matrix of the camera
  26062. */
  26063. getWorldMatrix(): Matrix;
  26064. /** @hidden */
  26065. _getViewMatrix(): Matrix;
  26066. /**
  26067. * Gets the current view matrix of the camera.
  26068. * @param force forces the camera to recompute the matrix without looking at the cached state
  26069. * @returns the view matrix
  26070. */
  26071. getViewMatrix(force?: boolean): Matrix;
  26072. /**
  26073. * Freeze the projection matrix.
  26074. * It will prevent the cache check of the camera projection compute and can speed up perf
  26075. * if no parameter of the camera are meant to change
  26076. * @param projection Defines manually a projection if necessary
  26077. */
  26078. freezeProjectionMatrix(projection?: Matrix): void;
  26079. /**
  26080. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26081. */
  26082. unfreezeProjectionMatrix(): void;
  26083. /**
  26084. * Gets the current projection matrix of the camera.
  26085. * @param force forces the camera to recompute the matrix without looking at the cached state
  26086. * @returns the projection matrix
  26087. */
  26088. getProjectionMatrix(force?: boolean): Matrix;
  26089. /**
  26090. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26091. * @returns a Matrix
  26092. */
  26093. getTransformationMatrix(): Matrix;
  26094. private _updateFrustumPlanes;
  26095. /**
  26096. * Checks if a cullable object (mesh...) is in the camera frustum
  26097. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26098. * @param target The object to check
  26099. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26100. * @returns true if the object is in frustum otherwise false
  26101. */
  26102. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26103. /**
  26104. * Checks if a cullable object (mesh...) is in the camera frustum
  26105. * Unlike isInFrustum this cheks the full bounding box
  26106. * @param target The object to check
  26107. * @returns true if the object is in frustum otherwise false
  26108. */
  26109. isCompletelyInFrustum(target: ICullable): boolean;
  26110. /**
  26111. * Gets a ray in the forward direction from the camera.
  26112. * @param length Defines the length of the ray to create
  26113. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26114. * @param origin Defines the start point of the ray which defaults to the camera position
  26115. * @returns the forward ray
  26116. */
  26117. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26118. /**
  26119. * Releases resources associated with this node.
  26120. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26121. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26122. */
  26123. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26124. /** @hidden */
  26125. _isLeftCamera: boolean;
  26126. /**
  26127. * Gets the left camera of a rig setup in case of Rigged Camera
  26128. */
  26129. readonly isLeftCamera: boolean;
  26130. /** @hidden */
  26131. _isRightCamera: boolean;
  26132. /**
  26133. * Gets the right camera of a rig setup in case of Rigged Camera
  26134. */
  26135. readonly isRightCamera: boolean;
  26136. /**
  26137. * Gets the left camera of a rig setup in case of Rigged Camera
  26138. */
  26139. readonly leftCamera: Nullable<FreeCamera>;
  26140. /**
  26141. * Gets the right camera of a rig setup in case of Rigged Camera
  26142. */
  26143. readonly rightCamera: Nullable<FreeCamera>;
  26144. /**
  26145. * Gets the left camera target of a rig setup in case of Rigged Camera
  26146. * @returns the target position
  26147. */
  26148. getLeftTarget(): Nullable<Vector3>;
  26149. /**
  26150. * Gets the right camera target of a rig setup in case of Rigged Camera
  26151. * @returns the target position
  26152. */
  26153. getRightTarget(): Nullable<Vector3>;
  26154. /**
  26155. * @hidden
  26156. */
  26157. setCameraRigMode(mode: number, rigParams: any): void;
  26158. /** @hidden */
  26159. static _setStereoscopicRigMode(camera: Camera): void;
  26160. /** @hidden */
  26161. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26162. /** @hidden */
  26163. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26164. /** @hidden */
  26165. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26166. /** @hidden */
  26167. _getVRProjectionMatrix(): Matrix;
  26168. protected _updateCameraRotationMatrix(): void;
  26169. protected _updateWebVRCameraRotationMatrix(): void;
  26170. /**
  26171. * This function MUST be overwritten by the different WebVR cameras available.
  26172. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26173. * @hidden
  26174. */
  26175. _getWebVRProjectionMatrix(): Matrix;
  26176. /**
  26177. * This function MUST be overwritten by the different WebVR cameras available.
  26178. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26179. * @hidden
  26180. */
  26181. _getWebVRViewMatrix(): Matrix;
  26182. /** @hidden */
  26183. setCameraRigParameter(name: string, value: any): void;
  26184. /**
  26185. * needs to be overridden by children so sub has required properties to be copied
  26186. * @hidden
  26187. */
  26188. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26189. /**
  26190. * May need to be overridden by children
  26191. * @hidden
  26192. */
  26193. _updateRigCameras(): void;
  26194. /** @hidden */
  26195. _setupInputs(): void;
  26196. /**
  26197. * Serialiaze the camera setup to a json represention
  26198. * @returns the JSON representation
  26199. */
  26200. serialize(): any;
  26201. /**
  26202. * Clones the current camera.
  26203. * @param name The cloned camera name
  26204. * @returns the cloned camera
  26205. */
  26206. clone(name: string): Camera;
  26207. /**
  26208. * Gets the direction of the camera relative to a given local axis.
  26209. * @param localAxis Defines the reference axis to provide a relative direction.
  26210. * @return the direction
  26211. */
  26212. getDirection(localAxis: Vector3): Vector3;
  26213. /**
  26214. * Returns the current camera absolute rotation
  26215. */
  26216. readonly absoluteRotation: Quaternion;
  26217. /**
  26218. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26219. * @param localAxis Defines the reference axis to provide a relative direction.
  26220. * @param result Defines the vector to store the result in
  26221. */
  26222. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26223. /**
  26224. * Gets a camera constructor for a given camera type
  26225. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26226. * @param name The name of the camera the result will be able to instantiate
  26227. * @param scene The scene the result will construct the camera in
  26228. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26229. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26230. * @returns a factory method to construc the camera
  26231. */
  26232. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26233. /**
  26234. * Compute the world matrix of the camera.
  26235. * @returns the camera world matrix
  26236. */
  26237. computeWorldMatrix(): Matrix;
  26238. /**
  26239. * Parse a JSON and creates the camera from the parsed information
  26240. * @param parsedCamera The JSON to parse
  26241. * @param scene The scene to instantiate the camera in
  26242. * @returns the newly constructed camera
  26243. */
  26244. static Parse(parsedCamera: any, scene: Scene): Camera;
  26245. }
  26246. }
  26247. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26248. import { Nullable } from "babylonjs/types";
  26249. import { Scene } from "babylonjs/scene";
  26250. import { Vector4 } from "babylonjs/Maths/math.vector";
  26251. import { Mesh } from "babylonjs/Meshes/mesh";
  26252. /**
  26253. * Class containing static functions to help procedurally build meshes
  26254. */
  26255. export class DiscBuilder {
  26256. /**
  26257. * Creates a plane polygonal mesh. By default, this is a disc
  26258. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26259. * * 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
  26260. * * 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
  26261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26262. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26264. * @param name defines the name of the mesh
  26265. * @param options defines the options used to create the mesh
  26266. * @param scene defines the hosting scene
  26267. * @returns the plane polygonal mesh
  26268. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26269. */
  26270. static CreateDisc(name: string, options: {
  26271. radius?: number;
  26272. tessellation?: number;
  26273. arc?: number;
  26274. updatable?: boolean;
  26275. sideOrientation?: number;
  26276. frontUVs?: Vector4;
  26277. backUVs?: Vector4;
  26278. }, scene?: Nullable<Scene>): Mesh;
  26279. }
  26280. }
  26281. declare module "babylonjs/Materials/fresnelParameters" {
  26282. import { Color3 } from "babylonjs/Maths/math.color";
  26283. /**
  26284. * This represents all the required information to add a fresnel effect on a material:
  26285. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26286. */
  26287. export class FresnelParameters {
  26288. private _isEnabled;
  26289. /**
  26290. * Define if the fresnel effect is enable or not.
  26291. */
  26292. isEnabled: boolean;
  26293. /**
  26294. * Define the color used on edges (grazing angle)
  26295. */
  26296. leftColor: Color3;
  26297. /**
  26298. * Define the color used on center
  26299. */
  26300. rightColor: Color3;
  26301. /**
  26302. * Define bias applied to computed fresnel term
  26303. */
  26304. bias: number;
  26305. /**
  26306. * Defined the power exponent applied to fresnel term
  26307. */
  26308. power: number;
  26309. /**
  26310. * Clones the current fresnel and its valuues
  26311. * @returns a clone fresnel configuration
  26312. */
  26313. clone(): FresnelParameters;
  26314. /**
  26315. * Serializes the current fresnel parameters to a JSON representation.
  26316. * @return the JSON serialization
  26317. */
  26318. serialize(): any;
  26319. /**
  26320. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26321. * @param parsedFresnelParameters Define the JSON representation
  26322. * @returns the parsed parameters
  26323. */
  26324. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26325. }
  26326. }
  26327. declare module "babylonjs/Materials/pushMaterial" {
  26328. import { Nullable } from "babylonjs/types";
  26329. import { Scene } from "babylonjs/scene";
  26330. import { Matrix } from "babylonjs/Maths/math.vector";
  26331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26332. import { Mesh } from "babylonjs/Meshes/mesh";
  26333. import { Material } from "babylonjs/Materials/material";
  26334. import { Effect } from "babylonjs/Materials/effect";
  26335. /**
  26336. * Base class of materials working in push mode in babylon JS
  26337. * @hidden
  26338. */
  26339. export class PushMaterial extends Material {
  26340. protected _activeEffect: Effect;
  26341. protected _normalMatrix: Matrix;
  26342. /**
  26343. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26344. * This means that the material can keep using a previous shader while a new one is being compiled.
  26345. * This is mostly used when shader parallel compilation is supported (true by default)
  26346. */
  26347. allowShaderHotSwapping: boolean;
  26348. constructor(name: string, scene: Scene);
  26349. getEffect(): Effect;
  26350. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26351. /**
  26352. * Binds the given world matrix to the active effect
  26353. *
  26354. * @param world the matrix to bind
  26355. */
  26356. bindOnlyWorldMatrix(world: Matrix): void;
  26357. /**
  26358. * Binds the given normal matrix to the active effect
  26359. *
  26360. * @param normalMatrix the matrix to bind
  26361. */
  26362. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26363. bind(world: Matrix, mesh?: Mesh): void;
  26364. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26365. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26366. }
  26367. }
  26368. declare module "babylonjs/Materials/materialFlags" {
  26369. /**
  26370. * This groups all the flags used to control the materials channel.
  26371. */
  26372. export class MaterialFlags {
  26373. private static _DiffuseTextureEnabled;
  26374. /**
  26375. * Are diffuse textures enabled in the application.
  26376. */
  26377. static DiffuseTextureEnabled: boolean;
  26378. private static _AmbientTextureEnabled;
  26379. /**
  26380. * Are ambient textures enabled in the application.
  26381. */
  26382. static AmbientTextureEnabled: boolean;
  26383. private static _OpacityTextureEnabled;
  26384. /**
  26385. * Are opacity textures enabled in the application.
  26386. */
  26387. static OpacityTextureEnabled: boolean;
  26388. private static _ReflectionTextureEnabled;
  26389. /**
  26390. * Are reflection textures enabled in the application.
  26391. */
  26392. static ReflectionTextureEnabled: boolean;
  26393. private static _EmissiveTextureEnabled;
  26394. /**
  26395. * Are emissive textures enabled in the application.
  26396. */
  26397. static EmissiveTextureEnabled: boolean;
  26398. private static _SpecularTextureEnabled;
  26399. /**
  26400. * Are specular textures enabled in the application.
  26401. */
  26402. static SpecularTextureEnabled: boolean;
  26403. private static _BumpTextureEnabled;
  26404. /**
  26405. * Are bump textures enabled in the application.
  26406. */
  26407. static BumpTextureEnabled: boolean;
  26408. private static _LightmapTextureEnabled;
  26409. /**
  26410. * Are lightmap textures enabled in the application.
  26411. */
  26412. static LightmapTextureEnabled: boolean;
  26413. private static _RefractionTextureEnabled;
  26414. /**
  26415. * Are refraction textures enabled in the application.
  26416. */
  26417. static RefractionTextureEnabled: boolean;
  26418. private static _ColorGradingTextureEnabled;
  26419. /**
  26420. * Are color grading textures enabled in the application.
  26421. */
  26422. static ColorGradingTextureEnabled: boolean;
  26423. private static _FresnelEnabled;
  26424. /**
  26425. * Are fresnels enabled in the application.
  26426. */
  26427. static FresnelEnabled: boolean;
  26428. private static _ClearCoatTextureEnabled;
  26429. /**
  26430. * Are clear coat textures enabled in the application.
  26431. */
  26432. static ClearCoatTextureEnabled: boolean;
  26433. private static _ClearCoatBumpTextureEnabled;
  26434. /**
  26435. * Are clear coat bump textures enabled in the application.
  26436. */
  26437. static ClearCoatBumpTextureEnabled: boolean;
  26438. private static _ClearCoatTintTextureEnabled;
  26439. /**
  26440. * Are clear coat tint textures enabled in the application.
  26441. */
  26442. static ClearCoatTintTextureEnabled: boolean;
  26443. private static _SheenTextureEnabled;
  26444. /**
  26445. * Are sheen textures enabled in the application.
  26446. */
  26447. static SheenTextureEnabled: boolean;
  26448. private static _AnisotropicTextureEnabled;
  26449. /**
  26450. * Are anisotropic textures enabled in the application.
  26451. */
  26452. static AnisotropicTextureEnabled: boolean;
  26453. private static _ThicknessTextureEnabled;
  26454. /**
  26455. * Are thickness textures enabled in the application.
  26456. */
  26457. static ThicknessTextureEnabled: boolean;
  26458. }
  26459. }
  26460. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26461. /** @hidden */
  26462. export var defaultFragmentDeclaration: {
  26463. name: string;
  26464. shader: string;
  26465. };
  26466. }
  26467. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26468. /** @hidden */
  26469. export var defaultUboDeclaration: {
  26470. name: string;
  26471. shader: string;
  26472. };
  26473. }
  26474. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26475. /** @hidden */
  26476. export var lightFragmentDeclaration: {
  26477. name: string;
  26478. shader: string;
  26479. };
  26480. }
  26481. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26482. /** @hidden */
  26483. export var lightUboDeclaration: {
  26484. name: string;
  26485. shader: string;
  26486. };
  26487. }
  26488. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26489. /** @hidden */
  26490. export var lightsFragmentFunctions: {
  26491. name: string;
  26492. shader: string;
  26493. };
  26494. }
  26495. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26496. /** @hidden */
  26497. export var shadowsFragmentFunctions: {
  26498. name: string;
  26499. shader: string;
  26500. };
  26501. }
  26502. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26503. /** @hidden */
  26504. export var fresnelFunction: {
  26505. name: string;
  26506. shader: string;
  26507. };
  26508. }
  26509. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26510. /** @hidden */
  26511. export var reflectionFunction: {
  26512. name: string;
  26513. shader: string;
  26514. };
  26515. }
  26516. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26517. /** @hidden */
  26518. export var bumpFragmentFunctions: {
  26519. name: string;
  26520. shader: string;
  26521. };
  26522. }
  26523. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26524. /** @hidden */
  26525. export var logDepthDeclaration: {
  26526. name: string;
  26527. shader: string;
  26528. };
  26529. }
  26530. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26531. /** @hidden */
  26532. export var bumpFragment: {
  26533. name: string;
  26534. shader: string;
  26535. };
  26536. }
  26537. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26538. /** @hidden */
  26539. export var depthPrePass: {
  26540. name: string;
  26541. shader: string;
  26542. };
  26543. }
  26544. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26545. /** @hidden */
  26546. export var lightFragment: {
  26547. name: string;
  26548. shader: string;
  26549. };
  26550. }
  26551. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26552. /** @hidden */
  26553. export var logDepthFragment: {
  26554. name: string;
  26555. shader: string;
  26556. };
  26557. }
  26558. declare module "babylonjs/Shaders/default.fragment" {
  26559. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26560. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26561. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26562. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26563. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26564. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26565. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26566. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26567. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26568. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26569. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26570. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26571. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26572. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26573. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26574. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26575. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26576. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26577. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26578. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26579. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26580. /** @hidden */
  26581. export var defaultPixelShader: {
  26582. name: string;
  26583. shader: string;
  26584. };
  26585. }
  26586. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  26587. /** @hidden */
  26588. export var defaultVertexDeclaration: {
  26589. name: string;
  26590. shader: string;
  26591. };
  26592. }
  26593. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  26594. /** @hidden */
  26595. export var bumpVertexDeclaration: {
  26596. name: string;
  26597. shader: string;
  26598. };
  26599. }
  26600. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  26601. /** @hidden */
  26602. export var bumpVertex: {
  26603. name: string;
  26604. shader: string;
  26605. };
  26606. }
  26607. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  26608. /** @hidden */
  26609. export var fogVertex: {
  26610. name: string;
  26611. shader: string;
  26612. };
  26613. }
  26614. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  26615. /** @hidden */
  26616. export var shadowsVertex: {
  26617. name: string;
  26618. shader: string;
  26619. };
  26620. }
  26621. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  26622. /** @hidden */
  26623. export var pointCloudVertex: {
  26624. name: string;
  26625. shader: string;
  26626. };
  26627. }
  26628. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  26629. /** @hidden */
  26630. export var logDepthVertex: {
  26631. name: string;
  26632. shader: string;
  26633. };
  26634. }
  26635. declare module "babylonjs/Shaders/default.vertex" {
  26636. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  26637. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26638. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26639. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26640. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26641. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26642. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26643. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26644. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26645. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26646. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26647. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26648. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26649. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26650. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26651. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26652. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26653. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26654. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26655. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26656. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  26657. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26658. /** @hidden */
  26659. export var defaultVertexShader: {
  26660. name: string;
  26661. shader: string;
  26662. };
  26663. }
  26664. declare module "babylonjs/Materials/standardMaterial" {
  26665. import { SmartArray } from "babylonjs/Misc/smartArray";
  26666. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26667. import { Nullable } from "babylonjs/types";
  26668. import { Scene } from "babylonjs/scene";
  26669. import { Matrix } from "babylonjs/Maths/math.vector";
  26670. import { Color3 } from "babylonjs/Maths/math.color";
  26671. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26673. import { Mesh } from "babylonjs/Meshes/mesh";
  26674. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26675. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  26676. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  26677. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26678. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26679. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26680. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26681. import "babylonjs/Shaders/default.fragment";
  26682. import "babylonjs/Shaders/default.vertex";
  26683. /** @hidden */
  26684. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26685. MAINUV1: boolean;
  26686. MAINUV2: boolean;
  26687. DIFFUSE: boolean;
  26688. DIFFUSEDIRECTUV: number;
  26689. AMBIENT: boolean;
  26690. AMBIENTDIRECTUV: number;
  26691. OPACITY: boolean;
  26692. OPACITYDIRECTUV: number;
  26693. OPACITYRGB: boolean;
  26694. REFLECTION: boolean;
  26695. EMISSIVE: boolean;
  26696. EMISSIVEDIRECTUV: number;
  26697. SPECULAR: boolean;
  26698. SPECULARDIRECTUV: number;
  26699. BUMP: boolean;
  26700. BUMPDIRECTUV: number;
  26701. PARALLAX: boolean;
  26702. PARALLAXOCCLUSION: boolean;
  26703. SPECULAROVERALPHA: boolean;
  26704. CLIPPLANE: boolean;
  26705. CLIPPLANE2: boolean;
  26706. CLIPPLANE3: boolean;
  26707. CLIPPLANE4: boolean;
  26708. ALPHATEST: boolean;
  26709. DEPTHPREPASS: boolean;
  26710. ALPHAFROMDIFFUSE: boolean;
  26711. POINTSIZE: boolean;
  26712. FOG: boolean;
  26713. SPECULARTERM: boolean;
  26714. DIFFUSEFRESNEL: boolean;
  26715. OPACITYFRESNEL: boolean;
  26716. REFLECTIONFRESNEL: boolean;
  26717. REFRACTIONFRESNEL: boolean;
  26718. EMISSIVEFRESNEL: boolean;
  26719. FRESNEL: boolean;
  26720. NORMAL: boolean;
  26721. UV1: boolean;
  26722. UV2: boolean;
  26723. VERTEXCOLOR: boolean;
  26724. VERTEXALPHA: boolean;
  26725. NUM_BONE_INFLUENCERS: number;
  26726. BonesPerMesh: number;
  26727. BONETEXTURE: boolean;
  26728. INSTANCES: boolean;
  26729. GLOSSINESS: boolean;
  26730. ROUGHNESS: boolean;
  26731. EMISSIVEASILLUMINATION: boolean;
  26732. LINKEMISSIVEWITHDIFFUSE: boolean;
  26733. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26734. LIGHTMAP: boolean;
  26735. LIGHTMAPDIRECTUV: number;
  26736. OBJECTSPACE_NORMALMAP: boolean;
  26737. USELIGHTMAPASSHADOWMAP: boolean;
  26738. REFLECTIONMAP_3D: boolean;
  26739. REFLECTIONMAP_SPHERICAL: boolean;
  26740. REFLECTIONMAP_PLANAR: boolean;
  26741. REFLECTIONMAP_CUBIC: boolean;
  26742. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26743. REFLECTIONMAP_PROJECTION: boolean;
  26744. REFLECTIONMAP_SKYBOX: boolean;
  26745. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26746. REFLECTIONMAP_EXPLICIT: boolean;
  26747. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26748. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26749. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26750. INVERTCUBICMAP: boolean;
  26751. LOGARITHMICDEPTH: boolean;
  26752. REFRACTION: boolean;
  26753. REFRACTIONMAP_3D: boolean;
  26754. REFLECTIONOVERALPHA: boolean;
  26755. TWOSIDEDLIGHTING: boolean;
  26756. SHADOWFLOAT: boolean;
  26757. MORPHTARGETS: boolean;
  26758. MORPHTARGETS_NORMAL: boolean;
  26759. MORPHTARGETS_TANGENT: boolean;
  26760. MORPHTARGETS_UV: boolean;
  26761. NUM_MORPH_INFLUENCERS: number;
  26762. NONUNIFORMSCALING: boolean;
  26763. PREMULTIPLYALPHA: boolean;
  26764. IMAGEPROCESSING: boolean;
  26765. VIGNETTE: boolean;
  26766. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26767. VIGNETTEBLENDMODEOPAQUE: boolean;
  26768. TONEMAPPING: boolean;
  26769. TONEMAPPING_ACES: boolean;
  26770. CONTRAST: boolean;
  26771. COLORCURVES: boolean;
  26772. COLORGRADING: boolean;
  26773. COLORGRADING3D: boolean;
  26774. SAMPLER3DGREENDEPTH: boolean;
  26775. SAMPLER3DBGRMAP: boolean;
  26776. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26777. MULTIVIEW: boolean;
  26778. /**
  26779. * If the reflection texture on this material is in linear color space
  26780. * @hidden
  26781. */
  26782. IS_REFLECTION_LINEAR: boolean;
  26783. /**
  26784. * If the refraction texture on this material is in linear color space
  26785. * @hidden
  26786. */
  26787. IS_REFRACTION_LINEAR: boolean;
  26788. EXPOSURE: boolean;
  26789. constructor();
  26790. setReflectionMode(modeToEnable: string): void;
  26791. }
  26792. /**
  26793. * This is the default material used in Babylon. It is the best trade off between quality
  26794. * and performances.
  26795. * @see http://doc.babylonjs.com/babylon101/materials
  26796. */
  26797. export class StandardMaterial extends PushMaterial {
  26798. private _diffuseTexture;
  26799. /**
  26800. * The basic texture of the material as viewed under a light.
  26801. */
  26802. diffuseTexture: Nullable<BaseTexture>;
  26803. private _ambientTexture;
  26804. /**
  26805. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26806. */
  26807. ambientTexture: Nullable<BaseTexture>;
  26808. private _opacityTexture;
  26809. /**
  26810. * Define the transparency of the material from a texture.
  26811. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26812. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26813. */
  26814. opacityTexture: Nullable<BaseTexture>;
  26815. private _reflectionTexture;
  26816. /**
  26817. * Define the texture used to display the reflection.
  26818. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26819. */
  26820. reflectionTexture: Nullable<BaseTexture>;
  26821. private _emissiveTexture;
  26822. /**
  26823. * Define texture of the material as if self lit.
  26824. * This will be mixed in the final result even in the absence of light.
  26825. */
  26826. emissiveTexture: Nullable<BaseTexture>;
  26827. private _specularTexture;
  26828. /**
  26829. * Define how the color and intensity of the highlight given by the light in the material.
  26830. */
  26831. specularTexture: Nullable<BaseTexture>;
  26832. private _bumpTexture;
  26833. /**
  26834. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26835. * 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.
  26836. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26837. */
  26838. bumpTexture: Nullable<BaseTexture>;
  26839. private _lightmapTexture;
  26840. /**
  26841. * Complex lighting can be computationally expensive to compute at runtime.
  26842. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26843. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26844. */
  26845. lightmapTexture: Nullable<BaseTexture>;
  26846. private _refractionTexture;
  26847. /**
  26848. * Define the texture used to display the refraction.
  26849. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26850. */
  26851. refractionTexture: Nullable<BaseTexture>;
  26852. /**
  26853. * The color of the material lit by the environmental background lighting.
  26854. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26855. */
  26856. ambientColor: Color3;
  26857. /**
  26858. * The basic color of the material as viewed under a light.
  26859. */
  26860. diffuseColor: Color3;
  26861. /**
  26862. * Define how the color and intensity of the highlight given by the light in the material.
  26863. */
  26864. specularColor: Color3;
  26865. /**
  26866. * Define the color of the material as if self lit.
  26867. * This will be mixed in the final result even in the absence of light.
  26868. */
  26869. emissiveColor: Color3;
  26870. /**
  26871. * Defines how sharp are the highlights in the material.
  26872. * The bigger the value the sharper giving a more glossy feeling to the result.
  26873. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26874. */
  26875. specularPower: number;
  26876. private _useAlphaFromDiffuseTexture;
  26877. /**
  26878. * Does the transparency come from the diffuse texture alpha channel.
  26879. */
  26880. useAlphaFromDiffuseTexture: boolean;
  26881. private _useEmissiveAsIllumination;
  26882. /**
  26883. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26884. */
  26885. useEmissiveAsIllumination: boolean;
  26886. private _linkEmissiveWithDiffuse;
  26887. /**
  26888. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26889. * the emissive level when the final color is close to one.
  26890. */
  26891. linkEmissiveWithDiffuse: boolean;
  26892. private _useSpecularOverAlpha;
  26893. /**
  26894. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26895. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26896. */
  26897. useSpecularOverAlpha: boolean;
  26898. private _useReflectionOverAlpha;
  26899. /**
  26900. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26901. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26902. */
  26903. useReflectionOverAlpha: boolean;
  26904. private _disableLighting;
  26905. /**
  26906. * Does lights from the scene impacts this material.
  26907. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26908. */
  26909. disableLighting: boolean;
  26910. private _useObjectSpaceNormalMap;
  26911. /**
  26912. * Allows using an object space normal map (instead of tangent space).
  26913. */
  26914. useObjectSpaceNormalMap: boolean;
  26915. private _useParallax;
  26916. /**
  26917. * Is parallax enabled or not.
  26918. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26919. */
  26920. useParallax: boolean;
  26921. private _useParallaxOcclusion;
  26922. /**
  26923. * Is parallax occlusion enabled or not.
  26924. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26925. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26926. */
  26927. useParallaxOcclusion: boolean;
  26928. /**
  26929. * 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.
  26930. */
  26931. parallaxScaleBias: number;
  26932. private _roughness;
  26933. /**
  26934. * Helps to define how blurry the reflections should appears in the material.
  26935. */
  26936. roughness: number;
  26937. /**
  26938. * In case of refraction, define the value of the index of refraction.
  26939. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26940. */
  26941. indexOfRefraction: number;
  26942. /**
  26943. * Invert the refraction texture alongside the y axis.
  26944. * It can be useful with procedural textures or probe for instance.
  26945. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26946. */
  26947. invertRefractionY: boolean;
  26948. /**
  26949. * Defines the alpha limits in alpha test mode.
  26950. */
  26951. alphaCutOff: number;
  26952. private _useLightmapAsShadowmap;
  26953. /**
  26954. * In case of light mapping, define whether the map contains light or shadow informations.
  26955. */
  26956. useLightmapAsShadowmap: boolean;
  26957. private _diffuseFresnelParameters;
  26958. /**
  26959. * Define the diffuse fresnel parameters of the material.
  26960. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26961. */
  26962. diffuseFresnelParameters: FresnelParameters;
  26963. private _opacityFresnelParameters;
  26964. /**
  26965. * Define the opacity fresnel parameters of the material.
  26966. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26967. */
  26968. opacityFresnelParameters: FresnelParameters;
  26969. private _reflectionFresnelParameters;
  26970. /**
  26971. * Define the reflection fresnel parameters of the material.
  26972. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26973. */
  26974. reflectionFresnelParameters: FresnelParameters;
  26975. private _refractionFresnelParameters;
  26976. /**
  26977. * Define the refraction fresnel parameters of the material.
  26978. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26979. */
  26980. refractionFresnelParameters: FresnelParameters;
  26981. private _emissiveFresnelParameters;
  26982. /**
  26983. * Define the emissive fresnel parameters of the material.
  26984. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26985. */
  26986. emissiveFresnelParameters: FresnelParameters;
  26987. private _useReflectionFresnelFromSpecular;
  26988. /**
  26989. * If true automatically deducts the fresnels values from the material specularity.
  26990. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26991. */
  26992. useReflectionFresnelFromSpecular: boolean;
  26993. private _useGlossinessFromSpecularMapAlpha;
  26994. /**
  26995. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26996. */
  26997. useGlossinessFromSpecularMapAlpha: boolean;
  26998. private _maxSimultaneousLights;
  26999. /**
  27000. * Defines the maximum number of lights that can be used in the material
  27001. */
  27002. maxSimultaneousLights: number;
  27003. private _invertNormalMapX;
  27004. /**
  27005. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27006. */
  27007. invertNormalMapX: boolean;
  27008. private _invertNormalMapY;
  27009. /**
  27010. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27011. */
  27012. invertNormalMapY: boolean;
  27013. private _twoSidedLighting;
  27014. /**
  27015. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27016. */
  27017. twoSidedLighting: boolean;
  27018. /**
  27019. * Default configuration related to image processing available in the standard Material.
  27020. */
  27021. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27022. /**
  27023. * Gets the image processing configuration used either in this material.
  27024. */
  27025. /**
  27026. * Sets the Default image processing configuration used either in the this material.
  27027. *
  27028. * If sets to null, the scene one is in use.
  27029. */
  27030. imageProcessingConfiguration: ImageProcessingConfiguration;
  27031. /**
  27032. * Keep track of the image processing observer to allow dispose and replace.
  27033. */
  27034. private _imageProcessingObserver;
  27035. /**
  27036. * Attaches a new image processing configuration to the Standard Material.
  27037. * @param configuration
  27038. */
  27039. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27040. /**
  27041. * Gets wether the color curves effect is enabled.
  27042. */
  27043. /**
  27044. * Sets wether the color curves effect is enabled.
  27045. */
  27046. cameraColorCurvesEnabled: boolean;
  27047. /**
  27048. * Gets wether the color grading effect is enabled.
  27049. */
  27050. /**
  27051. * Gets wether the color grading effect is enabled.
  27052. */
  27053. cameraColorGradingEnabled: boolean;
  27054. /**
  27055. * Gets wether tonemapping is enabled or not.
  27056. */
  27057. /**
  27058. * Sets wether tonemapping is enabled or not
  27059. */
  27060. cameraToneMappingEnabled: boolean;
  27061. /**
  27062. * The camera exposure used on this material.
  27063. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27064. * This corresponds to a photographic exposure.
  27065. */
  27066. /**
  27067. * The camera exposure used on this material.
  27068. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27069. * This corresponds to a photographic exposure.
  27070. */
  27071. cameraExposure: number;
  27072. /**
  27073. * Gets The camera contrast used on this material.
  27074. */
  27075. /**
  27076. * Sets The camera contrast used on this material.
  27077. */
  27078. cameraContrast: number;
  27079. /**
  27080. * Gets the Color Grading 2D Lookup Texture.
  27081. */
  27082. /**
  27083. * Sets the Color Grading 2D Lookup Texture.
  27084. */
  27085. cameraColorGradingTexture: Nullable<BaseTexture>;
  27086. /**
  27087. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27088. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27089. * 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;
  27090. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27091. */
  27092. /**
  27093. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27094. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27095. * 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;
  27096. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27097. */
  27098. cameraColorCurves: Nullable<ColorCurves>;
  27099. /**
  27100. * Custom callback helping to override the default shader used in the material.
  27101. */
  27102. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27103. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27104. protected _worldViewProjectionMatrix: Matrix;
  27105. protected _globalAmbientColor: Color3;
  27106. protected _useLogarithmicDepth: boolean;
  27107. protected _rebuildInParallel: boolean;
  27108. /**
  27109. * Instantiates a new standard material.
  27110. * This is the default material used in Babylon. It is the best trade off between quality
  27111. * and performances.
  27112. * @see http://doc.babylonjs.com/babylon101/materials
  27113. * @param name Define the name of the material in the scene
  27114. * @param scene Define the scene the material belong to
  27115. */
  27116. constructor(name: string, scene: Scene);
  27117. /**
  27118. * Gets a boolean indicating that current material needs to register RTT
  27119. */
  27120. readonly hasRenderTargetTextures: boolean;
  27121. /**
  27122. * Gets the current class name of the material e.g. "StandardMaterial"
  27123. * Mainly use in serialization.
  27124. * @returns the class name
  27125. */
  27126. getClassName(): string;
  27127. /**
  27128. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27129. * You can try switching to logarithmic depth.
  27130. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27131. */
  27132. useLogarithmicDepth: boolean;
  27133. /**
  27134. * Specifies if the material will require alpha blending
  27135. * @returns a boolean specifying if alpha blending is needed
  27136. */
  27137. needAlphaBlending(): boolean;
  27138. /**
  27139. * Specifies if this material should be rendered in alpha test mode
  27140. * @returns a boolean specifying if an alpha test is needed.
  27141. */
  27142. needAlphaTesting(): boolean;
  27143. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27144. /**
  27145. * Get the texture used for alpha test purpose.
  27146. * @returns the diffuse texture in case of the standard material.
  27147. */
  27148. getAlphaTestTexture(): Nullable<BaseTexture>;
  27149. /**
  27150. * Get if the submesh is ready to be used and all its information available.
  27151. * Child classes can use it to update shaders
  27152. * @param mesh defines the mesh to check
  27153. * @param subMesh defines which submesh to check
  27154. * @param useInstances specifies that instances should be used
  27155. * @returns a boolean indicating that the submesh is ready or not
  27156. */
  27157. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27158. /**
  27159. * Builds the material UBO layouts.
  27160. * Used internally during the effect preparation.
  27161. */
  27162. buildUniformLayout(): void;
  27163. /**
  27164. * Unbinds the material from the mesh
  27165. */
  27166. unbind(): void;
  27167. /**
  27168. * Binds the submesh to this material by preparing the effect and shader to draw
  27169. * @param world defines the world transformation matrix
  27170. * @param mesh defines the mesh containing the submesh
  27171. * @param subMesh defines the submesh to bind the material to
  27172. */
  27173. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27174. /**
  27175. * Get the list of animatables in the material.
  27176. * @returns the list of animatables object used in the material
  27177. */
  27178. getAnimatables(): IAnimatable[];
  27179. /**
  27180. * Gets the active textures from the material
  27181. * @returns an array of textures
  27182. */
  27183. getActiveTextures(): BaseTexture[];
  27184. /**
  27185. * Specifies if the material uses a texture
  27186. * @param texture defines the texture to check against the material
  27187. * @returns a boolean specifying if the material uses the texture
  27188. */
  27189. hasTexture(texture: BaseTexture): boolean;
  27190. /**
  27191. * Disposes the material
  27192. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27193. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27194. */
  27195. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27196. /**
  27197. * Makes a duplicate of the material, and gives it a new name
  27198. * @param name defines the new name for the duplicated material
  27199. * @returns the cloned material
  27200. */
  27201. clone(name: string): StandardMaterial;
  27202. /**
  27203. * Serializes this material in a JSON representation
  27204. * @returns the serialized material object
  27205. */
  27206. serialize(): any;
  27207. /**
  27208. * Creates a standard material from parsed material data
  27209. * @param source defines the JSON representation of the material
  27210. * @param scene defines the hosting scene
  27211. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27212. * @returns a new standard material
  27213. */
  27214. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27215. /**
  27216. * Are diffuse textures enabled in the application.
  27217. */
  27218. static DiffuseTextureEnabled: boolean;
  27219. /**
  27220. * Are ambient textures enabled in the application.
  27221. */
  27222. static AmbientTextureEnabled: boolean;
  27223. /**
  27224. * Are opacity textures enabled in the application.
  27225. */
  27226. static OpacityTextureEnabled: boolean;
  27227. /**
  27228. * Are reflection textures enabled in the application.
  27229. */
  27230. static ReflectionTextureEnabled: boolean;
  27231. /**
  27232. * Are emissive textures enabled in the application.
  27233. */
  27234. static EmissiveTextureEnabled: boolean;
  27235. /**
  27236. * Are specular textures enabled in the application.
  27237. */
  27238. static SpecularTextureEnabled: boolean;
  27239. /**
  27240. * Are bump textures enabled in the application.
  27241. */
  27242. static BumpTextureEnabled: boolean;
  27243. /**
  27244. * Are lightmap textures enabled in the application.
  27245. */
  27246. static LightmapTextureEnabled: boolean;
  27247. /**
  27248. * Are refraction textures enabled in the application.
  27249. */
  27250. static RefractionTextureEnabled: boolean;
  27251. /**
  27252. * Are color grading textures enabled in the application.
  27253. */
  27254. static ColorGradingTextureEnabled: boolean;
  27255. /**
  27256. * Are fresnels enabled in the application.
  27257. */
  27258. static FresnelEnabled: boolean;
  27259. }
  27260. }
  27261. declare module "babylonjs/Particles/solidParticleSystem" {
  27262. import { Nullable } from "babylonjs/types";
  27263. import { Vector3 } from "babylonjs/Maths/math.vector";
  27264. import { Mesh } from "babylonjs/Meshes/mesh";
  27265. import { Scene, IDisposable } from "babylonjs/scene";
  27266. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27267. import { Material } from "babylonjs/Materials/material";
  27268. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27269. /**
  27270. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27271. *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.
  27272. * The SPS is also a particle system. It provides some methods to manage the particles.
  27273. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27274. *
  27275. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27276. */
  27277. export class SolidParticleSystem implements IDisposable {
  27278. /**
  27279. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27280. * Example : var p = SPS.particles[i];
  27281. */
  27282. particles: SolidParticle[];
  27283. /**
  27284. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27285. */
  27286. nbParticles: number;
  27287. /**
  27288. * If the particles must ever face the camera (default false). Useful for planar particles.
  27289. */
  27290. billboard: boolean;
  27291. /**
  27292. * Recompute normals when adding a shape
  27293. */
  27294. recomputeNormals: boolean;
  27295. /**
  27296. * This a counter ofr your own usage. It's not set by any SPS functions.
  27297. */
  27298. counter: number;
  27299. /**
  27300. * The SPS name. This name is also given to the underlying mesh.
  27301. */
  27302. name: string;
  27303. /**
  27304. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27305. */
  27306. mesh: Mesh;
  27307. /**
  27308. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27309. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27310. */
  27311. vars: any;
  27312. /**
  27313. * This array is populated when the SPS is set as 'pickable'.
  27314. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27315. * Each element of this array is an object `{idx: int, faceId: int}`.
  27316. * `idx` is the picked particle index in the `SPS.particles` array
  27317. * `faceId` is the picked face index counted within this particle.
  27318. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27319. */
  27320. pickedParticles: {
  27321. idx: number;
  27322. faceId: number;
  27323. }[];
  27324. /**
  27325. * This array is populated when `enableDepthSort` is set to true.
  27326. * Each element of this array is an instance of the class DepthSortedParticle.
  27327. */
  27328. depthSortedParticles: DepthSortedParticle[];
  27329. /**
  27330. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27331. * @hidden
  27332. */
  27333. _bSphereOnly: boolean;
  27334. /**
  27335. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27336. * @hidden
  27337. */
  27338. _bSphereRadiusFactor: number;
  27339. private _scene;
  27340. private _positions;
  27341. private _indices;
  27342. private _normals;
  27343. private _colors;
  27344. private _uvs;
  27345. private _indices32;
  27346. private _positions32;
  27347. private _normals32;
  27348. private _fixedNormal32;
  27349. private _colors32;
  27350. private _uvs32;
  27351. private _index;
  27352. private _updatable;
  27353. private _pickable;
  27354. private _isVisibilityBoxLocked;
  27355. private _alwaysVisible;
  27356. private _depthSort;
  27357. private _expandable;
  27358. private _shapeCounter;
  27359. private _copy;
  27360. private _color;
  27361. private _computeParticleColor;
  27362. private _computeParticleTexture;
  27363. private _computeParticleRotation;
  27364. private _computeParticleVertex;
  27365. private _computeBoundingBox;
  27366. private _depthSortParticles;
  27367. private _camera;
  27368. private _mustUnrotateFixedNormals;
  27369. private _particlesIntersect;
  27370. private _needs32Bits;
  27371. private _isNotBuilt;
  27372. private _lastParticleId;
  27373. private _idxOfId;
  27374. private _multimaterialEnabled;
  27375. private _useModelMaterial;
  27376. private _indicesByMaterial;
  27377. private _materialIndexes;
  27378. private _depthSortFunction;
  27379. private _materialSortFunction;
  27380. private _materials;
  27381. private _multimaterial;
  27382. private _materialIndexesById;
  27383. private _defaultMaterial;
  27384. private _autoUpdateSubMeshes;
  27385. /**
  27386. * Creates a SPS (Solid Particle System) object.
  27387. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27388. * @param scene (Scene) is the scene in which the SPS is added.
  27389. * @param options defines the options of the sps e.g.
  27390. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27391. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27392. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27393. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  27394. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27395. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27396. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27397. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27398. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27399. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27400. */
  27401. constructor(name: string, scene: Scene, options?: {
  27402. updatable?: boolean;
  27403. isPickable?: boolean;
  27404. enableDepthSort?: boolean;
  27405. particleIntersection?: boolean;
  27406. boundingSphereOnly?: boolean;
  27407. bSphereRadiusFactor?: number;
  27408. expandable?: boolean;
  27409. useModelMaterial?: boolean;
  27410. enableMultiMaterial?: boolean;
  27411. });
  27412. /**
  27413. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27414. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27415. * @returns the created mesh
  27416. */
  27417. buildMesh(): Mesh;
  27418. /**
  27419. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27420. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27421. * Thus the particles generated from `digest()` have their property `position` set yet.
  27422. * @param mesh ( Mesh ) is the mesh to be digested
  27423. * @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
  27424. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27425. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27426. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27427. * @returns the current SPS
  27428. */
  27429. digest(mesh: Mesh, options?: {
  27430. facetNb?: number;
  27431. number?: number;
  27432. delta?: number;
  27433. storage?: [];
  27434. }): SolidParticleSystem;
  27435. /**
  27436. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27437. * @hidden
  27438. */
  27439. private _unrotateFixedNormals;
  27440. /**
  27441. * Resets the temporary working copy particle
  27442. * @hidden
  27443. */
  27444. private _resetCopy;
  27445. /**
  27446. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27447. * @param p the current index in the positions array to be updated
  27448. * @param ind the current index in the indices array
  27449. * @param shape a Vector3 array, the shape geometry
  27450. * @param positions the positions array to be updated
  27451. * @param meshInd the shape indices array
  27452. * @param indices the indices array to be updated
  27453. * @param meshUV the shape uv array
  27454. * @param uvs the uv array to be updated
  27455. * @param meshCol the shape color array
  27456. * @param colors the color array to be updated
  27457. * @param meshNor the shape normals array
  27458. * @param normals the normals array to be updated
  27459. * @param idx the particle index
  27460. * @param idxInShape the particle index in its shape
  27461. * @param options the addShape() method passed options
  27462. * @model the particle model
  27463. * @hidden
  27464. */
  27465. private _meshBuilder;
  27466. /**
  27467. * Returns a shape Vector3 array from positions float array
  27468. * @param positions float array
  27469. * @returns a vector3 array
  27470. * @hidden
  27471. */
  27472. private _posToShape;
  27473. /**
  27474. * Returns a shapeUV array from a float uvs (array deep copy)
  27475. * @param uvs as a float array
  27476. * @returns a shapeUV array
  27477. * @hidden
  27478. */
  27479. private _uvsToShapeUV;
  27480. /**
  27481. * Adds a new particle object in the particles array
  27482. * @param idx particle index in particles array
  27483. * @param id particle id
  27484. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27485. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27486. * @param model particle ModelShape object
  27487. * @param shapeId model shape identifier
  27488. * @param idxInShape index of the particle in the current model
  27489. * @param bInfo model bounding info object
  27490. * @param storage target storage array, if any
  27491. * @hidden
  27492. */
  27493. private _addParticle;
  27494. /**
  27495. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27496. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27497. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27498. * @param nb (positive integer) the number of particles to be created from this model
  27499. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27500. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27501. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27502. * @returns the number of shapes in the system
  27503. */
  27504. addShape(mesh: Mesh, nb: number, options?: {
  27505. positionFunction?: any;
  27506. vertexFunction?: any;
  27507. storage?: [];
  27508. }): number;
  27509. /**
  27510. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27511. * @hidden
  27512. */
  27513. private _rebuildParticle;
  27514. /**
  27515. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27516. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  27517. * @returns the SPS.
  27518. */
  27519. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27520. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27521. * Returns an array with the removed particles.
  27522. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  27523. * The SPS can't be empty so at least one particle needs to remain in place.
  27524. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27525. * @param start index of the first particle to remove
  27526. * @param end index of the last particle to remove (included)
  27527. * @returns an array populated with the removed particles
  27528. */
  27529. removeParticles(start: number, end: number): SolidParticle[];
  27530. /**
  27531. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27532. * @param solidParticleArray an array populated with Solid Particles objects
  27533. * @returns the SPS
  27534. */
  27535. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27536. /**
  27537. * Creates a new particle and modifies the SPS mesh geometry :
  27538. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27539. * - calls _addParticle() to populate the particle array
  27540. * factorized code from addShape() and insertParticlesFromArray()
  27541. * @param idx particle index in the particles array
  27542. * @param i particle index in its shape
  27543. * @param modelShape particle ModelShape object
  27544. * @param shape shape vertex array
  27545. * @param meshInd shape indices array
  27546. * @param meshUV shape uv array
  27547. * @param meshCol shape color array
  27548. * @param meshNor shape normals array
  27549. * @param bbInfo shape bounding info
  27550. * @param storage target particle storage
  27551. * @options addShape() passed options
  27552. * @hidden
  27553. */
  27554. private _insertNewParticle;
  27555. /**
  27556. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27557. * This method calls `updateParticle()` for each particle of the SPS.
  27558. * For an animated SPS, it is usually called within the render loop.
  27559. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  27560. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27561. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27562. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27563. * @returns the SPS.
  27564. */
  27565. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27566. /**
  27567. * Disposes the SPS.
  27568. */
  27569. dispose(): void;
  27570. /**
  27571. * Returns a SolidParticle object from its identifier : particle.id
  27572. * @param id (integer) the particle Id
  27573. * @returns the searched particle or null if not found in the SPS.
  27574. */
  27575. getParticleById(id: number): Nullable<SolidParticle>;
  27576. /**
  27577. * Returns a new array populated with the particles having the passed shapeId.
  27578. * @param shapeId (integer) the shape identifier
  27579. * @returns a new solid particle array
  27580. */
  27581. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27582. /**
  27583. * Populates the passed array "ref" with the particles having the passed shapeId.
  27584. * @param shapeId the shape identifier
  27585. * @returns the SPS
  27586. * @param ref
  27587. */
  27588. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27589. /**
  27590. * Computes the required SubMeshes according the materials assigned to the particles.
  27591. * @returns the solid particle system.
  27592. * Does nothing if called before the SPS mesh is built.
  27593. */
  27594. computeSubMeshes(): SolidParticleSystem;
  27595. /**
  27596. * Sorts the solid particles by material when MultiMaterial is enabled.
  27597. * Updates the indices32 array.
  27598. * Updates the indicesByMaterial array.
  27599. * Updates the mesh indices array.
  27600. * @returns the SPS
  27601. * @hidden
  27602. */
  27603. private _sortParticlesByMaterial;
  27604. /**
  27605. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27606. * @hidden
  27607. */
  27608. private _setMaterialIndexesById;
  27609. /**
  27610. * Returns an array with unique values of Materials from the passed array
  27611. * @param array the material array to be checked and filtered
  27612. * @hidden
  27613. */
  27614. private _filterUniqueMaterialId;
  27615. /**
  27616. * Sets a new Standard Material as _defaultMaterial if not already set.
  27617. * @hidden
  27618. */
  27619. private _setDefaultMaterial;
  27620. /**
  27621. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27622. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27623. * @returns the SPS.
  27624. */
  27625. refreshVisibleSize(): SolidParticleSystem;
  27626. /**
  27627. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27628. * @param size the size (float) of the visibility box
  27629. * note : this doesn't lock the SPS mesh bounding box.
  27630. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27631. */
  27632. setVisibilityBox(size: number): void;
  27633. /**
  27634. * Gets whether the SPS as always visible or not
  27635. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27636. */
  27637. /**
  27638. * Sets the SPS as always visible or not
  27639. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27640. */
  27641. isAlwaysVisible: boolean;
  27642. /**
  27643. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27644. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27645. */
  27646. /**
  27647. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27648. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27649. */
  27650. isVisibilityBoxLocked: boolean;
  27651. /**
  27652. * Tells to `setParticles()` to compute the particle rotations or not.
  27653. * Default value : true. The SPS is faster when it's set to false.
  27654. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27655. */
  27656. /**
  27657. * Gets if `setParticles()` computes the particle rotations or not.
  27658. * Default value : true. The SPS is faster when it's set to false.
  27659. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27660. */
  27661. computeParticleRotation: boolean;
  27662. /**
  27663. * Tells to `setParticles()` to compute the particle colors or not.
  27664. * Default value : true. The SPS is faster when it's set to false.
  27665. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27666. */
  27667. /**
  27668. * Gets if `setParticles()` computes the particle colors or not.
  27669. * Default value : true. The SPS is faster when it's set to false.
  27670. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27671. */
  27672. computeParticleColor: boolean;
  27673. /**
  27674. * Gets if `setParticles()` computes the particle textures or not.
  27675. * Default value : true. The SPS is faster when it's set to false.
  27676. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27677. */
  27678. computeParticleTexture: boolean;
  27679. /**
  27680. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27681. * Default value : false. The SPS is faster when it's set to false.
  27682. * Note : the particle custom vertex positions aren't stored values.
  27683. */
  27684. /**
  27685. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27686. * Default value : false. The SPS is faster when it's set to false.
  27687. * Note : the particle custom vertex positions aren't stored values.
  27688. */
  27689. computeParticleVertex: boolean;
  27690. /**
  27691. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27692. */
  27693. /**
  27694. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27695. */
  27696. computeBoundingBox: boolean;
  27697. /**
  27698. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27699. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27700. * Default : `true`
  27701. */
  27702. /**
  27703. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27704. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27705. * Default : `true`
  27706. */
  27707. depthSortParticles: boolean;
  27708. /**
  27709. * Gets if the SPS is created as expandable at construction time.
  27710. * Default : `false`
  27711. */
  27712. readonly expandable: boolean;
  27713. /**
  27714. * Gets if the SPS supports the Multi Materials
  27715. */
  27716. readonly multimaterialEnabled: boolean;
  27717. /**
  27718. * Gets if the SPS uses the model materials for its own multimaterial.
  27719. */
  27720. readonly useModelMaterial: boolean;
  27721. /**
  27722. * The SPS used material array.
  27723. */
  27724. readonly materials: Material[];
  27725. /**
  27726. * Sets the SPS MultiMaterial from the passed materials.
  27727. * Note : the passed array is internally copied and not used then by reference.
  27728. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27729. */
  27730. setMultiMaterial(materials: Material[]): void;
  27731. /**
  27732. * The SPS computed multimaterial object
  27733. */
  27734. multimaterial: MultiMaterial;
  27735. /**
  27736. * If the subMeshes must be updated on the next call to setParticles()
  27737. */
  27738. autoUpdateSubMeshes: boolean;
  27739. /**
  27740. * This function does nothing. It may be overwritten to set all the particle first values.
  27741. * The SPS doesn't call this function, you may have to call it by your own.
  27742. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27743. */
  27744. initParticles(): void;
  27745. /**
  27746. * This function does nothing. It may be overwritten to recycle a particle.
  27747. * The SPS doesn't call this function, you may have to call it by your own.
  27748. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27749. * @param particle The particle to recycle
  27750. * @returns the recycled particle
  27751. */
  27752. recycleParticle(particle: SolidParticle): SolidParticle;
  27753. /**
  27754. * Updates a particle : this function should be overwritten by the user.
  27755. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27756. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27757. * @example : just set a particle position or velocity and recycle conditions
  27758. * @param particle The particle to update
  27759. * @returns the updated particle
  27760. */
  27761. updateParticle(particle: SolidParticle): SolidParticle;
  27762. /**
  27763. * Updates a vertex of a particle : it can be overwritten by the user.
  27764. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27765. * @param particle the current particle
  27766. * @param vertex the current index of the current particle
  27767. * @param pt the index of the current vertex in the particle shape
  27768. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27769. * @example : just set a vertex particle position
  27770. * @returns the updated vertex
  27771. */
  27772. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27773. /**
  27774. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27775. * This does nothing and may be overwritten by the user.
  27776. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27777. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27778. * @param update the boolean update value actually passed to setParticles()
  27779. */
  27780. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27781. /**
  27782. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27783. * This will be passed three parameters.
  27784. * This does nothing and may be overwritten by the user.
  27785. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27786. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27787. * @param update the boolean update value actually passed to setParticles()
  27788. */
  27789. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27790. }
  27791. }
  27792. declare module "babylonjs/Particles/solidParticle" {
  27793. import { Nullable } from "babylonjs/types";
  27794. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  27795. import { Color4 } from "babylonjs/Maths/math.color";
  27796. import { Mesh } from "babylonjs/Meshes/mesh";
  27797. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27798. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  27799. import { Plane } from "babylonjs/Maths/math.plane";
  27800. import { Material } from "babylonjs/Materials/material";
  27801. /**
  27802. * Represents one particle of a solid particle system.
  27803. */
  27804. export class SolidParticle {
  27805. /**
  27806. * particle global index
  27807. */
  27808. idx: number;
  27809. /**
  27810. * particle identifier
  27811. */
  27812. id: number;
  27813. /**
  27814. * The color of the particle
  27815. */
  27816. color: Nullable<Color4>;
  27817. /**
  27818. * The world space position of the particle.
  27819. */
  27820. position: Vector3;
  27821. /**
  27822. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27823. */
  27824. rotation: Vector3;
  27825. /**
  27826. * The world space rotation quaternion of the particle.
  27827. */
  27828. rotationQuaternion: Nullable<Quaternion>;
  27829. /**
  27830. * The scaling of the particle.
  27831. */
  27832. scaling: Vector3;
  27833. /**
  27834. * The uvs of the particle.
  27835. */
  27836. uvs: Vector4;
  27837. /**
  27838. * The current speed of the particle.
  27839. */
  27840. velocity: Vector3;
  27841. /**
  27842. * The pivot point in the particle local space.
  27843. */
  27844. pivot: Vector3;
  27845. /**
  27846. * Must the particle be translated from its pivot point in its local space ?
  27847. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27848. * Default : false
  27849. */
  27850. translateFromPivot: boolean;
  27851. /**
  27852. * Is the particle active or not ?
  27853. */
  27854. alive: boolean;
  27855. /**
  27856. * Is the particle visible or not ?
  27857. */
  27858. isVisible: boolean;
  27859. /**
  27860. * Index of this particle in the global "positions" array (Internal use)
  27861. * @hidden
  27862. */
  27863. _pos: number;
  27864. /**
  27865. * @hidden Index of this particle in the global "indices" array (Internal use)
  27866. */
  27867. _ind: number;
  27868. /**
  27869. * @hidden ModelShape of this particle (Internal use)
  27870. */
  27871. _model: ModelShape;
  27872. /**
  27873. * ModelShape id of this particle
  27874. */
  27875. shapeId: number;
  27876. /**
  27877. * Index of the particle in its shape id
  27878. */
  27879. idxInShape: number;
  27880. /**
  27881. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27882. */
  27883. _modelBoundingInfo: BoundingInfo;
  27884. /**
  27885. * @hidden Particle BoundingInfo object (Internal use)
  27886. */
  27887. _boundingInfo: BoundingInfo;
  27888. /**
  27889. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27890. */
  27891. _sps: SolidParticleSystem;
  27892. /**
  27893. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27894. */
  27895. _stillInvisible: boolean;
  27896. /**
  27897. * @hidden Last computed particle rotation matrix
  27898. */
  27899. _rotationMatrix: number[];
  27900. /**
  27901. * Parent particle Id, if any.
  27902. * Default null.
  27903. */
  27904. parentId: Nullable<number>;
  27905. /**
  27906. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27907. */
  27908. materialIndex: Nullable<number>;
  27909. /**
  27910. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27911. * The possible values are :
  27912. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27913. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27914. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27915. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27916. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27917. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27918. * */
  27919. cullingStrategy: number;
  27920. /**
  27921. * @hidden Internal global position in the SPS.
  27922. */
  27923. _globalPosition: Vector3;
  27924. /**
  27925. * Creates a Solid Particle object.
  27926. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27927. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27928. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27929. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27930. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27931. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27932. * @param shapeId (integer) is the model shape identifier in the SPS.
  27933. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27934. * @param sps defines the sps it is associated to
  27935. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27936. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27937. */
  27938. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27939. /**
  27940. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27941. * @param target the particle target
  27942. * @returns the current particle
  27943. */
  27944. copyToRef(target: SolidParticle): SolidParticle;
  27945. /**
  27946. * Legacy support, changed scale to scaling
  27947. */
  27948. /**
  27949. * Legacy support, changed scale to scaling
  27950. */
  27951. scale: Vector3;
  27952. /**
  27953. * Legacy support, changed quaternion to rotationQuaternion
  27954. */
  27955. /**
  27956. * Legacy support, changed quaternion to rotationQuaternion
  27957. */
  27958. quaternion: Nullable<Quaternion>;
  27959. /**
  27960. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27961. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27962. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27963. * @returns true if it intersects
  27964. */
  27965. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27966. /**
  27967. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27968. * A particle is in the frustum if its bounding box intersects the frustum
  27969. * @param frustumPlanes defines the frustum to test
  27970. * @returns true if the particle is in the frustum planes
  27971. */
  27972. isInFrustum(frustumPlanes: Plane[]): boolean;
  27973. /**
  27974. * get the rotation matrix of the particle
  27975. * @hidden
  27976. */
  27977. getRotationMatrix(m: Matrix): void;
  27978. }
  27979. /**
  27980. * Represents the shape of the model used by one particle of a solid particle system.
  27981. * SPS internal tool, don't use it manually.
  27982. */
  27983. export class ModelShape {
  27984. /**
  27985. * The shape id
  27986. * @hidden
  27987. */
  27988. shapeID: number;
  27989. /**
  27990. * flat array of model positions (internal use)
  27991. * @hidden
  27992. */
  27993. _shape: Vector3[];
  27994. /**
  27995. * flat array of model UVs (internal use)
  27996. * @hidden
  27997. */
  27998. _shapeUV: number[];
  27999. /**
  28000. * color array of the model
  28001. * @hidden
  28002. */
  28003. _shapeColors: number[];
  28004. /**
  28005. * indices array of the model
  28006. * @hidden
  28007. */
  28008. _indices: number[];
  28009. /**
  28010. * normals array of the model
  28011. * @hidden
  28012. */
  28013. _normals: number[];
  28014. /**
  28015. * length of the shape in the model indices array (internal use)
  28016. * @hidden
  28017. */
  28018. _indicesLength: number;
  28019. /**
  28020. * Custom position function (internal use)
  28021. * @hidden
  28022. */
  28023. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28024. /**
  28025. * Custom vertex function (internal use)
  28026. * @hidden
  28027. */
  28028. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28029. /**
  28030. * Model material (internal use)
  28031. * @hidden
  28032. */
  28033. _material: Nullable<Material>;
  28034. /**
  28035. * 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.
  28036. * SPS internal tool, don't use it manually.
  28037. * @hidden
  28038. */
  28039. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  28040. }
  28041. /**
  28042. * Represents a Depth Sorted Particle in the solid particle system.
  28043. * @hidden
  28044. */
  28045. export class DepthSortedParticle {
  28046. /**
  28047. * Index of the particle in the "indices" array
  28048. */
  28049. ind: number;
  28050. /**
  28051. * Length of the particle shape in the "indices" array
  28052. */
  28053. indicesLength: number;
  28054. /**
  28055. * Squared distance from the particle to the camera
  28056. */
  28057. sqDistance: number;
  28058. /**
  28059. * Material index when used with MultiMaterials
  28060. */
  28061. materialIndex: number;
  28062. /**
  28063. * Creates a new sorted particle
  28064. * @param materialIndex
  28065. */
  28066. constructor(ind: number, indLength: number, materialIndex: number);
  28067. }
  28068. }
  28069. declare module "babylonjs/Collisions/meshCollisionData" {
  28070. import { Collider } from "babylonjs/Collisions/collider";
  28071. import { Vector3 } from "babylonjs/Maths/math.vector";
  28072. import { Nullable } from "babylonjs/types";
  28073. import { Observer } from "babylonjs/Misc/observable";
  28074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28075. /**
  28076. * @hidden
  28077. */
  28078. export class _MeshCollisionData {
  28079. _checkCollisions: boolean;
  28080. _collisionMask: number;
  28081. _collisionGroup: number;
  28082. _collider: Nullable<Collider>;
  28083. _oldPositionForCollisions: Vector3;
  28084. _diffPositionForCollisions: Vector3;
  28085. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28086. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28087. }
  28088. }
  28089. declare module "babylonjs/Meshes/abstractMesh" {
  28090. import { Observable } from "babylonjs/Misc/observable";
  28091. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28092. import { Camera } from "babylonjs/Cameras/camera";
  28093. import { Scene, IDisposable } from "babylonjs/scene";
  28094. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28095. import { Node } from "babylonjs/node";
  28096. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28097. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28098. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28099. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28100. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28101. import { Material } from "babylonjs/Materials/material";
  28102. import { Light } from "babylonjs/Lights/light";
  28103. import { Skeleton } from "babylonjs/Bones/skeleton";
  28104. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28105. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28106. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28107. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28108. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28109. import { Plane } from "babylonjs/Maths/math.plane";
  28110. import { Ray } from "babylonjs/Culling/ray";
  28111. import { Collider } from "babylonjs/Collisions/collider";
  28112. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28113. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28114. /** @hidden */
  28115. class _FacetDataStorage {
  28116. facetPositions: Vector3[];
  28117. facetNormals: Vector3[];
  28118. facetPartitioning: number[][];
  28119. facetNb: number;
  28120. partitioningSubdivisions: number;
  28121. partitioningBBoxRatio: number;
  28122. facetDataEnabled: boolean;
  28123. facetParameters: any;
  28124. bbSize: Vector3;
  28125. subDiv: {
  28126. max: number;
  28127. X: number;
  28128. Y: number;
  28129. Z: number;
  28130. };
  28131. facetDepthSort: boolean;
  28132. facetDepthSortEnabled: boolean;
  28133. depthSortedIndices: IndicesArray;
  28134. depthSortedFacets: {
  28135. ind: number;
  28136. sqDistance: number;
  28137. }[];
  28138. facetDepthSortFunction: (f1: {
  28139. ind: number;
  28140. sqDistance: number;
  28141. }, f2: {
  28142. ind: number;
  28143. sqDistance: number;
  28144. }) => number;
  28145. facetDepthSortFrom: Vector3;
  28146. facetDepthSortOrigin: Vector3;
  28147. invertedMatrix: Matrix;
  28148. }
  28149. /**
  28150. * @hidden
  28151. **/
  28152. class _InternalAbstractMeshDataInfo {
  28153. _hasVertexAlpha: boolean;
  28154. _useVertexColors: boolean;
  28155. _numBoneInfluencers: number;
  28156. _applyFog: boolean;
  28157. _receiveShadows: boolean;
  28158. _facetData: _FacetDataStorage;
  28159. _visibility: number;
  28160. _skeleton: Nullable<Skeleton>;
  28161. _layerMask: number;
  28162. _computeBonesUsingShaders: boolean;
  28163. _isActive: boolean;
  28164. _onlyForInstances: boolean;
  28165. _isActiveIntermediate: boolean;
  28166. _onlyForInstancesIntermediate: boolean;
  28167. _actAsRegularMesh: boolean;
  28168. }
  28169. /**
  28170. * Class used to store all common mesh properties
  28171. */
  28172. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28173. /** No occlusion */
  28174. static OCCLUSION_TYPE_NONE: number;
  28175. /** Occlusion set to optimisitic */
  28176. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28177. /** Occlusion set to strict */
  28178. static OCCLUSION_TYPE_STRICT: number;
  28179. /** Use an accurante occlusion algorithm */
  28180. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28181. /** Use a conservative occlusion algorithm */
  28182. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28183. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28184. * Test order :
  28185. * Is the bounding sphere outside the frustum ?
  28186. * If not, are the bounding box vertices outside the frustum ?
  28187. * It not, then the cullable object is in the frustum.
  28188. */
  28189. static readonly CULLINGSTRATEGY_STANDARD: number;
  28190. /** Culling strategy : Bounding Sphere Only.
  28191. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28192. * It's also less accurate than the standard because some not visible objects can still be selected.
  28193. * Test : is the bounding sphere outside the frustum ?
  28194. * If not, then the cullable object is in the frustum.
  28195. */
  28196. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28197. /** Culling strategy : Optimistic Inclusion.
  28198. * This in an inclusion test first, then the standard exclusion test.
  28199. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28200. * 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.
  28201. * Anyway, it's as accurate as the standard strategy.
  28202. * Test :
  28203. * Is the cullable object bounding sphere center in the frustum ?
  28204. * If not, apply the default culling strategy.
  28205. */
  28206. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28207. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28208. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28209. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28210. * 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.
  28211. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28212. * Test :
  28213. * Is the cullable object bounding sphere center in the frustum ?
  28214. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28215. */
  28216. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28217. /**
  28218. * No billboard
  28219. */
  28220. static readonly BILLBOARDMODE_NONE: number;
  28221. /** Billboard on X axis */
  28222. static readonly BILLBOARDMODE_X: number;
  28223. /** Billboard on Y axis */
  28224. static readonly BILLBOARDMODE_Y: number;
  28225. /** Billboard on Z axis */
  28226. static readonly BILLBOARDMODE_Z: number;
  28227. /** Billboard on all axes */
  28228. static readonly BILLBOARDMODE_ALL: number;
  28229. /** Billboard on using position instead of orientation */
  28230. static readonly BILLBOARDMODE_USE_POSITION: number;
  28231. /** @hidden */
  28232. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28233. /**
  28234. * The culling strategy to use to check whether the mesh must be rendered or not.
  28235. * This value can be changed at any time and will be used on the next render mesh selection.
  28236. * The possible values are :
  28237. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28238. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28239. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28240. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28241. * Please read each static variable documentation to get details about the culling process.
  28242. * */
  28243. cullingStrategy: number;
  28244. /**
  28245. * Gets the number of facets in the mesh
  28246. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28247. */
  28248. readonly facetNb: number;
  28249. /**
  28250. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28251. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28252. */
  28253. partitioningSubdivisions: number;
  28254. /**
  28255. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28256. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28257. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28258. */
  28259. partitioningBBoxRatio: number;
  28260. /**
  28261. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28262. * Works only for updatable meshes.
  28263. * Doesn't work with multi-materials
  28264. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28265. */
  28266. mustDepthSortFacets: boolean;
  28267. /**
  28268. * The location (Vector3) where the facet depth sort must be computed from.
  28269. * By default, the active camera position.
  28270. * Used only when facet depth sort is enabled
  28271. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28272. */
  28273. facetDepthSortFrom: Vector3;
  28274. /**
  28275. * gets a boolean indicating if facetData is enabled
  28276. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28277. */
  28278. readonly isFacetDataEnabled: boolean;
  28279. /** @hidden */
  28280. _updateNonUniformScalingState(value: boolean): boolean;
  28281. /**
  28282. * An event triggered when this mesh collides with another one
  28283. */
  28284. onCollideObservable: Observable<AbstractMesh>;
  28285. /** Set a function to call when this mesh collides with another one */
  28286. onCollide: () => void;
  28287. /**
  28288. * An event triggered when the collision's position changes
  28289. */
  28290. onCollisionPositionChangeObservable: Observable<Vector3>;
  28291. /** Set a function to call when the collision's position changes */
  28292. onCollisionPositionChange: () => void;
  28293. /**
  28294. * An event triggered when material is changed
  28295. */
  28296. onMaterialChangedObservable: Observable<AbstractMesh>;
  28297. /**
  28298. * Gets or sets the orientation for POV movement & rotation
  28299. */
  28300. definedFacingForward: boolean;
  28301. /** @hidden */
  28302. _occlusionQuery: Nullable<WebGLQuery>;
  28303. /** @hidden */
  28304. _renderingGroup: Nullable<RenderingGroup>;
  28305. /**
  28306. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28307. */
  28308. /**
  28309. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28310. */
  28311. visibility: number;
  28312. /** Gets or sets the alpha index used to sort transparent meshes
  28313. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28314. */
  28315. alphaIndex: number;
  28316. /**
  28317. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28318. */
  28319. isVisible: boolean;
  28320. /**
  28321. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28322. */
  28323. isPickable: boolean;
  28324. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28325. showSubMeshesBoundingBox: boolean;
  28326. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28327. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28328. */
  28329. isBlocker: boolean;
  28330. /**
  28331. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28332. */
  28333. enablePointerMoveEvents: boolean;
  28334. /**
  28335. * Specifies the rendering group id for this mesh (0 by default)
  28336. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28337. */
  28338. renderingGroupId: number;
  28339. private _material;
  28340. /** Gets or sets current material */
  28341. material: Nullable<Material>;
  28342. /**
  28343. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28344. * @see http://doc.babylonjs.com/babylon101/shadows
  28345. */
  28346. receiveShadows: boolean;
  28347. /** Defines color to use when rendering outline */
  28348. outlineColor: Color3;
  28349. /** Define width to use when rendering outline */
  28350. outlineWidth: number;
  28351. /** Defines color to use when rendering overlay */
  28352. overlayColor: Color3;
  28353. /** Defines alpha to use when rendering overlay */
  28354. overlayAlpha: number;
  28355. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28356. hasVertexAlpha: boolean;
  28357. /** 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) */
  28358. useVertexColors: boolean;
  28359. /**
  28360. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28361. */
  28362. computeBonesUsingShaders: boolean;
  28363. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28364. numBoneInfluencers: number;
  28365. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28366. applyFog: boolean;
  28367. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28368. useOctreeForRenderingSelection: boolean;
  28369. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28370. useOctreeForPicking: boolean;
  28371. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28372. useOctreeForCollisions: boolean;
  28373. /**
  28374. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28375. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28376. */
  28377. layerMask: number;
  28378. /**
  28379. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28380. */
  28381. alwaysSelectAsActiveMesh: boolean;
  28382. /**
  28383. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28384. */
  28385. doNotSyncBoundingInfo: boolean;
  28386. /**
  28387. * Gets or sets the current action manager
  28388. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28389. */
  28390. actionManager: Nullable<AbstractActionManager>;
  28391. private _meshCollisionData;
  28392. /**
  28393. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28394. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28395. */
  28396. ellipsoid: Vector3;
  28397. /**
  28398. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28399. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28400. */
  28401. ellipsoidOffset: Vector3;
  28402. /**
  28403. * Gets or sets a collision mask used to mask collisions (default is -1).
  28404. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28405. */
  28406. collisionMask: number;
  28407. /**
  28408. * Gets or sets the current collision group mask (-1 by default).
  28409. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28410. */
  28411. collisionGroup: number;
  28412. /**
  28413. * Defines edge width used when edgesRenderer is enabled
  28414. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28415. */
  28416. edgesWidth: number;
  28417. /**
  28418. * Defines edge color used when edgesRenderer is enabled
  28419. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28420. */
  28421. edgesColor: Color4;
  28422. /** @hidden */
  28423. _edgesRenderer: Nullable<IEdgesRenderer>;
  28424. /** @hidden */
  28425. _masterMesh: Nullable<AbstractMesh>;
  28426. /** @hidden */
  28427. _boundingInfo: Nullable<BoundingInfo>;
  28428. /** @hidden */
  28429. _renderId: number;
  28430. /**
  28431. * Gets or sets the list of subMeshes
  28432. * @see http://doc.babylonjs.com/how_to/multi_materials
  28433. */
  28434. subMeshes: SubMesh[];
  28435. /** @hidden */
  28436. _intersectionsInProgress: AbstractMesh[];
  28437. /** @hidden */
  28438. _unIndexed: boolean;
  28439. /** @hidden */
  28440. _lightSources: Light[];
  28441. /** Gets the list of lights affecting that mesh */
  28442. readonly lightSources: Light[];
  28443. /** @hidden */
  28444. readonly _positions: Nullable<Vector3[]>;
  28445. /** @hidden */
  28446. _waitingData: {
  28447. lods: Nullable<any>;
  28448. actions: Nullable<any>;
  28449. freezeWorldMatrix: Nullable<boolean>;
  28450. };
  28451. /** @hidden */
  28452. _bonesTransformMatrices: Nullable<Float32Array>;
  28453. /** @hidden */
  28454. _transformMatrixTexture: Nullable<RawTexture>;
  28455. /**
  28456. * Gets or sets a skeleton to apply skining transformations
  28457. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28458. */
  28459. skeleton: Nullable<Skeleton>;
  28460. /**
  28461. * An event triggered when the mesh is rebuilt.
  28462. */
  28463. onRebuildObservable: Observable<AbstractMesh>;
  28464. /**
  28465. * Creates a new AbstractMesh
  28466. * @param name defines the name of the mesh
  28467. * @param scene defines the hosting scene
  28468. */
  28469. constructor(name: string, scene?: Nullable<Scene>);
  28470. /**
  28471. * Returns the string "AbstractMesh"
  28472. * @returns "AbstractMesh"
  28473. */
  28474. getClassName(): string;
  28475. /**
  28476. * Gets a string representation of the current mesh
  28477. * @param fullDetails defines a boolean indicating if full details must be included
  28478. * @returns a string representation of the current mesh
  28479. */
  28480. toString(fullDetails?: boolean): string;
  28481. /**
  28482. * @hidden
  28483. */
  28484. protected _getEffectiveParent(): Nullable<Node>;
  28485. /** @hidden */
  28486. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28487. /** @hidden */
  28488. _rebuild(): void;
  28489. /** @hidden */
  28490. _resyncLightSources(): void;
  28491. /** @hidden */
  28492. _resyncLightSource(light: Light): void;
  28493. /** @hidden */
  28494. _unBindEffect(): void;
  28495. /** @hidden */
  28496. _removeLightSource(light: Light, dispose: boolean): void;
  28497. private _markSubMeshesAsDirty;
  28498. /** @hidden */
  28499. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28500. /** @hidden */
  28501. _markSubMeshesAsAttributesDirty(): void;
  28502. /** @hidden */
  28503. _markSubMeshesAsMiscDirty(): void;
  28504. /**
  28505. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28506. */
  28507. scaling: Vector3;
  28508. /**
  28509. * Returns true if the mesh is blocked. Implemented by child classes
  28510. */
  28511. readonly isBlocked: boolean;
  28512. /**
  28513. * Returns the mesh itself by default. Implemented by child classes
  28514. * @param camera defines the camera to use to pick the right LOD level
  28515. * @returns the currentAbstractMesh
  28516. */
  28517. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28518. /**
  28519. * Returns 0 by default. Implemented by child classes
  28520. * @returns an integer
  28521. */
  28522. getTotalVertices(): number;
  28523. /**
  28524. * Returns a positive integer : the total number of indices in this mesh geometry.
  28525. * @returns the numner of indices or zero if the mesh has no geometry.
  28526. */
  28527. getTotalIndices(): number;
  28528. /**
  28529. * Returns null by default. Implemented by child classes
  28530. * @returns null
  28531. */
  28532. getIndices(): Nullable<IndicesArray>;
  28533. /**
  28534. * Returns the array of the requested vertex data kind. Implemented by child classes
  28535. * @param kind defines the vertex data kind to use
  28536. * @returns null
  28537. */
  28538. getVerticesData(kind: string): Nullable<FloatArray>;
  28539. /**
  28540. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28541. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28542. * Note that a new underlying VertexBuffer object is created each call.
  28543. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28544. * @param kind defines vertex data kind:
  28545. * * VertexBuffer.PositionKind
  28546. * * VertexBuffer.UVKind
  28547. * * VertexBuffer.UV2Kind
  28548. * * VertexBuffer.UV3Kind
  28549. * * VertexBuffer.UV4Kind
  28550. * * VertexBuffer.UV5Kind
  28551. * * VertexBuffer.UV6Kind
  28552. * * VertexBuffer.ColorKind
  28553. * * VertexBuffer.MatricesIndicesKind
  28554. * * VertexBuffer.MatricesIndicesExtraKind
  28555. * * VertexBuffer.MatricesWeightsKind
  28556. * * VertexBuffer.MatricesWeightsExtraKind
  28557. * @param data defines the data source
  28558. * @param updatable defines if the data must be flagged as updatable (or static)
  28559. * @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
  28560. * @returns the current mesh
  28561. */
  28562. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28563. /**
  28564. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28565. * If the mesh has no geometry, it is simply returned as it is.
  28566. * @param kind defines vertex data kind:
  28567. * * VertexBuffer.PositionKind
  28568. * * VertexBuffer.UVKind
  28569. * * VertexBuffer.UV2Kind
  28570. * * VertexBuffer.UV3Kind
  28571. * * VertexBuffer.UV4Kind
  28572. * * VertexBuffer.UV5Kind
  28573. * * VertexBuffer.UV6Kind
  28574. * * VertexBuffer.ColorKind
  28575. * * VertexBuffer.MatricesIndicesKind
  28576. * * VertexBuffer.MatricesIndicesExtraKind
  28577. * * VertexBuffer.MatricesWeightsKind
  28578. * * VertexBuffer.MatricesWeightsExtraKind
  28579. * @param data defines the data source
  28580. * @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
  28581. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28582. * @returns the current mesh
  28583. */
  28584. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28585. /**
  28586. * Sets the mesh indices,
  28587. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28588. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28589. * @param totalVertices Defines the total number of vertices
  28590. * @returns the current mesh
  28591. */
  28592. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28593. /**
  28594. * Gets a boolean indicating if specific vertex data is present
  28595. * @param kind defines the vertex data kind to use
  28596. * @returns true is data kind is present
  28597. */
  28598. isVerticesDataPresent(kind: string): boolean;
  28599. /**
  28600. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28601. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28602. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28603. * @returns a BoundingInfo
  28604. */
  28605. getBoundingInfo(): BoundingInfo;
  28606. /**
  28607. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28608. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28609. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28610. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28611. * @returns the current mesh
  28612. */
  28613. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28614. /**
  28615. * Overwrite the current bounding info
  28616. * @param boundingInfo defines the new bounding info
  28617. * @returns the current mesh
  28618. */
  28619. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28620. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28621. readonly useBones: boolean;
  28622. /** @hidden */
  28623. _preActivate(): void;
  28624. /** @hidden */
  28625. _preActivateForIntermediateRendering(renderId: number): void;
  28626. /** @hidden */
  28627. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28628. /** @hidden */
  28629. _postActivate(): void;
  28630. /** @hidden */
  28631. _freeze(): void;
  28632. /** @hidden */
  28633. _unFreeze(): void;
  28634. /**
  28635. * Gets the current world matrix
  28636. * @returns a Matrix
  28637. */
  28638. getWorldMatrix(): Matrix;
  28639. /** @hidden */
  28640. _getWorldMatrixDeterminant(): number;
  28641. /**
  28642. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28643. */
  28644. readonly isAnInstance: boolean;
  28645. /**
  28646. * Gets a boolean indicating if this mesh has instances
  28647. */
  28648. readonly hasInstances: boolean;
  28649. /**
  28650. * Perform relative position change from the point of view of behind the front of the mesh.
  28651. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28652. * Supports definition of mesh facing forward or backward
  28653. * @param amountRight defines the distance on the right axis
  28654. * @param amountUp defines the distance on the up axis
  28655. * @param amountForward defines the distance on the forward axis
  28656. * @returns the current mesh
  28657. */
  28658. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28659. /**
  28660. * Calculate relative position change from the point of view of behind the front of the mesh.
  28661. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28662. * Supports definition of mesh facing forward or backward
  28663. * @param amountRight defines the distance on the right axis
  28664. * @param amountUp defines the distance on the up axis
  28665. * @param amountForward defines the distance on the forward axis
  28666. * @returns the new displacement vector
  28667. */
  28668. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28669. /**
  28670. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28671. * Supports definition of mesh facing forward or backward
  28672. * @param flipBack defines the flip
  28673. * @param twirlClockwise defines the twirl
  28674. * @param tiltRight defines the tilt
  28675. * @returns the current mesh
  28676. */
  28677. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28678. /**
  28679. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28680. * Supports definition of mesh facing forward or backward.
  28681. * @param flipBack defines the flip
  28682. * @param twirlClockwise defines the twirl
  28683. * @param tiltRight defines the tilt
  28684. * @returns the new rotation vector
  28685. */
  28686. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28687. /**
  28688. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28689. * This means the mesh underlying bounding box and sphere are recomputed.
  28690. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28691. * @returns the current mesh
  28692. */
  28693. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28694. /** @hidden */
  28695. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28696. /** @hidden */
  28697. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28698. /** @hidden */
  28699. _updateBoundingInfo(): AbstractMesh;
  28700. /** @hidden */
  28701. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28702. /** @hidden */
  28703. protected _afterComputeWorldMatrix(): void;
  28704. /** @hidden */
  28705. readonly _effectiveMesh: AbstractMesh;
  28706. /**
  28707. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28708. * A mesh is in the frustum if its bounding box intersects the frustum
  28709. * @param frustumPlanes defines the frustum to test
  28710. * @returns true if the mesh is in the frustum planes
  28711. */
  28712. isInFrustum(frustumPlanes: Plane[]): boolean;
  28713. /**
  28714. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28715. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28716. * @param frustumPlanes defines the frustum to test
  28717. * @returns true if the mesh is completely in the frustum planes
  28718. */
  28719. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28720. /**
  28721. * True if the mesh intersects another mesh or a SolidParticle object
  28722. * @param mesh defines a target mesh or SolidParticle to test
  28723. * @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)
  28724. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28725. * @returns true if there is an intersection
  28726. */
  28727. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28728. /**
  28729. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28730. * @param point defines the point to test
  28731. * @returns true if there is an intersection
  28732. */
  28733. intersectsPoint(point: Vector3): boolean;
  28734. /**
  28735. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28736. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28737. */
  28738. checkCollisions: boolean;
  28739. /**
  28740. * Gets Collider object used to compute collisions (not physics)
  28741. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28742. */
  28743. readonly collider: Nullable<Collider>;
  28744. /**
  28745. * Move the mesh using collision engine
  28746. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28747. * @param displacement defines the requested displacement vector
  28748. * @returns the current mesh
  28749. */
  28750. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28751. private _onCollisionPositionChange;
  28752. /** @hidden */
  28753. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28754. /** @hidden */
  28755. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28756. /** @hidden */
  28757. _checkCollision(collider: Collider): AbstractMesh;
  28758. /** @hidden */
  28759. _generatePointsArray(): boolean;
  28760. /**
  28761. * Checks if the passed Ray intersects with the mesh
  28762. * @param ray defines the ray to use
  28763. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28764. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28765. * @returns the picking info
  28766. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28767. */
  28768. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28769. /**
  28770. * Clones the current mesh
  28771. * @param name defines the mesh name
  28772. * @param newParent defines the new mesh parent
  28773. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28774. * @returns the new mesh
  28775. */
  28776. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28777. /**
  28778. * Disposes all the submeshes of the current meshnp
  28779. * @returns the current mesh
  28780. */
  28781. releaseSubMeshes(): AbstractMesh;
  28782. /**
  28783. * Releases resources associated with this abstract mesh.
  28784. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28785. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28786. */
  28787. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28788. /**
  28789. * Adds the passed mesh as a child to the current mesh
  28790. * @param mesh defines the child mesh
  28791. * @returns the current mesh
  28792. */
  28793. addChild(mesh: AbstractMesh): AbstractMesh;
  28794. /**
  28795. * Removes the passed mesh from the current mesh children list
  28796. * @param mesh defines the child mesh
  28797. * @returns the current mesh
  28798. */
  28799. removeChild(mesh: AbstractMesh): AbstractMesh;
  28800. /** @hidden */
  28801. private _initFacetData;
  28802. /**
  28803. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28804. * This method can be called within the render loop.
  28805. * 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
  28806. * @returns the current mesh
  28807. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28808. */
  28809. updateFacetData(): AbstractMesh;
  28810. /**
  28811. * Returns the facetLocalNormals array.
  28812. * The normals are expressed in the mesh local spac
  28813. * @returns an array of Vector3
  28814. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28815. */
  28816. getFacetLocalNormals(): Vector3[];
  28817. /**
  28818. * Returns the facetLocalPositions array.
  28819. * The facet positions are expressed in the mesh local space
  28820. * @returns an array of Vector3
  28821. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28822. */
  28823. getFacetLocalPositions(): Vector3[];
  28824. /**
  28825. * Returns the facetLocalPartioning array
  28826. * @returns an array of array of numbers
  28827. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28828. */
  28829. getFacetLocalPartitioning(): number[][];
  28830. /**
  28831. * Returns the i-th facet position in the world system.
  28832. * This method allocates a new Vector3 per call
  28833. * @param i defines the facet index
  28834. * @returns a new Vector3
  28835. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28836. */
  28837. getFacetPosition(i: number): Vector3;
  28838. /**
  28839. * Sets the reference Vector3 with the i-th facet position in the world system
  28840. * @param i defines the facet index
  28841. * @param ref defines the target vector
  28842. * @returns the current mesh
  28843. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28844. */
  28845. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28846. /**
  28847. * Returns the i-th facet normal in the world system.
  28848. * This method allocates a new Vector3 per call
  28849. * @param i defines the facet index
  28850. * @returns a new Vector3
  28851. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28852. */
  28853. getFacetNormal(i: number): Vector3;
  28854. /**
  28855. * Sets the reference Vector3 with the i-th facet normal in the world system
  28856. * @param i defines the facet index
  28857. * @param ref defines the target vector
  28858. * @returns the current mesh
  28859. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28860. */
  28861. getFacetNormalToRef(i: number, ref: Vector3): this;
  28862. /**
  28863. * 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)
  28864. * @param x defines x coordinate
  28865. * @param y defines y coordinate
  28866. * @param z defines z coordinate
  28867. * @returns the array of facet indexes
  28868. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28869. */
  28870. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28871. /**
  28872. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28873. * @param projected sets as the (x,y,z) world projection on the facet
  28874. * @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
  28875. * @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
  28876. * @param x defines x coordinate
  28877. * @param y defines y coordinate
  28878. * @param z defines z coordinate
  28879. * @returns the face index if found (or null instead)
  28880. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28881. */
  28882. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28883. /**
  28884. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28885. * @param projected sets as the (x,y,z) local projection on the facet
  28886. * @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
  28887. * @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
  28888. * @param x defines x coordinate
  28889. * @param y defines y coordinate
  28890. * @param z defines z coordinate
  28891. * @returns the face index if found (or null instead)
  28892. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28893. */
  28894. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28895. /**
  28896. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28897. * @returns the parameters
  28898. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28899. */
  28900. getFacetDataParameters(): any;
  28901. /**
  28902. * Disables the feature FacetData and frees the related memory
  28903. * @returns the current mesh
  28904. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28905. */
  28906. disableFacetData(): AbstractMesh;
  28907. /**
  28908. * Updates the AbstractMesh indices array
  28909. * @param indices defines the data source
  28910. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28911. * @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)
  28912. * @returns the current mesh
  28913. */
  28914. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28915. /**
  28916. * Creates new normals data for the mesh
  28917. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28918. * @returns the current mesh
  28919. */
  28920. createNormals(updatable: boolean): AbstractMesh;
  28921. /**
  28922. * Align the mesh with a normal
  28923. * @param normal defines the normal to use
  28924. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28925. * @returns the current mesh
  28926. */
  28927. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28928. /** @hidden */
  28929. _checkOcclusionQuery(): boolean;
  28930. /**
  28931. * Disables the mesh edge rendering mode
  28932. * @returns the currentAbstractMesh
  28933. */
  28934. disableEdgesRendering(): AbstractMesh;
  28935. /**
  28936. * Enables the edge rendering mode on the mesh.
  28937. * This mode makes the mesh edges visible
  28938. * @param epsilon defines the maximal distance between two angles to detect a face
  28939. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28940. * @returns the currentAbstractMesh
  28941. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28942. */
  28943. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28944. }
  28945. }
  28946. declare module "babylonjs/Actions/actionEvent" {
  28947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28948. import { Nullable } from "babylonjs/types";
  28949. import { Sprite } from "babylonjs/Sprites/sprite";
  28950. import { Scene } from "babylonjs/scene";
  28951. import { Vector2 } from "babylonjs/Maths/math.vector";
  28952. /**
  28953. * Interface used to define ActionEvent
  28954. */
  28955. export interface IActionEvent {
  28956. /** The mesh or sprite that triggered the action */
  28957. source: any;
  28958. /** The X mouse cursor position at the time of the event */
  28959. pointerX: number;
  28960. /** The Y mouse cursor position at the time of the event */
  28961. pointerY: number;
  28962. /** The mesh that is currently pointed at (can be null) */
  28963. meshUnderPointer: Nullable<AbstractMesh>;
  28964. /** the original (browser) event that triggered the ActionEvent */
  28965. sourceEvent?: any;
  28966. /** additional data for the event */
  28967. additionalData?: any;
  28968. }
  28969. /**
  28970. * ActionEvent is the event being sent when an action is triggered.
  28971. */
  28972. export class ActionEvent implements IActionEvent {
  28973. /** The mesh or sprite that triggered the action */
  28974. source: any;
  28975. /** The X mouse cursor position at the time of the event */
  28976. pointerX: number;
  28977. /** The Y mouse cursor position at the time of the event */
  28978. pointerY: number;
  28979. /** The mesh that is currently pointed at (can be null) */
  28980. meshUnderPointer: Nullable<AbstractMesh>;
  28981. /** the original (browser) event that triggered the ActionEvent */
  28982. sourceEvent?: any;
  28983. /** additional data for the event */
  28984. additionalData?: any;
  28985. /**
  28986. * Creates a new ActionEvent
  28987. * @param source The mesh or sprite that triggered the action
  28988. * @param pointerX The X mouse cursor position at the time of the event
  28989. * @param pointerY The Y mouse cursor position at the time of the event
  28990. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28991. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28992. * @param additionalData additional data for the event
  28993. */
  28994. constructor(
  28995. /** The mesh or sprite that triggered the action */
  28996. source: any,
  28997. /** The X mouse cursor position at the time of the event */
  28998. pointerX: number,
  28999. /** The Y mouse cursor position at the time of the event */
  29000. pointerY: number,
  29001. /** The mesh that is currently pointed at (can be null) */
  29002. meshUnderPointer: Nullable<AbstractMesh>,
  29003. /** the original (browser) event that triggered the ActionEvent */
  29004. sourceEvent?: any,
  29005. /** additional data for the event */
  29006. additionalData?: any);
  29007. /**
  29008. * Helper function to auto-create an ActionEvent from a source mesh.
  29009. * @param source The source mesh that triggered the event
  29010. * @param evt The original (browser) event
  29011. * @param additionalData additional data for the event
  29012. * @returns the new ActionEvent
  29013. */
  29014. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29015. /**
  29016. * Helper function to auto-create an ActionEvent from a source sprite
  29017. * @param source The source sprite that triggered the event
  29018. * @param scene Scene associated with the sprite
  29019. * @param evt The original (browser) event
  29020. * @param additionalData additional data for the event
  29021. * @returns the new ActionEvent
  29022. */
  29023. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29024. /**
  29025. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29026. * @param scene the scene where the event occurred
  29027. * @param evt The original (browser) event
  29028. * @returns the new ActionEvent
  29029. */
  29030. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29031. /**
  29032. * Helper function to auto-create an ActionEvent from a primitive
  29033. * @param prim defines the target primitive
  29034. * @param pointerPos defines the pointer position
  29035. * @param evt The original (browser) event
  29036. * @param additionalData additional data for the event
  29037. * @returns the new ActionEvent
  29038. */
  29039. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29040. }
  29041. }
  29042. declare module "babylonjs/Actions/abstractActionManager" {
  29043. import { IDisposable } from "babylonjs/scene";
  29044. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29045. import { IAction } from "babylonjs/Actions/action";
  29046. import { Nullable } from "babylonjs/types";
  29047. /**
  29048. * Abstract class used to decouple action Manager from scene and meshes.
  29049. * Do not instantiate.
  29050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29051. */
  29052. export abstract class AbstractActionManager implements IDisposable {
  29053. /** Gets the list of active triggers */
  29054. static Triggers: {
  29055. [key: string]: number;
  29056. };
  29057. /** Gets the cursor to use when hovering items */
  29058. hoverCursor: string;
  29059. /** Gets the list of actions */
  29060. actions: IAction[];
  29061. /**
  29062. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29063. */
  29064. isRecursive: boolean;
  29065. /**
  29066. * Releases all associated resources
  29067. */
  29068. abstract dispose(): void;
  29069. /**
  29070. * Does this action manager has pointer triggers
  29071. */
  29072. abstract readonly hasPointerTriggers: boolean;
  29073. /**
  29074. * Does this action manager has pick triggers
  29075. */
  29076. abstract readonly hasPickTriggers: boolean;
  29077. /**
  29078. * Process a specific trigger
  29079. * @param trigger defines the trigger to process
  29080. * @param evt defines the event details to be processed
  29081. */
  29082. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29083. /**
  29084. * Does this action manager handles actions of any of the given triggers
  29085. * @param triggers defines the triggers to be tested
  29086. * @return a boolean indicating whether one (or more) of the triggers is handled
  29087. */
  29088. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29089. /**
  29090. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29091. * speed.
  29092. * @param triggerA defines the trigger to be tested
  29093. * @param triggerB defines the trigger to be tested
  29094. * @return a boolean indicating whether one (or more) of the triggers is handled
  29095. */
  29096. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29097. /**
  29098. * Does this action manager handles actions of a given trigger
  29099. * @param trigger defines the trigger to be tested
  29100. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29101. * @return whether the trigger is handled
  29102. */
  29103. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29104. /**
  29105. * Serialize this manager to a JSON object
  29106. * @param name defines the property name to store this manager
  29107. * @returns a JSON representation of this manager
  29108. */
  29109. abstract serialize(name: string): any;
  29110. /**
  29111. * Registers an action to this action manager
  29112. * @param action defines the action to be registered
  29113. * @return the action amended (prepared) after registration
  29114. */
  29115. abstract registerAction(action: IAction): Nullable<IAction>;
  29116. /**
  29117. * Unregisters an action to this action manager
  29118. * @param action defines the action to be unregistered
  29119. * @return a boolean indicating whether the action has been unregistered
  29120. */
  29121. abstract unregisterAction(action: IAction): Boolean;
  29122. /**
  29123. * Does exist one action manager with at least one trigger
  29124. **/
  29125. static readonly HasTriggers: boolean;
  29126. /**
  29127. * Does exist one action manager with at least one pick trigger
  29128. **/
  29129. static readonly HasPickTriggers: boolean;
  29130. /**
  29131. * Does exist one action manager that handles actions of a given trigger
  29132. * @param trigger defines the trigger to be tested
  29133. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29134. **/
  29135. static HasSpecificTrigger(trigger: number): boolean;
  29136. }
  29137. }
  29138. declare module "babylonjs/node" {
  29139. import { Scene } from "babylonjs/scene";
  29140. import { Nullable } from "babylonjs/types";
  29141. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29142. import { Engine } from "babylonjs/Engines/engine";
  29143. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29144. import { Observable } from "babylonjs/Misc/observable";
  29145. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29146. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29147. import { Animatable } from "babylonjs/Animations/animatable";
  29148. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29149. import { Animation } from "babylonjs/Animations/animation";
  29150. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29152. /**
  29153. * Defines how a node can be built from a string name.
  29154. */
  29155. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29156. /**
  29157. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29158. */
  29159. export class Node implements IBehaviorAware<Node> {
  29160. /** @hidden */
  29161. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29162. private static _NodeConstructors;
  29163. /**
  29164. * Add a new node constructor
  29165. * @param type defines the type name of the node to construct
  29166. * @param constructorFunc defines the constructor function
  29167. */
  29168. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29169. /**
  29170. * Returns a node constructor based on type name
  29171. * @param type defines the type name
  29172. * @param name defines the new node name
  29173. * @param scene defines the hosting scene
  29174. * @param options defines optional options to transmit to constructors
  29175. * @returns the new constructor or null
  29176. */
  29177. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29178. /**
  29179. * Gets or sets the name of the node
  29180. */
  29181. name: string;
  29182. /**
  29183. * Gets or sets the id of the node
  29184. */
  29185. id: string;
  29186. /**
  29187. * Gets or sets the unique id of the node
  29188. */
  29189. uniqueId: number;
  29190. /**
  29191. * Gets or sets a string used to store user defined state for the node
  29192. */
  29193. state: string;
  29194. /**
  29195. * Gets or sets an object used to store user defined information for the node
  29196. */
  29197. metadata: any;
  29198. /**
  29199. * For internal use only. Please do not use.
  29200. */
  29201. reservedDataStore: any;
  29202. /**
  29203. * List of inspectable custom properties (used by the Inspector)
  29204. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29205. */
  29206. inspectableCustomProperties: IInspectable[];
  29207. private _doNotSerialize;
  29208. /**
  29209. * Gets or sets a boolean used to define if the node must be serialized
  29210. */
  29211. doNotSerialize: boolean;
  29212. /** @hidden */
  29213. _isDisposed: boolean;
  29214. /**
  29215. * Gets a list of Animations associated with the node
  29216. */
  29217. animations: import("babylonjs/Animations/animation").Animation[];
  29218. protected _ranges: {
  29219. [name: string]: Nullable<AnimationRange>;
  29220. };
  29221. /**
  29222. * Callback raised when the node is ready to be used
  29223. */
  29224. onReady: Nullable<(node: Node) => void>;
  29225. private _isEnabled;
  29226. private _isParentEnabled;
  29227. private _isReady;
  29228. /** @hidden */
  29229. _currentRenderId: number;
  29230. private _parentUpdateId;
  29231. /** @hidden */
  29232. _childUpdateId: number;
  29233. /** @hidden */
  29234. _waitingParentId: Nullable<string>;
  29235. /** @hidden */
  29236. _scene: Scene;
  29237. /** @hidden */
  29238. _cache: any;
  29239. private _parentNode;
  29240. private _children;
  29241. /** @hidden */
  29242. _worldMatrix: Matrix;
  29243. /** @hidden */
  29244. _worldMatrixDeterminant: number;
  29245. /** @hidden */
  29246. _worldMatrixDeterminantIsDirty: boolean;
  29247. /** @hidden */
  29248. private _sceneRootNodesIndex;
  29249. /**
  29250. * Gets a boolean indicating if the node has been disposed
  29251. * @returns true if the node was disposed
  29252. */
  29253. isDisposed(): boolean;
  29254. /**
  29255. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29256. * @see https://doc.babylonjs.com/how_to/parenting
  29257. */
  29258. parent: Nullable<Node>;
  29259. /** @hidden */
  29260. _addToSceneRootNodes(): void;
  29261. /** @hidden */
  29262. _removeFromSceneRootNodes(): void;
  29263. private _animationPropertiesOverride;
  29264. /**
  29265. * Gets or sets the animation properties override
  29266. */
  29267. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  29268. /**
  29269. * Gets a string idenfifying the name of the class
  29270. * @returns "Node" string
  29271. */
  29272. getClassName(): string;
  29273. /** @hidden */
  29274. readonly _isNode: boolean;
  29275. /**
  29276. * An event triggered when the mesh is disposed
  29277. */
  29278. onDisposeObservable: Observable<Node>;
  29279. private _onDisposeObserver;
  29280. /**
  29281. * Sets a callback that will be raised when the node will be disposed
  29282. */
  29283. onDispose: () => void;
  29284. /**
  29285. * Creates a new Node
  29286. * @param name the name and id to be given to this node
  29287. * @param scene the scene this node will be added to
  29288. */
  29289. constructor(name: string, scene?: Nullable<Scene>);
  29290. /**
  29291. * Gets the scene of the node
  29292. * @returns a scene
  29293. */
  29294. getScene(): Scene;
  29295. /**
  29296. * Gets the engine of the node
  29297. * @returns a Engine
  29298. */
  29299. getEngine(): Engine;
  29300. private _behaviors;
  29301. /**
  29302. * Attach a behavior to the node
  29303. * @see http://doc.babylonjs.com/features/behaviour
  29304. * @param behavior defines the behavior to attach
  29305. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29306. * @returns the current Node
  29307. */
  29308. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29309. /**
  29310. * Remove an attached behavior
  29311. * @see http://doc.babylonjs.com/features/behaviour
  29312. * @param behavior defines the behavior to attach
  29313. * @returns the current Node
  29314. */
  29315. removeBehavior(behavior: Behavior<Node>): Node;
  29316. /**
  29317. * Gets the list of attached behaviors
  29318. * @see http://doc.babylonjs.com/features/behaviour
  29319. */
  29320. readonly behaviors: Behavior<Node>[];
  29321. /**
  29322. * Gets an attached behavior by name
  29323. * @param name defines the name of the behavior to look for
  29324. * @see http://doc.babylonjs.com/features/behaviour
  29325. * @returns null if behavior was not found else the requested behavior
  29326. */
  29327. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29328. /**
  29329. * Returns the latest update of the World matrix
  29330. * @returns a Matrix
  29331. */
  29332. getWorldMatrix(): Matrix;
  29333. /** @hidden */
  29334. _getWorldMatrixDeterminant(): number;
  29335. /**
  29336. * Returns directly the latest state of the mesh World matrix.
  29337. * A Matrix is returned.
  29338. */
  29339. readonly worldMatrixFromCache: Matrix;
  29340. /** @hidden */
  29341. _initCache(): void;
  29342. /** @hidden */
  29343. updateCache(force?: boolean): void;
  29344. /** @hidden */
  29345. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29346. /** @hidden */
  29347. _updateCache(ignoreParentClass?: boolean): void;
  29348. /** @hidden */
  29349. _isSynchronized(): boolean;
  29350. /** @hidden */
  29351. _markSyncedWithParent(): void;
  29352. /** @hidden */
  29353. isSynchronizedWithParent(): boolean;
  29354. /** @hidden */
  29355. isSynchronized(): boolean;
  29356. /**
  29357. * Is this node ready to be used/rendered
  29358. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29359. * @return true if the node is ready
  29360. */
  29361. isReady(completeCheck?: boolean): boolean;
  29362. /**
  29363. * Is this node enabled?
  29364. * 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
  29365. * @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
  29366. * @return whether this node (and its parent) is enabled
  29367. */
  29368. isEnabled(checkAncestors?: boolean): boolean;
  29369. /** @hidden */
  29370. protected _syncParentEnabledState(): void;
  29371. /**
  29372. * Set the enabled state of this node
  29373. * @param value defines the new enabled state
  29374. */
  29375. setEnabled(value: boolean): void;
  29376. /**
  29377. * Is this node a descendant of the given node?
  29378. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29379. * @param ancestor defines the parent node to inspect
  29380. * @returns a boolean indicating if this node is a descendant of the given node
  29381. */
  29382. isDescendantOf(ancestor: Node): boolean;
  29383. /** @hidden */
  29384. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29385. /**
  29386. * Will return all nodes that have this node as ascendant
  29387. * @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
  29388. * @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
  29389. * @return all children nodes of all types
  29390. */
  29391. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29392. /**
  29393. * Get all child-meshes of this node
  29394. * @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)
  29395. * @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
  29396. * @returns an array of AbstractMesh
  29397. */
  29398. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29399. /**
  29400. * Get all direct children of this node
  29401. * @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
  29402. * @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)
  29403. * @returns an array of Node
  29404. */
  29405. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29406. /** @hidden */
  29407. _setReady(state: boolean): void;
  29408. /**
  29409. * Get an animation by name
  29410. * @param name defines the name of the animation to look for
  29411. * @returns null if not found else the requested animation
  29412. */
  29413. getAnimationByName(name: string): Nullable<Animation>;
  29414. /**
  29415. * Creates an animation range for this node
  29416. * @param name defines the name of the range
  29417. * @param from defines the starting key
  29418. * @param to defines the end key
  29419. */
  29420. createAnimationRange(name: string, from: number, to: number): void;
  29421. /**
  29422. * Delete a specific animation range
  29423. * @param name defines the name of the range to delete
  29424. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29425. */
  29426. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29427. /**
  29428. * Get an animation range by name
  29429. * @param name defines the name of the animation range to look for
  29430. * @returns null if not found else the requested animation range
  29431. */
  29432. getAnimationRange(name: string): Nullable<AnimationRange>;
  29433. /**
  29434. * Gets the list of all animation ranges defined on this node
  29435. * @returns an array
  29436. */
  29437. getAnimationRanges(): Nullable<AnimationRange>[];
  29438. /**
  29439. * Will start the animation sequence
  29440. * @param name defines the range frames for animation sequence
  29441. * @param loop defines if the animation should loop (false by default)
  29442. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29443. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29444. * @returns the object created for this animation. If range does not exist, it will return null
  29445. */
  29446. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29447. /**
  29448. * Serialize animation ranges into a JSON compatible object
  29449. * @returns serialization object
  29450. */
  29451. serializeAnimationRanges(): any;
  29452. /**
  29453. * Computes the world matrix of the node
  29454. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29455. * @returns the world matrix
  29456. */
  29457. computeWorldMatrix(force?: boolean): Matrix;
  29458. /**
  29459. * Releases resources associated with this node.
  29460. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29461. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29462. */
  29463. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29464. /**
  29465. * Parse animation range data from a serialization object and store them into a given node
  29466. * @param node defines where to store the animation ranges
  29467. * @param parsedNode defines the serialization object to read data from
  29468. * @param scene defines the hosting scene
  29469. */
  29470. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29471. /**
  29472. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29473. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29474. * @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
  29475. * @returns the new bounding vectors
  29476. */
  29477. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29478. min: Vector3;
  29479. max: Vector3;
  29480. };
  29481. }
  29482. }
  29483. declare module "babylonjs/Animations/animation" {
  29484. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29485. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29486. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29487. import { Nullable } from "babylonjs/types";
  29488. import { Scene } from "babylonjs/scene";
  29489. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29490. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29491. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29492. import { Node } from "babylonjs/node";
  29493. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29494. import { Size } from "babylonjs/Maths/math.size";
  29495. import { Animatable } from "babylonjs/Animations/animatable";
  29496. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29497. /**
  29498. * @hidden
  29499. */
  29500. export class _IAnimationState {
  29501. key: number;
  29502. repeatCount: number;
  29503. workValue?: any;
  29504. loopMode?: number;
  29505. offsetValue?: any;
  29506. highLimitValue?: any;
  29507. }
  29508. /**
  29509. * Class used to store any kind of animation
  29510. */
  29511. export class Animation {
  29512. /**Name of the animation */
  29513. name: string;
  29514. /**Property to animate */
  29515. targetProperty: string;
  29516. /**The frames per second of the animation */
  29517. framePerSecond: number;
  29518. /**The data type of the animation */
  29519. dataType: number;
  29520. /**The loop mode of the animation */
  29521. loopMode?: number | undefined;
  29522. /**Specifies if blending should be enabled */
  29523. enableBlending?: boolean | undefined;
  29524. /**
  29525. * Use matrix interpolation instead of using direct key value when animating matrices
  29526. */
  29527. static AllowMatricesInterpolation: boolean;
  29528. /**
  29529. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29530. */
  29531. static AllowMatrixDecomposeForInterpolation: boolean;
  29532. /**
  29533. * Stores the key frames of the animation
  29534. */
  29535. private _keys;
  29536. /**
  29537. * Stores the easing function of the animation
  29538. */
  29539. private _easingFunction;
  29540. /**
  29541. * @hidden Internal use only
  29542. */
  29543. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  29544. /**
  29545. * The set of event that will be linked to this animation
  29546. */
  29547. private _events;
  29548. /**
  29549. * Stores an array of target property paths
  29550. */
  29551. targetPropertyPath: string[];
  29552. /**
  29553. * Stores the blending speed of the animation
  29554. */
  29555. blendingSpeed: number;
  29556. /**
  29557. * Stores the animation ranges for the animation
  29558. */
  29559. private _ranges;
  29560. /**
  29561. * @hidden Internal use
  29562. */
  29563. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29564. /**
  29565. * Sets up an animation
  29566. * @param property The property to animate
  29567. * @param animationType The animation type to apply
  29568. * @param framePerSecond The frames per second of the animation
  29569. * @param easingFunction The easing function used in the animation
  29570. * @returns The created animation
  29571. */
  29572. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29573. /**
  29574. * Create and start an animation on a node
  29575. * @param name defines the name of the global animation that will be run on all nodes
  29576. * @param node defines the root node where the animation will take place
  29577. * @param targetProperty defines property to animate
  29578. * @param framePerSecond defines the number of frame per second yo use
  29579. * @param totalFrame defines the number of frames in total
  29580. * @param from defines the initial value
  29581. * @param to defines the final value
  29582. * @param loopMode defines which loop mode you want to use (off by default)
  29583. * @param easingFunction defines the easing function to use (linear by default)
  29584. * @param onAnimationEnd defines the callback to call when animation end
  29585. * @returns the animatable created for this animation
  29586. */
  29587. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29588. /**
  29589. * Create and start an animation on a node and its descendants
  29590. * @param name defines the name of the global animation that will be run on all nodes
  29591. * @param node defines the root node where the animation will take place
  29592. * @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
  29593. * @param targetProperty defines property to animate
  29594. * @param framePerSecond defines the number of frame per second to use
  29595. * @param totalFrame defines the number of frames in total
  29596. * @param from defines the initial value
  29597. * @param to defines the final value
  29598. * @param loopMode defines which loop mode you want to use (off by default)
  29599. * @param easingFunction defines the easing function to use (linear by default)
  29600. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29601. * @returns the list of animatables created for all nodes
  29602. * @example https://www.babylonjs-playground.com/#MH0VLI
  29603. */
  29604. 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[]>;
  29605. /**
  29606. * Creates a new animation, merges it with the existing animations and starts it
  29607. * @param name Name of the animation
  29608. * @param node Node which contains the scene that begins the animations
  29609. * @param targetProperty Specifies which property to animate
  29610. * @param framePerSecond The frames per second of the animation
  29611. * @param totalFrame The total number of frames
  29612. * @param from The frame at the beginning of the animation
  29613. * @param to The frame at the end of the animation
  29614. * @param loopMode Specifies the loop mode of the animation
  29615. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29616. * @param onAnimationEnd Callback to run once the animation is complete
  29617. * @returns Nullable animation
  29618. */
  29619. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29620. /**
  29621. * Transition property of an host to the target Value
  29622. * @param property The property to transition
  29623. * @param targetValue The target Value of the property
  29624. * @param host The object where the property to animate belongs
  29625. * @param scene Scene used to run the animation
  29626. * @param frameRate Framerate (in frame/s) to use
  29627. * @param transition The transition type we want to use
  29628. * @param duration The duration of the animation, in milliseconds
  29629. * @param onAnimationEnd Callback trigger at the end of the animation
  29630. * @returns Nullable animation
  29631. */
  29632. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29633. /**
  29634. * Return the array of runtime animations currently using this animation
  29635. */
  29636. readonly runtimeAnimations: RuntimeAnimation[];
  29637. /**
  29638. * Specifies if any of the runtime animations are currently running
  29639. */
  29640. readonly hasRunningRuntimeAnimations: boolean;
  29641. /**
  29642. * Initializes the animation
  29643. * @param name Name of the animation
  29644. * @param targetProperty Property to animate
  29645. * @param framePerSecond The frames per second of the animation
  29646. * @param dataType The data type of the animation
  29647. * @param loopMode The loop mode of the animation
  29648. * @param enableBlending Specifies if blending should be enabled
  29649. */
  29650. constructor(
  29651. /**Name of the animation */
  29652. name: string,
  29653. /**Property to animate */
  29654. targetProperty: string,
  29655. /**The frames per second of the animation */
  29656. framePerSecond: number,
  29657. /**The data type of the animation */
  29658. dataType: number,
  29659. /**The loop mode of the animation */
  29660. loopMode?: number | undefined,
  29661. /**Specifies if blending should be enabled */
  29662. enableBlending?: boolean | undefined);
  29663. /**
  29664. * Converts the animation to a string
  29665. * @param fullDetails support for multiple levels of logging within scene loading
  29666. * @returns String form of the animation
  29667. */
  29668. toString(fullDetails?: boolean): string;
  29669. /**
  29670. * Add an event to this animation
  29671. * @param event Event to add
  29672. */
  29673. addEvent(event: AnimationEvent): void;
  29674. /**
  29675. * Remove all events found at the given frame
  29676. * @param frame The frame to remove events from
  29677. */
  29678. removeEvents(frame: number): void;
  29679. /**
  29680. * Retrieves all the events from the animation
  29681. * @returns Events from the animation
  29682. */
  29683. getEvents(): AnimationEvent[];
  29684. /**
  29685. * Creates an animation range
  29686. * @param name Name of the animation range
  29687. * @param from Starting frame of the animation range
  29688. * @param to Ending frame of the animation
  29689. */
  29690. createRange(name: string, from: number, to: number): void;
  29691. /**
  29692. * Deletes an animation range by name
  29693. * @param name Name of the animation range to delete
  29694. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29695. */
  29696. deleteRange(name: string, deleteFrames?: boolean): void;
  29697. /**
  29698. * Gets the animation range by name, or null if not defined
  29699. * @param name Name of the animation range
  29700. * @returns Nullable animation range
  29701. */
  29702. getRange(name: string): Nullable<AnimationRange>;
  29703. /**
  29704. * Gets the key frames from the animation
  29705. * @returns The key frames of the animation
  29706. */
  29707. getKeys(): Array<IAnimationKey>;
  29708. /**
  29709. * Gets the highest frame rate of the animation
  29710. * @returns Highest frame rate of the animation
  29711. */
  29712. getHighestFrame(): number;
  29713. /**
  29714. * Gets the easing function of the animation
  29715. * @returns Easing function of the animation
  29716. */
  29717. getEasingFunction(): IEasingFunction;
  29718. /**
  29719. * Sets the easing function of the animation
  29720. * @param easingFunction A custom mathematical formula for animation
  29721. */
  29722. setEasingFunction(easingFunction: EasingFunction): void;
  29723. /**
  29724. * Interpolates a scalar linearly
  29725. * @param startValue Start value of the animation curve
  29726. * @param endValue End value of the animation curve
  29727. * @param gradient Scalar amount to interpolate
  29728. * @returns Interpolated scalar value
  29729. */
  29730. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29731. /**
  29732. * Interpolates a scalar cubically
  29733. * @param startValue Start value of the animation curve
  29734. * @param outTangent End tangent of the animation
  29735. * @param endValue End value of the animation curve
  29736. * @param inTangent Start tangent of the animation curve
  29737. * @param gradient Scalar amount to interpolate
  29738. * @returns Interpolated scalar value
  29739. */
  29740. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29741. /**
  29742. * Interpolates a quaternion using a spherical linear interpolation
  29743. * @param startValue Start value of the animation curve
  29744. * @param endValue End value of the animation curve
  29745. * @param gradient Scalar amount to interpolate
  29746. * @returns Interpolated quaternion value
  29747. */
  29748. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29749. /**
  29750. * Interpolates a quaternion cubically
  29751. * @param startValue Start value of the animation curve
  29752. * @param outTangent End tangent of the animation curve
  29753. * @param endValue End value of the animation curve
  29754. * @param inTangent Start tangent of the animation curve
  29755. * @param gradient Scalar amount to interpolate
  29756. * @returns Interpolated quaternion value
  29757. */
  29758. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29759. /**
  29760. * Interpolates a Vector3 linearl
  29761. * @param startValue Start value of the animation curve
  29762. * @param endValue End value of the animation curve
  29763. * @param gradient Scalar amount to interpolate
  29764. * @returns Interpolated scalar value
  29765. */
  29766. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29767. /**
  29768. * Interpolates a Vector3 cubically
  29769. * @param startValue Start value of the animation curve
  29770. * @param outTangent End tangent of the animation
  29771. * @param endValue End value of the animation curve
  29772. * @param inTangent Start tangent of the animation curve
  29773. * @param gradient Scalar amount to interpolate
  29774. * @returns InterpolatedVector3 value
  29775. */
  29776. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29777. /**
  29778. * Interpolates a Vector2 linearly
  29779. * @param startValue Start value of the animation curve
  29780. * @param endValue End value of the animation curve
  29781. * @param gradient Scalar amount to interpolate
  29782. * @returns Interpolated Vector2 value
  29783. */
  29784. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29785. /**
  29786. * Interpolates a Vector2 cubically
  29787. * @param startValue Start value of the animation curve
  29788. * @param outTangent End tangent of the animation
  29789. * @param endValue End value of the animation curve
  29790. * @param inTangent Start tangent of the animation curve
  29791. * @param gradient Scalar amount to interpolate
  29792. * @returns Interpolated Vector2 value
  29793. */
  29794. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29795. /**
  29796. * Interpolates a size linearly
  29797. * @param startValue Start value of the animation curve
  29798. * @param endValue End value of the animation curve
  29799. * @param gradient Scalar amount to interpolate
  29800. * @returns Interpolated Size value
  29801. */
  29802. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29803. /**
  29804. * Interpolates a Color3 linearly
  29805. * @param startValue Start value of the animation curve
  29806. * @param endValue End value of the animation curve
  29807. * @param gradient Scalar amount to interpolate
  29808. * @returns Interpolated Color3 value
  29809. */
  29810. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29811. /**
  29812. * Interpolates a Color4 linearly
  29813. * @param startValue Start value of the animation curve
  29814. * @param endValue End value of the animation curve
  29815. * @param gradient Scalar amount to interpolate
  29816. * @returns Interpolated Color3 value
  29817. */
  29818. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29819. /**
  29820. * @hidden Internal use only
  29821. */
  29822. _getKeyValue(value: any): any;
  29823. /**
  29824. * @hidden Internal use only
  29825. */
  29826. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29827. /**
  29828. * Defines the function to use to interpolate matrices
  29829. * @param startValue defines the start matrix
  29830. * @param endValue defines the end matrix
  29831. * @param gradient defines the gradient between both matrices
  29832. * @param result defines an optional target matrix where to store the interpolation
  29833. * @returns the interpolated matrix
  29834. */
  29835. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29836. /**
  29837. * Makes a copy of the animation
  29838. * @returns Cloned animation
  29839. */
  29840. clone(): Animation;
  29841. /**
  29842. * Sets the key frames of the animation
  29843. * @param values The animation key frames to set
  29844. */
  29845. setKeys(values: Array<IAnimationKey>): void;
  29846. /**
  29847. * Serializes the animation to an object
  29848. * @returns Serialized object
  29849. */
  29850. serialize(): any;
  29851. /**
  29852. * Float animation type
  29853. */
  29854. static readonly ANIMATIONTYPE_FLOAT: number;
  29855. /**
  29856. * Vector3 animation type
  29857. */
  29858. static readonly ANIMATIONTYPE_VECTOR3: number;
  29859. /**
  29860. * Quaternion animation type
  29861. */
  29862. static readonly ANIMATIONTYPE_QUATERNION: number;
  29863. /**
  29864. * Matrix animation type
  29865. */
  29866. static readonly ANIMATIONTYPE_MATRIX: number;
  29867. /**
  29868. * Color3 animation type
  29869. */
  29870. static readonly ANIMATIONTYPE_COLOR3: number;
  29871. /**
  29872. * Color3 animation type
  29873. */
  29874. static readonly ANIMATIONTYPE_COLOR4: number;
  29875. /**
  29876. * Vector2 animation type
  29877. */
  29878. static readonly ANIMATIONTYPE_VECTOR2: number;
  29879. /**
  29880. * Size animation type
  29881. */
  29882. static readonly ANIMATIONTYPE_SIZE: number;
  29883. /**
  29884. * Relative Loop Mode
  29885. */
  29886. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29887. /**
  29888. * Cycle Loop Mode
  29889. */
  29890. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29891. /**
  29892. * Constant Loop Mode
  29893. */
  29894. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29895. /** @hidden */
  29896. static _UniversalLerp(left: any, right: any, amount: number): any;
  29897. /**
  29898. * Parses an animation object and creates an animation
  29899. * @param parsedAnimation Parsed animation object
  29900. * @returns Animation object
  29901. */
  29902. static Parse(parsedAnimation: any): Animation;
  29903. /**
  29904. * Appends the serialized animations from the source animations
  29905. * @param source Source containing the animations
  29906. * @param destination Target to store the animations
  29907. */
  29908. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29909. }
  29910. }
  29911. declare module "babylonjs/Animations/animatable.interface" {
  29912. import { Nullable } from "babylonjs/types";
  29913. import { Animation } from "babylonjs/Animations/animation";
  29914. /**
  29915. * Interface containing an array of animations
  29916. */
  29917. export interface IAnimatable {
  29918. /**
  29919. * Array of animations
  29920. */
  29921. animations: Nullable<Array<Animation>>;
  29922. }
  29923. }
  29924. declare module "babylonjs/Misc/decorators" {
  29925. import { Nullable } from "babylonjs/types";
  29926. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29927. import { Scene } from "babylonjs/scene";
  29928. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29929. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29930. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29931. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29932. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29933. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29934. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29935. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29936. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29937. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29938. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29939. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29940. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29941. /**
  29942. * Decorator used to define property that can be serialized as reference to a camera
  29943. * @param sourceName defines the name of the property to decorate
  29944. */
  29945. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29946. /**
  29947. * Class used to help serialization objects
  29948. */
  29949. export class SerializationHelper {
  29950. /** @hidden */
  29951. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  29952. /** @hidden */
  29953. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  29954. /** @hidden */
  29955. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  29956. /** @hidden */
  29957. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  29958. /**
  29959. * Appends the serialized animations from the source animations
  29960. * @param source Source containing the animations
  29961. * @param destination Target to store the animations
  29962. */
  29963. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29964. /**
  29965. * Static function used to serialized a specific entity
  29966. * @param entity defines the entity to serialize
  29967. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29968. * @returns a JSON compatible object representing the serialization of the entity
  29969. */
  29970. static Serialize<T>(entity: T, serializationObject?: any): any;
  29971. /**
  29972. * Creates a new entity from a serialization data object
  29973. * @param creationFunction defines a function used to instanciated the new entity
  29974. * @param source defines the source serialization data
  29975. * @param scene defines the hosting scene
  29976. * @param rootUrl defines the root url for resources
  29977. * @returns a new entity
  29978. */
  29979. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29980. /**
  29981. * Clones an object
  29982. * @param creationFunction defines the function used to instanciate the new object
  29983. * @param source defines the source object
  29984. * @returns the cloned object
  29985. */
  29986. static Clone<T>(creationFunction: () => T, source: T): T;
  29987. /**
  29988. * Instanciates a new object based on a source one (some data will be shared between both object)
  29989. * @param creationFunction defines the function used to instanciate the new object
  29990. * @param source defines the source object
  29991. * @returns the new object
  29992. */
  29993. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29994. }
  29995. }
  29996. declare module "babylonjs/Misc/guid" {
  29997. /**
  29998. * Class used to manipulate GUIDs
  29999. */
  30000. export class GUID {
  30001. /**
  30002. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30003. * Be aware Math.random() could cause collisions, but:
  30004. * "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"
  30005. * @returns a pseudo random id
  30006. */
  30007. static RandomId(): string;
  30008. }
  30009. }
  30010. declare module "babylonjs/Materials/Textures/baseTexture" {
  30011. import { Observable } from "babylonjs/Misc/observable";
  30012. import { Nullable } from "babylonjs/types";
  30013. import { Scene } from "babylonjs/scene";
  30014. import { Matrix } from "babylonjs/Maths/math.vector";
  30015. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30016. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30017. import { ISize } from "babylonjs/Maths/math.size";
  30018. /**
  30019. * Base class of all the textures in babylon.
  30020. * It groups all the common properties the materials, post process, lights... might need
  30021. * in order to make a correct use of the texture.
  30022. */
  30023. export class BaseTexture implements IAnimatable {
  30024. /**
  30025. * Default anisotropic filtering level for the application.
  30026. * It is set to 4 as a good tradeoff between perf and quality.
  30027. */
  30028. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30029. /**
  30030. * Gets or sets the unique id of the texture
  30031. */
  30032. uniqueId: number;
  30033. /**
  30034. * Define the name of the texture.
  30035. */
  30036. name: string;
  30037. /**
  30038. * Gets or sets an object used to store user defined information.
  30039. */
  30040. metadata: any;
  30041. /**
  30042. * For internal use only. Please do not use.
  30043. */
  30044. reservedDataStore: any;
  30045. private _hasAlpha;
  30046. /**
  30047. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30048. */
  30049. hasAlpha: boolean;
  30050. /**
  30051. * Defines if the alpha value should be determined via the rgb values.
  30052. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30053. */
  30054. getAlphaFromRGB: boolean;
  30055. /**
  30056. * Intensity or strength of the texture.
  30057. * It is commonly used by materials to fine tune the intensity of the texture
  30058. */
  30059. level: number;
  30060. /**
  30061. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30062. * This is part of the texture as textures usually maps to one uv set.
  30063. */
  30064. coordinatesIndex: number;
  30065. private _coordinatesMode;
  30066. /**
  30067. * How a texture is mapped.
  30068. *
  30069. * | Value | Type | Description |
  30070. * | ----- | ----------------------------------- | ----------- |
  30071. * | 0 | EXPLICIT_MODE | |
  30072. * | 1 | SPHERICAL_MODE | |
  30073. * | 2 | PLANAR_MODE | |
  30074. * | 3 | CUBIC_MODE | |
  30075. * | 4 | PROJECTION_MODE | |
  30076. * | 5 | SKYBOX_MODE | |
  30077. * | 6 | INVCUBIC_MODE | |
  30078. * | 7 | EQUIRECTANGULAR_MODE | |
  30079. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30080. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30081. */
  30082. coordinatesMode: number;
  30083. /**
  30084. * | Value | Type | Description |
  30085. * | ----- | ------------------ | ----------- |
  30086. * | 0 | CLAMP_ADDRESSMODE | |
  30087. * | 1 | WRAP_ADDRESSMODE | |
  30088. * | 2 | MIRROR_ADDRESSMODE | |
  30089. */
  30090. wrapU: number;
  30091. /**
  30092. * | Value | Type | Description |
  30093. * | ----- | ------------------ | ----------- |
  30094. * | 0 | CLAMP_ADDRESSMODE | |
  30095. * | 1 | WRAP_ADDRESSMODE | |
  30096. * | 2 | MIRROR_ADDRESSMODE | |
  30097. */
  30098. wrapV: number;
  30099. /**
  30100. * | Value | Type | Description |
  30101. * | ----- | ------------------ | ----------- |
  30102. * | 0 | CLAMP_ADDRESSMODE | |
  30103. * | 1 | WRAP_ADDRESSMODE | |
  30104. * | 2 | MIRROR_ADDRESSMODE | |
  30105. */
  30106. wrapR: number;
  30107. /**
  30108. * With compliant hardware and browser (supporting anisotropic filtering)
  30109. * this defines the level of anisotropic filtering in the texture.
  30110. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30111. */
  30112. anisotropicFilteringLevel: number;
  30113. /**
  30114. * Define if the texture is a cube texture or if false a 2d texture.
  30115. */
  30116. isCube: boolean;
  30117. /**
  30118. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30119. */
  30120. is3D: boolean;
  30121. /**
  30122. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30123. */
  30124. is2DArray: boolean;
  30125. /**
  30126. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30127. * HDR texture are usually stored in linear space.
  30128. * This only impacts the PBR and Background materials
  30129. */
  30130. gammaSpace: boolean;
  30131. /**
  30132. * Gets or sets whether or not the texture contains RGBD data.
  30133. */
  30134. isRGBD: boolean;
  30135. /**
  30136. * Is Z inverted in the texture (useful in a cube texture).
  30137. */
  30138. invertZ: boolean;
  30139. /**
  30140. * Are mip maps generated for this texture or not.
  30141. */
  30142. readonly noMipmap: boolean;
  30143. /**
  30144. * @hidden
  30145. */
  30146. lodLevelInAlpha: boolean;
  30147. /**
  30148. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30149. */
  30150. lodGenerationOffset: number;
  30151. /**
  30152. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30153. */
  30154. lodGenerationScale: number;
  30155. /**
  30156. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30157. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30158. * average roughness values.
  30159. */
  30160. linearSpecularLOD: boolean;
  30161. /**
  30162. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30163. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30164. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30165. */
  30166. irradianceTexture: Nullable<BaseTexture>;
  30167. /**
  30168. * Define if the texture is a render target.
  30169. */
  30170. isRenderTarget: boolean;
  30171. /**
  30172. * Define the unique id of the texture in the scene.
  30173. */
  30174. readonly uid: string;
  30175. /**
  30176. * Return a string representation of the texture.
  30177. * @returns the texture as a string
  30178. */
  30179. toString(): string;
  30180. /**
  30181. * Get the class name of the texture.
  30182. * @returns "BaseTexture"
  30183. */
  30184. getClassName(): string;
  30185. /**
  30186. * Define the list of animation attached to the texture.
  30187. */
  30188. animations: import("babylonjs/Animations/animation").Animation[];
  30189. /**
  30190. * An event triggered when the texture is disposed.
  30191. */
  30192. onDisposeObservable: Observable<BaseTexture>;
  30193. private _onDisposeObserver;
  30194. /**
  30195. * Callback triggered when the texture has been disposed.
  30196. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30197. */
  30198. onDispose: () => void;
  30199. /**
  30200. * Define the current state of the loading sequence when in delayed load mode.
  30201. */
  30202. delayLoadState: number;
  30203. private _scene;
  30204. /** @hidden */
  30205. _texture: Nullable<InternalTexture>;
  30206. private _uid;
  30207. /**
  30208. * Define if the texture is preventinga material to render or not.
  30209. * If not and the texture is not ready, the engine will use a default black texture instead.
  30210. */
  30211. readonly isBlocking: boolean;
  30212. /**
  30213. * Instantiates a new BaseTexture.
  30214. * Base class of all the textures in babylon.
  30215. * It groups all the common properties the materials, post process, lights... might need
  30216. * in order to make a correct use of the texture.
  30217. * @param scene Define the scene the texture blongs to
  30218. */
  30219. constructor(scene: Nullable<Scene>);
  30220. /**
  30221. * Get the scene the texture belongs to.
  30222. * @returns the scene or null if undefined
  30223. */
  30224. getScene(): Nullable<Scene>;
  30225. /**
  30226. * Get the texture transform matrix used to offset tile the texture for istance.
  30227. * @returns the transformation matrix
  30228. */
  30229. getTextureMatrix(): Matrix;
  30230. /**
  30231. * Get the texture reflection matrix used to rotate/transform the reflection.
  30232. * @returns the reflection matrix
  30233. */
  30234. getReflectionTextureMatrix(): Matrix;
  30235. /**
  30236. * Get the underlying lower level texture from Babylon.
  30237. * @returns the insternal texture
  30238. */
  30239. getInternalTexture(): Nullable<InternalTexture>;
  30240. /**
  30241. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30242. * @returns true if ready or not blocking
  30243. */
  30244. isReadyOrNotBlocking(): boolean;
  30245. /**
  30246. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30247. * @returns true if fully ready
  30248. */
  30249. isReady(): boolean;
  30250. private _cachedSize;
  30251. /**
  30252. * Get the size of the texture.
  30253. * @returns the texture size.
  30254. */
  30255. getSize(): ISize;
  30256. /**
  30257. * Get the base size of the texture.
  30258. * It can be different from the size if the texture has been resized for POT for instance
  30259. * @returns the base size
  30260. */
  30261. getBaseSize(): ISize;
  30262. /**
  30263. * Update the sampling mode of the texture.
  30264. * Default is Trilinear mode.
  30265. *
  30266. * | Value | Type | Description |
  30267. * | ----- | ------------------ | ----------- |
  30268. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30269. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30270. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30271. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30272. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30273. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30274. * | 7 | NEAREST_LINEAR | |
  30275. * | 8 | NEAREST_NEAREST | |
  30276. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30277. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30278. * | 11 | LINEAR_LINEAR | |
  30279. * | 12 | LINEAR_NEAREST | |
  30280. *
  30281. * > _mag_: magnification filter (close to the viewer)
  30282. * > _min_: minification filter (far from the viewer)
  30283. * > _mip_: filter used between mip map levels
  30284. *@param samplingMode Define the new sampling mode of the texture
  30285. */
  30286. updateSamplingMode(samplingMode: number): void;
  30287. /**
  30288. * Scales the texture if is `canRescale()`
  30289. * @param ratio the resize factor we want to use to rescale
  30290. */
  30291. scale(ratio: number): void;
  30292. /**
  30293. * Get if the texture can rescale.
  30294. */
  30295. readonly canRescale: boolean;
  30296. /** @hidden */
  30297. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30298. /** @hidden */
  30299. _rebuild(): void;
  30300. /**
  30301. * Triggers the load sequence in delayed load mode.
  30302. */
  30303. delayLoad(): void;
  30304. /**
  30305. * Clones the texture.
  30306. * @returns the cloned texture
  30307. */
  30308. clone(): Nullable<BaseTexture>;
  30309. /**
  30310. * Get the texture underlying type (INT, FLOAT...)
  30311. */
  30312. readonly textureType: number;
  30313. /**
  30314. * Get the texture underlying format (RGB, RGBA...)
  30315. */
  30316. readonly textureFormat: number;
  30317. /**
  30318. * Indicates that textures need to be re-calculated for all materials
  30319. */
  30320. protected _markAllSubMeshesAsTexturesDirty(): void;
  30321. /**
  30322. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30323. * This will returns an RGBA array buffer containing either in values (0-255) or
  30324. * float values (0-1) depending of the underlying buffer type.
  30325. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30326. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30327. * @param buffer defines a user defined buffer to fill with data (can be null)
  30328. * @returns The Array buffer containing the pixels data.
  30329. */
  30330. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30331. /**
  30332. * Release and destroy the underlying lower level texture aka internalTexture.
  30333. */
  30334. releaseInternalTexture(): void;
  30335. /** @hidden */
  30336. readonly _lodTextureHigh: Nullable<BaseTexture>;
  30337. /** @hidden */
  30338. readonly _lodTextureMid: Nullable<BaseTexture>;
  30339. /** @hidden */
  30340. readonly _lodTextureLow: Nullable<BaseTexture>;
  30341. /**
  30342. * Dispose the texture and release its associated resources.
  30343. */
  30344. dispose(): void;
  30345. /**
  30346. * Serialize the texture into a JSON representation that can be parsed later on.
  30347. * @returns the JSON representation of the texture
  30348. */
  30349. serialize(): any;
  30350. /**
  30351. * Helper function to be called back once a list of texture contains only ready textures.
  30352. * @param textures Define the list of textures to wait for
  30353. * @param callback Define the callback triggered once the entire list will be ready
  30354. */
  30355. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30356. }
  30357. }
  30358. declare module "babylonjs/Materials/effect" {
  30359. import { Observable } from "babylonjs/Misc/observable";
  30360. import { Nullable } from "babylonjs/types";
  30361. import { IDisposable } from "babylonjs/scene";
  30362. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30363. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30364. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30365. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30366. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30367. import { Engine } from "babylonjs/Engines/engine";
  30368. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30369. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30370. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30371. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30372. /**
  30373. * Options to be used when creating an effect.
  30374. */
  30375. export interface IEffectCreationOptions {
  30376. /**
  30377. * Atrributes that will be used in the shader.
  30378. */
  30379. attributes: string[];
  30380. /**
  30381. * Uniform varible names that will be set in the shader.
  30382. */
  30383. uniformsNames: string[];
  30384. /**
  30385. * Uniform buffer variable names that will be set in the shader.
  30386. */
  30387. uniformBuffersNames: string[];
  30388. /**
  30389. * Sampler texture variable names that will be set in the shader.
  30390. */
  30391. samplers: string[];
  30392. /**
  30393. * Define statements that will be set in the shader.
  30394. */
  30395. defines: any;
  30396. /**
  30397. * Possible fallbacks for this effect to improve performance when needed.
  30398. */
  30399. fallbacks: Nullable<IEffectFallbacks>;
  30400. /**
  30401. * Callback that will be called when the shader is compiled.
  30402. */
  30403. onCompiled: Nullable<(effect: Effect) => void>;
  30404. /**
  30405. * Callback that will be called if an error occurs during shader compilation.
  30406. */
  30407. onError: Nullable<(effect: Effect, errors: string) => void>;
  30408. /**
  30409. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30410. */
  30411. indexParameters?: any;
  30412. /**
  30413. * Max number of lights that can be used in the shader.
  30414. */
  30415. maxSimultaneousLights?: number;
  30416. /**
  30417. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30418. */
  30419. transformFeedbackVaryings?: Nullable<string[]>;
  30420. }
  30421. /**
  30422. * Effect containing vertex and fragment shader that can be executed on an object.
  30423. */
  30424. export class Effect implements IDisposable {
  30425. /**
  30426. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30427. */
  30428. static ShadersRepository: string;
  30429. /**
  30430. * Name of the effect.
  30431. */
  30432. name: any;
  30433. /**
  30434. * String container all the define statements that should be set on the shader.
  30435. */
  30436. defines: string;
  30437. /**
  30438. * Callback that will be called when the shader is compiled.
  30439. */
  30440. onCompiled: Nullable<(effect: Effect) => void>;
  30441. /**
  30442. * Callback that will be called if an error occurs during shader compilation.
  30443. */
  30444. onError: Nullable<(effect: Effect, errors: string) => void>;
  30445. /**
  30446. * Callback that will be called when effect is bound.
  30447. */
  30448. onBind: Nullable<(effect: Effect) => void>;
  30449. /**
  30450. * Unique ID of the effect.
  30451. */
  30452. uniqueId: number;
  30453. /**
  30454. * Observable that will be called when the shader is compiled.
  30455. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30456. */
  30457. onCompileObservable: Observable<Effect>;
  30458. /**
  30459. * Observable that will be called if an error occurs during shader compilation.
  30460. */
  30461. onErrorObservable: Observable<Effect>;
  30462. /** @hidden */
  30463. _onBindObservable: Nullable<Observable<Effect>>;
  30464. /**
  30465. * Observable that will be called when effect is bound.
  30466. */
  30467. readonly onBindObservable: Observable<Effect>;
  30468. /** @hidden */
  30469. _bonesComputationForcedToCPU: boolean;
  30470. private static _uniqueIdSeed;
  30471. private _engine;
  30472. private _uniformBuffersNames;
  30473. private _uniformsNames;
  30474. private _samplerList;
  30475. private _samplers;
  30476. private _isReady;
  30477. private _compilationError;
  30478. private _allFallbacksProcessed;
  30479. private _attributesNames;
  30480. private _attributes;
  30481. private _attributeLocationByName;
  30482. private _uniforms;
  30483. /**
  30484. * Key for the effect.
  30485. * @hidden
  30486. */
  30487. _key: string;
  30488. private _indexParameters;
  30489. private _fallbacks;
  30490. private _vertexSourceCode;
  30491. private _fragmentSourceCode;
  30492. private _vertexSourceCodeOverride;
  30493. private _fragmentSourceCodeOverride;
  30494. private _transformFeedbackVaryings;
  30495. /**
  30496. * Compiled shader to webGL program.
  30497. * @hidden
  30498. */
  30499. _pipelineContext: Nullable<IPipelineContext>;
  30500. private _valueCache;
  30501. private static _baseCache;
  30502. /**
  30503. * Instantiates an effect.
  30504. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30505. * @param baseName Name of the effect.
  30506. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30507. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30508. * @param samplers List of sampler variables that will be passed to the shader.
  30509. * @param engine Engine to be used to render the effect
  30510. * @param defines Define statements to be added to the shader.
  30511. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30512. * @param onCompiled Callback that will be called when the shader is compiled.
  30513. * @param onError Callback that will be called if an error occurs during shader compilation.
  30514. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30515. */
  30516. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  30517. private _useFinalCode;
  30518. /**
  30519. * Unique key for this effect
  30520. */
  30521. readonly key: string;
  30522. /**
  30523. * If the effect has been compiled and prepared.
  30524. * @returns if the effect is compiled and prepared.
  30525. */
  30526. isReady(): boolean;
  30527. private _isReadyInternal;
  30528. /**
  30529. * The engine the effect was initialized with.
  30530. * @returns the engine.
  30531. */
  30532. getEngine(): Engine;
  30533. /**
  30534. * The pipeline context for this effect
  30535. * @returns the associated pipeline context
  30536. */
  30537. getPipelineContext(): Nullable<IPipelineContext>;
  30538. /**
  30539. * The set of names of attribute variables for the shader.
  30540. * @returns An array of attribute names.
  30541. */
  30542. getAttributesNames(): string[];
  30543. /**
  30544. * Returns the attribute at the given index.
  30545. * @param index The index of the attribute.
  30546. * @returns The location of the attribute.
  30547. */
  30548. getAttributeLocation(index: number): number;
  30549. /**
  30550. * Returns the attribute based on the name of the variable.
  30551. * @param name of the attribute to look up.
  30552. * @returns the attribute location.
  30553. */
  30554. getAttributeLocationByName(name: string): number;
  30555. /**
  30556. * The number of attributes.
  30557. * @returns the numnber of attributes.
  30558. */
  30559. getAttributesCount(): number;
  30560. /**
  30561. * Gets the index of a uniform variable.
  30562. * @param uniformName of the uniform to look up.
  30563. * @returns the index.
  30564. */
  30565. getUniformIndex(uniformName: string): number;
  30566. /**
  30567. * Returns the attribute based on the name of the variable.
  30568. * @param uniformName of the uniform to look up.
  30569. * @returns the location of the uniform.
  30570. */
  30571. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30572. /**
  30573. * Returns an array of sampler variable names
  30574. * @returns The array of sampler variable neames.
  30575. */
  30576. getSamplers(): string[];
  30577. /**
  30578. * The error from the last compilation.
  30579. * @returns the error string.
  30580. */
  30581. getCompilationError(): string;
  30582. /**
  30583. * Gets a boolean indicating that all fallbacks were used during compilation
  30584. * @returns true if all fallbacks were used
  30585. */
  30586. allFallbacksProcessed(): boolean;
  30587. /**
  30588. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30589. * @param func The callback to be used.
  30590. */
  30591. executeWhenCompiled(func: (effect: Effect) => void): void;
  30592. private _checkIsReady;
  30593. private _loadShader;
  30594. /**
  30595. * Recompiles the webGL program
  30596. * @param vertexSourceCode The source code for the vertex shader.
  30597. * @param fragmentSourceCode The source code for the fragment shader.
  30598. * @param onCompiled Callback called when completed.
  30599. * @param onError Callback called on error.
  30600. * @hidden
  30601. */
  30602. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30603. /**
  30604. * Prepares the effect
  30605. * @hidden
  30606. */
  30607. _prepareEffect(): void;
  30608. private _processCompilationErrors;
  30609. /**
  30610. * Checks if the effect is supported. (Must be called after compilation)
  30611. */
  30612. readonly isSupported: boolean;
  30613. /**
  30614. * Binds a texture to the engine to be used as output of the shader.
  30615. * @param channel Name of the output variable.
  30616. * @param texture Texture to bind.
  30617. * @hidden
  30618. */
  30619. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30620. /**
  30621. * Sets a texture on the engine to be used in the shader.
  30622. * @param channel Name of the sampler variable.
  30623. * @param texture Texture to set.
  30624. */
  30625. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30626. /**
  30627. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30628. * @param channel Name of the sampler variable.
  30629. * @param texture Texture to set.
  30630. */
  30631. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30632. /**
  30633. * Sets an array of textures on the engine to be used in the shader.
  30634. * @param channel Name of the variable.
  30635. * @param textures Textures to set.
  30636. */
  30637. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30638. /**
  30639. * 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)
  30640. * @param channel Name of the sampler variable.
  30641. * @param postProcess Post process to get the input texture from.
  30642. */
  30643. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30644. /**
  30645. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30646. * 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)
  30647. * @param channel Name of the sampler variable.
  30648. * @param postProcess Post process to get the output texture from.
  30649. */
  30650. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30651. /** @hidden */
  30652. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30653. /** @hidden */
  30654. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30655. /** @hidden */
  30656. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30657. /** @hidden */
  30658. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30659. /**
  30660. * Binds a buffer to a uniform.
  30661. * @param buffer Buffer to bind.
  30662. * @param name Name of the uniform variable to bind to.
  30663. */
  30664. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30665. /**
  30666. * Binds block to a uniform.
  30667. * @param blockName Name of the block to bind.
  30668. * @param index Index to bind.
  30669. */
  30670. bindUniformBlock(blockName: string, index: number): void;
  30671. /**
  30672. * Sets an interger value on a uniform variable.
  30673. * @param uniformName Name of the variable.
  30674. * @param value Value to be set.
  30675. * @returns this effect.
  30676. */
  30677. setInt(uniformName: string, value: number): Effect;
  30678. /**
  30679. * Sets an int array on a uniform variable.
  30680. * @param uniformName Name of the variable.
  30681. * @param array array to be set.
  30682. * @returns this effect.
  30683. */
  30684. setIntArray(uniformName: string, array: Int32Array): Effect;
  30685. /**
  30686. * 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)
  30687. * @param uniformName Name of the variable.
  30688. * @param array array to be set.
  30689. * @returns this effect.
  30690. */
  30691. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30692. /**
  30693. * 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)
  30694. * @param uniformName Name of the variable.
  30695. * @param array array to be set.
  30696. * @returns this effect.
  30697. */
  30698. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30699. /**
  30700. * 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)
  30701. * @param uniformName Name of the variable.
  30702. * @param array array to be set.
  30703. * @returns this effect.
  30704. */
  30705. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30706. /**
  30707. * Sets an float array on a uniform variable.
  30708. * @param uniformName Name of the variable.
  30709. * @param array array to be set.
  30710. * @returns this effect.
  30711. */
  30712. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30713. /**
  30714. * 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)
  30715. * @param uniformName Name of the variable.
  30716. * @param array array to be set.
  30717. * @returns this effect.
  30718. */
  30719. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30720. /**
  30721. * 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)
  30722. * @param uniformName Name of the variable.
  30723. * @param array array to be set.
  30724. * @returns this effect.
  30725. */
  30726. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30727. /**
  30728. * 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)
  30729. * @param uniformName Name of the variable.
  30730. * @param array array to be set.
  30731. * @returns this effect.
  30732. */
  30733. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30734. /**
  30735. * Sets an array on a uniform variable.
  30736. * @param uniformName Name of the variable.
  30737. * @param array array to be set.
  30738. * @returns this effect.
  30739. */
  30740. setArray(uniformName: string, array: number[]): Effect;
  30741. /**
  30742. * 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)
  30743. * @param uniformName Name of the variable.
  30744. * @param array array to be set.
  30745. * @returns this effect.
  30746. */
  30747. setArray2(uniformName: string, array: number[]): Effect;
  30748. /**
  30749. * 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)
  30750. * @param uniformName Name of the variable.
  30751. * @param array array to be set.
  30752. * @returns this effect.
  30753. */
  30754. setArray3(uniformName: string, array: number[]): Effect;
  30755. /**
  30756. * 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)
  30757. * @param uniformName Name of the variable.
  30758. * @param array array to be set.
  30759. * @returns this effect.
  30760. */
  30761. setArray4(uniformName: string, array: number[]): Effect;
  30762. /**
  30763. * Sets matrices on a uniform variable.
  30764. * @param uniformName Name of the variable.
  30765. * @param matrices matrices to be set.
  30766. * @returns this effect.
  30767. */
  30768. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30769. /**
  30770. * Sets matrix on a uniform variable.
  30771. * @param uniformName Name of the variable.
  30772. * @param matrix matrix to be set.
  30773. * @returns this effect.
  30774. */
  30775. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30776. /**
  30777. * 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)
  30778. * @param uniformName Name of the variable.
  30779. * @param matrix matrix to be set.
  30780. * @returns this effect.
  30781. */
  30782. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30783. /**
  30784. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30785. * @param uniformName Name of the variable.
  30786. * @param matrix matrix to be set.
  30787. * @returns this effect.
  30788. */
  30789. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30790. /**
  30791. * Sets a float on a uniform variable.
  30792. * @param uniformName Name of the variable.
  30793. * @param value value to be set.
  30794. * @returns this effect.
  30795. */
  30796. setFloat(uniformName: string, value: number): Effect;
  30797. /**
  30798. * Sets a boolean on a uniform variable.
  30799. * @param uniformName Name of the variable.
  30800. * @param bool value to be set.
  30801. * @returns this effect.
  30802. */
  30803. setBool(uniformName: string, bool: boolean): Effect;
  30804. /**
  30805. * Sets a Vector2 on a uniform variable.
  30806. * @param uniformName Name of the variable.
  30807. * @param vector2 vector2 to be set.
  30808. * @returns this effect.
  30809. */
  30810. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30811. /**
  30812. * Sets a float2 on a uniform variable.
  30813. * @param uniformName Name of the variable.
  30814. * @param x First float in float2.
  30815. * @param y Second float in float2.
  30816. * @returns this effect.
  30817. */
  30818. setFloat2(uniformName: string, x: number, y: number): Effect;
  30819. /**
  30820. * Sets a Vector3 on a uniform variable.
  30821. * @param uniformName Name of the variable.
  30822. * @param vector3 Value to be set.
  30823. * @returns this effect.
  30824. */
  30825. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30826. /**
  30827. * Sets a float3 on a uniform variable.
  30828. * @param uniformName Name of the variable.
  30829. * @param x First float in float3.
  30830. * @param y Second float in float3.
  30831. * @param z Third float in float3.
  30832. * @returns this effect.
  30833. */
  30834. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30835. /**
  30836. * Sets a Vector4 on a uniform variable.
  30837. * @param uniformName Name of the variable.
  30838. * @param vector4 Value to be set.
  30839. * @returns this effect.
  30840. */
  30841. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30842. /**
  30843. * Sets a float4 on a uniform variable.
  30844. * @param uniformName Name of the variable.
  30845. * @param x First float in float4.
  30846. * @param y Second float in float4.
  30847. * @param z Third float in float4.
  30848. * @param w Fourth float in float4.
  30849. * @returns this effect.
  30850. */
  30851. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30852. /**
  30853. * Sets a Color3 on a uniform variable.
  30854. * @param uniformName Name of the variable.
  30855. * @param color3 Value to be set.
  30856. * @returns this effect.
  30857. */
  30858. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30859. /**
  30860. * Sets a Color4 on a uniform variable.
  30861. * @param uniformName Name of the variable.
  30862. * @param color3 Value to be set.
  30863. * @param alpha Alpha value to be set.
  30864. * @returns this effect.
  30865. */
  30866. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30867. /**
  30868. * Sets a Color4 on a uniform variable
  30869. * @param uniformName defines the name of the variable
  30870. * @param color4 defines the value to be set
  30871. * @returns this effect.
  30872. */
  30873. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30874. /** Release all associated resources */
  30875. dispose(): void;
  30876. /**
  30877. * This function will add a new shader to the shader store
  30878. * @param name the name of the shader
  30879. * @param pixelShader optional pixel shader content
  30880. * @param vertexShader optional vertex shader content
  30881. */
  30882. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30883. /**
  30884. * Store of each shader (The can be looked up using effect.key)
  30885. */
  30886. static ShadersStore: {
  30887. [key: string]: string;
  30888. };
  30889. /**
  30890. * Store of each included file for a shader (The can be looked up using effect.key)
  30891. */
  30892. static IncludesShadersStore: {
  30893. [key: string]: string;
  30894. };
  30895. /**
  30896. * Resets the cache of effects.
  30897. */
  30898. static ResetCache(): void;
  30899. }
  30900. }
  30901. declare module "babylonjs/Engines/engineCapabilities" {
  30902. /**
  30903. * Interface used to describe the capabilities of the engine relatively to the current browser
  30904. */
  30905. export interface EngineCapabilities {
  30906. /** Maximum textures units per fragment shader */
  30907. maxTexturesImageUnits: number;
  30908. /** Maximum texture units per vertex shader */
  30909. maxVertexTextureImageUnits: number;
  30910. /** Maximum textures units in the entire pipeline */
  30911. maxCombinedTexturesImageUnits: number;
  30912. /** Maximum texture size */
  30913. maxTextureSize: number;
  30914. /** Maximum texture samples */
  30915. maxSamples?: number;
  30916. /** Maximum cube texture size */
  30917. maxCubemapTextureSize: number;
  30918. /** Maximum render texture size */
  30919. maxRenderTextureSize: number;
  30920. /** Maximum number of vertex attributes */
  30921. maxVertexAttribs: number;
  30922. /** Maximum number of varyings */
  30923. maxVaryingVectors: number;
  30924. /** Maximum number of uniforms per vertex shader */
  30925. maxVertexUniformVectors: number;
  30926. /** Maximum number of uniforms per fragment shader */
  30927. maxFragmentUniformVectors: number;
  30928. /** Defines if standard derivates (dx/dy) are supported */
  30929. standardDerivatives: boolean;
  30930. /** Defines if s3tc texture compression is supported */
  30931. s3tc?: WEBGL_compressed_texture_s3tc;
  30932. /** Defines if pvrtc texture compression is supported */
  30933. pvrtc: any;
  30934. /** Defines if etc1 texture compression is supported */
  30935. etc1: any;
  30936. /** Defines if etc2 texture compression is supported */
  30937. etc2: any;
  30938. /** Defines if astc texture compression is supported */
  30939. astc: any;
  30940. /** Defines if float textures are supported */
  30941. textureFloat: boolean;
  30942. /** Defines if vertex array objects are supported */
  30943. vertexArrayObject: boolean;
  30944. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30945. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30946. /** Gets the maximum level of anisotropy supported */
  30947. maxAnisotropy: number;
  30948. /** Defines if instancing is supported */
  30949. instancedArrays: boolean;
  30950. /** Defines if 32 bits indices are supported */
  30951. uintIndices: boolean;
  30952. /** Defines if high precision shaders are supported */
  30953. highPrecisionShaderSupported: boolean;
  30954. /** Defines if depth reading in the fragment shader is supported */
  30955. fragmentDepthSupported: boolean;
  30956. /** Defines if float texture linear filtering is supported*/
  30957. textureFloatLinearFiltering: boolean;
  30958. /** Defines if rendering to float textures is supported */
  30959. textureFloatRender: boolean;
  30960. /** Defines if half float textures are supported*/
  30961. textureHalfFloat: boolean;
  30962. /** Defines if half float texture linear filtering is supported*/
  30963. textureHalfFloatLinearFiltering: boolean;
  30964. /** Defines if rendering to half float textures is supported */
  30965. textureHalfFloatRender: boolean;
  30966. /** Defines if textureLOD shader command is supported */
  30967. textureLOD: boolean;
  30968. /** Defines if draw buffers extension is supported */
  30969. drawBuffersExtension: boolean;
  30970. /** Defines if depth textures are supported */
  30971. depthTextureExtension: boolean;
  30972. /** Defines if float color buffer are supported */
  30973. colorBufferFloat: boolean;
  30974. /** Gets disjoint timer query extension (null if not supported) */
  30975. timerQuery?: EXT_disjoint_timer_query;
  30976. /** Defines if timestamp can be used with timer query */
  30977. canUseTimestampForTimerQuery: boolean;
  30978. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30979. multiview?: any;
  30980. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30981. oculusMultiview?: any;
  30982. /** Function used to let the system compiles shaders in background */
  30983. parallelShaderCompile?: {
  30984. COMPLETION_STATUS_KHR: number;
  30985. };
  30986. /** Max number of texture samples for MSAA */
  30987. maxMSAASamples: number;
  30988. /** Defines if the blend min max extension is supported */
  30989. blendMinMax: boolean;
  30990. }
  30991. }
  30992. declare module "babylonjs/States/depthCullingState" {
  30993. import { Nullable } from "babylonjs/types";
  30994. /**
  30995. * @hidden
  30996. **/
  30997. export class DepthCullingState {
  30998. private _isDepthTestDirty;
  30999. private _isDepthMaskDirty;
  31000. private _isDepthFuncDirty;
  31001. private _isCullFaceDirty;
  31002. private _isCullDirty;
  31003. private _isZOffsetDirty;
  31004. private _isFrontFaceDirty;
  31005. private _depthTest;
  31006. private _depthMask;
  31007. private _depthFunc;
  31008. private _cull;
  31009. private _cullFace;
  31010. private _zOffset;
  31011. private _frontFace;
  31012. /**
  31013. * Initializes the state.
  31014. */
  31015. constructor();
  31016. readonly isDirty: boolean;
  31017. zOffset: number;
  31018. cullFace: Nullable<number>;
  31019. cull: Nullable<boolean>;
  31020. depthFunc: Nullable<number>;
  31021. depthMask: boolean;
  31022. depthTest: boolean;
  31023. frontFace: Nullable<number>;
  31024. reset(): void;
  31025. apply(gl: WebGLRenderingContext): void;
  31026. }
  31027. }
  31028. declare module "babylonjs/States/stencilState" {
  31029. /**
  31030. * @hidden
  31031. **/
  31032. export class StencilState {
  31033. /** 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 */
  31034. static readonly ALWAYS: number;
  31035. /** Passed to stencilOperation to specify that stencil value must be kept */
  31036. static readonly KEEP: number;
  31037. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31038. static readonly REPLACE: number;
  31039. private _isStencilTestDirty;
  31040. private _isStencilMaskDirty;
  31041. private _isStencilFuncDirty;
  31042. private _isStencilOpDirty;
  31043. private _stencilTest;
  31044. private _stencilMask;
  31045. private _stencilFunc;
  31046. private _stencilFuncRef;
  31047. private _stencilFuncMask;
  31048. private _stencilOpStencilFail;
  31049. private _stencilOpDepthFail;
  31050. private _stencilOpStencilDepthPass;
  31051. readonly isDirty: boolean;
  31052. stencilFunc: number;
  31053. stencilFuncRef: number;
  31054. stencilFuncMask: number;
  31055. stencilOpStencilFail: number;
  31056. stencilOpDepthFail: number;
  31057. stencilOpStencilDepthPass: number;
  31058. stencilMask: number;
  31059. stencilTest: boolean;
  31060. constructor();
  31061. reset(): void;
  31062. apply(gl: WebGLRenderingContext): void;
  31063. }
  31064. }
  31065. declare module "babylonjs/States/alphaCullingState" {
  31066. /**
  31067. * @hidden
  31068. **/
  31069. export class AlphaState {
  31070. private _isAlphaBlendDirty;
  31071. private _isBlendFunctionParametersDirty;
  31072. private _isBlendEquationParametersDirty;
  31073. private _isBlendConstantsDirty;
  31074. private _alphaBlend;
  31075. private _blendFunctionParameters;
  31076. private _blendEquationParameters;
  31077. private _blendConstants;
  31078. /**
  31079. * Initializes the state.
  31080. */
  31081. constructor();
  31082. readonly isDirty: boolean;
  31083. alphaBlend: boolean;
  31084. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31085. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31086. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31087. reset(): void;
  31088. apply(gl: WebGLRenderingContext): void;
  31089. }
  31090. }
  31091. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31092. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31093. /** @hidden */
  31094. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31095. attributeProcessor(attribute: string): string;
  31096. varyingProcessor(varying: string, isFragment: boolean): string;
  31097. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31098. }
  31099. }
  31100. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31101. /**
  31102. * Interface for attribute information associated with buffer instanciation
  31103. */
  31104. export interface InstancingAttributeInfo {
  31105. /**
  31106. * Name of the GLSL attribute
  31107. * if attribute index is not specified, this is used to retrieve the index from the effect
  31108. */
  31109. attributeName: string;
  31110. /**
  31111. * Index/offset of the attribute in the vertex shader
  31112. * if not specified, this will be computes from the name.
  31113. */
  31114. index?: number;
  31115. /**
  31116. * size of the attribute, 1, 2, 3 or 4
  31117. */
  31118. attributeSize: number;
  31119. /**
  31120. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31121. */
  31122. offset: number;
  31123. /**
  31124. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31125. * default to 1
  31126. */
  31127. divisor?: number;
  31128. /**
  31129. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31130. * default is FLOAT
  31131. */
  31132. attributeType?: number;
  31133. /**
  31134. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31135. */
  31136. normalized?: boolean;
  31137. }
  31138. }
  31139. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31140. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31141. import { Nullable } from "babylonjs/types";
  31142. module "babylonjs/Engines/thinEngine" {
  31143. interface ThinEngine {
  31144. /**
  31145. * Update a video texture
  31146. * @param texture defines the texture to update
  31147. * @param video defines the video element to use
  31148. * @param invertY defines if data must be stored with Y axis inverted
  31149. */
  31150. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31151. }
  31152. }
  31153. }
  31154. declare module "babylonjs/Materials/Textures/videoTexture" {
  31155. import { Observable } from "babylonjs/Misc/observable";
  31156. import { Nullable } from "babylonjs/types";
  31157. import { Scene } from "babylonjs/scene";
  31158. import { Texture } from "babylonjs/Materials/Textures/texture";
  31159. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31160. /**
  31161. * Settings for finer control over video usage
  31162. */
  31163. export interface VideoTextureSettings {
  31164. /**
  31165. * Applies `autoplay` to video, if specified
  31166. */
  31167. autoPlay?: boolean;
  31168. /**
  31169. * Applies `loop` to video, if specified
  31170. */
  31171. loop?: boolean;
  31172. /**
  31173. * Automatically updates internal texture from video at every frame in the render loop
  31174. */
  31175. autoUpdateTexture: boolean;
  31176. /**
  31177. * Image src displayed during the video loading or until the user interacts with the video.
  31178. */
  31179. poster?: string;
  31180. }
  31181. /**
  31182. * If you want to display a video in your scene, this is the special texture for that.
  31183. * This special texture works similar to other textures, with the exception of a few parameters.
  31184. * @see https://doc.babylonjs.com/how_to/video_texture
  31185. */
  31186. export class VideoTexture extends Texture {
  31187. /**
  31188. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31189. */
  31190. readonly autoUpdateTexture: boolean;
  31191. /**
  31192. * The video instance used by the texture internally
  31193. */
  31194. readonly video: HTMLVideoElement;
  31195. private _onUserActionRequestedObservable;
  31196. /**
  31197. * Event triggerd when a dom action is required by the user to play the video.
  31198. * This happens due to recent changes in browser policies preventing video to auto start.
  31199. */
  31200. readonly onUserActionRequestedObservable: Observable<Texture>;
  31201. private _generateMipMaps;
  31202. private _engine;
  31203. private _stillImageCaptured;
  31204. private _displayingPosterTexture;
  31205. private _settings;
  31206. private _createInternalTextureOnEvent;
  31207. private _frameId;
  31208. /**
  31209. * Creates a video texture.
  31210. * If you want to display a video in your scene, this is the special texture for that.
  31211. * This special texture works similar to other textures, with the exception of a few parameters.
  31212. * @see https://doc.babylonjs.com/how_to/video_texture
  31213. * @param name optional name, will detect from video source, if not defined
  31214. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31215. * @param scene is obviously the current scene.
  31216. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31217. * @param invertY is false by default but can be used to invert video on Y axis
  31218. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31219. * @param settings allows finer control over video usage
  31220. */
  31221. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31222. private _getName;
  31223. private _getVideo;
  31224. private _createInternalTexture;
  31225. private reset;
  31226. /**
  31227. * @hidden Internal method to initiate `update`.
  31228. */
  31229. _rebuild(): void;
  31230. /**
  31231. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31232. */
  31233. update(): void;
  31234. /**
  31235. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31236. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31237. */
  31238. updateTexture(isVisible: boolean): void;
  31239. protected _updateInternalTexture: () => void;
  31240. /**
  31241. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31242. * @param url New url.
  31243. */
  31244. updateURL(url: string): void;
  31245. /**
  31246. * Dispose the texture and release its associated resources.
  31247. */
  31248. dispose(): void;
  31249. /**
  31250. * Creates a video texture straight from a stream.
  31251. * @param scene Define the scene the texture should be created in
  31252. * @param stream Define the stream the texture should be created from
  31253. * @returns The created video texture as a promise
  31254. */
  31255. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31256. /**
  31257. * Creates a video texture straight from your WebCam video feed.
  31258. * @param scene Define the scene the texture should be created in
  31259. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31260. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31261. * @returns The created video texture as a promise
  31262. */
  31263. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31264. minWidth: number;
  31265. maxWidth: number;
  31266. minHeight: number;
  31267. maxHeight: number;
  31268. deviceId: string;
  31269. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31270. /**
  31271. * Creates a video texture straight from your WebCam video feed.
  31272. * @param scene Define the scene the texture should be created in
  31273. * @param onReady Define a callback to triggered once the texture will be ready
  31274. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31275. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31276. */
  31277. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31278. minWidth: number;
  31279. maxWidth: number;
  31280. minHeight: number;
  31281. maxHeight: number;
  31282. deviceId: string;
  31283. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31284. }
  31285. }
  31286. declare module "babylonjs/Engines/thinEngine" {
  31287. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31288. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31289. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31290. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31291. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31292. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31293. import { Observable } from "babylonjs/Misc/observable";
  31294. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31295. import { StencilState } from "babylonjs/States/stencilState";
  31296. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31297. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31298. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31299. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31300. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31301. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31302. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31303. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31304. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31306. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31307. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31308. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31309. /**
  31310. * Defines the interface used by objects working like Scene
  31311. * @hidden
  31312. */
  31313. interface ISceneLike {
  31314. _addPendingData(data: any): void;
  31315. _removePendingData(data: any): void;
  31316. offlineProvider: IOfflineProvider;
  31317. }
  31318. /** Interface defining initialization parameters for Engine class */
  31319. export interface EngineOptions extends WebGLContextAttributes {
  31320. /**
  31321. * Defines if the engine should no exceed a specified device ratio
  31322. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31323. */
  31324. limitDeviceRatio?: number;
  31325. /**
  31326. * Defines if webvr should be enabled automatically
  31327. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31328. */
  31329. autoEnableWebVR?: boolean;
  31330. /**
  31331. * Defines if webgl2 should be turned off even if supported
  31332. * @see http://doc.babylonjs.com/features/webgl2
  31333. */
  31334. disableWebGL2Support?: boolean;
  31335. /**
  31336. * Defines if webaudio should be initialized as well
  31337. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31338. */
  31339. audioEngine?: boolean;
  31340. /**
  31341. * Defines if animations should run using a deterministic lock step
  31342. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31343. */
  31344. deterministicLockstep?: boolean;
  31345. /** Defines the maximum steps to use with deterministic lock step mode */
  31346. lockstepMaxSteps?: number;
  31347. /** Defines the seconds between each deterministic lock step */
  31348. timeStep?: number;
  31349. /**
  31350. * Defines that engine should ignore context lost events
  31351. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31352. */
  31353. doNotHandleContextLost?: boolean;
  31354. /**
  31355. * Defines that engine should ignore modifying touch action attribute and style
  31356. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31357. */
  31358. doNotHandleTouchAction?: boolean;
  31359. /**
  31360. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31361. */
  31362. useHighPrecisionFloats?: boolean;
  31363. }
  31364. /**
  31365. * The base engine class (root of all engines)
  31366. */
  31367. export class ThinEngine {
  31368. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31369. static ExceptionList: ({
  31370. key: string;
  31371. capture: string;
  31372. captureConstraint: number;
  31373. targets: string[];
  31374. } | {
  31375. key: string;
  31376. capture: null;
  31377. captureConstraint: null;
  31378. targets: string[];
  31379. })[];
  31380. /** @hidden */
  31381. static _TextureLoaders: IInternalTextureLoader[];
  31382. /**
  31383. * Returns the current npm package of the sdk
  31384. */
  31385. static readonly NpmPackage: string;
  31386. /**
  31387. * Returns the current version of the framework
  31388. */
  31389. static readonly Version: string;
  31390. /**
  31391. * Returns a string describing the current engine
  31392. */
  31393. readonly description: string;
  31394. /**
  31395. * Gets or sets the epsilon value used by collision engine
  31396. */
  31397. static CollisionsEpsilon: number;
  31398. /**
  31399. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31400. */
  31401. static ShadersRepository: string;
  31402. /**
  31403. * Gets or sets the textures that the engine should not attempt to load as compressed
  31404. */
  31405. protected _excludedCompressedTextures: string[];
  31406. /**
  31407. * Filters the compressed texture formats to only include
  31408. * files that are not included in the skippable list
  31409. *
  31410. * @param url the current extension
  31411. * @param textureFormatInUse the current compressed texture format
  31412. * @returns "format" string
  31413. */
  31414. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31415. /** @hidden */
  31416. _shaderProcessor: IShaderProcessor;
  31417. /**
  31418. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31419. */
  31420. forcePOTTextures: boolean;
  31421. /**
  31422. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31423. */
  31424. isFullscreen: boolean;
  31425. /**
  31426. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31427. */
  31428. cullBackFaces: boolean;
  31429. /**
  31430. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31431. */
  31432. renderEvenInBackground: boolean;
  31433. /**
  31434. * Gets or sets a boolean indicating that cache can be kept between frames
  31435. */
  31436. preventCacheWipeBetweenFrames: boolean;
  31437. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31438. validateShaderPrograms: boolean;
  31439. /**
  31440. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31441. * This can provide greater z depth for distant objects.
  31442. */
  31443. useReverseDepthBuffer: boolean;
  31444. /**
  31445. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31446. */
  31447. disableUniformBuffers: boolean;
  31448. /** @hidden */
  31449. _uniformBuffers: UniformBuffer[];
  31450. /**
  31451. * Gets a boolean indicating that the engine supports uniform buffers
  31452. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31453. */
  31454. readonly supportsUniformBuffers: boolean;
  31455. /** @hidden */
  31456. _gl: WebGLRenderingContext;
  31457. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31458. protected _windowIsBackground: boolean;
  31459. protected _webGLVersion: number;
  31460. protected _creationOptions: EngineOptions;
  31461. protected _highPrecisionShadersAllowed: boolean;
  31462. /** @hidden */
  31463. readonly _shouldUseHighPrecisionShader: boolean;
  31464. /**
  31465. * Gets a boolean indicating that only power of 2 textures are supported
  31466. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31467. */
  31468. readonly needPOTTextures: boolean;
  31469. /** @hidden */
  31470. _badOS: boolean;
  31471. /** @hidden */
  31472. _badDesktopOS: boolean;
  31473. private _hardwareScalingLevel;
  31474. /** @hidden */
  31475. _caps: EngineCapabilities;
  31476. private _isStencilEnable;
  31477. private _glVersion;
  31478. private _glRenderer;
  31479. private _glVendor;
  31480. /** @hidden */
  31481. _videoTextureSupported: boolean;
  31482. protected _renderingQueueLaunched: boolean;
  31483. protected _activeRenderLoops: (() => void)[];
  31484. /**
  31485. * Observable signaled when a context lost event is raised
  31486. */
  31487. onContextLostObservable: Observable<ThinEngine>;
  31488. /**
  31489. * Observable signaled when a context restored event is raised
  31490. */
  31491. onContextRestoredObservable: Observable<ThinEngine>;
  31492. private _onContextLost;
  31493. private _onContextRestored;
  31494. protected _contextWasLost: boolean;
  31495. /** @hidden */
  31496. _doNotHandleContextLost: boolean;
  31497. /**
  31498. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31499. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31500. */
  31501. doNotHandleContextLost: boolean;
  31502. /**
  31503. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31504. */
  31505. disableVertexArrayObjects: boolean;
  31506. /** @hidden */
  31507. protected _colorWrite: boolean;
  31508. /** @hidden */
  31509. protected _colorWriteChanged: boolean;
  31510. /** @hidden */
  31511. protected _depthCullingState: DepthCullingState;
  31512. /** @hidden */
  31513. protected _stencilState: StencilState;
  31514. /** @hidden */
  31515. _alphaState: AlphaState;
  31516. /** @hidden */
  31517. _alphaMode: number;
  31518. /** @hidden */
  31519. _alphaEquation: number;
  31520. /** @hidden */
  31521. _internalTexturesCache: InternalTexture[];
  31522. /** @hidden */
  31523. protected _activeChannel: number;
  31524. private _currentTextureChannel;
  31525. /** @hidden */
  31526. protected _boundTexturesCache: {
  31527. [key: string]: Nullable<InternalTexture>;
  31528. };
  31529. /** @hidden */
  31530. protected _currentEffect: Nullable<Effect>;
  31531. /** @hidden */
  31532. protected _currentProgram: Nullable<WebGLProgram>;
  31533. private _compiledEffects;
  31534. private _vertexAttribArraysEnabled;
  31535. /** @hidden */
  31536. protected _cachedViewport: Nullable<IViewportLike>;
  31537. private _cachedVertexArrayObject;
  31538. /** @hidden */
  31539. protected _cachedVertexBuffers: any;
  31540. /** @hidden */
  31541. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31542. /** @hidden */
  31543. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31544. /** @hidden */
  31545. _currentRenderTarget: Nullable<InternalTexture>;
  31546. private _uintIndicesCurrentlySet;
  31547. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31548. /** @hidden */
  31549. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31550. private _currentBufferPointers;
  31551. private _currentInstanceLocations;
  31552. private _currentInstanceBuffers;
  31553. private _textureUnits;
  31554. /** @hidden */
  31555. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31556. /** @hidden */
  31557. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31558. /** @hidden */
  31559. _boundRenderFunction: any;
  31560. private _vaoRecordInProgress;
  31561. private _mustWipeVertexAttributes;
  31562. private _emptyTexture;
  31563. private _emptyCubeTexture;
  31564. private _emptyTexture3D;
  31565. private _emptyTexture2DArray;
  31566. /** @hidden */
  31567. _frameHandler: number;
  31568. private _nextFreeTextureSlots;
  31569. private _maxSimultaneousTextures;
  31570. private _activeRequests;
  31571. protected _texturesSupported: string[];
  31572. /** @hidden */
  31573. _textureFormatInUse: Nullable<string>;
  31574. protected readonly _supportsHardwareTextureRescaling: boolean;
  31575. /**
  31576. * Gets the list of texture formats supported
  31577. */
  31578. readonly texturesSupported: Array<string>;
  31579. /**
  31580. * Gets the list of texture formats in use
  31581. */
  31582. readonly textureFormatInUse: Nullable<string>;
  31583. /**
  31584. * Gets the current viewport
  31585. */
  31586. readonly currentViewport: Nullable<IViewportLike>;
  31587. /**
  31588. * Gets the default empty texture
  31589. */
  31590. readonly emptyTexture: InternalTexture;
  31591. /**
  31592. * Gets the default empty 3D texture
  31593. */
  31594. readonly emptyTexture3D: InternalTexture;
  31595. /**
  31596. * Gets the default empty 2D array texture
  31597. */
  31598. readonly emptyTexture2DArray: InternalTexture;
  31599. /**
  31600. * Gets the default empty cube texture
  31601. */
  31602. readonly emptyCubeTexture: InternalTexture;
  31603. /**
  31604. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31605. */
  31606. readonly premultipliedAlpha: boolean;
  31607. /**
  31608. * Observable event triggered before each texture is initialized
  31609. */
  31610. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31611. /**
  31612. * Creates a new engine
  31613. * @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
  31614. * @param antialias defines enable antialiasing (default: false)
  31615. * @param options defines further options to be sent to the getContext() function
  31616. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31617. */
  31618. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31619. private _rebuildInternalTextures;
  31620. private _rebuildEffects;
  31621. /**
  31622. * Gets a boolean indicating if all created effects are ready
  31623. * @returns true if all effects are ready
  31624. */
  31625. areAllEffectsReady(): boolean;
  31626. protected _rebuildBuffers(): void;
  31627. private _initGLContext;
  31628. /**
  31629. * Gets version of the current webGL context
  31630. */
  31631. readonly webGLVersion: number;
  31632. /**
  31633. * Gets a string idenfifying the name of the class
  31634. * @returns "Engine" string
  31635. */
  31636. getClassName(): string;
  31637. /**
  31638. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31639. */
  31640. readonly isStencilEnable: boolean;
  31641. /** @hidden */
  31642. _prepareWorkingCanvas(): void;
  31643. /**
  31644. * Reset the texture cache to empty state
  31645. */
  31646. resetTextureCache(): void;
  31647. /**
  31648. * Gets an object containing information about the current webGL context
  31649. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31650. */
  31651. getGlInfo(): {
  31652. vendor: string;
  31653. renderer: string;
  31654. version: string;
  31655. };
  31656. /**
  31657. * Defines the hardware scaling level.
  31658. * By default the hardware scaling level is computed from the window device ratio.
  31659. * 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.
  31660. * @param level defines the level to use
  31661. */
  31662. setHardwareScalingLevel(level: number): void;
  31663. /**
  31664. * Gets the current hardware scaling level.
  31665. * By default the hardware scaling level is computed from the window device ratio.
  31666. * 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.
  31667. * @returns a number indicating the current hardware scaling level
  31668. */
  31669. getHardwareScalingLevel(): number;
  31670. /**
  31671. * Gets the list of loaded textures
  31672. * @returns an array containing all loaded textures
  31673. */
  31674. getLoadedTexturesCache(): InternalTexture[];
  31675. /**
  31676. * Gets the object containing all engine capabilities
  31677. * @returns the EngineCapabilities object
  31678. */
  31679. getCaps(): EngineCapabilities;
  31680. /**
  31681. * stop executing a render loop function and remove it from the execution array
  31682. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31683. */
  31684. stopRenderLoop(renderFunction?: () => void): void;
  31685. /** @hidden */
  31686. _renderLoop(): void;
  31687. /**
  31688. * Gets the HTML canvas attached with the current webGL context
  31689. * @returns a HTML canvas
  31690. */
  31691. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31692. /**
  31693. * Gets host window
  31694. * @returns the host window object
  31695. */
  31696. getHostWindow(): Nullable<Window>;
  31697. /**
  31698. * Gets the current render width
  31699. * @param useScreen defines if screen size must be used (or the current render target if any)
  31700. * @returns a number defining the current render width
  31701. */
  31702. getRenderWidth(useScreen?: boolean): number;
  31703. /**
  31704. * Gets the current render height
  31705. * @param useScreen defines if screen size must be used (or the current render target if any)
  31706. * @returns a number defining the current render height
  31707. */
  31708. getRenderHeight(useScreen?: boolean): number;
  31709. /**
  31710. * Can be used to override the current requestAnimationFrame requester.
  31711. * @hidden
  31712. */
  31713. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31714. /**
  31715. * Register and execute a render loop. The engine can have more than one render function
  31716. * @param renderFunction defines the function to continuously execute
  31717. */
  31718. runRenderLoop(renderFunction: () => void): void;
  31719. /**
  31720. * Clear the current render buffer or the current render target (if any is set up)
  31721. * @param color defines the color to use
  31722. * @param backBuffer defines if the back buffer must be cleared
  31723. * @param depth defines if the depth buffer must be cleared
  31724. * @param stencil defines if the stencil buffer must be cleared
  31725. */
  31726. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31727. private _viewportCached;
  31728. /** @hidden */
  31729. _viewport(x: number, y: number, width: number, height: number): void;
  31730. /**
  31731. * Set the WebGL's viewport
  31732. * @param viewport defines the viewport element to be used
  31733. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31734. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31735. */
  31736. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31737. /**
  31738. * Begin a new frame
  31739. */
  31740. beginFrame(): void;
  31741. /**
  31742. * Enf the current frame
  31743. */
  31744. endFrame(): void;
  31745. /**
  31746. * Resize the view according to the canvas' size
  31747. */
  31748. resize(): void;
  31749. /**
  31750. * Force a specific size of the canvas
  31751. * @param width defines the new canvas' width
  31752. * @param height defines the new canvas' height
  31753. */
  31754. setSize(width: number, height: number): void;
  31755. /**
  31756. * Binds the frame buffer to the specified texture.
  31757. * @param texture The texture to render to or null for the default canvas
  31758. * @param faceIndex The face of the texture to render to in case of cube texture
  31759. * @param requiredWidth The width of the target to render to
  31760. * @param requiredHeight The height of the target to render to
  31761. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31762. * @param depthStencilTexture The depth stencil texture to use to render
  31763. * @param lodLevel defines le lod level to bind to the frame buffer
  31764. */
  31765. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31766. /** @hidden */
  31767. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31768. /**
  31769. * Unbind the current render target texture from the webGL context
  31770. * @param texture defines the render target texture to unbind
  31771. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31772. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31773. */
  31774. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31775. /**
  31776. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31777. */
  31778. flushFramebuffer(): void;
  31779. /**
  31780. * Unbind the current render target and bind the default framebuffer
  31781. */
  31782. restoreDefaultFramebuffer(): void;
  31783. /** @hidden */
  31784. protected _resetVertexBufferBinding(): void;
  31785. /**
  31786. * Creates a vertex buffer
  31787. * @param data the data for the vertex buffer
  31788. * @returns the new WebGL static buffer
  31789. */
  31790. createVertexBuffer(data: DataArray): DataBuffer;
  31791. private _createVertexBuffer;
  31792. /**
  31793. * Creates a dynamic vertex buffer
  31794. * @param data the data for the dynamic vertex buffer
  31795. * @returns the new WebGL dynamic buffer
  31796. */
  31797. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31798. protected _resetIndexBufferBinding(): void;
  31799. /**
  31800. * Creates a new index buffer
  31801. * @param indices defines the content of the index buffer
  31802. * @param updatable defines if the index buffer must be updatable
  31803. * @returns a new webGL buffer
  31804. */
  31805. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31806. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31807. /**
  31808. * Bind a webGL buffer to the webGL context
  31809. * @param buffer defines the buffer to bind
  31810. */
  31811. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31812. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31813. private bindBuffer;
  31814. /**
  31815. * update the bound buffer with the given data
  31816. * @param data defines the data to update
  31817. */
  31818. updateArrayBuffer(data: Float32Array): void;
  31819. private _vertexAttribPointer;
  31820. private _bindIndexBufferWithCache;
  31821. private _bindVertexBuffersAttributes;
  31822. /**
  31823. * Records a vertex array object
  31824. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31825. * @param vertexBuffers defines the list of vertex buffers to store
  31826. * @param indexBuffer defines the index buffer to store
  31827. * @param effect defines the effect to store
  31828. * @returns the new vertex array object
  31829. */
  31830. recordVertexArrayObject(vertexBuffers: {
  31831. [key: string]: VertexBuffer;
  31832. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31833. /**
  31834. * Bind a specific vertex array object
  31835. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31836. * @param vertexArrayObject defines the vertex array object to bind
  31837. * @param indexBuffer defines the index buffer to bind
  31838. */
  31839. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31840. /**
  31841. * Bind webGl buffers directly to the webGL context
  31842. * @param vertexBuffer defines the vertex buffer to bind
  31843. * @param indexBuffer defines the index buffer to bind
  31844. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31845. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31846. * @param effect defines the effect associated with the vertex buffer
  31847. */
  31848. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31849. private _unbindVertexArrayObject;
  31850. /**
  31851. * Bind a list of vertex buffers to the webGL context
  31852. * @param vertexBuffers defines the list of vertex buffers to bind
  31853. * @param indexBuffer defines the index buffer to bind
  31854. * @param effect defines the effect associated with the vertex buffers
  31855. */
  31856. bindBuffers(vertexBuffers: {
  31857. [key: string]: Nullable<VertexBuffer>;
  31858. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31859. /**
  31860. * Unbind all instance attributes
  31861. */
  31862. unbindInstanceAttributes(): void;
  31863. /**
  31864. * Release and free the memory of a vertex array object
  31865. * @param vao defines the vertex array object to delete
  31866. */
  31867. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31868. /** @hidden */
  31869. _releaseBuffer(buffer: DataBuffer): boolean;
  31870. protected _deleteBuffer(buffer: DataBuffer): void;
  31871. /**
  31872. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31873. * @param instancesBuffer defines the webGL buffer to update and bind
  31874. * @param data defines the data to store in the buffer
  31875. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31876. */
  31877. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31878. /**
  31879. * Bind the content of a webGL buffer used with instanciation
  31880. * @param instancesBuffer defines the webGL buffer to bind
  31881. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31882. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  31883. */
  31884. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31885. /**
  31886. * Disable the instance attribute corresponding to the name in parameter
  31887. * @param name defines the name of the attribute to disable
  31888. */
  31889. disableInstanceAttributeByName(name: string): void;
  31890. /**
  31891. * Disable the instance attribute corresponding to the location in parameter
  31892. * @param attributeLocation defines the attribute location of the attribute to disable
  31893. */
  31894. disableInstanceAttribute(attributeLocation: number): void;
  31895. /**
  31896. * Disable the attribute corresponding to the location in parameter
  31897. * @param attributeLocation defines the attribute location of the attribute to disable
  31898. */
  31899. disableAttributeByIndex(attributeLocation: number): void;
  31900. /**
  31901. * Send a draw order
  31902. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31903. * @param indexStart defines the starting index
  31904. * @param indexCount defines the number of index to draw
  31905. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31906. */
  31907. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31908. /**
  31909. * Draw a list of points
  31910. * @param verticesStart defines the index of first vertex to draw
  31911. * @param verticesCount defines the count of vertices to draw
  31912. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31913. */
  31914. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31915. /**
  31916. * Draw a list of unindexed primitives
  31917. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31918. * @param verticesStart defines the index of first vertex to draw
  31919. * @param verticesCount defines the count of vertices to draw
  31920. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31921. */
  31922. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31923. /**
  31924. * Draw a list of indexed primitives
  31925. * @param fillMode defines the primitive to use
  31926. * @param indexStart defines the starting index
  31927. * @param indexCount defines the number of index to draw
  31928. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31929. */
  31930. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31931. /**
  31932. * Draw a list of unindexed primitives
  31933. * @param fillMode defines the primitive to use
  31934. * @param verticesStart defines the index of first vertex to draw
  31935. * @param verticesCount defines the count of vertices to draw
  31936. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31937. */
  31938. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31939. private _drawMode;
  31940. /** @hidden */
  31941. protected _reportDrawCall(): void;
  31942. /** @hidden */
  31943. _releaseEffect(effect: Effect): void;
  31944. /** @hidden */
  31945. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31946. /**
  31947. * Create a new effect (used to store vertex/fragment shaders)
  31948. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31949. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31950. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31951. * @param samplers defines an array of string used to represent textures
  31952. * @param defines defines the string containing the defines to use to compile the shaders
  31953. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31954. * @param onCompiled defines a function to call when the effect creation is successful
  31955. * @param onError defines a function to call when the effect creation has failed
  31956. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31957. * @returns the new Effect
  31958. */
  31959. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31960. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31961. private _compileShader;
  31962. private _compileRawShader;
  31963. /**
  31964. * Directly creates a webGL program
  31965. * @param pipelineContext defines the pipeline context to attach to
  31966. * @param vertexCode defines the vertex shader code to use
  31967. * @param fragmentCode defines the fragment shader code to use
  31968. * @param context defines the webGL context to use (if not set, the current one will be used)
  31969. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31970. * @returns the new webGL program
  31971. */
  31972. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31973. /**
  31974. * Creates a webGL program
  31975. * @param pipelineContext defines the pipeline context to attach to
  31976. * @param vertexCode defines the vertex shader code to use
  31977. * @param fragmentCode defines the fragment shader code to use
  31978. * @param defines defines the string containing the defines to use to compile the shaders
  31979. * @param context defines the webGL context to use (if not set, the current one will be used)
  31980. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31981. * @returns the new webGL program
  31982. */
  31983. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31984. /**
  31985. * Creates a new pipeline context
  31986. * @returns the new pipeline
  31987. */
  31988. createPipelineContext(): IPipelineContext;
  31989. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31990. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31991. /** @hidden */
  31992. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31993. /** @hidden */
  31994. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31995. /** @hidden */
  31996. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31997. /**
  31998. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31999. * @param pipelineContext defines the pipeline context to use
  32000. * @param uniformsNames defines the list of uniform names
  32001. * @returns an array of webGL uniform locations
  32002. */
  32003. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32004. /**
  32005. * Gets the lsit of active attributes for a given webGL program
  32006. * @param pipelineContext defines the pipeline context to use
  32007. * @param attributesNames defines the list of attribute names to get
  32008. * @returns an array of indices indicating the offset of each attribute
  32009. */
  32010. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32011. /**
  32012. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32013. * @param effect defines the effect to activate
  32014. */
  32015. enableEffect(effect: Nullable<Effect>): void;
  32016. /**
  32017. * Set the value of an uniform to a number (int)
  32018. * @param uniform defines the webGL uniform location where to store the value
  32019. * @param value defines the int number to store
  32020. */
  32021. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32022. /**
  32023. * Set the value of an uniform to an array of int32
  32024. * @param uniform defines the webGL uniform location where to store the value
  32025. * @param array defines the array of int32 to store
  32026. */
  32027. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32028. /**
  32029. * Set the value of an uniform to an array of int32 (stored as vec2)
  32030. * @param uniform defines the webGL uniform location where to store the value
  32031. * @param array defines the array of int32 to store
  32032. */
  32033. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32034. /**
  32035. * Set the value of an uniform to an array of int32 (stored as vec3)
  32036. * @param uniform defines the webGL uniform location where to store the value
  32037. * @param array defines the array of int32 to store
  32038. */
  32039. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32040. /**
  32041. * Set the value of an uniform to an array of int32 (stored as vec4)
  32042. * @param uniform defines the webGL uniform location where to store the value
  32043. * @param array defines the array of int32 to store
  32044. */
  32045. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32046. /**
  32047. * Set the value of an uniform to an array of number
  32048. * @param uniform defines the webGL uniform location where to store the value
  32049. * @param array defines the array of number to store
  32050. */
  32051. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32052. /**
  32053. * Set the value of an uniform to an array of number (stored as vec2)
  32054. * @param uniform defines the webGL uniform location where to store the value
  32055. * @param array defines the array of number to store
  32056. */
  32057. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32058. /**
  32059. * Set the value of an uniform to an array of number (stored as vec3)
  32060. * @param uniform defines the webGL uniform location where to store the value
  32061. * @param array defines the array of number to store
  32062. */
  32063. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32064. /**
  32065. * Set the value of an uniform to an array of number (stored as vec4)
  32066. * @param uniform defines the webGL uniform location where to store the value
  32067. * @param array defines the array of number to store
  32068. */
  32069. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32070. /**
  32071. * Set the value of an uniform to an array of float32 (stored as matrices)
  32072. * @param uniform defines the webGL uniform location where to store the value
  32073. * @param matrices defines the array of float32 to store
  32074. */
  32075. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32076. /**
  32077. * Set the value of an uniform to a matrix (3x3)
  32078. * @param uniform defines the webGL uniform location where to store the value
  32079. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32080. */
  32081. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32082. /**
  32083. * Set the value of an uniform to a matrix (2x2)
  32084. * @param uniform defines the webGL uniform location where to store the value
  32085. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32086. */
  32087. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32088. /**
  32089. * Set the value of an uniform to a number (float)
  32090. * @param uniform defines the webGL uniform location where to store the value
  32091. * @param value defines the float number to store
  32092. */
  32093. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32094. /**
  32095. * Set the value of an uniform to a vec2
  32096. * @param uniform defines the webGL uniform location where to store the value
  32097. * @param x defines the 1st component of the value
  32098. * @param y defines the 2nd component of the value
  32099. */
  32100. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32101. /**
  32102. * Set the value of an uniform to a vec3
  32103. * @param uniform defines the webGL uniform location where to store the value
  32104. * @param x defines the 1st component of the value
  32105. * @param y defines the 2nd component of the value
  32106. * @param z defines the 3rd component of the value
  32107. */
  32108. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32109. /**
  32110. * Set the value of an uniform to a vec4
  32111. * @param uniform defines the webGL uniform location where to store the value
  32112. * @param x defines the 1st component of the value
  32113. * @param y defines the 2nd component of the value
  32114. * @param z defines the 3rd component of the value
  32115. * @param w defines the 4th component of the value
  32116. */
  32117. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32118. /**
  32119. * Apply all cached states (depth, culling, stencil and alpha)
  32120. */
  32121. applyStates(): void;
  32122. /**
  32123. * Enable or disable color writing
  32124. * @param enable defines the state to set
  32125. */
  32126. setColorWrite(enable: boolean): void;
  32127. /**
  32128. * Gets a boolean indicating if color writing is enabled
  32129. * @returns the current color writing state
  32130. */
  32131. getColorWrite(): boolean;
  32132. /**
  32133. * Gets the depth culling state manager
  32134. */
  32135. readonly depthCullingState: DepthCullingState;
  32136. /**
  32137. * Gets the alpha state manager
  32138. */
  32139. readonly alphaState: AlphaState;
  32140. /**
  32141. * Gets the stencil state manager
  32142. */
  32143. readonly stencilState: StencilState;
  32144. /**
  32145. * Clears the list of texture accessible through engine.
  32146. * This can help preventing texture load conflict due to name collision.
  32147. */
  32148. clearInternalTexturesCache(): void;
  32149. /**
  32150. * Force the entire cache to be cleared
  32151. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32152. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32153. */
  32154. wipeCaches(bruteForce?: boolean): void;
  32155. /** @hidden */
  32156. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32157. min: number;
  32158. mag: number;
  32159. };
  32160. /** @hidden */
  32161. _createTexture(): WebGLTexture;
  32162. /**
  32163. * Usually called from Texture.ts.
  32164. * Passed information to create a WebGLTexture
  32165. * @param urlArg defines a value which contains one of the following:
  32166. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32167. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32168. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32169. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32170. * @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)
  32171. * @param scene needed for loading to the correct scene
  32172. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32173. * @param onLoad optional callback to be called upon successful completion
  32174. * @param onError optional callback to be called upon failure
  32175. * @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
  32176. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32177. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32178. * @param forcedExtension defines the extension to use to pick the right loader
  32179. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32180. * @param mimeType defines an optional mime type
  32181. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32182. */
  32183. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  32184. /**
  32185. * @hidden
  32186. */
  32187. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32188. /**
  32189. * Creates a raw texture
  32190. * @param data defines the data to store in the texture
  32191. * @param width defines the width of the texture
  32192. * @param height defines the height of the texture
  32193. * @param format defines the format of the data
  32194. * @param generateMipMaps defines if the engine should generate the mip levels
  32195. * @param invertY defines if data must be stored with Y axis inverted
  32196. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32197. * @param compression defines the compression used (null by default)
  32198. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32199. * @returns the raw texture inside an InternalTexture
  32200. */
  32201. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32202. /**
  32203. * Creates a new raw cube texture
  32204. * @param data defines the array of data to use to create each face
  32205. * @param size defines the size of the textures
  32206. * @param format defines the format of the data
  32207. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32208. * @param generateMipMaps defines if the engine should generate the mip levels
  32209. * @param invertY defines if data must be stored with Y axis inverted
  32210. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32211. * @param compression defines the compression used (null by default)
  32212. * @returns the cube texture as an InternalTexture
  32213. */
  32214. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32215. /**
  32216. * Creates a new raw 3D texture
  32217. * @param data defines the data used to create the texture
  32218. * @param width defines the width of the texture
  32219. * @param height defines the height of the texture
  32220. * @param depth defines the depth of the texture
  32221. * @param format defines the format of the texture
  32222. * @param generateMipMaps defines if the engine must generate mip levels
  32223. * @param invertY defines if data must be stored with Y axis inverted
  32224. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32225. * @param compression defines the compressed used (can be null)
  32226. * @param textureType defines the compressed used (can be null)
  32227. * @returns a new raw 3D texture (stored in an InternalTexture)
  32228. */
  32229. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32230. /**
  32231. * Creates a new raw 2D array texture
  32232. * @param data defines the data used to create the texture
  32233. * @param width defines the width of the texture
  32234. * @param height defines the height of the texture
  32235. * @param depth defines the number of layers of the texture
  32236. * @param format defines the format of the texture
  32237. * @param generateMipMaps defines if the engine must generate mip levels
  32238. * @param invertY defines if data must be stored with Y axis inverted
  32239. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32240. * @param compression defines the compressed used (can be null)
  32241. * @param textureType defines the compressed used (can be null)
  32242. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32243. */
  32244. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32245. private _unpackFlipYCached;
  32246. /**
  32247. * In case you are sharing the context with other applications, it might
  32248. * be interested to not cache the unpack flip y state to ensure a consistent
  32249. * value would be set.
  32250. */
  32251. enableUnpackFlipYCached: boolean;
  32252. /** @hidden */
  32253. _unpackFlipY(value: boolean): void;
  32254. /** @hidden */
  32255. _getUnpackAlignement(): number;
  32256. private _getTextureTarget;
  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. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32262. */
  32263. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32264. /**
  32265. * Update the sampling mode of a given texture
  32266. * @param texture defines the texture to update
  32267. * @param wrapU defines the texture wrap mode of the u coordinates
  32268. * @param wrapV defines the texture wrap mode of the v coordinates
  32269. * @param wrapR defines the texture wrap mode of the r coordinates
  32270. */
  32271. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32272. /** @hidden */
  32273. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32274. width: number;
  32275. height: number;
  32276. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32277. /** @hidden */
  32278. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32279. /** @hidden */
  32280. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32281. /** @hidden */
  32282. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32283. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32284. private _prepareWebGLTexture;
  32285. /** @hidden */
  32286. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32287. private _getDepthStencilBuffer;
  32288. /** @hidden */
  32289. _releaseFramebufferObjects(texture: InternalTexture): void;
  32290. /** @hidden */
  32291. _releaseTexture(texture: InternalTexture): void;
  32292. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32293. protected _setProgram(program: WebGLProgram): void;
  32294. protected _boundUniforms: {
  32295. [key: number]: WebGLUniformLocation;
  32296. };
  32297. /**
  32298. * Binds an effect to the webGL context
  32299. * @param effect defines the effect to bind
  32300. */
  32301. bindSamplers(effect: Effect): void;
  32302. private _activateCurrentTexture;
  32303. /** @hidden */
  32304. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32305. /** @hidden */
  32306. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32307. /**
  32308. * Unbind all textures from the webGL context
  32309. */
  32310. unbindAllTextures(): void;
  32311. /**
  32312. * Sets a texture to the according uniform.
  32313. * @param channel The texture channel
  32314. * @param uniform The uniform to set
  32315. * @param texture The texture to apply
  32316. */
  32317. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32318. private _bindSamplerUniformToChannel;
  32319. private _getTextureWrapMode;
  32320. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32321. /**
  32322. * Sets an array of texture to the webGL context
  32323. * @param channel defines the channel where the texture array must be set
  32324. * @param uniform defines the associated uniform location
  32325. * @param textures defines the array of textures to bind
  32326. */
  32327. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32328. /** @hidden */
  32329. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32330. private _setTextureParameterFloat;
  32331. private _setTextureParameterInteger;
  32332. /**
  32333. * Unbind all vertex attributes from the webGL context
  32334. */
  32335. unbindAllAttributes(): void;
  32336. /**
  32337. * 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
  32338. */
  32339. releaseEffects(): void;
  32340. /**
  32341. * Dispose and release all associated resources
  32342. */
  32343. dispose(): void;
  32344. /**
  32345. * Attach a new callback raised when context lost event is fired
  32346. * @param callback defines the callback to call
  32347. */
  32348. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32349. /**
  32350. * Attach a new callback raised when context restored event is fired
  32351. * @param callback defines the callback to call
  32352. */
  32353. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32354. /**
  32355. * Get the current error code of the webGL context
  32356. * @returns the error code
  32357. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32358. */
  32359. getError(): number;
  32360. private _canRenderToFloatFramebuffer;
  32361. private _canRenderToHalfFloatFramebuffer;
  32362. private _canRenderToFramebuffer;
  32363. /** @hidden */
  32364. _getWebGLTextureType(type: number): number;
  32365. /** @hidden */
  32366. _getInternalFormat(format: number): number;
  32367. /** @hidden */
  32368. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32369. /** @hidden */
  32370. _getRGBAMultiSampleBufferFormat(type: number): number;
  32371. /** @hidden */
  32372. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  32373. /**
  32374. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32375. * @param x defines the x coordinate of the rectangle where pixels must be read
  32376. * @param y defines the y coordinate of the rectangle where pixels must be read
  32377. * @param width defines the width of the rectangle where pixels must be read
  32378. * @param height defines the height of the rectangle where pixels must be read
  32379. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  32380. * @returns a Uint8Array containing RGBA colors
  32381. */
  32382. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32383. /**
  32384. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32385. * @returns true if the engine can be created
  32386. * @ignorenaming
  32387. */
  32388. static isSupported(): boolean;
  32389. /**
  32390. * Find the next highest power of two.
  32391. * @param x Number to start search from.
  32392. * @return Next highest power of two.
  32393. */
  32394. static CeilingPOT(x: number): number;
  32395. /**
  32396. * Find the next lowest power of two.
  32397. * @param x Number to start search from.
  32398. * @return Next lowest power of two.
  32399. */
  32400. static FloorPOT(x: number): number;
  32401. /**
  32402. * Find the nearest power of two.
  32403. * @param x Number to start search from.
  32404. * @return Next nearest power of two.
  32405. */
  32406. static NearestPOT(x: number): number;
  32407. /**
  32408. * Get the closest exponent of two
  32409. * @param value defines the value to approximate
  32410. * @param max defines the maximum value to return
  32411. * @param mode defines how to define the closest value
  32412. * @returns closest exponent of two of the given value
  32413. */
  32414. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32415. /**
  32416. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32417. * @param func - the function to be called
  32418. * @param requester - the object that will request the next frame. Falls back to window.
  32419. * @returns frame number
  32420. */
  32421. static QueueNewFrame(func: () => void, requester?: any): number;
  32422. /**
  32423. * Gets host document
  32424. * @returns the host document object
  32425. */
  32426. getHostDocument(): Document;
  32427. }
  32428. }
  32429. declare module "babylonjs/Maths/sphericalPolynomial" {
  32430. import { Vector3 } from "babylonjs/Maths/math.vector";
  32431. import { Color3 } from "babylonjs/Maths/math.color";
  32432. /**
  32433. * Class representing spherical harmonics coefficients to the 3rd degree
  32434. */
  32435. export class SphericalHarmonics {
  32436. /**
  32437. * Defines whether or not the harmonics have been prescaled for rendering.
  32438. */
  32439. preScaled: boolean;
  32440. /**
  32441. * The l0,0 coefficients of the spherical harmonics
  32442. */
  32443. l00: Vector3;
  32444. /**
  32445. * The l1,-1 coefficients of the spherical harmonics
  32446. */
  32447. l1_1: Vector3;
  32448. /**
  32449. * The l1,0 coefficients of the spherical harmonics
  32450. */
  32451. l10: Vector3;
  32452. /**
  32453. * The l1,1 coefficients of the spherical harmonics
  32454. */
  32455. l11: Vector3;
  32456. /**
  32457. * The l2,-2 coefficients of the spherical harmonics
  32458. */
  32459. l2_2: Vector3;
  32460. /**
  32461. * The l2,-1 coefficients of the spherical harmonics
  32462. */
  32463. l2_1: Vector3;
  32464. /**
  32465. * The l2,0 coefficients of the spherical harmonics
  32466. */
  32467. l20: Vector3;
  32468. /**
  32469. * The l2,1 coefficients of the spherical harmonics
  32470. */
  32471. l21: Vector3;
  32472. /**
  32473. * The l2,2 coefficients of the spherical harmonics
  32474. */
  32475. l22: Vector3;
  32476. /**
  32477. * Adds a light to the spherical harmonics
  32478. * @param direction the direction of the light
  32479. * @param color the color of the light
  32480. * @param deltaSolidAngle the delta solid angle of the light
  32481. */
  32482. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32483. /**
  32484. * Scales the spherical harmonics by the given amount
  32485. * @param scale the amount to scale
  32486. */
  32487. scaleInPlace(scale: number): void;
  32488. /**
  32489. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32490. *
  32491. * ```
  32492. * E_lm = A_l * L_lm
  32493. * ```
  32494. *
  32495. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32496. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32497. * the scaling factors are given in equation 9.
  32498. */
  32499. convertIncidentRadianceToIrradiance(): void;
  32500. /**
  32501. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32502. *
  32503. * ```
  32504. * L = (1/pi) * E * rho
  32505. * ```
  32506. *
  32507. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32508. */
  32509. convertIrradianceToLambertianRadiance(): void;
  32510. /**
  32511. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32512. * required operations at run time.
  32513. *
  32514. * This is simply done by scaling back the SH with Ylm constants parameter.
  32515. * The trigonometric part being applied by the shader at run time.
  32516. */
  32517. preScaleForRendering(): void;
  32518. /**
  32519. * Constructs a spherical harmonics from an array.
  32520. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32521. * @returns the spherical harmonics
  32522. */
  32523. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32524. /**
  32525. * Gets the spherical harmonics from polynomial
  32526. * @param polynomial the spherical polynomial
  32527. * @returns the spherical harmonics
  32528. */
  32529. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32530. }
  32531. /**
  32532. * Class representing spherical polynomial coefficients to the 3rd degree
  32533. */
  32534. export class SphericalPolynomial {
  32535. private _harmonics;
  32536. /**
  32537. * The spherical harmonics used to create the polynomials.
  32538. */
  32539. readonly preScaledHarmonics: SphericalHarmonics;
  32540. /**
  32541. * The x coefficients of the spherical polynomial
  32542. */
  32543. x: Vector3;
  32544. /**
  32545. * The y coefficients of the spherical polynomial
  32546. */
  32547. y: Vector3;
  32548. /**
  32549. * The z coefficients of the spherical polynomial
  32550. */
  32551. z: Vector3;
  32552. /**
  32553. * The xx coefficients of the spherical polynomial
  32554. */
  32555. xx: Vector3;
  32556. /**
  32557. * The yy coefficients of the spherical polynomial
  32558. */
  32559. yy: Vector3;
  32560. /**
  32561. * The zz coefficients of the spherical polynomial
  32562. */
  32563. zz: Vector3;
  32564. /**
  32565. * The xy coefficients of the spherical polynomial
  32566. */
  32567. xy: Vector3;
  32568. /**
  32569. * The yz coefficients of the spherical polynomial
  32570. */
  32571. yz: Vector3;
  32572. /**
  32573. * The zx coefficients of the spherical polynomial
  32574. */
  32575. zx: Vector3;
  32576. /**
  32577. * Adds an ambient color to the spherical polynomial
  32578. * @param color the color to add
  32579. */
  32580. addAmbient(color: Color3): void;
  32581. /**
  32582. * Scales the spherical polynomial by the given amount
  32583. * @param scale the amount to scale
  32584. */
  32585. scaleInPlace(scale: number): void;
  32586. /**
  32587. * Gets the spherical polynomial from harmonics
  32588. * @param harmonics the spherical harmonics
  32589. * @returns the spherical polynomial
  32590. */
  32591. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32592. /**
  32593. * Constructs a spherical polynomial from an array.
  32594. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32595. * @returns the spherical polynomial
  32596. */
  32597. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32598. }
  32599. }
  32600. declare module "babylonjs/Materials/Textures/internalTexture" {
  32601. import { Observable } from "babylonjs/Misc/observable";
  32602. import { Nullable, int } from "babylonjs/types";
  32603. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  32604. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32605. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  32606. /**
  32607. * Defines the source of the internal texture
  32608. */
  32609. export enum InternalTextureSource {
  32610. /**
  32611. * The source of the texture data is unknown
  32612. */
  32613. Unknown = 0,
  32614. /**
  32615. * Texture data comes from an URL
  32616. */
  32617. Url = 1,
  32618. /**
  32619. * Texture data is only used for temporary storage
  32620. */
  32621. Temp = 2,
  32622. /**
  32623. * Texture data comes from raw data (ArrayBuffer)
  32624. */
  32625. Raw = 3,
  32626. /**
  32627. * Texture content is dynamic (video or dynamic texture)
  32628. */
  32629. Dynamic = 4,
  32630. /**
  32631. * Texture content is generated by rendering to it
  32632. */
  32633. RenderTarget = 5,
  32634. /**
  32635. * Texture content is part of a multi render target process
  32636. */
  32637. MultiRenderTarget = 6,
  32638. /**
  32639. * Texture data comes from a cube data file
  32640. */
  32641. Cube = 7,
  32642. /**
  32643. * Texture data comes from a raw cube data
  32644. */
  32645. CubeRaw = 8,
  32646. /**
  32647. * Texture data come from a prefiltered cube data file
  32648. */
  32649. CubePrefiltered = 9,
  32650. /**
  32651. * Texture content is raw 3D data
  32652. */
  32653. Raw3D = 10,
  32654. /**
  32655. * Texture content is raw 2D array data
  32656. */
  32657. Raw2DArray = 11,
  32658. /**
  32659. * Texture content is a depth texture
  32660. */
  32661. Depth = 12,
  32662. /**
  32663. * Texture data comes from a raw cube data encoded with RGBD
  32664. */
  32665. CubeRawRGBD = 13
  32666. }
  32667. /**
  32668. * Class used to store data associated with WebGL texture data for the engine
  32669. * This class should not be used directly
  32670. */
  32671. export class InternalTexture {
  32672. /** @hidden */
  32673. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32674. /**
  32675. * Defines if the texture is ready
  32676. */
  32677. isReady: boolean;
  32678. /**
  32679. * Defines if the texture is a cube texture
  32680. */
  32681. isCube: boolean;
  32682. /**
  32683. * Defines if the texture contains 3D data
  32684. */
  32685. is3D: boolean;
  32686. /**
  32687. * Defines if the texture contains 2D array data
  32688. */
  32689. is2DArray: boolean;
  32690. /**
  32691. * Defines if the texture contains multiview data
  32692. */
  32693. isMultiview: boolean;
  32694. /**
  32695. * Gets the URL used to load this texture
  32696. */
  32697. url: string;
  32698. /**
  32699. * Gets the sampling mode of the texture
  32700. */
  32701. samplingMode: number;
  32702. /**
  32703. * Gets a boolean indicating if the texture needs mipmaps generation
  32704. */
  32705. generateMipMaps: boolean;
  32706. /**
  32707. * Gets the number of samples used by the texture (WebGL2+ only)
  32708. */
  32709. samples: number;
  32710. /**
  32711. * Gets the type of the texture (int, float...)
  32712. */
  32713. type: number;
  32714. /**
  32715. * Gets the format of the texture (RGB, RGBA...)
  32716. */
  32717. format: number;
  32718. /**
  32719. * Observable called when the texture is loaded
  32720. */
  32721. onLoadedObservable: Observable<InternalTexture>;
  32722. /**
  32723. * Gets the width of the texture
  32724. */
  32725. width: number;
  32726. /**
  32727. * Gets the height of the texture
  32728. */
  32729. height: number;
  32730. /**
  32731. * Gets the depth of the texture
  32732. */
  32733. depth: number;
  32734. /**
  32735. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32736. */
  32737. baseWidth: number;
  32738. /**
  32739. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32740. */
  32741. baseHeight: number;
  32742. /**
  32743. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32744. */
  32745. baseDepth: number;
  32746. /**
  32747. * Gets a boolean indicating if the texture is inverted on Y axis
  32748. */
  32749. invertY: boolean;
  32750. /** @hidden */
  32751. _invertVScale: boolean;
  32752. /** @hidden */
  32753. _associatedChannel: number;
  32754. /** @hidden */
  32755. _source: InternalTextureSource;
  32756. /** @hidden */
  32757. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32758. /** @hidden */
  32759. _bufferView: Nullable<ArrayBufferView>;
  32760. /** @hidden */
  32761. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32762. /** @hidden */
  32763. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32764. /** @hidden */
  32765. _size: number;
  32766. /** @hidden */
  32767. _extension: string;
  32768. /** @hidden */
  32769. _files: Nullable<string[]>;
  32770. /** @hidden */
  32771. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32772. /** @hidden */
  32773. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32774. /** @hidden */
  32775. _framebuffer: Nullable<WebGLFramebuffer>;
  32776. /** @hidden */
  32777. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32778. /** @hidden */
  32779. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32780. /** @hidden */
  32781. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32782. /** @hidden */
  32783. _attachments: Nullable<number[]>;
  32784. /** @hidden */
  32785. _cachedCoordinatesMode: Nullable<number>;
  32786. /** @hidden */
  32787. _cachedWrapU: Nullable<number>;
  32788. /** @hidden */
  32789. _cachedWrapV: Nullable<number>;
  32790. /** @hidden */
  32791. _cachedWrapR: Nullable<number>;
  32792. /** @hidden */
  32793. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32794. /** @hidden */
  32795. _isDisabled: boolean;
  32796. /** @hidden */
  32797. _compression: Nullable<string>;
  32798. /** @hidden */
  32799. _generateStencilBuffer: boolean;
  32800. /** @hidden */
  32801. _generateDepthBuffer: boolean;
  32802. /** @hidden */
  32803. _comparisonFunction: number;
  32804. /** @hidden */
  32805. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32806. /** @hidden */
  32807. _lodGenerationScale: number;
  32808. /** @hidden */
  32809. _lodGenerationOffset: number;
  32810. /** @hidden */
  32811. _colorTextureArray: Nullable<WebGLTexture>;
  32812. /** @hidden */
  32813. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32814. /** @hidden */
  32815. _lodTextureHigh: Nullable<BaseTexture>;
  32816. /** @hidden */
  32817. _lodTextureMid: Nullable<BaseTexture>;
  32818. /** @hidden */
  32819. _lodTextureLow: Nullable<BaseTexture>;
  32820. /** @hidden */
  32821. _isRGBD: boolean;
  32822. /** @hidden */
  32823. _linearSpecularLOD: boolean;
  32824. /** @hidden */
  32825. _irradianceTexture: Nullable<BaseTexture>;
  32826. /** @hidden */
  32827. _webGLTexture: Nullable<WebGLTexture>;
  32828. /** @hidden */
  32829. _references: number;
  32830. private _engine;
  32831. /**
  32832. * Gets the Engine the texture belongs to.
  32833. * @returns The babylon engine
  32834. */
  32835. getEngine(): ThinEngine;
  32836. /**
  32837. * Gets the data source type of the texture
  32838. */
  32839. readonly source: InternalTextureSource;
  32840. /**
  32841. * Creates a new InternalTexture
  32842. * @param engine defines the engine to use
  32843. * @param source defines the type of data that will be used
  32844. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32845. */
  32846. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32847. /**
  32848. * Increments the number of references (ie. the number of Texture that point to it)
  32849. */
  32850. incrementReferences(): void;
  32851. /**
  32852. * Change the size of the texture (not the size of the content)
  32853. * @param width defines the new width
  32854. * @param height defines the new height
  32855. * @param depth defines the new depth (1 by default)
  32856. */
  32857. updateSize(width: int, height: int, depth?: int): void;
  32858. /** @hidden */
  32859. _rebuild(): void;
  32860. /** @hidden */
  32861. _swapAndDie(target: InternalTexture): void;
  32862. /**
  32863. * Dispose the current allocated resources
  32864. */
  32865. dispose(): void;
  32866. }
  32867. }
  32868. declare module "babylonjs/Audio/analyser" {
  32869. import { Scene } from "babylonjs/scene";
  32870. /**
  32871. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32872. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32873. */
  32874. export class Analyser {
  32875. /**
  32876. * Gets or sets the smoothing
  32877. * @ignorenaming
  32878. */
  32879. SMOOTHING: number;
  32880. /**
  32881. * Gets or sets the FFT table size
  32882. * @ignorenaming
  32883. */
  32884. FFT_SIZE: number;
  32885. /**
  32886. * Gets or sets the bar graph amplitude
  32887. * @ignorenaming
  32888. */
  32889. BARGRAPHAMPLITUDE: number;
  32890. /**
  32891. * Gets or sets the position of the debug canvas
  32892. * @ignorenaming
  32893. */
  32894. DEBUGCANVASPOS: {
  32895. x: number;
  32896. y: number;
  32897. };
  32898. /**
  32899. * Gets or sets the debug canvas size
  32900. * @ignorenaming
  32901. */
  32902. DEBUGCANVASSIZE: {
  32903. width: number;
  32904. height: number;
  32905. };
  32906. private _byteFreqs;
  32907. private _byteTime;
  32908. private _floatFreqs;
  32909. private _webAudioAnalyser;
  32910. private _debugCanvas;
  32911. private _debugCanvasContext;
  32912. private _scene;
  32913. private _registerFunc;
  32914. private _audioEngine;
  32915. /**
  32916. * Creates a new analyser
  32917. * @param scene defines hosting scene
  32918. */
  32919. constructor(scene: Scene);
  32920. /**
  32921. * Get the number of data values you will have to play with for the visualization
  32922. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32923. * @returns a number
  32924. */
  32925. getFrequencyBinCount(): number;
  32926. /**
  32927. * Gets the current frequency data as a byte array
  32928. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32929. * @returns a Uint8Array
  32930. */
  32931. getByteFrequencyData(): Uint8Array;
  32932. /**
  32933. * Gets the current waveform as a byte array
  32934. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32935. * @returns a Uint8Array
  32936. */
  32937. getByteTimeDomainData(): Uint8Array;
  32938. /**
  32939. * Gets the current frequency data as a float array
  32940. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32941. * @returns a Float32Array
  32942. */
  32943. getFloatFrequencyData(): Float32Array;
  32944. /**
  32945. * Renders the debug canvas
  32946. */
  32947. drawDebugCanvas(): void;
  32948. /**
  32949. * Stops rendering the debug canvas and removes it
  32950. */
  32951. stopDebugCanvas(): void;
  32952. /**
  32953. * Connects two audio nodes
  32954. * @param inputAudioNode defines first node to connect
  32955. * @param outputAudioNode defines second node to connect
  32956. */
  32957. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32958. /**
  32959. * Releases all associated resources
  32960. */
  32961. dispose(): void;
  32962. }
  32963. }
  32964. declare module "babylonjs/Audio/audioEngine" {
  32965. import { IDisposable } from "babylonjs/scene";
  32966. import { Analyser } from "babylonjs/Audio/analyser";
  32967. import { Nullable } from "babylonjs/types";
  32968. import { Observable } from "babylonjs/Misc/observable";
  32969. /**
  32970. * This represents an audio engine and it is responsible
  32971. * to play, synchronize and analyse sounds throughout the application.
  32972. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32973. */
  32974. export interface IAudioEngine extends IDisposable {
  32975. /**
  32976. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32977. */
  32978. readonly canUseWebAudio: boolean;
  32979. /**
  32980. * Gets the current AudioContext if available.
  32981. */
  32982. readonly audioContext: Nullable<AudioContext>;
  32983. /**
  32984. * The master gain node defines the global audio volume of your audio engine.
  32985. */
  32986. readonly masterGain: GainNode;
  32987. /**
  32988. * Gets whether or not mp3 are supported by your browser.
  32989. */
  32990. readonly isMP3supported: boolean;
  32991. /**
  32992. * Gets whether or not ogg are supported by your browser.
  32993. */
  32994. readonly isOGGsupported: boolean;
  32995. /**
  32996. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32997. * @ignoreNaming
  32998. */
  32999. WarnedWebAudioUnsupported: boolean;
  33000. /**
  33001. * Defines if the audio engine relies on a custom unlocked button.
  33002. * In this case, the embedded button will not be displayed.
  33003. */
  33004. useCustomUnlockedButton: boolean;
  33005. /**
  33006. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33007. */
  33008. readonly unlocked: boolean;
  33009. /**
  33010. * Event raised when audio has been unlocked on the browser.
  33011. */
  33012. onAudioUnlockedObservable: Observable<AudioEngine>;
  33013. /**
  33014. * Event raised when audio has been locked on the browser.
  33015. */
  33016. onAudioLockedObservable: Observable<AudioEngine>;
  33017. /**
  33018. * Flags the audio engine in Locked state.
  33019. * This happens due to new browser policies preventing audio to autoplay.
  33020. */
  33021. lock(): void;
  33022. /**
  33023. * Unlocks the audio engine once a user action has been done on the dom.
  33024. * This is helpful to resume play once browser policies have been satisfied.
  33025. */
  33026. unlock(): void;
  33027. }
  33028. /**
  33029. * This represents the default audio engine used in babylon.
  33030. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33032. */
  33033. export class AudioEngine implements IAudioEngine {
  33034. private _audioContext;
  33035. private _audioContextInitialized;
  33036. private _muteButton;
  33037. private _hostElement;
  33038. /**
  33039. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33040. */
  33041. canUseWebAudio: boolean;
  33042. /**
  33043. * The master gain node defines the global audio volume of your audio engine.
  33044. */
  33045. masterGain: GainNode;
  33046. /**
  33047. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33048. * @ignoreNaming
  33049. */
  33050. WarnedWebAudioUnsupported: boolean;
  33051. /**
  33052. * Gets whether or not mp3 are supported by your browser.
  33053. */
  33054. isMP3supported: boolean;
  33055. /**
  33056. * Gets whether or not ogg are supported by your browser.
  33057. */
  33058. isOGGsupported: boolean;
  33059. /**
  33060. * Gets whether audio has been unlocked on the device.
  33061. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33062. * a user interaction has happened.
  33063. */
  33064. unlocked: boolean;
  33065. /**
  33066. * Defines if the audio engine relies on a custom unlocked button.
  33067. * In this case, the embedded button will not be displayed.
  33068. */
  33069. useCustomUnlockedButton: boolean;
  33070. /**
  33071. * Event raised when audio has been unlocked on the browser.
  33072. */
  33073. onAudioUnlockedObservable: Observable<AudioEngine>;
  33074. /**
  33075. * Event raised when audio has been locked on the browser.
  33076. */
  33077. onAudioLockedObservable: Observable<AudioEngine>;
  33078. /**
  33079. * Gets the current AudioContext if available.
  33080. */
  33081. readonly audioContext: Nullable<AudioContext>;
  33082. private _connectedAnalyser;
  33083. /**
  33084. * Instantiates a new audio engine.
  33085. *
  33086. * There should be only one per page as some browsers restrict the number
  33087. * of audio contexts you can create.
  33088. * @param hostElement defines the host element where to display the mute icon if necessary
  33089. */
  33090. constructor(hostElement?: Nullable<HTMLElement>);
  33091. /**
  33092. * Flags the audio engine in Locked state.
  33093. * This happens due to new browser policies preventing audio to autoplay.
  33094. */
  33095. lock(): void;
  33096. /**
  33097. * Unlocks the audio engine once a user action has been done on the dom.
  33098. * This is helpful to resume play once browser policies have been satisfied.
  33099. */
  33100. unlock(): void;
  33101. private _resumeAudioContext;
  33102. private _initializeAudioContext;
  33103. private _tryToRun;
  33104. private _triggerRunningState;
  33105. private _triggerSuspendedState;
  33106. private _displayMuteButton;
  33107. private _moveButtonToTopLeft;
  33108. private _onResize;
  33109. private _hideMuteButton;
  33110. /**
  33111. * Destroy and release the resources associated with the audio ccontext.
  33112. */
  33113. dispose(): void;
  33114. /**
  33115. * Gets the global volume sets on the master gain.
  33116. * @returns the global volume if set or -1 otherwise
  33117. */
  33118. getGlobalVolume(): number;
  33119. /**
  33120. * Sets the global volume of your experience (sets on the master gain).
  33121. * @param newVolume Defines the new global volume of the application
  33122. */
  33123. setGlobalVolume(newVolume: number): void;
  33124. /**
  33125. * Connect the audio engine to an audio analyser allowing some amazing
  33126. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33127. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33128. * @param analyser The analyser to connect to the engine
  33129. */
  33130. connectToAnalyser(analyser: Analyser): void;
  33131. }
  33132. }
  33133. declare module "babylonjs/Loading/loadingScreen" {
  33134. /**
  33135. * Interface used to present a loading screen while loading a scene
  33136. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33137. */
  33138. export interface ILoadingScreen {
  33139. /**
  33140. * Function called to display the loading screen
  33141. */
  33142. displayLoadingUI: () => void;
  33143. /**
  33144. * Function called to hide the loading screen
  33145. */
  33146. hideLoadingUI: () => void;
  33147. /**
  33148. * Gets or sets the color to use for the background
  33149. */
  33150. loadingUIBackgroundColor: string;
  33151. /**
  33152. * Gets or sets the text to display while loading
  33153. */
  33154. loadingUIText: string;
  33155. }
  33156. /**
  33157. * Class used for the default loading screen
  33158. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33159. */
  33160. export class DefaultLoadingScreen implements ILoadingScreen {
  33161. private _renderingCanvas;
  33162. private _loadingText;
  33163. private _loadingDivBackgroundColor;
  33164. private _loadingDiv;
  33165. private _loadingTextDiv;
  33166. /** Gets or sets the logo url to use for the default loading screen */
  33167. static DefaultLogoUrl: string;
  33168. /** Gets or sets the spinner url to use for the default loading screen */
  33169. static DefaultSpinnerUrl: string;
  33170. /**
  33171. * Creates a new default loading screen
  33172. * @param _renderingCanvas defines the canvas used to render the scene
  33173. * @param _loadingText defines the default text to display
  33174. * @param _loadingDivBackgroundColor defines the default background color
  33175. */
  33176. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33177. /**
  33178. * Function called to display the loading screen
  33179. */
  33180. displayLoadingUI(): void;
  33181. /**
  33182. * Function called to hide the loading screen
  33183. */
  33184. hideLoadingUI(): void;
  33185. /**
  33186. * Gets or sets the text to display while loading
  33187. */
  33188. loadingUIText: string;
  33189. /**
  33190. * Gets or sets the color to use for the background
  33191. */
  33192. loadingUIBackgroundColor: string;
  33193. private _resizeLoadingUI;
  33194. }
  33195. }
  33196. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33197. /**
  33198. * Interface for any object that can request an animation frame
  33199. */
  33200. export interface ICustomAnimationFrameRequester {
  33201. /**
  33202. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33203. */
  33204. renderFunction?: Function;
  33205. /**
  33206. * Called to request the next frame to render to
  33207. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33208. */
  33209. requestAnimationFrame: Function;
  33210. /**
  33211. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33212. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33213. */
  33214. requestID?: number;
  33215. }
  33216. }
  33217. declare module "babylonjs/Misc/performanceMonitor" {
  33218. /**
  33219. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33220. */
  33221. export class PerformanceMonitor {
  33222. private _enabled;
  33223. private _rollingFrameTime;
  33224. private _lastFrameTimeMs;
  33225. /**
  33226. * constructor
  33227. * @param frameSampleSize The number of samples required to saturate the sliding window
  33228. */
  33229. constructor(frameSampleSize?: number);
  33230. /**
  33231. * Samples current frame
  33232. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33233. */
  33234. sampleFrame(timeMs?: number): void;
  33235. /**
  33236. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33237. */
  33238. readonly averageFrameTime: number;
  33239. /**
  33240. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33241. */
  33242. readonly averageFrameTimeVariance: number;
  33243. /**
  33244. * Returns the frame time of the most recent frame
  33245. */
  33246. readonly instantaneousFrameTime: number;
  33247. /**
  33248. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33249. */
  33250. readonly averageFPS: number;
  33251. /**
  33252. * Returns the average framerate in frames per second using the most recent frame time
  33253. */
  33254. readonly instantaneousFPS: number;
  33255. /**
  33256. * Returns true if enough samples have been taken to completely fill the sliding window
  33257. */
  33258. readonly isSaturated: boolean;
  33259. /**
  33260. * Enables contributions to the sliding window sample set
  33261. */
  33262. enable(): void;
  33263. /**
  33264. * Disables contributions to the sliding window sample set
  33265. * Samples will not be interpolated over the disabled period
  33266. */
  33267. disable(): void;
  33268. /**
  33269. * Returns true if sampling is enabled
  33270. */
  33271. readonly isEnabled: boolean;
  33272. /**
  33273. * Resets performance monitor
  33274. */
  33275. reset(): void;
  33276. }
  33277. /**
  33278. * RollingAverage
  33279. *
  33280. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33281. */
  33282. export class RollingAverage {
  33283. /**
  33284. * Current average
  33285. */
  33286. average: number;
  33287. /**
  33288. * Current variance
  33289. */
  33290. variance: number;
  33291. protected _samples: Array<number>;
  33292. protected _sampleCount: number;
  33293. protected _pos: number;
  33294. protected _m2: number;
  33295. /**
  33296. * constructor
  33297. * @param length The number of samples required to saturate the sliding window
  33298. */
  33299. constructor(length: number);
  33300. /**
  33301. * Adds a sample to the sample set
  33302. * @param v The sample value
  33303. */
  33304. add(v: number): void;
  33305. /**
  33306. * Returns previously added values or null if outside of history or outside the sliding window domain
  33307. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33308. * @return Value previously recorded with add() or null if outside of range
  33309. */
  33310. history(i: number): number;
  33311. /**
  33312. * Returns true if enough samples have been taken to completely fill the sliding window
  33313. * @return true if sample-set saturated
  33314. */
  33315. isSaturated(): boolean;
  33316. /**
  33317. * Resets the rolling average (equivalent to 0 samples taken so far)
  33318. */
  33319. reset(): void;
  33320. /**
  33321. * Wraps a value around the sample range boundaries
  33322. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33323. * @return Wrapped position in sample range
  33324. */
  33325. protected _wrapPosition(i: number): number;
  33326. }
  33327. }
  33328. declare module "babylonjs/Misc/perfCounter" {
  33329. /**
  33330. * This class is used to track a performance counter which is number based.
  33331. * The user has access to many properties which give statistics of different nature.
  33332. *
  33333. * The implementer can track two kinds of Performance Counter: time and count.
  33334. * 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.
  33335. * 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.
  33336. */
  33337. export class PerfCounter {
  33338. /**
  33339. * Gets or sets a global boolean to turn on and off all the counters
  33340. */
  33341. static Enabled: boolean;
  33342. /**
  33343. * Returns the smallest value ever
  33344. */
  33345. readonly min: number;
  33346. /**
  33347. * Returns the biggest value ever
  33348. */
  33349. readonly max: number;
  33350. /**
  33351. * Returns the average value since the performance counter is running
  33352. */
  33353. readonly average: number;
  33354. /**
  33355. * Returns the average value of the last second the counter was monitored
  33356. */
  33357. readonly lastSecAverage: number;
  33358. /**
  33359. * Returns the current value
  33360. */
  33361. readonly current: number;
  33362. /**
  33363. * Gets the accumulated total
  33364. */
  33365. readonly total: number;
  33366. /**
  33367. * Gets the total value count
  33368. */
  33369. readonly count: number;
  33370. /**
  33371. * Creates a new counter
  33372. */
  33373. constructor();
  33374. /**
  33375. * Call this method to start monitoring a new frame.
  33376. * 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.
  33377. */
  33378. fetchNewFrame(): void;
  33379. /**
  33380. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33381. * @param newCount the count value to add to the monitored count
  33382. * @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.
  33383. */
  33384. addCount(newCount: number, fetchResult: boolean): void;
  33385. /**
  33386. * Start monitoring this performance counter
  33387. */
  33388. beginMonitoring(): void;
  33389. /**
  33390. * Compute the time lapsed since the previous beginMonitoring() call.
  33391. * @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
  33392. */
  33393. endMonitoring(newFrame?: boolean): void;
  33394. private _fetchResult;
  33395. private _startMonitoringTime;
  33396. private _min;
  33397. private _max;
  33398. private _average;
  33399. private _current;
  33400. private _totalValueCount;
  33401. private _totalAccumulated;
  33402. private _lastSecAverage;
  33403. private _lastSecAccumulated;
  33404. private _lastSecTime;
  33405. private _lastSecValueCount;
  33406. }
  33407. }
  33408. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33409. module "babylonjs/Engines/thinEngine" {
  33410. interface ThinEngine {
  33411. /**
  33412. * Sets alpha constants used by some alpha blending modes
  33413. * @param r defines the red component
  33414. * @param g defines the green component
  33415. * @param b defines the blue component
  33416. * @param a defines the alpha component
  33417. */
  33418. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33419. /**
  33420. * Sets the current alpha mode
  33421. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33422. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33423. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33424. */
  33425. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33426. /**
  33427. * Gets the current alpha mode
  33428. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33429. * @returns the current alpha mode
  33430. */
  33431. getAlphaMode(): number;
  33432. /**
  33433. * Sets the current alpha equation
  33434. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33435. */
  33436. setAlphaEquation(equation: number): void;
  33437. /**
  33438. * Gets the current alpha equation.
  33439. * @returns the current alpha equation
  33440. */
  33441. getAlphaEquation(): number;
  33442. }
  33443. }
  33444. }
  33445. declare module "babylonjs/Engines/engine" {
  33446. import { Observable } from "babylonjs/Misc/observable";
  33447. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33448. import { Scene } from "babylonjs/scene";
  33449. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33450. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33451. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33452. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33453. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33454. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  33455. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  33456. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  33457. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  33458. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33459. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  33460. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  33461. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33462. import "babylonjs/Engines/Extensions/engine.alpha";
  33463. import { Material } from "babylonjs/Materials/material";
  33464. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33465. /**
  33466. * Defines the interface used by display changed events
  33467. */
  33468. export interface IDisplayChangedEventArgs {
  33469. /** Gets the vrDisplay object (if any) */
  33470. vrDisplay: Nullable<any>;
  33471. /** Gets a boolean indicating if webVR is supported */
  33472. vrSupported: boolean;
  33473. }
  33474. /**
  33475. * Defines the interface used by objects containing a viewport (like a camera)
  33476. */
  33477. interface IViewportOwnerLike {
  33478. /**
  33479. * Gets or sets the viewport
  33480. */
  33481. viewport: IViewportLike;
  33482. }
  33483. /**
  33484. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33485. */
  33486. export class Engine extends ThinEngine {
  33487. /** Defines that alpha blending is disabled */
  33488. static readonly ALPHA_DISABLE: number;
  33489. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33490. static readonly ALPHA_ADD: number;
  33491. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33492. static readonly ALPHA_COMBINE: number;
  33493. /** Defines that alpha blending to DEST - SRC * DEST */
  33494. static readonly ALPHA_SUBTRACT: number;
  33495. /** Defines that alpha blending to SRC * DEST */
  33496. static readonly ALPHA_MULTIPLY: number;
  33497. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33498. static readonly ALPHA_MAXIMIZED: number;
  33499. /** Defines that alpha blending to SRC + DEST */
  33500. static readonly ALPHA_ONEONE: number;
  33501. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33502. static readonly ALPHA_PREMULTIPLIED: number;
  33503. /**
  33504. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33505. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33506. */
  33507. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33508. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33509. static readonly ALPHA_INTERPOLATE: number;
  33510. /**
  33511. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33512. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33513. */
  33514. static readonly ALPHA_SCREENMODE: number;
  33515. /** Defines that the ressource is not delayed*/
  33516. static readonly DELAYLOADSTATE_NONE: number;
  33517. /** Defines that the ressource was successfully delay loaded */
  33518. static readonly DELAYLOADSTATE_LOADED: number;
  33519. /** Defines that the ressource is currently delay loading */
  33520. static readonly DELAYLOADSTATE_LOADING: number;
  33521. /** Defines that the ressource is delayed and has not started loading */
  33522. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33523. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33524. static readonly NEVER: number;
  33525. /** 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 */
  33526. static readonly ALWAYS: number;
  33527. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33528. static readonly LESS: number;
  33529. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33530. static readonly EQUAL: number;
  33531. /** 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 */
  33532. static readonly LEQUAL: number;
  33533. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33534. static readonly GREATER: number;
  33535. /** 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 */
  33536. static readonly GEQUAL: number;
  33537. /** 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 */
  33538. static readonly NOTEQUAL: number;
  33539. /** Passed to stencilOperation to specify that stencil value must be kept */
  33540. static readonly KEEP: number;
  33541. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33542. static readonly REPLACE: number;
  33543. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33544. static readonly INCR: number;
  33545. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33546. static readonly DECR: number;
  33547. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33548. static readonly INVERT: number;
  33549. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33550. static readonly INCR_WRAP: number;
  33551. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33552. static readonly DECR_WRAP: number;
  33553. /** Texture is not repeating outside of 0..1 UVs */
  33554. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33555. /** Texture is repeating outside of 0..1 UVs */
  33556. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33557. /** Texture is repeating and mirrored */
  33558. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33559. /** ALPHA */
  33560. static readonly TEXTUREFORMAT_ALPHA: number;
  33561. /** LUMINANCE */
  33562. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33563. /** LUMINANCE_ALPHA */
  33564. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33565. /** RGB */
  33566. static readonly TEXTUREFORMAT_RGB: number;
  33567. /** RGBA */
  33568. static readonly TEXTUREFORMAT_RGBA: number;
  33569. /** RED */
  33570. static readonly TEXTUREFORMAT_RED: number;
  33571. /** RED (2nd reference) */
  33572. static readonly TEXTUREFORMAT_R: number;
  33573. /** RG */
  33574. static readonly TEXTUREFORMAT_RG: number;
  33575. /** RED_INTEGER */
  33576. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33577. /** RED_INTEGER (2nd reference) */
  33578. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33579. /** RG_INTEGER */
  33580. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33581. /** RGB_INTEGER */
  33582. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33583. /** RGBA_INTEGER */
  33584. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33585. /** UNSIGNED_BYTE */
  33586. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33587. /** UNSIGNED_BYTE (2nd reference) */
  33588. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33589. /** FLOAT */
  33590. static readonly TEXTURETYPE_FLOAT: number;
  33591. /** HALF_FLOAT */
  33592. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33593. /** BYTE */
  33594. static readonly TEXTURETYPE_BYTE: number;
  33595. /** SHORT */
  33596. static readonly TEXTURETYPE_SHORT: number;
  33597. /** UNSIGNED_SHORT */
  33598. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33599. /** INT */
  33600. static readonly TEXTURETYPE_INT: number;
  33601. /** UNSIGNED_INT */
  33602. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33603. /** UNSIGNED_SHORT_4_4_4_4 */
  33604. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33605. /** UNSIGNED_SHORT_5_5_5_1 */
  33606. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33607. /** UNSIGNED_SHORT_5_6_5 */
  33608. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33609. /** UNSIGNED_INT_2_10_10_10_REV */
  33610. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33611. /** UNSIGNED_INT_24_8 */
  33612. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33613. /** UNSIGNED_INT_10F_11F_11F_REV */
  33614. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33615. /** UNSIGNED_INT_5_9_9_9_REV */
  33616. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33617. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33618. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33619. /** nearest is mag = nearest and min = nearest and mip = linear */
  33620. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33621. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33622. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33623. /** Trilinear is mag = linear and min = linear and mip = linear */
  33624. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33625. /** nearest is mag = nearest and min = nearest and mip = linear */
  33626. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33627. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33628. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33629. /** Trilinear is mag = linear and min = linear and mip = linear */
  33630. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33631. /** mag = nearest and min = nearest and mip = nearest */
  33632. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33633. /** mag = nearest and min = linear and mip = nearest */
  33634. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33635. /** mag = nearest and min = linear and mip = linear */
  33636. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33637. /** mag = nearest and min = linear and mip = none */
  33638. static readonly TEXTURE_NEAREST_LINEAR: number;
  33639. /** mag = nearest and min = nearest and mip = none */
  33640. static readonly TEXTURE_NEAREST_NEAREST: number;
  33641. /** mag = linear and min = nearest and mip = nearest */
  33642. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33643. /** mag = linear and min = nearest and mip = linear */
  33644. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33645. /** mag = linear and min = linear and mip = none */
  33646. static readonly TEXTURE_LINEAR_LINEAR: number;
  33647. /** mag = linear and min = nearest and mip = none */
  33648. static readonly TEXTURE_LINEAR_NEAREST: number;
  33649. /** Explicit coordinates mode */
  33650. static readonly TEXTURE_EXPLICIT_MODE: number;
  33651. /** Spherical coordinates mode */
  33652. static readonly TEXTURE_SPHERICAL_MODE: number;
  33653. /** Planar coordinates mode */
  33654. static readonly TEXTURE_PLANAR_MODE: number;
  33655. /** Cubic coordinates mode */
  33656. static readonly TEXTURE_CUBIC_MODE: number;
  33657. /** Projection coordinates mode */
  33658. static readonly TEXTURE_PROJECTION_MODE: number;
  33659. /** Skybox coordinates mode */
  33660. static readonly TEXTURE_SKYBOX_MODE: number;
  33661. /** Inverse Cubic coordinates mode */
  33662. static readonly TEXTURE_INVCUBIC_MODE: number;
  33663. /** Equirectangular coordinates mode */
  33664. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33665. /** Equirectangular Fixed coordinates mode */
  33666. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33667. /** Equirectangular Fixed Mirrored coordinates mode */
  33668. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33669. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33670. static readonly SCALEMODE_FLOOR: number;
  33671. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33672. static readonly SCALEMODE_NEAREST: number;
  33673. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33674. static readonly SCALEMODE_CEILING: number;
  33675. /**
  33676. * Returns the current npm package of the sdk
  33677. */
  33678. static readonly NpmPackage: string;
  33679. /**
  33680. * Returns the current version of the framework
  33681. */
  33682. static readonly Version: string;
  33683. /** Gets the list of created engines */
  33684. static readonly Instances: Engine[];
  33685. /**
  33686. * Gets the latest created engine
  33687. */
  33688. static readonly LastCreatedEngine: Nullable<Engine>;
  33689. /**
  33690. * Gets the latest created scene
  33691. */
  33692. static readonly LastCreatedScene: Nullable<Scene>;
  33693. /**
  33694. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33695. * @param flag defines which part of the materials must be marked as dirty
  33696. * @param predicate defines a predicate used to filter which materials should be affected
  33697. */
  33698. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33699. /**
  33700. * Method called to create the default loading screen.
  33701. * This can be overriden in your own app.
  33702. * @param canvas The rendering canvas element
  33703. * @returns The loading screen
  33704. */
  33705. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33706. /**
  33707. * Method called to create the default rescale post process on each engine.
  33708. */
  33709. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33710. /**
  33711. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33712. **/
  33713. enableOfflineSupport: boolean;
  33714. /**
  33715. * 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)
  33716. **/
  33717. disableManifestCheck: boolean;
  33718. /**
  33719. * Gets the list of created scenes
  33720. */
  33721. scenes: Scene[];
  33722. /**
  33723. * Event raised when a new scene is created
  33724. */
  33725. onNewSceneAddedObservable: Observable<Scene>;
  33726. /**
  33727. * Gets the list of created postprocesses
  33728. */
  33729. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  33730. /**
  33731. * Gets a boolean indicating if the pointer is currently locked
  33732. */
  33733. isPointerLock: boolean;
  33734. /**
  33735. * Observable event triggered each time the rendering canvas is resized
  33736. */
  33737. onResizeObservable: Observable<Engine>;
  33738. /**
  33739. * Observable event triggered each time the canvas loses focus
  33740. */
  33741. onCanvasBlurObservable: Observable<Engine>;
  33742. /**
  33743. * Observable event triggered each time the canvas gains focus
  33744. */
  33745. onCanvasFocusObservable: Observable<Engine>;
  33746. /**
  33747. * Observable event triggered each time the canvas receives pointerout event
  33748. */
  33749. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33750. /**
  33751. * Observable raised when the engine begins a new frame
  33752. */
  33753. onBeginFrameObservable: Observable<Engine>;
  33754. /**
  33755. * If set, will be used to request the next animation frame for the render loop
  33756. */
  33757. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33758. /**
  33759. * Observable raised when the engine ends the current frame
  33760. */
  33761. onEndFrameObservable: Observable<Engine>;
  33762. /**
  33763. * Observable raised when the engine is about to compile a shader
  33764. */
  33765. onBeforeShaderCompilationObservable: Observable<Engine>;
  33766. /**
  33767. * Observable raised when the engine has jsut compiled a shader
  33768. */
  33769. onAfterShaderCompilationObservable: Observable<Engine>;
  33770. /**
  33771. * Gets the audio engine
  33772. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33773. * @ignorenaming
  33774. */
  33775. static audioEngine: IAudioEngine;
  33776. /**
  33777. * Default AudioEngine factory responsible of creating the Audio Engine.
  33778. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33779. */
  33780. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33781. /**
  33782. * Default offline support factory responsible of creating a tool used to store data locally.
  33783. * By default, this will create a Database object if the workload has been embedded.
  33784. */
  33785. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33786. private _loadingScreen;
  33787. private _pointerLockRequested;
  33788. private _dummyFramebuffer;
  33789. private _rescalePostProcess;
  33790. private _deterministicLockstep;
  33791. private _lockstepMaxSteps;
  33792. private _timeStep;
  33793. protected readonly _supportsHardwareTextureRescaling: boolean;
  33794. private _fps;
  33795. private _deltaTime;
  33796. /** @hidden */
  33797. _drawCalls: PerfCounter;
  33798. /**
  33799. * Turn this value on if you want to pause FPS computation when in background
  33800. */
  33801. disablePerformanceMonitorInBackground: boolean;
  33802. private _performanceMonitor;
  33803. /**
  33804. * Gets the performance monitor attached to this engine
  33805. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33806. */
  33807. readonly performanceMonitor: PerformanceMonitor;
  33808. private _onFocus;
  33809. private _onBlur;
  33810. private _onCanvasPointerOut;
  33811. private _onCanvasBlur;
  33812. private _onCanvasFocus;
  33813. private _onFullscreenChange;
  33814. private _onPointerLockChange;
  33815. /**
  33816. * Gets the HTML element used to attach event listeners
  33817. * @returns a HTML element
  33818. */
  33819. getInputElement(): Nullable<HTMLElement>;
  33820. /**
  33821. * Creates a new engine
  33822. * @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
  33823. * @param antialias defines enable antialiasing (default: false)
  33824. * @param options defines further options to be sent to the getContext() function
  33825. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33826. */
  33827. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33828. /**
  33829. * Gets current aspect ratio
  33830. * @param viewportOwner defines the camera to use to get the aspect ratio
  33831. * @param useScreen defines if screen size must be used (or the current render target if any)
  33832. * @returns a number defining the aspect ratio
  33833. */
  33834. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33835. /**
  33836. * Gets current screen aspect ratio
  33837. * @returns a number defining the aspect ratio
  33838. */
  33839. getScreenAspectRatio(): number;
  33840. /**
  33841. * Gets the client rect of the HTML canvas attached with the current webGL context
  33842. * @returns a client rectanglee
  33843. */
  33844. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33845. /**
  33846. * Gets the client rect of the HTML element used for events
  33847. * @returns a client rectanglee
  33848. */
  33849. getInputElementClientRect(): Nullable<ClientRect>;
  33850. /**
  33851. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33852. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33853. * @returns true if engine is in deterministic lock step mode
  33854. */
  33855. isDeterministicLockStep(): boolean;
  33856. /**
  33857. * Gets the max steps when engine is running in deterministic lock step
  33858. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33859. * @returns the max steps
  33860. */
  33861. getLockstepMaxSteps(): number;
  33862. /**
  33863. * Returns the time in ms between steps when using deterministic lock step.
  33864. * @returns time step in (ms)
  33865. */
  33866. getTimeStep(): number;
  33867. /**
  33868. * Force the mipmap generation for the given render target texture
  33869. * @param texture defines the render target texture to use
  33870. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33871. */
  33872. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33873. /** States */
  33874. /**
  33875. * Set various states to the webGL context
  33876. * @param culling defines backface culling state
  33877. * @param zOffset defines the value to apply to zOffset (0 by default)
  33878. * @param force defines if states must be applied even if cache is up to date
  33879. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33880. */
  33881. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33882. /**
  33883. * Set the z offset to apply to current rendering
  33884. * @param value defines the offset to apply
  33885. */
  33886. setZOffset(value: number): void;
  33887. /**
  33888. * Gets the current value of the zOffset
  33889. * @returns the current zOffset state
  33890. */
  33891. getZOffset(): number;
  33892. /**
  33893. * Enable or disable depth buffering
  33894. * @param enable defines the state to set
  33895. */
  33896. setDepthBuffer(enable: boolean): void;
  33897. /**
  33898. * Gets a boolean indicating if depth writing is enabled
  33899. * @returns the current depth writing state
  33900. */
  33901. getDepthWrite(): boolean;
  33902. /**
  33903. * Enable or disable depth writing
  33904. * @param enable defines the state to set
  33905. */
  33906. setDepthWrite(enable: boolean): void;
  33907. /**
  33908. * Gets a boolean indicating if stencil buffer is enabled
  33909. * @returns the current stencil buffer state
  33910. */
  33911. getStencilBuffer(): boolean;
  33912. /**
  33913. * Enable or disable the stencil buffer
  33914. * @param enable defines if the stencil buffer must be enabled or disabled
  33915. */
  33916. setStencilBuffer(enable: boolean): void;
  33917. /**
  33918. * Gets the current stencil mask
  33919. * @returns a number defining the new stencil mask to use
  33920. */
  33921. getStencilMask(): number;
  33922. /**
  33923. * Sets the current stencil mask
  33924. * @param mask defines the new stencil mask to use
  33925. */
  33926. setStencilMask(mask: number): void;
  33927. /**
  33928. * Gets the current stencil function
  33929. * @returns a number defining the stencil function to use
  33930. */
  33931. getStencilFunction(): number;
  33932. /**
  33933. * Gets the current stencil reference value
  33934. * @returns a number defining the stencil reference value to use
  33935. */
  33936. getStencilFunctionReference(): number;
  33937. /**
  33938. * Gets the current stencil mask
  33939. * @returns a number defining the stencil mask to use
  33940. */
  33941. getStencilFunctionMask(): number;
  33942. /**
  33943. * Sets the current stencil function
  33944. * @param stencilFunc defines the new stencil function to use
  33945. */
  33946. setStencilFunction(stencilFunc: number): void;
  33947. /**
  33948. * Sets the current stencil reference
  33949. * @param reference defines the new stencil reference to use
  33950. */
  33951. setStencilFunctionReference(reference: number): void;
  33952. /**
  33953. * Sets the current stencil mask
  33954. * @param mask defines the new stencil mask to use
  33955. */
  33956. setStencilFunctionMask(mask: number): void;
  33957. /**
  33958. * Gets the current stencil operation when stencil fails
  33959. * @returns a number defining stencil operation to use when stencil fails
  33960. */
  33961. getStencilOperationFail(): number;
  33962. /**
  33963. * Gets the current stencil operation when depth fails
  33964. * @returns a number defining stencil operation to use when depth fails
  33965. */
  33966. getStencilOperationDepthFail(): number;
  33967. /**
  33968. * Gets the current stencil operation when stencil passes
  33969. * @returns a number defining stencil operation to use when stencil passes
  33970. */
  33971. getStencilOperationPass(): number;
  33972. /**
  33973. * Sets the stencil operation to use when stencil fails
  33974. * @param operation defines the stencil operation to use when stencil fails
  33975. */
  33976. setStencilOperationFail(operation: number): void;
  33977. /**
  33978. * Sets the stencil operation to use when depth fails
  33979. * @param operation defines the stencil operation to use when depth fails
  33980. */
  33981. setStencilOperationDepthFail(operation: number): void;
  33982. /**
  33983. * Sets the stencil operation to use when stencil passes
  33984. * @param operation defines the stencil operation to use when stencil passes
  33985. */
  33986. setStencilOperationPass(operation: number): void;
  33987. /**
  33988. * Sets a boolean indicating if the dithering state is enabled or disabled
  33989. * @param value defines the dithering state
  33990. */
  33991. setDitheringState(value: boolean): void;
  33992. /**
  33993. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33994. * @param value defines the rasterizer state
  33995. */
  33996. setRasterizerState(value: boolean): void;
  33997. /**
  33998. * Gets the current depth function
  33999. * @returns a number defining the depth function
  34000. */
  34001. getDepthFunction(): Nullable<number>;
  34002. /**
  34003. * Sets the current depth function
  34004. * @param depthFunc defines the function to use
  34005. */
  34006. setDepthFunction(depthFunc: number): void;
  34007. /**
  34008. * Sets the current depth function to GREATER
  34009. */
  34010. setDepthFunctionToGreater(): void;
  34011. /**
  34012. * Sets the current depth function to GEQUAL
  34013. */
  34014. setDepthFunctionToGreaterOrEqual(): void;
  34015. /**
  34016. * Sets the current depth function to LESS
  34017. */
  34018. setDepthFunctionToLess(): void;
  34019. /**
  34020. * Sets the current depth function to LEQUAL
  34021. */
  34022. setDepthFunctionToLessOrEqual(): void;
  34023. private _cachedStencilBuffer;
  34024. private _cachedStencilFunction;
  34025. private _cachedStencilMask;
  34026. private _cachedStencilOperationPass;
  34027. private _cachedStencilOperationFail;
  34028. private _cachedStencilOperationDepthFail;
  34029. private _cachedStencilReference;
  34030. /**
  34031. * Caches the the state of the stencil buffer
  34032. */
  34033. cacheStencilState(): void;
  34034. /**
  34035. * Restores the state of the stencil buffer
  34036. */
  34037. restoreStencilState(): void;
  34038. /**
  34039. * Directly set the WebGL Viewport
  34040. * @param x defines the x coordinate of the viewport (in screen space)
  34041. * @param y defines the y coordinate of the viewport (in screen space)
  34042. * @param width defines the width of the viewport (in screen space)
  34043. * @param height defines the height of the viewport (in screen space)
  34044. * @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
  34045. */
  34046. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34047. /**
  34048. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34049. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34050. * @param y defines the y-coordinate of the corner of the clear rectangle
  34051. * @param width defines the width of the clear rectangle
  34052. * @param height defines the height of the clear rectangle
  34053. * @param clearColor defines the clear color
  34054. */
  34055. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34056. /**
  34057. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34058. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34059. * @param y defines the y-coordinate of the corner of the clear rectangle
  34060. * @param width defines the width of the clear rectangle
  34061. * @param height defines the height of the clear rectangle
  34062. */
  34063. enableScissor(x: number, y: number, width: number, height: number): void;
  34064. /**
  34065. * Disable previously set scissor test rectangle
  34066. */
  34067. disableScissor(): void;
  34068. protected _reportDrawCall(): void;
  34069. /**
  34070. * Initializes a webVR display and starts listening to display change events
  34071. * The onVRDisplayChangedObservable will be notified upon these changes
  34072. * @returns The onVRDisplayChangedObservable
  34073. */
  34074. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34075. /** @hidden */
  34076. _prepareVRComponent(): void;
  34077. /** @hidden */
  34078. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34079. /** @hidden */
  34080. _submitVRFrame(): void;
  34081. /**
  34082. * Call this function to leave webVR mode
  34083. * Will do nothing if webVR is not supported or if there is no webVR device
  34084. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34085. */
  34086. disableVR(): void;
  34087. /**
  34088. * Gets a boolean indicating that the system is in VR mode and is presenting
  34089. * @returns true if VR mode is engaged
  34090. */
  34091. isVRPresenting(): boolean;
  34092. /** @hidden */
  34093. _requestVRFrame(): void;
  34094. /** @hidden */
  34095. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34096. /**
  34097. * Gets the source code of the vertex shader associated with a specific webGL program
  34098. * @param program defines the program to use
  34099. * @returns a string containing the source code of the vertex shader associated with the program
  34100. */
  34101. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34102. /**
  34103. * Gets the source code of the fragment shader associated with a specific webGL program
  34104. * @param program defines the program to use
  34105. * @returns a string containing the source code of the fragment shader associated with the program
  34106. */
  34107. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34108. /**
  34109. * Sets a depth stencil texture from a render target to the according uniform.
  34110. * @param channel The texture channel
  34111. * @param uniform The uniform to set
  34112. * @param texture The render target texture containing the depth stencil texture to apply
  34113. */
  34114. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34115. /**
  34116. * Sets a texture to the webGL context from a postprocess
  34117. * @param channel defines the channel to use
  34118. * @param postProcess defines the source postprocess
  34119. */
  34120. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34121. /**
  34122. * Binds the output of the passed in post process to the texture channel specified
  34123. * @param channel The channel the texture should be bound to
  34124. * @param postProcess The post process which's output should be bound
  34125. */
  34126. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34127. /** @hidden */
  34128. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34129. protected _rebuildBuffers(): void;
  34130. /** @hidden */
  34131. _renderFrame(): void;
  34132. _renderLoop(): void;
  34133. /** @hidden */
  34134. _renderViews(): boolean;
  34135. /**
  34136. * Toggle full screen mode
  34137. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34138. */
  34139. switchFullscreen(requestPointerLock: boolean): void;
  34140. /**
  34141. * Enters full screen mode
  34142. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34143. */
  34144. enterFullscreen(requestPointerLock: boolean): void;
  34145. /**
  34146. * Exits full screen mode
  34147. */
  34148. exitFullscreen(): void;
  34149. /**
  34150. * Enters Pointerlock mode
  34151. */
  34152. enterPointerlock(): void;
  34153. /**
  34154. * Exits Pointerlock mode
  34155. */
  34156. exitPointerlock(): void;
  34157. /**
  34158. * Begin a new frame
  34159. */
  34160. beginFrame(): void;
  34161. /**
  34162. * Enf the current frame
  34163. */
  34164. endFrame(): void;
  34165. resize(): void;
  34166. /**
  34167. * Set the compressed texture format to use, based on the formats you have, and the formats
  34168. * supported by the hardware / browser.
  34169. *
  34170. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34171. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34172. * to API arguments needed to compressed textures. This puts the burden on the container
  34173. * generator to house the arcane code for determining these for current & future formats.
  34174. *
  34175. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34176. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34177. *
  34178. * Note: The result of this call is not taken into account when a texture is base64.
  34179. *
  34180. * @param formatsAvailable defines the list of those format families you have created
  34181. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34182. *
  34183. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34184. * @returns The extension selected.
  34185. */
  34186. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34187. /**
  34188. * Set the compressed texture extensions or file names to skip.
  34189. *
  34190. * @param skippedFiles defines the list of those texture files you want to skip
  34191. * Example: [".dds", ".env", "myfile.png"]
  34192. */
  34193. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34194. /**
  34195. * Force a specific size of the canvas
  34196. * @param width defines the new canvas' width
  34197. * @param height defines the new canvas' height
  34198. */
  34199. setSize(width: number, height: number): void;
  34200. /**
  34201. * Updates a dynamic vertex buffer.
  34202. * @param vertexBuffer the vertex buffer to update
  34203. * @param data the data used to update the vertex buffer
  34204. * @param byteOffset the byte offset of the data
  34205. * @param byteLength the byte length of the data
  34206. */
  34207. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34208. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34209. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34210. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34211. _releaseTexture(texture: InternalTexture): void;
  34212. /**
  34213. * @hidden
  34214. * Rescales a texture
  34215. * @param source input texutre
  34216. * @param destination destination texture
  34217. * @param scene scene to use to render the resize
  34218. * @param internalFormat format to use when resizing
  34219. * @param onComplete callback to be called when resize has completed
  34220. */
  34221. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34222. /**
  34223. * Gets the current framerate
  34224. * @returns a number representing the framerate
  34225. */
  34226. getFps(): number;
  34227. /**
  34228. * Gets the time spent between current and previous frame
  34229. * @returns a number representing the delta time in ms
  34230. */
  34231. getDeltaTime(): number;
  34232. private _measureFps;
  34233. /** @hidden */
  34234. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34235. /**
  34236. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  34237. * @param renderTarget The render target to set the frame buffer for
  34238. */
  34239. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  34240. /**
  34241. * Update a dynamic index buffer
  34242. * @param indexBuffer defines the target index buffer
  34243. * @param indices defines the data to update
  34244. * @param offset defines the offset in the target index buffer where update should start
  34245. */
  34246. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34247. /**
  34248. * Updates the sample count of a render target texture
  34249. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34250. * @param texture defines the texture to update
  34251. * @param samples defines the sample count to set
  34252. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34253. */
  34254. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34255. /**
  34256. * Updates a depth texture Comparison Mode and Function.
  34257. * If the comparison Function is equal to 0, the mode will be set to none.
  34258. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34259. * @param texture The texture to set the comparison function for
  34260. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34261. */
  34262. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34263. /**
  34264. * Creates a webGL buffer to use with instanciation
  34265. * @param capacity defines the size of the buffer
  34266. * @returns the webGL buffer
  34267. */
  34268. createInstancesBuffer(capacity: number): DataBuffer;
  34269. /**
  34270. * Delete a webGL buffer used with instanciation
  34271. * @param buffer defines the webGL buffer to delete
  34272. */
  34273. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34274. /** @hidden */
  34275. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34276. dispose(): void;
  34277. private _disableTouchAction;
  34278. /**
  34279. * Display the loading screen
  34280. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34281. */
  34282. displayLoadingUI(): void;
  34283. /**
  34284. * Hide the loading screen
  34285. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34286. */
  34287. hideLoadingUI(): void;
  34288. /**
  34289. * Gets the current loading screen object
  34290. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34291. */
  34292. /**
  34293. * Sets the current loading screen object
  34294. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34295. */
  34296. loadingScreen: ILoadingScreen;
  34297. /**
  34298. * Sets the current loading screen text
  34299. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34300. */
  34301. loadingUIText: string;
  34302. /**
  34303. * Sets the current loading screen background color
  34304. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34305. */
  34306. loadingUIBackgroundColor: string;
  34307. /** Pointerlock and fullscreen */
  34308. /**
  34309. * Ask the browser to promote the current element to pointerlock mode
  34310. * @param element defines the DOM element to promote
  34311. */
  34312. static _RequestPointerlock(element: HTMLElement): void;
  34313. /**
  34314. * Asks the browser to exit pointerlock mode
  34315. */
  34316. static _ExitPointerlock(): void;
  34317. /**
  34318. * Ask the browser to promote the current element to fullscreen rendering mode
  34319. * @param element defines the DOM element to promote
  34320. */
  34321. static _RequestFullscreen(element: HTMLElement): void;
  34322. /**
  34323. * Asks the browser to exit fullscreen mode
  34324. */
  34325. static _ExitFullscreen(): void;
  34326. }
  34327. }
  34328. declare module "babylonjs/Engines/engineStore" {
  34329. import { Nullable } from "babylonjs/types";
  34330. import { Engine } from "babylonjs/Engines/engine";
  34331. import { Scene } from "babylonjs/scene";
  34332. /**
  34333. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34334. * during the life time of the application.
  34335. */
  34336. export class EngineStore {
  34337. /** Gets the list of created engines */
  34338. static Instances: import("babylonjs/Engines/engine").Engine[];
  34339. /** @hidden */
  34340. static _LastCreatedScene: Nullable<Scene>;
  34341. /**
  34342. * Gets the latest created engine
  34343. */
  34344. static readonly LastCreatedEngine: Nullable<Engine>;
  34345. /**
  34346. * Gets the latest created scene
  34347. */
  34348. static readonly LastCreatedScene: Nullable<Scene>;
  34349. /**
  34350. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34351. * @ignorenaming
  34352. */
  34353. static UseFallbackTexture: boolean;
  34354. /**
  34355. * Texture content used if a texture cannot loaded
  34356. * @ignorenaming
  34357. */
  34358. static FallbackTexture: string;
  34359. }
  34360. }
  34361. declare module "babylonjs/Misc/promise" {
  34362. /**
  34363. * Helper class that provides a small promise polyfill
  34364. */
  34365. export class PromisePolyfill {
  34366. /**
  34367. * Static function used to check if the polyfill is required
  34368. * If this is the case then the function will inject the polyfill to window.Promise
  34369. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34370. */
  34371. static Apply(force?: boolean): void;
  34372. }
  34373. }
  34374. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34375. /**
  34376. * Interface for screenshot methods with describe argument called `size` as object with options
  34377. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34378. */
  34379. export interface IScreenshotSize {
  34380. /**
  34381. * number in pixels for canvas height
  34382. */
  34383. height?: number;
  34384. /**
  34385. * multiplier allowing render at a higher or lower resolution
  34386. * If value is defined then height and width will be ignored and taken from camera
  34387. */
  34388. precision?: number;
  34389. /**
  34390. * number in pixels for canvas width
  34391. */
  34392. width?: number;
  34393. }
  34394. }
  34395. declare module "babylonjs/Misc/tools" {
  34396. import { Nullable, float } from "babylonjs/types";
  34397. import { DomManagement } from "babylonjs/Misc/domManagement";
  34398. import { WebRequest } from "babylonjs/Misc/webRequest";
  34399. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34400. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34401. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34402. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34403. import { Camera } from "babylonjs/Cameras/camera";
  34404. import { Engine } from "babylonjs/Engines/engine";
  34405. interface IColor4Like {
  34406. r: float;
  34407. g: float;
  34408. b: float;
  34409. a: float;
  34410. }
  34411. /**
  34412. * Class containing a set of static utilities functions
  34413. */
  34414. export class Tools {
  34415. /**
  34416. * Gets or sets the base URL to use to load assets
  34417. */
  34418. static BaseUrl: string;
  34419. /**
  34420. * Enable/Disable Custom HTTP Request Headers globally.
  34421. * default = false
  34422. * @see CustomRequestHeaders
  34423. */
  34424. static UseCustomRequestHeaders: boolean;
  34425. /**
  34426. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34427. * i.e. when loading files, where the server/service expects an Authorization header
  34428. */
  34429. static CustomRequestHeaders: {
  34430. [key: string]: string;
  34431. };
  34432. /**
  34433. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34434. */
  34435. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  34436. /**
  34437. * Default behaviour for cors in the application.
  34438. * It can be a string if the expected behavior is identical in the entire app.
  34439. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34440. */
  34441. static CorsBehavior: string | ((url: string | string[]) => string);
  34442. /**
  34443. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34444. * @ignorenaming
  34445. */
  34446. static UseFallbackTexture: boolean;
  34447. /**
  34448. * Use this object to register external classes like custom textures or material
  34449. * to allow the laoders to instantiate them
  34450. */
  34451. static RegisteredExternalClasses: {
  34452. [key: string]: Object;
  34453. };
  34454. /**
  34455. * Texture content used if a texture cannot loaded
  34456. * @ignorenaming
  34457. */
  34458. static fallbackTexture: string;
  34459. /**
  34460. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34461. * @param u defines the coordinate on X axis
  34462. * @param v defines the coordinate on Y axis
  34463. * @param width defines the width of the source data
  34464. * @param height defines the height of the source data
  34465. * @param pixels defines the source byte array
  34466. * @param color defines the output color
  34467. */
  34468. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34469. /**
  34470. * Interpolates between a and b via alpha
  34471. * @param a The lower value (returned when alpha = 0)
  34472. * @param b The upper value (returned when alpha = 1)
  34473. * @param alpha The interpolation-factor
  34474. * @return The mixed value
  34475. */
  34476. static Mix(a: number, b: number, alpha: number): number;
  34477. /**
  34478. * Tries to instantiate a new object from a given class name
  34479. * @param className defines the class name to instantiate
  34480. * @returns the new object or null if the system was not able to do the instantiation
  34481. */
  34482. static Instantiate(className: string): any;
  34483. /**
  34484. * Provides a slice function that will work even on IE
  34485. * @param data defines the array to slice
  34486. * @param start defines the start of the data (optional)
  34487. * @param end defines the end of the data (optional)
  34488. * @returns the new sliced array
  34489. */
  34490. static Slice<T>(data: T, start?: number, end?: number): T;
  34491. /**
  34492. * Polyfill for setImmediate
  34493. * @param action defines the action to execute after the current execution block
  34494. */
  34495. static SetImmediate(action: () => void): void;
  34496. /**
  34497. * Function indicating if a number is an exponent of 2
  34498. * @param value defines the value to test
  34499. * @returns true if the value is an exponent of 2
  34500. */
  34501. static IsExponentOfTwo(value: number): boolean;
  34502. private static _tmpFloatArray;
  34503. /**
  34504. * Returns the nearest 32-bit single precision float representation of a Number
  34505. * @param value A Number. If the parameter is of a different type, it will get converted
  34506. * to a number or to NaN if it cannot be converted
  34507. * @returns number
  34508. */
  34509. static FloatRound(value: number): number;
  34510. /**
  34511. * Extracts the filename from a path
  34512. * @param path defines the path to use
  34513. * @returns the filename
  34514. */
  34515. static GetFilename(path: string): string;
  34516. /**
  34517. * Extracts the "folder" part of a path (everything before the filename).
  34518. * @param uri The URI to extract the info from
  34519. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34520. * @returns The "folder" part of the path
  34521. */
  34522. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34523. /**
  34524. * Extracts text content from a DOM element hierarchy
  34525. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34526. */
  34527. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34528. /**
  34529. * Convert an angle in radians to degrees
  34530. * @param angle defines the angle to convert
  34531. * @returns the angle in degrees
  34532. */
  34533. static ToDegrees(angle: number): number;
  34534. /**
  34535. * Convert an angle in degrees to radians
  34536. * @param angle defines the angle to convert
  34537. * @returns the angle in radians
  34538. */
  34539. static ToRadians(angle: number): number;
  34540. /**
  34541. * Returns an array if obj is not an array
  34542. * @param obj defines the object to evaluate as an array
  34543. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34544. * @returns either obj directly if obj is an array or a new array containing obj
  34545. */
  34546. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34547. /**
  34548. * Gets the pointer prefix to use
  34549. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34550. */
  34551. static GetPointerPrefix(): string;
  34552. /**
  34553. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34554. * @param url define the url we are trying
  34555. * @param element define the dom element where to configure the cors policy
  34556. */
  34557. static SetCorsBehavior(url: string | string[], element: {
  34558. crossOrigin: string | null;
  34559. }): void;
  34560. /**
  34561. * Removes unwanted characters from an url
  34562. * @param url defines the url to clean
  34563. * @returns the cleaned url
  34564. */
  34565. static CleanUrl(url: string): string;
  34566. /**
  34567. * Gets or sets a function used to pre-process url before using them to load assets
  34568. */
  34569. static PreprocessUrl: (url: string) => string;
  34570. /**
  34571. * Loads an image as an HTMLImageElement.
  34572. * @param input url string, ArrayBuffer, or Blob to load
  34573. * @param onLoad callback called when the image successfully loads
  34574. * @param onError callback called when the image fails to load
  34575. * @param offlineProvider offline provider for caching
  34576. * @param mimeType optional mime type
  34577. * @returns the HTMLImageElement of the loaded image
  34578. */
  34579. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34580. /**
  34581. * Loads a file from a url
  34582. * @param url url string, ArrayBuffer, or Blob to load
  34583. * @param onSuccess callback called when the file successfully loads
  34584. * @param onProgress callback called while file is loading (if the server supports this mode)
  34585. * @param offlineProvider defines the offline provider for caching
  34586. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34587. * @param onError callback called when the file fails to load
  34588. * @returns a file request object
  34589. */
  34590. 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;
  34591. /**
  34592. * Loads a file from a url
  34593. * @param url the file url to load
  34594. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  34595. */
  34596. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  34597. /**
  34598. * Load a script (identified by an url). When the url returns, the
  34599. * content of this file is added into a new script element, attached to the DOM (body element)
  34600. * @param scriptUrl defines the url of the script to laod
  34601. * @param onSuccess defines the callback called when the script is loaded
  34602. * @param onError defines the callback to call if an error occurs
  34603. * @param scriptId defines the id of the script element
  34604. */
  34605. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34606. /**
  34607. * Load an asynchronous script (identified by an url). When the url returns, the
  34608. * content of this file is added into a new script element, attached to the DOM (body element)
  34609. * @param scriptUrl defines the url of the script to laod
  34610. * @param scriptId defines the id of the script element
  34611. * @returns a promise request object
  34612. */
  34613. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  34614. /**
  34615. * Loads a file from a blob
  34616. * @param fileToLoad defines the blob to use
  34617. * @param callback defines the callback to call when data is loaded
  34618. * @param progressCallback defines the callback to call during loading process
  34619. * @returns a file request object
  34620. */
  34621. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34622. /**
  34623. * Reads a file from a File object
  34624. * @param file defines the file to load
  34625. * @param onSuccess defines the callback to call when data is loaded
  34626. * @param onProgress defines the callback to call during loading process
  34627. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34628. * @param onError defines the callback to call when an error occurs
  34629. * @returns a file request object
  34630. */
  34631. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34632. /**
  34633. * Creates a data url from a given string content
  34634. * @param content defines the content to convert
  34635. * @returns the new data url link
  34636. */
  34637. static FileAsURL(content: string): string;
  34638. /**
  34639. * Format the given number to a specific decimal format
  34640. * @param value defines the number to format
  34641. * @param decimals defines the number of decimals to use
  34642. * @returns the formatted string
  34643. */
  34644. static Format(value: number, decimals?: number): string;
  34645. /**
  34646. * Tries to copy an object by duplicating every property
  34647. * @param source defines the source object
  34648. * @param destination defines the target object
  34649. * @param doNotCopyList defines a list of properties to avoid
  34650. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34651. */
  34652. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34653. /**
  34654. * Gets a boolean indicating if the given object has no own property
  34655. * @param obj defines the object to test
  34656. * @returns true if object has no own property
  34657. */
  34658. static IsEmpty(obj: any): boolean;
  34659. /**
  34660. * Function used to register events at window level
  34661. * @param windowElement defines the Window object to use
  34662. * @param events defines the events to register
  34663. */
  34664. static RegisterTopRootEvents(windowElement: Window, events: {
  34665. name: string;
  34666. handler: Nullable<(e: FocusEvent) => any>;
  34667. }[]): void;
  34668. /**
  34669. * Function used to unregister events from window level
  34670. * @param windowElement defines the Window object to use
  34671. * @param events defines the events to unregister
  34672. */
  34673. static UnregisterTopRootEvents(windowElement: Window, events: {
  34674. name: string;
  34675. handler: Nullable<(e: FocusEvent) => any>;
  34676. }[]): void;
  34677. /**
  34678. * @ignore
  34679. */
  34680. static _ScreenshotCanvas: HTMLCanvasElement;
  34681. /**
  34682. * Dumps the current bound framebuffer
  34683. * @param width defines the rendering width
  34684. * @param height defines the rendering height
  34685. * @param engine defines the hosting engine
  34686. * @param successCallback defines the callback triggered once the data are available
  34687. * @param mimeType defines the mime type of the result
  34688. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34689. */
  34690. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34691. /**
  34692. * Converts the canvas data to blob.
  34693. * This acts as a polyfill for browsers not supporting the to blob function.
  34694. * @param canvas Defines the canvas to extract the data from
  34695. * @param successCallback Defines the callback triggered once the data are available
  34696. * @param mimeType Defines the mime type of the result
  34697. */
  34698. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34699. /**
  34700. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34701. * @param successCallback defines the callback triggered once the data are available
  34702. * @param mimeType defines the mime type of the result
  34703. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34704. */
  34705. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34706. /**
  34707. * Downloads a blob in the browser
  34708. * @param blob defines the blob to download
  34709. * @param fileName defines the name of the downloaded file
  34710. */
  34711. static Download(blob: Blob, fileName: string): void;
  34712. /**
  34713. * Captures a screenshot of the current rendering
  34714. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34715. * @param engine defines the rendering engine
  34716. * @param camera defines the source camera
  34717. * @param size This parameter can be set to a single number or to an object with the
  34718. * following (optional) properties: precision, width, height. If a single number is passed,
  34719. * it will be used for both width and height. If an object is passed, the screenshot size
  34720. * will be derived from the parameters. The precision property is a multiplier allowing
  34721. * rendering at a higher or lower resolution
  34722. * @param successCallback defines the callback receives a single parameter which contains the
  34723. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34724. * src parameter of an <img> to display it
  34725. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34726. * Check your browser for supported MIME types
  34727. */
  34728. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34729. /**
  34730. * Captures a screenshot of the current rendering
  34731. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34732. * @param engine defines the rendering engine
  34733. * @param camera defines the source camera
  34734. * @param size This parameter can be set to a single number or to an object with the
  34735. * following (optional) properties: precision, width, height. If a single number is passed,
  34736. * it will be used for both width and height. If an object is passed, the screenshot size
  34737. * will be derived from the parameters. The precision property is a multiplier allowing
  34738. * rendering at a higher or lower resolution
  34739. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34740. * Check your browser for supported MIME types
  34741. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34742. * to the src parameter of an <img> to display it
  34743. */
  34744. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34745. /**
  34746. * Generates an image screenshot from the specified camera.
  34747. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34748. * @param engine The engine to use for rendering
  34749. * @param camera The camera to use for rendering
  34750. * @param size This parameter can be set to a single number or to an object with the
  34751. * following (optional) properties: precision, width, height. If a single number is passed,
  34752. * it will be used for both width and height. If an object is passed, the screenshot size
  34753. * will be derived from the parameters. The precision property is a multiplier allowing
  34754. * rendering at a higher or lower resolution
  34755. * @param successCallback The callback receives a single parameter which contains the
  34756. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34757. * src parameter of an <img> to display it
  34758. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34759. * Check your browser for supported MIME types
  34760. * @param samples Texture samples (default: 1)
  34761. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34762. * @param fileName A name for for the downloaded file.
  34763. */
  34764. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34765. /**
  34766. * Generates an image screenshot from the specified camera.
  34767. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34768. * @param engine The engine to use for rendering
  34769. * @param camera The camera to use for rendering
  34770. * @param size This parameter can be set to a single number or to an object with the
  34771. * following (optional) properties: precision, width, height. If a single number is passed,
  34772. * it will be used for both width and height. If an object is passed, the screenshot size
  34773. * will be derived from the parameters. The precision property is a multiplier allowing
  34774. * rendering at a higher or lower resolution
  34775. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34776. * Check your browser for supported MIME types
  34777. * @param samples Texture samples (default: 1)
  34778. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34779. * @param fileName A name for for the downloaded file.
  34780. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34781. * to the src parameter of an <img> to display it
  34782. */
  34783. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34784. /**
  34785. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34786. * Be aware Math.random() could cause collisions, but:
  34787. * "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"
  34788. * @returns a pseudo random id
  34789. */
  34790. static RandomId(): string;
  34791. /**
  34792. * Test if the given uri is a base64 string
  34793. * @param uri The uri to test
  34794. * @return True if the uri is a base64 string or false otherwise
  34795. */
  34796. static IsBase64(uri: string): boolean;
  34797. /**
  34798. * Decode the given base64 uri.
  34799. * @param uri The uri to decode
  34800. * @return The decoded base64 data.
  34801. */
  34802. static DecodeBase64(uri: string): ArrayBuffer;
  34803. /**
  34804. * Gets the absolute url.
  34805. * @param url the input url
  34806. * @return the absolute url
  34807. */
  34808. static GetAbsoluteUrl(url: string): string;
  34809. /**
  34810. * No log
  34811. */
  34812. static readonly NoneLogLevel: number;
  34813. /**
  34814. * Only message logs
  34815. */
  34816. static readonly MessageLogLevel: number;
  34817. /**
  34818. * Only warning logs
  34819. */
  34820. static readonly WarningLogLevel: number;
  34821. /**
  34822. * Only error logs
  34823. */
  34824. static readonly ErrorLogLevel: number;
  34825. /**
  34826. * All logs
  34827. */
  34828. static readonly AllLogLevel: number;
  34829. /**
  34830. * Gets a value indicating the number of loading errors
  34831. * @ignorenaming
  34832. */
  34833. static readonly errorsCount: number;
  34834. /**
  34835. * Callback called when a new log is added
  34836. */
  34837. static OnNewCacheEntry: (entry: string) => void;
  34838. /**
  34839. * Log a message to the console
  34840. * @param message defines the message to log
  34841. */
  34842. static Log(message: string): void;
  34843. /**
  34844. * Write a warning message to the console
  34845. * @param message defines the message to log
  34846. */
  34847. static Warn(message: string): void;
  34848. /**
  34849. * Write an error message to the console
  34850. * @param message defines the message to log
  34851. */
  34852. static Error(message: string): void;
  34853. /**
  34854. * Gets current log cache (list of logs)
  34855. */
  34856. static readonly LogCache: string;
  34857. /**
  34858. * Clears the log cache
  34859. */
  34860. static ClearLogCache(): void;
  34861. /**
  34862. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34863. */
  34864. static LogLevels: number;
  34865. /**
  34866. * Checks if the window object exists
  34867. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34868. */
  34869. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34870. /**
  34871. * No performance log
  34872. */
  34873. static readonly PerformanceNoneLogLevel: number;
  34874. /**
  34875. * Use user marks to log performance
  34876. */
  34877. static readonly PerformanceUserMarkLogLevel: number;
  34878. /**
  34879. * Log performance to the console
  34880. */
  34881. static readonly PerformanceConsoleLogLevel: number;
  34882. private static _performance;
  34883. /**
  34884. * Sets the current performance log level
  34885. */
  34886. static PerformanceLogLevel: number;
  34887. private static _StartPerformanceCounterDisabled;
  34888. private static _EndPerformanceCounterDisabled;
  34889. private static _StartUserMark;
  34890. private static _EndUserMark;
  34891. private static _StartPerformanceConsole;
  34892. private static _EndPerformanceConsole;
  34893. /**
  34894. * Starts a performance counter
  34895. */
  34896. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34897. /**
  34898. * Ends a specific performance coutner
  34899. */
  34900. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34901. /**
  34902. * Gets either window.performance.now() if supported or Date.now() else
  34903. */
  34904. static readonly Now: number;
  34905. /**
  34906. * This method will return the name of the class used to create the instance of the given object.
  34907. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34908. * @param object the object to get the class name from
  34909. * @param isType defines if the object is actually a type
  34910. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34911. */
  34912. static GetClassName(object: any, isType?: boolean): string;
  34913. /**
  34914. * Gets the first element of an array satisfying a given predicate
  34915. * @param array defines the array to browse
  34916. * @param predicate defines the predicate to use
  34917. * @returns null if not found or the element
  34918. */
  34919. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34920. /**
  34921. * This method will return the name of the full name of the class, including its owning module (if any).
  34922. * 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).
  34923. * @param object the object to get the class name from
  34924. * @param isType defines if the object is actually a type
  34925. * @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.
  34926. * @ignorenaming
  34927. */
  34928. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34929. /**
  34930. * Returns a promise that resolves after the given amount of time.
  34931. * @param delay Number of milliseconds to delay
  34932. * @returns Promise that resolves after the given amount of time
  34933. */
  34934. static DelayAsync(delay: number): Promise<void>;
  34935. }
  34936. /**
  34937. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34938. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34939. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34940. * @param name The name of the class, case should be preserved
  34941. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34942. */
  34943. export function className(name: string, module?: string): (target: Object) => void;
  34944. /**
  34945. * An implementation of a loop for asynchronous functions.
  34946. */
  34947. export class AsyncLoop {
  34948. /**
  34949. * Defines the number of iterations for the loop
  34950. */
  34951. iterations: number;
  34952. /**
  34953. * Defines the current index of the loop.
  34954. */
  34955. index: number;
  34956. private _done;
  34957. private _fn;
  34958. private _successCallback;
  34959. /**
  34960. * Constructor.
  34961. * @param iterations the number of iterations.
  34962. * @param func the function to run each iteration
  34963. * @param successCallback the callback that will be called upon succesful execution
  34964. * @param offset starting offset.
  34965. */
  34966. constructor(
  34967. /**
  34968. * Defines the number of iterations for the loop
  34969. */
  34970. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34971. /**
  34972. * Execute the next iteration. Must be called after the last iteration was finished.
  34973. */
  34974. executeNext(): void;
  34975. /**
  34976. * Break the loop and run the success callback.
  34977. */
  34978. breakLoop(): void;
  34979. /**
  34980. * Create and run an async loop.
  34981. * @param iterations the number of iterations.
  34982. * @param fn the function to run each iteration
  34983. * @param successCallback the callback that will be called upon succesful execution
  34984. * @param offset starting offset.
  34985. * @returns the created async loop object
  34986. */
  34987. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34988. /**
  34989. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34990. * @param iterations total number of iterations
  34991. * @param syncedIterations number of synchronous iterations in each async iteration.
  34992. * @param fn the function to call each iteration.
  34993. * @param callback a success call back that will be called when iterating stops.
  34994. * @param breakFunction a break condition (optional)
  34995. * @param timeout timeout settings for the setTimeout function. default - 0.
  34996. * @returns the created async loop object
  34997. */
  34998. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34999. }
  35000. }
  35001. declare module "babylonjs/Misc/stringDictionary" {
  35002. import { Nullable } from "babylonjs/types";
  35003. /**
  35004. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35005. * The underlying implementation relies on an associative array to ensure the best performances.
  35006. * The value can be anything including 'null' but except 'undefined'
  35007. */
  35008. export class StringDictionary<T> {
  35009. /**
  35010. * This will clear this dictionary and copy the content from the 'source' one.
  35011. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35012. * @param source the dictionary to take the content from and copy to this dictionary
  35013. */
  35014. copyFrom(source: StringDictionary<T>): void;
  35015. /**
  35016. * Get a value based from its key
  35017. * @param key the given key to get the matching value from
  35018. * @return the value if found, otherwise undefined is returned
  35019. */
  35020. get(key: string): T | undefined;
  35021. /**
  35022. * Get a value from its key or add it if it doesn't exist.
  35023. * This method will ensure you that a given key/data will be present in the dictionary.
  35024. * @param key the given key to get the matching value from
  35025. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35026. * The factory will only be invoked if there's no data for the given key.
  35027. * @return the value corresponding to the key.
  35028. */
  35029. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35030. /**
  35031. * Get a value from its key if present in the dictionary otherwise add it
  35032. * @param key the key to get the value from
  35033. * @param val if there's no such key/value pair in the dictionary add it with this value
  35034. * @return the value corresponding to the key
  35035. */
  35036. getOrAdd(key: string, val: T): T;
  35037. /**
  35038. * Check if there's a given key in the dictionary
  35039. * @param key the key to check for
  35040. * @return true if the key is present, false otherwise
  35041. */
  35042. contains(key: string): boolean;
  35043. /**
  35044. * Add a new key and its corresponding value
  35045. * @param key the key to add
  35046. * @param value the value corresponding to the key
  35047. * @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
  35048. */
  35049. add(key: string, value: T): boolean;
  35050. /**
  35051. * Update a specific value associated to a key
  35052. * @param key defines the key to use
  35053. * @param value defines the value to store
  35054. * @returns true if the value was updated (or false if the key was not found)
  35055. */
  35056. set(key: string, value: T): boolean;
  35057. /**
  35058. * Get the element of the given key and remove it from the dictionary
  35059. * @param key defines the key to search
  35060. * @returns the value associated with the key or null if not found
  35061. */
  35062. getAndRemove(key: string): Nullable<T>;
  35063. /**
  35064. * Remove a key/value from the dictionary.
  35065. * @param key the key to remove
  35066. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35067. */
  35068. remove(key: string): boolean;
  35069. /**
  35070. * Clear the whole content of the dictionary
  35071. */
  35072. clear(): void;
  35073. /**
  35074. * Gets the current count
  35075. */
  35076. readonly count: number;
  35077. /**
  35078. * Execute a callback on each key/val of the dictionary.
  35079. * Note that you can remove any element in this dictionary in the callback implementation
  35080. * @param callback the callback to execute on a given key/value pair
  35081. */
  35082. forEach(callback: (key: string, val: T) => void): void;
  35083. /**
  35084. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35085. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35086. * Note that you can remove any element in this dictionary in the callback implementation
  35087. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35088. * @returns the first item
  35089. */
  35090. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35091. private _count;
  35092. private _data;
  35093. }
  35094. }
  35095. declare module "babylonjs/Collisions/collisionCoordinator" {
  35096. import { Nullable } from "babylonjs/types";
  35097. import { Scene } from "babylonjs/scene";
  35098. import { Vector3 } from "babylonjs/Maths/math.vector";
  35099. import { Collider } from "babylonjs/Collisions/collider";
  35100. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35101. /** @hidden */
  35102. export interface ICollisionCoordinator {
  35103. createCollider(): Collider;
  35104. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35105. init(scene: Scene): void;
  35106. }
  35107. /** @hidden */
  35108. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35109. private _scene;
  35110. private _scaledPosition;
  35111. private _scaledVelocity;
  35112. private _finalPosition;
  35113. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35114. createCollider(): Collider;
  35115. init(scene: Scene): void;
  35116. private _collideWithWorld;
  35117. }
  35118. }
  35119. declare module "babylonjs/Inputs/scene.inputManager" {
  35120. import { Nullable } from "babylonjs/types";
  35121. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35122. import { Vector2 } from "babylonjs/Maths/math.vector";
  35123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35124. import { Scene } from "babylonjs/scene";
  35125. /**
  35126. * Class used to manage all inputs for the scene.
  35127. */
  35128. export class InputManager {
  35129. /** The distance in pixel that you have to move to prevent some events */
  35130. static DragMovementThreshold: number;
  35131. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35132. static LongPressDelay: number;
  35133. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35134. static DoubleClickDelay: number;
  35135. /** If you need to check double click without raising a single click at first click, enable this flag */
  35136. static ExclusiveDoubleClickMode: boolean;
  35137. private _wheelEventName;
  35138. private _onPointerMove;
  35139. private _onPointerDown;
  35140. private _onPointerUp;
  35141. private _initClickEvent;
  35142. private _initActionManager;
  35143. private _delayedSimpleClick;
  35144. private _delayedSimpleClickTimeout;
  35145. private _previousDelayedSimpleClickTimeout;
  35146. private _meshPickProceed;
  35147. private _previousButtonPressed;
  35148. private _currentPickResult;
  35149. private _previousPickResult;
  35150. private _totalPointersPressed;
  35151. private _doubleClickOccured;
  35152. private _pointerOverMesh;
  35153. private _pickedDownMesh;
  35154. private _pickedUpMesh;
  35155. private _pointerX;
  35156. private _pointerY;
  35157. private _unTranslatedPointerX;
  35158. private _unTranslatedPointerY;
  35159. private _startingPointerPosition;
  35160. private _previousStartingPointerPosition;
  35161. private _startingPointerTime;
  35162. private _previousStartingPointerTime;
  35163. private _pointerCaptures;
  35164. private _onKeyDown;
  35165. private _onKeyUp;
  35166. private _onCanvasFocusObserver;
  35167. private _onCanvasBlurObserver;
  35168. private _scene;
  35169. /**
  35170. * Creates a new InputManager
  35171. * @param scene defines the hosting scene
  35172. */
  35173. constructor(scene: Scene);
  35174. /**
  35175. * Gets the mesh that is currently under the pointer
  35176. */
  35177. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35178. /**
  35179. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35180. */
  35181. readonly unTranslatedPointer: Vector2;
  35182. /**
  35183. * Gets or sets the current on-screen X position of the pointer
  35184. */
  35185. pointerX: number;
  35186. /**
  35187. * Gets or sets the current on-screen Y position of the pointer
  35188. */
  35189. pointerY: number;
  35190. private _updatePointerPosition;
  35191. private _processPointerMove;
  35192. private _setRayOnPointerInfo;
  35193. private _checkPrePointerObservable;
  35194. /**
  35195. * Use this method to simulate a pointer move on a mesh
  35196. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35197. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35198. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35199. */
  35200. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35201. /**
  35202. * Use this method to simulate a pointer down on a mesh
  35203. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35204. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35205. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35206. */
  35207. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35208. private _processPointerDown;
  35209. /** @hidden */
  35210. _isPointerSwiping(): boolean;
  35211. /**
  35212. * Use this method to simulate a pointer up on a mesh
  35213. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35214. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35215. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35216. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35217. */
  35218. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35219. private _processPointerUp;
  35220. /**
  35221. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35222. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35223. * @returns true if the pointer was captured
  35224. */
  35225. isPointerCaptured(pointerId?: number): boolean;
  35226. /**
  35227. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35228. * @param attachUp defines if you want to attach events to pointerup
  35229. * @param attachDown defines if you want to attach events to pointerdown
  35230. * @param attachMove defines if you want to attach events to pointermove
  35231. */
  35232. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35233. /**
  35234. * Detaches all event handlers
  35235. */
  35236. detachControl(): void;
  35237. /**
  35238. * Force the value of meshUnderPointer
  35239. * @param mesh defines the mesh to use
  35240. */
  35241. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35242. /**
  35243. * Gets the mesh under the pointer
  35244. * @returns a Mesh or null if no mesh is under the pointer
  35245. */
  35246. getPointerOverMesh(): Nullable<AbstractMesh>;
  35247. }
  35248. }
  35249. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35250. /**
  35251. * Helper class used to generate session unique ID
  35252. */
  35253. export class UniqueIdGenerator {
  35254. private static _UniqueIdCounter;
  35255. /**
  35256. * Gets an unique (relatively to the current scene) Id
  35257. */
  35258. static readonly UniqueId: number;
  35259. }
  35260. }
  35261. declare module "babylonjs/Animations/animationGroup" {
  35262. import { Animatable } from "babylonjs/Animations/animatable";
  35263. import { Animation } from "babylonjs/Animations/animation";
  35264. import { Scene, IDisposable } from "babylonjs/scene";
  35265. import { Observable } from "babylonjs/Misc/observable";
  35266. import { Nullable } from "babylonjs/types";
  35267. import "babylonjs/Animations/animatable";
  35268. /**
  35269. * This class defines the direct association between an animation and a target
  35270. */
  35271. export class TargetedAnimation {
  35272. /**
  35273. * Animation to perform
  35274. */
  35275. animation: Animation;
  35276. /**
  35277. * Target to animate
  35278. */
  35279. target: any;
  35280. /**
  35281. * Serialize the object
  35282. * @returns the JSON object representing the current entity
  35283. */
  35284. serialize(): any;
  35285. }
  35286. /**
  35287. * Use this class to create coordinated animations on multiple targets
  35288. */
  35289. export class AnimationGroup implements IDisposable {
  35290. /** The name of the animation group */
  35291. name: string;
  35292. private _scene;
  35293. private _targetedAnimations;
  35294. private _animatables;
  35295. private _from;
  35296. private _to;
  35297. private _isStarted;
  35298. private _isPaused;
  35299. private _speedRatio;
  35300. private _loopAnimation;
  35301. /**
  35302. * Gets or sets the unique id of the node
  35303. */
  35304. uniqueId: number;
  35305. /**
  35306. * This observable will notify when one animation have ended
  35307. */
  35308. onAnimationEndObservable: Observable<TargetedAnimation>;
  35309. /**
  35310. * Observer raised when one animation loops
  35311. */
  35312. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35313. /**
  35314. * Observer raised when all animations have looped
  35315. */
  35316. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35317. /**
  35318. * This observable will notify when all animations have ended.
  35319. */
  35320. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35321. /**
  35322. * This observable will notify when all animations have paused.
  35323. */
  35324. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35325. /**
  35326. * This observable will notify when all animations are playing.
  35327. */
  35328. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35329. /**
  35330. * Gets the first frame
  35331. */
  35332. readonly from: number;
  35333. /**
  35334. * Gets the last frame
  35335. */
  35336. readonly to: number;
  35337. /**
  35338. * Define if the animations are started
  35339. */
  35340. readonly isStarted: boolean;
  35341. /**
  35342. * Gets a value indicating that the current group is playing
  35343. */
  35344. readonly isPlaying: boolean;
  35345. /**
  35346. * Gets or sets the speed ratio to use for all animations
  35347. */
  35348. /**
  35349. * Gets or sets the speed ratio to use for all animations
  35350. */
  35351. speedRatio: number;
  35352. /**
  35353. * Gets or sets if all animations should loop or not
  35354. */
  35355. loopAnimation: boolean;
  35356. /**
  35357. * Gets the targeted animations for this animation group
  35358. */
  35359. readonly targetedAnimations: Array<TargetedAnimation>;
  35360. /**
  35361. * returning the list of animatables controlled by this animation group.
  35362. */
  35363. readonly animatables: Array<Animatable>;
  35364. /**
  35365. * Instantiates a new Animation Group.
  35366. * This helps managing several animations at once.
  35367. * @see http://doc.babylonjs.com/how_to/group
  35368. * @param name Defines the name of the group
  35369. * @param scene Defines the scene the group belongs to
  35370. */
  35371. constructor(
  35372. /** The name of the animation group */
  35373. name: string, scene?: Nullable<Scene>);
  35374. /**
  35375. * Add an animation (with its target) in the group
  35376. * @param animation defines the animation we want to add
  35377. * @param target defines the target of the animation
  35378. * @returns the TargetedAnimation object
  35379. */
  35380. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35381. /**
  35382. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35383. * It can add constant keys at begin or end
  35384. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35385. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35386. * @returns the animation group
  35387. */
  35388. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35389. private _animationLoopCount;
  35390. private _animationLoopFlags;
  35391. private _processLoop;
  35392. /**
  35393. * Start all animations on given targets
  35394. * @param loop defines if animations must loop
  35395. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35396. * @param from defines the from key (optional)
  35397. * @param to defines the to key (optional)
  35398. * @returns the current animation group
  35399. */
  35400. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35401. /**
  35402. * Pause all animations
  35403. * @returns the animation group
  35404. */
  35405. pause(): AnimationGroup;
  35406. /**
  35407. * Play all animations to initial state
  35408. * This function will start() the animations if they were not started or will restart() them if they were paused
  35409. * @param loop defines if animations must loop
  35410. * @returns the animation group
  35411. */
  35412. play(loop?: boolean): AnimationGroup;
  35413. /**
  35414. * Reset all animations to initial state
  35415. * @returns the animation group
  35416. */
  35417. reset(): AnimationGroup;
  35418. /**
  35419. * Restart animations from key 0
  35420. * @returns the animation group
  35421. */
  35422. restart(): AnimationGroup;
  35423. /**
  35424. * Stop all animations
  35425. * @returns the animation group
  35426. */
  35427. stop(): AnimationGroup;
  35428. /**
  35429. * Set animation weight for all animatables
  35430. * @param weight defines the weight to use
  35431. * @return the animationGroup
  35432. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35433. */
  35434. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35435. /**
  35436. * Synchronize and normalize all animatables with a source animatable
  35437. * @param root defines the root animatable to synchronize with
  35438. * @return the animationGroup
  35439. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35440. */
  35441. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35442. /**
  35443. * Goes to a specific frame in this animation group
  35444. * @param frame the frame number to go to
  35445. * @return the animationGroup
  35446. */
  35447. goToFrame(frame: number): AnimationGroup;
  35448. /**
  35449. * Dispose all associated resources
  35450. */
  35451. dispose(): void;
  35452. private _checkAnimationGroupEnded;
  35453. /**
  35454. * Clone the current animation group and returns a copy
  35455. * @param newName defines the name of the new group
  35456. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35457. * @returns the new aniamtion group
  35458. */
  35459. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35460. /**
  35461. * Serializes the animationGroup to an object
  35462. * @returns Serialized object
  35463. */
  35464. serialize(): any;
  35465. /**
  35466. * Returns a new AnimationGroup object parsed from the source provided.
  35467. * @param parsedAnimationGroup defines the source
  35468. * @param scene defines the scene that will receive the animationGroup
  35469. * @returns a new AnimationGroup
  35470. */
  35471. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35472. /**
  35473. * Returns the string "AnimationGroup"
  35474. * @returns "AnimationGroup"
  35475. */
  35476. getClassName(): string;
  35477. /**
  35478. * Creates a detailled string about the object
  35479. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35480. * @returns a string representing the object
  35481. */
  35482. toString(fullDetails?: boolean): string;
  35483. }
  35484. }
  35485. declare module "babylonjs/scene" {
  35486. import { Nullable } from "babylonjs/types";
  35487. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35488. import { Observable } from "babylonjs/Misc/observable";
  35489. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35490. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35491. import { Geometry } from "babylonjs/Meshes/geometry";
  35492. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35493. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35495. import { Mesh } from "babylonjs/Meshes/mesh";
  35496. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35497. import { Bone } from "babylonjs/Bones/bone";
  35498. import { Skeleton } from "babylonjs/Bones/skeleton";
  35499. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35500. import { Camera } from "babylonjs/Cameras/camera";
  35501. import { AbstractScene } from "babylonjs/abstractScene";
  35502. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35503. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35504. import { Material } from "babylonjs/Materials/material";
  35505. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35506. import { Effect } from "babylonjs/Materials/effect";
  35507. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35508. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35509. import { Light } from "babylonjs/Lights/light";
  35510. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35511. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  35512. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  35513. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  35514. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35515. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  35516. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35517. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  35518. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  35519. import { Engine } from "babylonjs/Engines/engine";
  35520. import { Node } from "babylonjs/node";
  35521. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  35522. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35523. import { WebRequest } from "babylonjs/Misc/webRequest";
  35524. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  35525. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  35526. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35527. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35528. import { Plane } from "babylonjs/Maths/math.plane";
  35529. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  35530. import { Ray } from "babylonjs/Culling/ray";
  35531. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  35532. import { Animation } from "babylonjs/Animations/animation";
  35533. import { Animatable } from "babylonjs/Animations/animatable";
  35534. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35535. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  35536. import { Collider } from "babylonjs/Collisions/collider";
  35537. /**
  35538. * Define an interface for all classes that will hold resources
  35539. */
  35540. export interface IDisposable {
  35541. /**
  35542. * Releases all held resources
  35543. */
  35544. dispose(): void;
  35545. }
  35546. /** Interface defining initialization parameters for Scene class */
  35547. export interface SceneOptions {
  35548. /**
  35549. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35550. * It will improve performance when the number of geometries becomes important.
  35551. */
  35552. useGeometryUniqueIdsMap?: boolean;
  35553. /**
  35554. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35555. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35556. */
  35557. useMaterialMeshMap?: boolean;
  35558. /**
  35559. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35560. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35561. */
  35562. useClonedMeshhMap?: boolean;
  35563. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35564. virtual?: boolean;
  35565. }
  35566. /**
  35567. * Represents a scene to be rendered by the engine.
  35568. * @see http://doc.babylonjs.com/features/scene
  35569. */
  35570. export class Scene extends AbstractScene implements IAnimatable {
  35571. /** The fog is deactivated */
  35572. static readonly FOGMODE_NONE: number;
  35573. /** The fog density is following an exponential function */
  35574. static readonly FOGMODE_EXP: number;
  35575. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35576. static readonly FOGMODE_EXP2: number;
  35577. /** The fog density is following a linear function. */
  35578. static readonly FOGMODE_LINEAR: number;
  35579. /**
  35580. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35581. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35582. */
  35583. static MinDeltaTime: number;
  35584. /**
  35585. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35586. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35587. */
  35588. static MaxDeltaTime: number;
  35589. /**
  35590. * Factory used to create the default material.
  35591. * @param name The name of the material to create
  35592. * @param scene The scene to create the material for
  35593. * @returns The default material
  35594. */
  35595. static DefaultMaterialFactory(scene: Scene): Material;
  35596. /**
  35597. * Factory used to create the a collision coordinator.
  35598. * @returns The collision coordinator
  35599. */
  35600. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35601. /** @hidden */
  35602. _inputManager: InputManager;
  35603. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35604. cameraToUseForPointers: Nullable<Camera>;
  35605. /** @hidden */
  35606. readonly _isScene: boolean;
  35607. /**
  35608. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35609. */
  35610. autoClear: boolean;
  35611. /**
  35612. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35613. */
  35614. autoClearDepthAndStencil: boolean;
  35615. /**
  35616. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35617. */
  35618. clearColor: Color4;
  35619. /**
  35620. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35621. */
  35622. ambientColor: Color3;
  35623. /**
  35624. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35625. * It should only be one of the following (if not the default embedded one):
  35626. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35627. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35628. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35629. * The material properties need to be setup according to the type of texture in use.
  35630. */
  35631. environmentBRDFTexture: BaseTexture;
  35632. /** @hidden */
  35633. protected _environmentTexture: Nullable<BaseTexture>;
  35634. /**
  35635. * Texture used in all pbr material as the reflection texture.
  35636. * As in the majority of the scene they are the same (exception for multi room and so on),
  35637. * this is easier to reference from here than from all the materials.
  35638. */
  35639. /**
  35640. * Texture used in all pbr material as the reflection texture.
  35641. * As in the majority of the scene they are the same (exception for multi room and so on),
  35642. * this is easier to set here than in all the materials.
  35643. */
  35644. environmentTexture: Nullable<BaseTexture>;
  35645. /** @hidden */
  35646. protected _environmentIntensity: number;
  35647. /**
  35648. * Intensity of the environment in all pbr material.
  35649. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35650. * As in the majority of the scene they are the same (exception for multi room and so on),
  35651. * this is easier to reference from here than from all the materials.
  35652. */
  35653. /**
  35654. * Intensity of the environment in all pbr material.
  35655. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35656. * As in the majority of the scene they are the same (exception for multi room and so on),
  35657. * this is easier to set here than in all the materials.
  35658. */
  35659. environmentIntensity: number;
  35660. /** @hidden */
  35661. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35662. /**
  35663. * Default image processing configuration used either in the rendering
  35664. * Forward main pass or through the imageProcessingPostProcess if present.
  35665. * As in the majority of the scene they are the same (exception for multi camera),
  35666. * this is easier to reference from here than from all the materials and post process.
  35667. *
  35668. * No setter as we it is a shared configuration, you can set the values instead.
  35669. */
  35670. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  35671. private _forceWireframe;
  35672. /**
  35673. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35674. */
  35675. forceWireframe: boolean;
  35676. private _forcePointsCloud;
  35677. /**
  35678. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35679. */
  35680. forcePointsCloud: boolean;
  35681. /**
  35682. * Gets or sets the active clipplane 1
  35683. */
  35684. clipPlane: Nullable<Plane>;
  35685. /**
  35686. * Gets or sets the active clipplane 2
  35687. */
  35688. clipPlane2: Nullable<Plane>;
  35689. /**
  35690. * Gets or sets the active clipplane 3
  35691. */
  35692. clipPlane3: Nullable<Plane>;
  35693. /**
  35694. * Gets or sets the active clipplane 4
  35695. */
  35696. clipPlane4: Nullable<Plane>;
  35697. /**
  35698. * Gets or sets a boolean indicating if animations are enabled
  35699. */
  35700. animationsEnabled: boolean;
  35701. private _animationPropertiesOverride;
  35702. /**
  35703. * Gets or sets the animation properties override
  35704. */
  35705. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  35706. /**
  35707. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35708. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35709. */
  35710. useConstantAnimationDeltaTime: boolean;
  35711. /**
  35712. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35713. * Please note that it requires to run a ray cast through the scene on every frame
  35714. */
  35715. constantlyUpdateMeshUnderPointer: boolean;
  35716. /**
  35717. * Defines the HTML cursor to use when hovering over interactive elements
  35718. */
  35719. hoverCursor: string;
  35720. /**
  35721. * Defines the HTML default cursor to use (empty by default)
  35722. */
  35723. defaultCursor: string;
  35724. /**
  35725. * Defines wether cursors are handled by the scene.
  35726. */
  35727. doNotHandleCursors: boolean;
  35728. /**
  35729. * This is used to call preventDefault() on pointer down
  35730. * in order to block unwanted artifacts like system double clicks
  35731. */
  35732. preventDefaultOnPointerDown: boolean;
  35733. /**
  35734. * This is used to call preventDefault() on pointer up
  35735. * in order to block unwanted artifacts like system double clicks
  35736. */
  35737. preventDefaultOnPointerUp: boolean;
  35738. /**
  35739. * Gets or sets user defined metadata
  35740. */
  35741. metadata: any;
  35742. /**
  35743. * For internal use only. Please do not use.
  35744. */
  35745. reservedDataStore: any;
  35746. /**
  35747. * Gets the name of the plugin used to load this scene (null by default)
  35748. */
  35749. loadingPluginName: string;
  35750. /**
  35751. * Use this array to add regular expressions used to disable offline support for specific urls
  35752. */
  35753. disableOfflineSupportExceptionRules: RegExp[];
  35754. /**
  35755. * An event triggered when the scene is disposed.
  35756. */
  35757. onDisposeObservable: Observable<Scene>;
  35758. private _onDisposeObserver;
  35759. /** Sets a function to be executed when this scene is disposed. */
  35760. onDispose: () => void;
  35761. /**
  35762. * An event triggered before rendering the scene (right after animations and physics)
  35763. */
  35764. onBeforeRenderObservable: Observable<Scene>;
  35765. private _onBeforeRenderObserver;
  35766. /** Sets a function to be executed before rendering this scene */
  35767. beforeRender: Nullable<() => void>;
  35768. /**
  35769. * An event triggered after rendering the scene
  35770. */
  35771. onAfterRenderObservable: Observable<Scene>;
  35772. /**
  35773. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35774. */
  35775. onAfterRenderCameraObservable: Observable<Camera>;
  35776. private _onAfterRenderObserver;
  35777. /** Sets a function to be executed after rendering this scene */
  35778. afterRender: Nullable<() => void>;
  35779. /**
  35780. * An event triggered before animating the scene
  35781. */
  35782. onBeforeAnimationsObservable: Observable<Scene>;
  35783. /**
  35784. * An event triggered after animations processing
  35785. */
  35786. onAfterAnimationsObservable: Observable<Scene>;
  35787. /**
  35788. * An event triggered before draw calls are ready to be sent
  35789. */
  35790. onBeforeDrawPhaseObservable: Observable<Scene>;
  35791. /**
  35792. * An event triggered after draw calls have been sent
  35793. */
  35794. onAfterDrawPhaseObservable: Observable<Scene>;
  35795. /**
  35796. * An event triggered when the scene is ready
  35797. */
  35798. onReadyObservable: Observable<Scene>;
  35799. /**
  35800. * An event triggered before rendering a camera
  35801. */
  35802. onBeforeCameraRenderObservable: Observable<Camera>;
  35803. private _onBeforeCameraRenderObserver;
  35804. /** Sets a function to be executed before rendering a camera*/
  35805. beforeCameraRender: () => void;
  35806. /**
  35807. * An event triggered after rendering a camera
  35808. */
  35809. onAfterCameraRenderObservable: Observable<Camera>;
  35810. private _onAfterCameraRenderObserver;
  35811. /** Sets a function to be executed after rendering a camera*/
  35812. afterCameraRender: () => void;
  35813. /**
  35814. * An event triggered when active meshes evaluation is about to start
  35815. */
  35816. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35817. /**
  35818. * An event triggered when active meshes evaluation is done
  35819. */
  35820. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35821. /**
  35822. * An event triggered when particles rendering is about to start
  35823. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35824. */
  35825. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35826. /**
  35827. * An event triggered when particles rendering is done
  35828. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35829. */
  35830. onAfterParticlesRenderingObservable: Observable<Scene>;
  35831. /**
  35832. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35833. */
  35834. onDataLoadedObservable: Observable<Scene>;
  35835. /**
  35836. * An event triggered when a camera is created
  35837. */
  35838. onNewCameraAddedObservable: Observable<Camera>;
  35839. /**
  35840. * An event triggered when a camera is removed
  35841. */
  35842. onCameraRemovedObservable: Observable<Camera>;
  35843. /**
  35844. * An event triggered when a light is created
  35845. */
  35846. onNewLightAddedObservable: Observable<Light>;
  35847. /**
  35848. * An event triggered when a light is removed
  35849. */
  35850. onLightRemovedObservable: Observable<Light>;
  35851. /**
  35852. * An event triggered when a geometry is created
  35853. */
  35854. onNewGeometryAddedObservable: Observable<Geometry>;
  35855. /**
  35856. * An event triggered when a geometry is removed
  35857. */
  35858. onGeometryRemovedObservable: Observable<Geometry>;
  35859. /**
  35860. * An event triggered when a transform node is created
  35861. */
  35862. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35863. /**
  35864. * An event triggered when a transform node is removed
  35865. */
  35866. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35867. /**
  35868. * An event triggered when a mesh is created
  35869. */
  35870. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35871. /**
  35872. * An event triggered when a mesh is removed
  35873. */
  35874. onMeshRemovedObservable: Observable<AbstractMesh>;
  35875. /**
  35876. * An event triggered when a skeleton is created
  35877. */
  35878. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35879. /**
  35880. * An event triggered when a skeleton is removed
  35881. */
  35882. onSkeletonRemovedObservable: Observable<Skeleton>;
  35883. /**
  35884. * An event triggered when a material is created
  35885. */
  35886. onNewMaterialAddedObservable: Observable<Material>;
  35887. /**
  35888. * An event triggered when a material is removed
  35889. */
  35890. onMaterialRemovedObservable: Observable<Material>;
  35891. /**
  35892. * An event triggered when a texture is created
  35893. */
  35894. onNewTextureAddedObservable: Observable<BaseTexture>;
  35895. /**
  35896. * An event triggered when a texture is removed
  35897. */
  35898. onTextureRemovedObservable: Observable<BaseTexture>;
  35899. /**
  35900. * An event triggered when render targets are about to be rendered
  35901. * Can happen multiple times per frame.
  35902. */
  35903. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35904. /**
  35905. * An event triggered when render targets were rendered.
  35906. * Can happen multiple times per frame.
  35907. */
  35908. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35909. /**
  35910. * An event triggered before calculating deterministic simulation step
  35911. */
  35912. onBeforeStepObservable: Observable<Scene>;
  35913. /**
  35914. * An event triggered after calculating deterministic simulation step
  35915. */
  35916. onAfterStepObservable: Observable<Scene>;
  35917. /**
  35918. * An event triggered when the activeCamera property is updated
  35919. */
  35920. onActiveCameraChanged: Observable<Scene>;
  35921. /**
  35922. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35923. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35924. * 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)
  35925. */
  35926. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35927. /**
  35928. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35929. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35930. * 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)
  35931. */
  35932. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35933. /**
  35934. * This Observable will when a mesh has been imported into the scene.
  35935. */
  35936. onMeshImportedObservable: Observable<AbstractMesh>;
  35937. /**
  35938. * This Observable will when an animation file has been imported into the scene.
  35939. */
  35940. onAnimationFileImportedObservable: Observable<Scene>;
  35941. /**
  35942. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35943. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35944. */
  35945. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35946. /** @hidden */
  35947. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35948. /**
  35949. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35950. */
  35951. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35952. /**
  35953. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35954. */
  35955. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35956. /**
  35957. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35958. */
  35959. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35960. /** Callback called when a pointer move is detected */
  35961. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35962. /** Callback called when a pointer down is detected */
  35963. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35964. /** Callback called when a pointer up is detected */
  35965. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35966. /** Callback called when a pointer pick is detected */
  35967. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35968. /**
  35969. * 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).
  35970. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35971. */
  35972. onPrePointerObservable: Observable<PointerInfoPre>;
  35973. /**
  35974. * Observable event triggered each time an input event is received from the rendering canvas
  35975. */
  35976. onPointerObservable: Observable<PointerInfo>;
  35977. /**
  35978. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35979. */
  35980. readonly unTranslatedPointer: Vector2;
  35981. /**
  35982. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35983. */
  35984. static DragMovementThreshold: number;
  35985. /**
  35986. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35987. */
  35988. static LongPressDelay: number;
  35989. /**
  35990. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35991. */
  35992. static DoubleClickDelay: number;
  35993. /** If you need to check double click without raising a single click at first click, enable this flag */
  35994. static ExclusiveDoubleClickMode: boolean;
  35995. /** @hidden */
  35996. _mirroredCameraPosition: Nullable<Vector3>;
  35997. /**
  35998. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35999. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36000. */
  36001. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36002. /**
  36003. * Observable event triggered each time an keyboard event is received from the hosting window
  36004. */
  36005. onKeyboardObservable: Observable<KeyboardInfo>;
  36006. private _useRightHandedSystem;
  36007. /**
  36008. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36009. */
  36010. useRightHandedSystem: boolean;
  36011. private _timeAccumulator;
  36012. private _currentStepId;
  36013. private _currentInternalStep;
  36014. /**
  36015. * Sets the step Id used by deterministic lock step
  36016. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36017. * @param newStepId defines the step Id
  36018. */
  36019. setStepId(newStepId: number): void;
  36020. /**
  36021. * Gets the step Id used by deterministic lock step
  36022. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36023. * @returns the step Id
  36024. */
  36025. getStepId(): number;
  36026. /**
  36027. * Gets the internal step used by deterministic lock step
  36028. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36029. * @returns the internal step
  36030. */
  36031. getInternalStep(): number;
  36032. private _fogEnabled;
  36033. /**
  36034. * Gets or sets a boolean indicating if fog is enabled on this scene
  36035. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36036. * (Default is true)
  36037. */
  36038. fogEnabled: boolean;
  36039. private _fogMode;
  36040. /**
  36041. * Gets or sets the fog mode to use
  36042. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36043. * | mode | value |
  36044. * | --- | --- |
  36045. * | FOGMODE_NONE | 0 |
  36046. * | FOGMODE_EXP | 1 |
  36047. * | FOGMODE_EXP2 | 2 |
  36048. * | FOGMODE_LINEAR | 3 |
  36049. */
  36050. fogMode: number;
  36051. /**
  36052. * Gets or sets the fog color to use
  36053. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36054. * (Default is Color3(0.2, 0.2, 0.3))
  36055. */
  36056. fogColor: Color3;
  36057. /**
  36058. * Gets or sets the fog density to use
  36059. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36060. * (Default is 0.1)
  36061. */
  36062. fogDensity: number;
  36063. /**
  36064. * Gets or sets the fog start distance to use
  36065. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36066. * (Default is 0)
  36067. */
  36068. fogStart: number;
  36069. /**
  36070. * Gets or sets the fog end distance to use
  36071. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36072. * (Default is 1000)
  36073. */
  36074. fogEnd: number;
  36075. private _shadowsEnabled;
  36076. /**
  36077. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36078. */
  36079. shadowsEnabled: boolean;
  36080. private _lightsEnabled;
  36081. /**
  36082. * Gets or sets a boolean indicating if lights are enabled on this scene
  36083. */
  36084. lightsEnabled: boolean;
  36085. /** All of the active cameras added to this scene. */
  36086. activeCameras: Camera[];
  36087. /** @hidden */
  36088. _activeCamera: Nullable<Camera>;
  36089. /** Gets or sets the current active camera */
  36090. activeCamera: Nullable<Camera>;
  36091. private _defaultMaterial;
  36092. /** The default material used on meshes when no material is affected */
  36093. /** The default material used on meshes when no material is affected */
  36094. defaultMaterial: Material;
  36095. private _texturesEnabled;
  36096. /**
  36097. * Gets or sets a boolean indicating if textures are enabled on this scene
  36098. */
  36099. texturesEnabled: boolean;
  36100. /**
  36101. * Gets or sets a boolean indicating if particles are enabled on this scene
  36102. */
  36103. particlesEnabled: boolean;
  36104. /**
  36105. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36106. */
  36107. spritesEnabled: boolean;
  36108. private _skeletonsEnabled;
  36109. /**
  36110. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36111. */
  36112. skeletonsEnabled: boolean;
  36113. /**
  36114. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36115. */
  36116. lensFlaresEnabled: boolean;
  36117. /**
  36118. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36119. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36120. */
  36121. collisionsEnabled: boolean;
  36122. private _collisionCoordinator;
  36123. /** @hidden */
  36124. readonly collisionCoordinator: ICollisionCoordinator;
  36125. /**
  36126. * Defines the gravity applied to this scene (used only for collisions)
  36127. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36128. */
  36129. gravity: Vector3;
  36130. /**
  36131. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36132. */
  36133. postProcessesEnabled: boolean;
  36134. /**
  36135. * The list of postprocesses added to the scene
  36136. */
  36137. postProcesses: PostProcess[];
  36138. /**
  36139. * Gets the current postprocess manager
  36140. */
  36141. postProcessManager: PostProcessManager;
  36142. /**
  36143. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36144. */
  36145. renderTargetsEnabled: boolean;
  36146. /**
  36147. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36148. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36149. */
  36150. dumpNextRenderTargets: boolean;
  36151. /**
  36152. * The list of user defined render targets added to the scene
  36153. */
  36154. customRenderTargets: RenderTargetTexture[];
  36155. /**
  36156. * Defines if texture loading must be delayed
  36157. * If true, textures will only be loaded when they need to be rendered
  36158. */
  36159. useDelayedTextureLoading: boolean;
  36160. /**
  36161. * Gets the list of meshes imported to the scene through SceneLoader
  36162. */
  36163. importedMeshesFiles: String[];
  36164. /**
  36165. * Gets or sets a boolean indicating if probes are enabled on this scene
  36166. */
  36167. probesEnabled: boolean;
  36168. /**
  36169. * Gets or sets the current offline provider to use to store scene data
  36170. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36171. */
  36172. offlineProvider: IOfflineProvider;
  36173. /**
  36174. * Gets or sets the action manager associated with the scene
  36175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36176. */
  36177. actionManager: AbstractActionManager;
  36178. private _meshesForIntersections;
  36179. /**
  36180. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36181. */
  36182. proceduralTexturesEnabled: boolean;
  36183. private _engine;
  36184. private _totalVertices;
  36185. /** @hidden */
  36186. _activeIndices: PerfCounter;
  36187. /** @hidden */
  36188. _activeParticles: PerfCounter;
  36189. /** @hidden */
  36190. _activeBones: PerfCounter;
  36191. private _animationRatio;
  36192. /** @hidden */
  36193. _animationTimeLast: number;
  36194. /** @hidden */
  36195. _animationTime: number;
  36196. /**
  36197. * Gets or sets a general scale for animation speed
  36198. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36199. */
  36200. animationTimeScale: number;
  36201. /** @hidden */
  36202. _cachedMaterial: Nullable<Material>;
  36203. /** @hidden */
  36204. _cachedEffect: Nullable<Effect>;
  36205. /** @hidden */
  36206. _cachedVisibility: Nullable<number>;
  36207. private _renderId;
  36208. private _frameId;
  36209. private _executeWhenReadyTimeoutId;
  36210. private _intermediateRendering;
  36211. private _viewUpdateFlag;
  36212. private _projectionUpdateFlag;
  36213. /** @hidden */
  36214. _toBeDisposed: Nullable<IDisposable>[];
  36215. private _activeRequests;
  36216. /** @hidden */
  36217. _pendingData: any[];
  36218. private _isDisposed;
  36219. /**
  36220. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36221. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36222. */
  36223. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36224. private _activeMeshes;
  36225. private _processedMaterials;
  36226. private _renderTargets;
  36227. /** @hidden */
  36228. _activeParticleSystems: SmartArray<IParticleSystem>;
  36229. private _activeSkeletons;
  36230. private _softwareSkinnedMeshes;
  36231. private _renderingManager;
  36232. /** @hidden */
  36233. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36234. private _transformMatrix;
  36235. private _sceneUbo;
  36236. /** @hidden */
  36237. _viewMatrix: Matrix;
  36238. private _projectionMatrix;
  36239. /** @hidden */
  36240. _forcedViewPosition: Nullable<Vector3>;
  36241. /** @hidden */
  36242. _frustumPlanes: Plane[];
  36243. /**
  36244. * Gets the list of frustum planes (built from the active camera)
  36245. */
  36246. readonly frustumPlanes: Plane[];
  36247. /**
  36248. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36249. * This is useful if there are more lights that the maximum simulteanous authorized
  36250. */
  36251. requireLightSorting: boolean;
  36252. /** @hidden */
  36253. readonly useMaterialMeshMap: boolean;
  36254. /** @hidden */
  36255. readonly useClonedMeshhMap: boolean;
  36256. private _externalData;
  36257. private _uid;
  36258. /**
  36259. * @hidden
  36260. * Backing store of defined scene components.
  36261. */
  36262. _components: ISceneComponent[];
  36263. /**
  36264. * @hidden
  36265. * Backing store of defined scene components.
  36266. */
  36267. _serializableComponents: ISceneSerializableComponent[];
  36268. /**
  36269. * List of components to register on the next registration step.
  36270. */
  36271. private _transientComponents;
  36272. /**
  36273. * Registers the transient components if needed.
  36274. */
  36275. private _registerTransientComponents;
  36276. /**
  36277. * @hidden
  36278. * Add a component to the scene.
  36279. * Note that the ccomponent could be registered on th next frame if this is called after
  36280. * the register component stage.
  36281. * @param component Defines the component to add to the scene
  36282. */
  36283. _addComponent(component: ISceneComponent): void;
  36284. /**
  36285. * @hidden
  36286. * Gets a component from the scene.
  36287. * @param name defines the name of the component to retrieve
  36288. * @returns the component or null if not present
  36289. */
  36290. _getComponent(name: string): Nullable<ISceneComponent>;
  36291. /**
  36292. * @hidden
  36293. * Defines the actions happening before camera updates.
  36294. */
  36295. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36296. /**
  36297. * @hidden
  36298. * Defines the actions happening before clear the canvas.
  36299. */
  36300. _beforeClearStage: Stage<SimpleStageAction>;
  36301. /**
  36302. * @hidden
  36303. * Defines the actions when collecting render targets for the frame.
  36304. */
  36305. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36306. /**
  36307. * @hidden
  36308. * Defines the actions happening for one camera in the frame.
  36309. */
  36310. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36311. /**
  36312. * @hidden
  36313. * Defines the actions happening during the per mesh ready checks.
  36314. */
  36315. _isReadyForMeshStage: Stage<MeshStageAction>;
  36316. /**
  36317. * @hidden
  36318. * Defines the actions happening before evaluate active mesh checks.
  36319. */
  36320. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36321. /**
  36322. * @hidden
  36323. * Defines the actions happening during the evaluate sub mesh checks.
  36324. */
  36325. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36326. /**
  36327. * @hidden
  36328. * Defines the actions happening during the active mesh stage.
  36329. */
  36330. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36331. /**
  36332. * @hidden
  36333. * Defines the actions happening during the per camera render target step.
  36334. */
  36335. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36336. /**
  36337. * @hidden
  36338. * Defines the actions happening just before the active camera is drawing.
  36339. */
  36340. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36341. /**
  36342. * @hidden
  36343. * Defines the actions happening just before a render target is drawing.
  36344. */
  36345. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36346. /**
  36347. * @hidden
  36348. * Defines the actions happening just before a rendering group is drawing.
  36349. */
  36350. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36351. /**
  36352. * @hidden
  36353. * Defines the actions happening just before a mesh is drawing.
  36354. */
  36355. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36356. /**
  36357. * @hidden
  36358. * Defines the actions happening just after a mesh has been drawn.
  36359. */
  36360. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36361. /**
  36362. * @hidden
  36363. * Defines the actions happening just after a rendering group has been drawn.
  36364. */
  36365. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36366. /**
  36367. * @hidden
  36368. * Defines the actions happening just after the active camera has been drawn.
  36369. */
  36370. _afterCameraDrawStage: Stage<CameraStageAction>;
  36371. /**
  36372. * @hidden
  36373. * Defines the actions happening just after a render target has been drawn.
  36374. */
  36375. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36376. /**
  36377. * @hidden
  36378. * Defines the actions happening just after rendering all cameras and computing intersections.
  36379. */
  36380. _afterRenderStage: Stage<SimpleStageAction>;
  36381. /**
  36382. * @hidden
  36383. * Defines the actions happening when a pointer move event happens.
  36384. */
  36385. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36386. /**
  36387. * @hidden
  36388. * Defines the actions happening when a pointer down event happens.
  36389. */
  36390. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36391. /**
  36392. * @hidden
  36393. * Defines the actions happening when a pointer up event happens.
  36394. */
  36395. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36396. /**
  36397. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36398. */
  36399. private geometriesByUniqueId;
  36400. /**
  36401. * Creates a new Scene
  36402. * @param engine defines the engine to use to render this scene
  36403. * @param options defines the scene options
  36404. */
  36405. constructor(engine: Engine, options?: SceneOptions);
  36406. /**
  36407. * Gets a string idenfifying the name of the class
  36408. * @returns "Scene" string
  36409. */
  36410. getClassName(): string;
  36411. private _defaultMeshCandidates;
  36412. /**
  36413. * @hidden
  36414. */
  36415. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36416. private _defaultSubMeshCandidates;
  36417. /**
  36418. * @hidden
  36419. */
  36420. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36421. /**
  36422. * Sets the default candidate providers for the scene.
  36423. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36424. * and getCollidingSubMeshCandidates to their default function
  36425. */
  36426. setDefaultCandidateProviders(): void;
  36427. /**
  36428. * Gets the mesh that is currently under the pointer
  36429. */
  36430. readonly meshUnderPointer: Nullable<AbstractMesh>;
  36431. /**
  36432. * Gets or sets the current on-screen X position of the pointer
  36433. */
  36434. pointerX: number;
  36435. /**
  36436. * Gets or sets the current on-screen Y position of the pointer
  36437. */
  36438. pointerY: number;
  36439. /**
  36440. * Gets the cached material (ie. the latest rendered one)
  36441. * @returns the cached material
  36442. */
  36443. getCachedMaterial(): Nullable<Material>;
  36444. /**
  36445. * Gets the cached effect (ie. the latest rendered one)
  36446. * @returns the cached effect
  36447. */
  36448. getCachedEffect(): Nullable<Effect>;
  36449. /**
  36450. * Gets the cached visibility state (ie. the latest rendered one)
  36451. * @returns the cached visibility state
  36452. */
  36453. getCachedVisibility(): Nullable<number>;
  36454. /**
  36455. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36456. * @param material defines the current material
  36457. * @param effect defines the current effect
  36458. * @param visibility defines the current visibility state
  36459. * @returns true if one parameter is not cached
  36460. */
  36461. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36462. /**
  36463. * Gets the engine associated with the scene
  36464. * @returns an Engine
  36465. */
  36466. getEngine(): Engine;
  36467. /**
  36468. * Gets the total number of vertices rendered per frame
  36469. * @returns the total number of vertices rendered per frame
  36470. */
  36471. getTotalVertices(): number;
  36472. /**
  36473. * Gets the performance counter for total vertices
  36474. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36475. */
  36476. readonly totalVerticesPerfCounter: PerfCounter;
  36477. /**
  36478. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36479. * @returns the total number of active indices rendered per frame
  36480. */
  36481. getActiveIndices(): number;
  36482. /**
  36483. * Gets the performance counter for active indices
  36484. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36485. */
  36486. readonly totalActiveIndicesPerfCounter: PerfCounter;
  36487. /**
  36488. * Gets the total number of active particles rendered per frame
  36489. * @returns the total number of active particles rendered per frame
  36490. */
  36491. getActiveParticles(): number;
  36492. /**
  36493. * Gets the performance counter for active particles
  36494. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36495. */
  36496. readonly activeParticlesPerfCounter: PerfCounter;
  36497. /**
  36498. * Gets the total number of active bones rendered per frame
  36499. * @returns the total number of active bones rendered per frame
  36500. */
  36501. getActiveBones(): number;
  36502. /**
  36503. * Gets the performance counter for active bones
  36504. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36505. */
  36506. readonly activeBonesPerfCounter: PerfCounter;
  36507. /**
  36508. * Gets the array of active meshes
  36509. * @returns an array of AbstractMesh
  36510. */
  36511. getActiveMeshes(): SmartArray<AbstractMesh>;
  36512. /**
  36513. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36514. * @returns a number
  36515. */
  36516. getAnimationRatio(): number;
  36517. /**
  36518. * Gets an unique Id for the current render phase
  36519. * @returns a number
  36520. */
  36521. getRenderId(): number;
  36522. /**
  36523. * Gets an unique Id for the current frame
  36524. * @returns a number
  36525. */
  36526. getFrameId(): number;
  36527. /** Call this function if you want to manually increment the render Id*/
  36528. incrementRenderId(): void;
  36529. private _createUbo;
  36530. /**
  36531. * Use this method to simulate a pointer move on a mesh
  36532. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36533. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36534. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36535. * @returns the current scene
  36536. */
  36537. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36538. /**
  36539. * Use this method to simulate a pointer down on a mesh
  36540. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36541. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36542. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36543. * @returns the current scene
  36544. */
  36545. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36546. /**
  36547. * Use this method to simulate a pointer up on a mesh
  36548. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36549. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36550. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36551. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36552. * @returns the current scene
  36553. */
  36554. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36555. /**
  36556. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36557. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36558. * @returns true if the pointer was captured
  36559. */
  36560. isPointerCaptured(pointerId?: number): boolean;
  36561. /**
  36562. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36563. * @param attachUp defines if you want to attach events to pointerup
  36564. * @param attachDown defines if you want to attach events to pointerdown
  36565. * @param attachMove defines if you want to attach events to pointermove
  36566. */
  36567. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36568. /** Detaches all event handlers*/
  36569. detachControl(): void;
  36570. /**
  36571. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36572. * Delay loaded resources are not taking in account
  36573. * @return true if all required resources are ready
  36574. */
  36575. isReady(): boolean;
  36576. /** Resets all cached information relative to material (including effect and visibility) */
  36577. resetCachedMaterial(): void;
  36578. /**
  36579. * Registers a function to be called before every frame render
  36580. * @param func defines the function to register
  36581. */
  36582. registerBeforeRender(func: () => void): void;
  36583. /**
  36584. * Unregisters a function called before every frame render
  36585. * @param func defines the function to unregister
  36586. */
  36587. unregisterBeforeRender(func: () => void): void;
  36588. /**
  36589. * Registers a function to be called after every frame render
  36590. * @param func defines the function to register
  36591. */
  36592. registerAfterRender(func: () => void): void;
  36593. /**
  36594. * Unregisters a function called after every frame render
  36595. * @param func defines the function to unregister
  36596. */
  36597. unregisterAfterRender(func: () => void): void;
  36598. private _executeOnceBeforeRender;
  36599. /**
  36600. * The provided function will run before render once and will be disposed afterwards.
  36601. * A timeout delay can be provided so that the function will be executed in N ms.
  36602. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36603. * @param func The function to be executed.
  36604. * @param timeout optional delay in ms
  36605. */
  36606. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36607. /** @hidden */
  36608. _addPendingData(data: any): void;
  36609. /** @hidden */
  36610. _removePendingData(data: any): void;
  36611. /**
  36612. * Returns the number of items waiting to be loaded
  36613. * @returns the number of items waiting to be loaded
  36614. */
  36615. getWaitingItemsCount(): number;
  36616. /**
  36617. * Returns a boolean indicating if the scene is still loading data
  36618. */
  36619. readonly isLoading: boolean;
  36620. /**
  36621. * Registers a function to be executed when the scene is ready
  36622. * @param {Function} func - the function to be executed
  36623. */
  36624. executeWhenReady(func: () => void): void;
  36625. /**
  36626. * Returns a promise that resolves when the scene is ready
  36627. * @returns A promise that resolves when the scene is ready
  36628. */
  36629. whenReadyAsync(): Promise<void>;
  36630. /** @hidden */
  36631. _checkIsReady(): void;
  36632. /**
  36633. * Gets all animatable attached to the scene
  36634. */
  36635. readonly animatables: Animatable[];
  36636. /**
  36637. * Resets the last animation time frame.
  36638. * Useful to override when animations start running when loading a scene for the first time.
  36639. */
  36640. resetLastAnimationTimeFrame(): void;
  36641. /**
  36642. * Gets the current view matrix
  36643. * @returns a Matrix
  36644. */
  36645. getViewMatrix(): Matrix;
  36646. /**
  36647. * Gets the current projection matrix
  36648. * @returns a Matrix
  36649. */
  36650. getProjectionMatrix(): Matrix;
  36651. /**
  36652. * Gets the current transform matrix
  36653. * @returns a Matrix made of View * Projection
  36654. */
  36655. getTransformMatrix(): Matrix;
  36656. /**
  36657. * Sets the current transform matrix
  36658. * @param viewL defines the View matrix to use
  36659. * @param projectionL defines the Projection matrix to use
  36660. * @param viewR defines the right View matrix to use (if provided)
  36661. * @param projectionR defines the right Projection matrix to use (if provided)
  36662. */
  36663. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36664. /**
  36665. * Gets the uniform buffer used to store scene data
  36666. * @returns a UniformBuffer
  36667. */
  36668. getSceneUniformBuffer(): UniformBuffer;
  36669. /**
  36670. * Gets an unique (relatively to the current scene) Id
  36671. * @returns an unique number for the scene
  36672. */
  36673. getUniqueId(): number;
  36674. /**
  36675. * Add a mesh to the list of scene's meshes
  36676. * @param newMesh defines the mesh to add
  36677. * @param recursive if all child meshes should also be added to the scene
  36678. */
  36679. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36680. /**
  36681. * Remove a mesh for the list of scene's meshes
  36682. * @param toRemove defines the mesh to remove
  36683. * @param recursive if all child meshes should also be removed from the scene
  36684. * @returns the index where the mesh was in the mesh list
  36685. */
  36686. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36687. /**
  36688. * Add a transform node to the list of scene's transform nodes
  36689. * @param newTransformNode defines the transform node to add
  36690. */
  36691. addTransformNode(newTransformNode: TransformNode): void;
  36692. /**
  36693. * Remove a transform node for the list of scene's transform nodes
  36694. * @param toRemove defines the transform node to remove
  36695. * @returns the index where the transform node was in the transform node list
  36696. */
  36697. removeTransformNode(toRemove: TransformNode): number;
  36698. /**
  36699. * Remove a skeleton for the list of scene's skeletons
  36700. * @param toRemove defines the skeleton to remove
  36701. * @returns the index where the skeleton was in the skeleton list
  36702. */
  36703. removeSkeleton(toRemove: Skeleton): number;
  36704. /**
  36705. * Remove a morph target for the list of scene's morph targets
  36706. * @param toRemove defines the morph target to remove
  36707. * @returns the index where the morph target was in the morph target list
  36708. */
  36709. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36710. /**
  36711. * Remove a light for the list of scene's lights
  36712. * @param toRemove defines the light to remove
  36713. * @returns the index where the light was in the light list
  36714. */
  36715. removeLight(toRemove: Light): number;
  36716. /**
  36717. * Remove a camera for the list of scene's cameras
  36718. * @param toRemove defines the camera to remove
  36719. * @returns the index where the camera was in the camera list
  36720. */
  36721. removeCamera(toRemove: Camera): number;
  36722. /**
  36723. * Remove a particle system for the list of scene's particle systems
  36724. * @param toRemove defines the particle system to remove
  36725. * @returns the index where the particle system was in the particle system list
  36726. */
  36727. removeParticleSystem(toRemove: IParticleSystem): number;
  36728. /**
  36729. * Remove a animation for the list of scene's animations
  36730. * @param toRemove defines the animation to remove
  36731. * @returns the index where the animation was in the animation list
  36732. */
  36733. removeAnimation(toRemove: Animation): number;
  36734. /**
  36735. * Will stop the animation of the given target
  36736. * @param target - the target
  36737. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36738. * @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)
  36739. */
  36740. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36741. /**
  36742. * Removes the given animation group from this scene.
  36743. * @param toRemove The animation group to remove
  36744. * @returns The index of the removed animation group
  36745. */
  36746. removeAnimationGroup(toRemove: AnimationGroup): number;
  36747. /**
  36748. * Removes the given multi-material from this scene.
  36749. * @param toRemove The multi-material to remove
  36750. * @returns The index of the removed multi-material
  36751. */
  36752. removeMultiMaterial(toRemove: MultiMaterial): number;
  36753. /**
  36754. * Removes the given material from this scene.
  36755. * @param toRemove The material to remove
  36756. * @returns The index of the removed material
  36757. */
  36758. removeMaterial(toRemove: Material): number;
  36759. /**
  36760. * Removes the given action manager from this scene.
  36761. * @param toRemove The action manager to remove
  36762. * @returns The index of the removed action manager
  36763. */
  36764. removeActionManager(toRemove: AbstractActionManager): number;
  36765. /**
  36766. * Removes the given texture from this scene.
  36767. * @param toRemove The texture to remove
  36768. * @returns The index of the removed texture
  36769. */
  36770. removeTexture(toRemove: BaseTexture): number;
  36771. /**
  36772. * Adds the given light to this scene
  36773. * @param newLight The light to add
  36774. */
  36775. addLight(newLight: Light): void;
  36776. /**
  36777. * Sorts the list list based on light priorities
  36778. */
  36779. sortLightsByPriority(): void;
  36780. /**
  36781. * Adds the given camera to this scene
  36782. * @param newCamera The camera to add
  36783. */
  36784. addCamera(newCamera: Camera): void;
  36785. /**
  36786. * Adds the given skeleton to this scene
  36787. * @param newSkeleton The skeleton to add
  36788. */
  36789. addSkeleton(newSkeleton: Skeleton): void;
  36790. /**
  36791. * Adds the given particle system to this scene
  36792. * @param newParticleSystem The particle system to add
  36793. */
  36794. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36795. /**
  36796. * Adds the given animation to this scene
  36797. * @param newAnimation The animation to add
  36798. */
  36799. addAnimation(newAnimation: Animation): void;
  36800. /**
  36801. * Adds the given animation group to this scene.
  36802. * @param newAnimationGroup The animation group to add
  36803. */
  36804. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36805. /**
  36806. * Adds the given multi-material to this scene
  36807. * @param newMultiMaterial The multi-material to add
  36808. */
  36809. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36810. /**
  36811. * Adds the given material to this scene
  36812. * @param newMaterial The material to add
  36813. */
  36814. addMaterial(newMaterial: Material): void;
  36815. /**
  36816. * Adds the given morph target to this scene
  36817. * @param newMorphTargetManager The morph target to add
  36818. */
  36819. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36820. /**
  36821. * Adds the given geometry to this scene
  36822. * @param newGeometry The geometry to add
  36823. */
  36824. addGeometry(newGeometry: Geometry): void;
  36825. /**
  36826. * Adds the given action manager to this scene
  36827. * @param newActionManager The action manager to add
  36828. */
  36829. addActionManager(newActionManager: AbstractActionManager): void;
  36830. /**
  36831. * Adds the given texture to this scene.
  36832. * @param newTexture The texture to add
  36833. */
  36834. addTexture(newTexture: BaseTexture): void;
  36835. /**
  36836. * Switch active camera
  36837. * @param newCamera defines the new active camera
  36838. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36839. */
  36840. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36841. /**
  36842. * sets the active camera of the scene using its ID
  36843. * @param id defines the camera's ID
  36844. * @return the new active camera or null if none found.
  36845. */
  36846. setActiveCameraByID(id: string): Nullable<Camera>;
  36847. /**
  36848. * sets the active camera of the scene using its name
  36849. * @param name defines the camera's name
  36850. * @returns the new active camera or null if none found.
  36851. */
  36852. setActiveCameraByName(name: string): Nullable<Camera>;
  36853. /**
  36854. * get an animation group using its name
  36855. * @param name defines the material's name
  36856. * @return the animation group or null if none found.
  36857. */
  36858. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36859. /**
  36860. * Get a material using its unique id
  36861. * @param uniqueId defines the material's unique id
  36862. * @return the material or null if none found.
  36863. */
  36864. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36865. /**
  36866. * get a material using its id
  36867. * @param id defines the material's ID
  36868. * @return the material or null if none found.
  36869. */
  36870. getMaterialByID(id: string): Nullable<Material>;
  36871. /**
  36872. * Gets a the last added material using a given id
  36873. * @param id defines the material's ID
  36874. * @return the last material with the given id or null if none found.
  36875. */
  36876. getLastMaterialByID(id: string): Nullable<Material>;
  36877. /**
  36878. * Gets a material using its name
  36879. * @param name defines the material's name
  36880. * @return the material or null if none found.
  36881. */
  36882. getMaterialByName(name: string): Nullable<Material>;
  36883. /**
  36884. * Get a texture using its unique id
  36885. * @param uniqueId defines the texture's unique id
  36886. * @return the texture or null if none found.
  36887. */
  36888. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36889. /**
  36890. * Gets a camera using its id
  36891. * @param id defines the id to look for
  36892. * @returns the camera or null if not found
  36893. */
  36894. getCameraByID(id: string): Nullable<Camera>;
  36895. /**
  36896. * Gets a camera using its unique id
  36897. * @param uniqueId defines the unique id to look for
  36898. * @returns the camera or null if not found
  36899. */
  36900. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36901. /**
  36902. * Gets a camera using its name
  36903. * @param name defines the camera's name
  36904. * @return the camera or null if none found.
  36905. */
  36906. getCameraByName(name: string): Nullable<Camera>;
  36907. /**
  36908. * Gets a bone using its id
  36909. * @param id defines the bone's id
  36910. * @return the bone or null if not found
  36911. */
  36912. getBoneByID(id: string): Nullable<Bone>;
  36913. /**
  36914. * Gets a bone using its id
  36915. * @param name defines the bone's name
  36916. * @return the bone or null if not found
  36917. */
  36918. getBoneByName(name: string): Nullable<Bone>;
  36919. /**
  36920. * Gets a light node using its name
  36921. * @param name defines the the light's name
  36922. * @return the light or null if none found.
  36923. */
  36924. getLightByName(name: string): Nullable<Light>;
  36925. /**
  36926. * Gets a light node using its id
  36927. * @param id defines the light's id
  36928. * @return the light or null if none found.
  36929. */
  36930. getLightByID(id: string): Nullable<Light>;
  36931. /**
  36932. * Gets a light node using its scene-generated unique ID
  36933. * @param uniqueId defines the light's unique id
  36934. * @return the light or null if none found.
  36935. */
  36936. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36937. /**
  36938. * Gets a particle system by id
  36939. * @param id defines the particle system id
  36940. * @return the corresponding system or null if none found
  36941. */
  36942. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36943. /**
  36944. * Gets a geometry using its ID
  36945. * @param id defines the geometry's id
  36946. * @return the geometry or null if none found.
  36947. */
  36948. getGeometryByID(id: string): Nullable<Geometry>;
  36949. private _getGeometryByUniqueID;
  36950. /**
  36951. * Add a new geometry to this scene
  36952. * @param geometry defines the geometry to be added to the scene.
  36953. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36954. * @return a boolean defining if the geometry was added or not
  36955. */
  36956. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36957. /**
  36958. * Removes an existing geometry
  36959. * @param geometry defines the geometry to be removed from the scene
  36960. * @return a boolean defining if the geometry was removed or not
  36961. */
  36962. removeGeometry(geometry: Geometry): boolean;
  36963. /**
  36964. * Gets the list of geometries attached to the scene
  36965. * @returns an array of Geometry
  36966. */
  36967. getGeometries(): Geometry[];
  36968. /**
  36969. * Gets the first added mesh found of a given ID
  36970. * @param id defines the id to search for
  36971. * @return the mesh found or null if not found at all
  36972. */
  36973. getMeshByID(id: string): Nullable<AbstractMesh>;
  36974. /**
  36975. * Gets a list of meshes using their id
  36976. * @param id defines the id to search for
  36977. * @returns a list of meshes
  36978. */
  36979. getMeshesByID(id: string): Array<AbstractMesh>;
  36980. /**
  36981. * Gets the first added transform node found of a given ID
  36982. * @param id defines the id to search for
  36983. * @return the found transform node or null if not found at all.
  36984. */
  36985. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36986. /**
  36987. * Gets a transform node with its auto-generated unique id
  36988. * @param uniqueId efines the unique id to search for
  36989. * @return the found transform node or null if not found at all.
  36990. */
  36991. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36992. /**
  36993. * Gets a list of transform nodes using their id
  36994. * @param id defines the id to search for
  36995. * @returns a list of transform nodes
  36996. */
  36997. getTransformNodesByID(id: string): Array<TransformNode>;
  36998. /**
  36999. * Gets a mesh with its auto-generated unique id
  37000. * @param uniqueId defines the unique id to search for
  37001. * @return the found mesh or null if not found at all.
  37002. */
  37003. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37004. /**
  37005. * Gets a the last added mesh using a given id
  37006. * @param id defines the id to search for
  37007. * @return the found mesh or null if not found at all.
  37008. */
  37009. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37010. /**
  37011. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37012. * @param id defines the id to search for
  37013. * @return the found node or null if not found at all
  37014. */
  37015. getLastEntryByID(id: string): Nullable<Node>;
  37016. /**
  37017. * Gets a node (Mesh, Camera, Light) using a given id
  37018. * @param id defines the id to search for
  37019. * @return the found node or null if not found at all
  37020. */
  37021. getNodeByID(id: string): Nullable<Node>;
  37022. /**
  37023. * Gets a node (Mesh, Camera, Light) using a given name
  37024. * @param name defines the name to search for
  37025. * @return the found node or null if not found at all.
  37026. */
  37027. getNodeByName(name: string): Nullable<Node>;
  37028. /**
  37029. * Gets a mesh using a given name
  37030. * @param name defines the name to search for
  37031. * @return the found mesh or null if not found at all.
  37032. */
  37033. getMeshByName(name: string): Nullable<AbstractMesh>;
  37034. /**
  37035. * Gets a transform node using a given name
  37036. * @param name defines the name to search for
  37037. * @return the found transform node or null if not found at all.
  37038. */
  37039. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37040. /**
  37041. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37042. * @param id defines the id to search for
  37043. * @return the found skeleton or null if not found at all.
  37044. */
  37045. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37046. /**
  37047. * Gets a skeleton using a given auto generated unique id
  37048. * @param uniqueId defines the unique id to search for
  37049. * @return the found skeleton or null if not found at all.
  37050. */
  37051. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37052. /**
  37053. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37054. * @param id defines the id to search for
  37055. * @return the found skeleton or null if not found at all.
  37056. */
  37057. getSkeletonById(id: string): Nullable<Skeleton>;
  37058. /**
  37059. * Gets a skeleton using a given name
  37060. * @param name defines the name to search for
  37061. * @return the found skeleton or null if not found at all.
  37062. */
  37063. getSkeletonByName(name: string): Nullable<Skeleton>;
  37064. /**
  37065. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37066. * @param id defines the id to search for
  37067. * @return the found morph target manager or null if not found at all.
  37068. */
  37069. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37070. /**
  37071. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37072. * @param id defines the id to search for
  37073. * @return the found morph target or null if not found at all.
  37074. */
  37075. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37076. /**
  37077. * Gets a boolean indicating if the given mesh is active
  37078. * @param mesh defines the mesh to look for
  37079. * @returns true if the mesh is in the active list
  37080. */
  37081. isActiveMesh(mesh: AbstractMesh): boolean;
  37082. /**
  37083. * Return a unique id as a string which can serve as an identifier for the scene
  37084. */
  37085. readonly uid: string;
  37086. /**
  37087. * Add an externaly attached data from its key.
  37088. * This method call will fail and return false, if such key already exists.
  37089. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37090. * @param key the unique key that identifies the data
  37091. * @param data the data object to associate to the key for this Engine instance
  37092. * @return true if no such key were already present and the data was added successfully, false otherwise
  37093. */
  37094. addExternalData<T>(key: string, data: T): boolean;
  37095. /**
  37096. * Get an externaly attached data from its key
  37097. * @param key the unique key that identifies the data
  37098. * @return the associated data, if present (can be null), or undefined if not present
  37099. */
  37100. getExternalData<T>(key: string): Nullable<T>;
  37101. /**
  37102. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37103. * @param key the unique key that identifies the data
  37104. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37105. * @return the associated data, can be null if the factory returned null.
  37106. */
  37107. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37108. /**
  37109. * Remove an externaly attached data from the Engine instance
  37110. * @param key the unique key that identifies the data
  37111. * @return true if the data was successfully removed, false if it doesn't exist
  37112. */
  37113. removeExternalData(key: string): boolean;
  37114. private _evaluateSubMesh;
  37115. /**
  37116. * Clear the processed materials smart array preventing retention point in material dispose.
  37117. */
  37118. freeProcessedMaterials(): void;
  37119. private _preventFreeActiveMeshesAndRenderingGroups;
  37120. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37121. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37122. * when disposing several meshes in a row or a hierarchy of meshes.
  37123. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37124. */
  37125. blockfreeActiveMeshesAndRenderingGroups: boolean;
  37126. /**
  37127. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37128. */
  37129. freeActiveMeshes(): void;
  37130. /**
  37131. * Clear the info related to rendering groups preventing retention points during dispose.
  37132. */
  37133. freeRenderingGroups(): void;
  37134. /** @hidden */
  37135. _isInIntermediateRendering(): boolean;
  37136. /**
  37137. * Lambda returning the list of potentially active meshes.
  37138. */
  37139. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37140. /**
  37141. * Lambda returning the list of potentially active sub meshes.
  37142. */
  37143. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37144. /**
  37145. * Lambda returning the list of potentially intersecting sub meshes.
  37146. */
  37147. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37148. /**
  37149. * Lambda returning the list of potentially colliding sub meshes.
  37150. */
  37151. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37152. private _activeMeshesFrozen;
  37153. private _skipEvaluateActiveMeshesCompletely;
  37154. /**
  37155. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37156. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37157. * @returns the current scene
  37158. */
  37159. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37160. /**
  37161. * Use this function to restart evaluating active meshes on every frame
  37162. * @returns the current scene
  37163. */
  37164. unfreezeActiveMeshes(): Scene;
  37165. private _evaluateActiveMeshes;
  37166. private _activeMesh;
  37167. /**
  37168. * Update the transform matrix to update from the current active camera
  37169. * @param force defines a boolean used to force the update even if cache is up to date
  37170. */
  37171. updateTransformMatrix(force?: boolean): void;
  37172. private _bindFrameBuffer;
  37173. /** @hidden */
  37174. _allowPostProcessClearColor: boolean;
  37175. /** @hidden */
  37176. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37177. private _processSubCameras;
  37178. private _checkIntersections;
  37179. /** @hidden */
  37180. _advancePhysicsEngineStep(step: number): void;
  37181. /**
  37182. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37183. */
  37184. getDeterministicFrameTime: () => number;
  37185. /** @hidden */
  37186. _animate(): void;
  37187. /** Execute all animations (for a frame) */
  37188. animate(): void;
  37189. /**
  37190. * Render the scene
  37191. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37192. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37193. */
  37194. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37195. /**
  37196. * Freeze all materials
  37197. * A frozen material will not be updatable but should be faster to render
  37198. */
  37199. freezeMaterials(): void;
  37200. /**
  37201. * Unfreeze all materials
  37202. * A frozen material will not be updatable but should be faster to render
  37203. */
  37204. unfreezeMaterials(): void;
  37205. /**
  37206. * Releases all held ressources
  37207. */
  37208. dispose(): void;
  37209. /**
  37210. * Gets if the scene is already disposed
  37211. */
  37212. readonly isDisposed: boolean;
  37213. /**
  37214. * Call this function to reduce memory footprint of the scene.
  37215. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37216. */
  37217. clearCachedVertexData(): void;
  37218. /**
  37219. * This function will remove the local cached buffer data from texture.
  37220. * It will save memory but will prevent the texture from being rebuilt
  37221. */
  37222. cleanCachedTextureBuffer(): void;
  37223. /**
  37224. * Get the world extend vectors with an optional filter
  37225. *
  37226. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37227. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37228. */
  37229. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37230. min: Vector3;
  37231. max: Vector3;
  37232. };
  37233. /**
  37234. * Creates a ray that can be used to pick in the scene
  37235. * @param x defines the x coordinate of the origin (on-screen)
  37236. * @param y defines the y coordinate of the origin (on-screen)
  37237. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37238. * @param camera defines the camera to use for the picking
  37239. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37240. * @returns a Ray
  37241. */
  37242. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37243. /**
  37244. * Creates a ray that can be used to pick in the scene
  37245. * @param x defines the x coordinate of the origin (on-screen)
  37246. * @param y defines the y coordinate of the origin (on-screen)
  37247. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37248. * @param result defines the ray where to store the picking ray
  37249. * @param camera defines the camera to use for the picking
  37250. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37251. * @returns the current scene
  37252. */
  37253. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37254. /**
  37255. * Creates a ray that can be used to pick in the scene
  37256. * @param x defines the x coordinate of the origin (on-screen)
  37257. * @param y defines the y coordinate of the origin (on-screen)
  37258. * @param camera defines the camera to use for the picking
  37259. * @returns a Ray
  37260. */
  37261. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37262. /**
  37263. * Creates a ray that can be used to pick in the scene
  37264. * @param x defines the x coordinate of the origin (on-screen)
  37265. * @param y defines the y coordinate of the origin (on-screen)
  37266. * @param result defines the ray where to store the picking ray
  37267. * @param camera defines the camera to use for the picking
  37268. * @returns the current scene
  37269. */
  37270. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37271. /** Launch a ray to try to pick a mesh in the scene
  37272. * @param x position on screen
  37273. * @param y position on screen
  37274. * @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
  37275. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37276. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37277. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37278. * @returns a PickingInfo
  37279. */
  37280. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37281. /** Use the given ray to pick a mesh in the scene
  37282. * @param ray The ray to use to pick meshes
  37283. * @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
  37284. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37285. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37286. * @returns a PickingInfo
  37287. */
  37288. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37289. /**
  37290. * Launch a ray to try to pick a mesh in the scene
  37291. * @param x X position on screen
  37292. * @param y Y position on screen
  37293. * @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
  37294. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37295. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37296. * @returns an array of PickingInfo
  37297. */
  37298. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37299. /**
  37300. * Launch a ray to try to pick a mesh in the scene
  37301. * @param ray Ray to use
  37302. * @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
  37303. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37304. * @returns an array of PickingInfo
  37305. */
  37306. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37307. /**
  37308. * Force the value of meshUnderPointer
  37309. * @param mesh defines the mesh to use
  37310. */
  37311. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37312. /**
  37313. * Gets the mesh under the pointer
  37314. * @returns a Mesh or null if no mesh is under the pointer
  37315. */
  37316. getPointerOverMesh(): Nullable<AbstractMesh>;
  37317. /** @hidden */
  37318. _rebuildGeometries(): void;
  37319. /** @hidden */
  37320. _rebuildTextures(): void;
  37321. private _getByTags;
  37322. /**
  37323. * Get a list of meshes by tags
  37324. * @param tagsQuery defines the tags query to use
  37325. * @param forEach defines a predicate used to filter results
  37326. * @returns an array of Mesh
  37327. */
  37328. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37329. /**
  37330. * Get a list of cameras by tags
  37331. * @param tagsQuery defines the tags query to use
  37332. * @param forEach defines a predicate used to filter results
  37333. * @returns an array of Camera
  37334. */
  37335. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37336. /**
  37337. * Get a list of lights by tags
  37338. * @param tagsQuery defines the tags query to use
  37339. * @param forEach defines a predicate used to filter results
  37340. * @returns an array of Light
  37341. */
  37342. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37343. /**
  37344. * Get a list of materials by tags
  37345. * @param tagsQuery defines the tags query to use
  37346. * @param forEach defines a predicate used to filter results
  37347. * @returns an array of Material
  37348. */
  37349. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37350. /**
  37351. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37352. * This allowed control for front to back rendering or reversly depending of the special needs.
  37353. *
  37354. * @param renderingGroupId The rendering group id corresponding to its index
  37355. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37356. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37357. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37358. */
  37359. 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;
  37360. /**
  37361. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37362. *
  37363. * @param renderingGroupId The rendering group id corresponding to its index
  37364. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37365. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37366. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37367. */
  37368. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37369. /**
  37370. * Gets the current auto clear configuration for one rendering group of the rendering
  37371. * manager.
  37372. * @param index the rendering group index to get the information for
  37373. * @returns The auto clear setup for the requested rendering group
  37374. */
  37375. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37376. private _blockMaterialDirtyMechanism;
  37377. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37378. blockMaterialDirtyMechanism: boolean;
  37379. /**
  37380. * Will flag all materials as dirty to trigger new shader compilation
  37381. * @param flag defines the flag used to specify which material part must be marked as dirty
  37382. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37383. */
  37384. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37385. /** @hidden */
  37386. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  37387. /** @hidden */
  37388. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37389. /** @hidden */
  37390. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  37391. /** @hidden */
  37392. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37393. /** @hidden */
  37394. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37395. /** @hidden */
  37396. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37397. }
  37398. }
  37399. declare module "babylonjs/assetContainer" {
  37400. import { AbstractScene } from "babylonjs/abstractScene";
  37401. import { Scene } from "babylonjs/scene";
  37402. import { Mesh } from "babylonjs/Meshes/mesh";
  37403. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37404. import { Skeleton } from "babylonjs/Bones/skeleton";
  37405. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37406. import { Animatable } from "babylonjs/Animations/animatable";
  37407. import { Nullable } from "babylonjs/types";
  37408. import { Node } from "babylonjs/node";
  37409. /**
  37410. * Set of assets to keep when moving a scene into an asset container.
  37411. */
  37412. export class KeepAssets extends AbstractScene {
  37413. }
  37414. /**
  37415. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37416. */
  37417. export class InstantiatedEntries {
  37418. /**
  37419. * List of new root nodes (eg. nodes with no parent)
  37420. */
  37421. rootNodes: TransformNode[];
  37422. /**
  37423. * List of new skeletons
  37424. */
  37425. skeletons: Skeleton[];
  37426. /**
  37427. * List of new animation groups
  37428. */
  37429. animationGroups: AnimationGroup[];
  37430. }
  37431. /**
  37432. * Container with a set of assets that can be added or removed from a scene.
  37433. */
  37434. export class AssetContainer extends AbstractScene {
  37435. /**
  37436. * The scene the AssetContainer belongs to.
  37437. */
  37438. scene: Scene;
  37439. /**
  37440. * Instantiates an AssetContainer.
  37441. * @param scene The scene the AssetContainer belongs to.
  37442. */
  37443. constructor(scene: Scene);
  37444. /**
  37445. * Instantiate or clone all meshes and add the new ones to the scene.
  37446. * Skeletons and animation groups will all be cloned
  37447. * @param nameFunction defines an optional function used to get new names for clones
  37448. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37449. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37450. */
  37451. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37452. /**
  37453. * Adds all the assets from the container to the scene.
  37454. */
  37455. addAllToScene(): void;
  37456. /**
  37457. * Removes all the assets in the container from the scene
  37458. */
  37459. removeAllFromScene(): void;
  37460. /**
  37461. * Disposes all the assets in the container
  37462. */
  37463. dispose(): void;
  37464. private _moveAssets;
  37465. /**
  37466. * Removes all the assets contained in the scene and adds them to the container.
  37467. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37468. */
  37469. moveAllFromScene(keepAssets?: KeepAssets): void;
  37470. /**
  37471. * 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.
  37472. * @returns the root mesh
  37473. */
  37474. createRootMesh(): Mesh;
  37475. /**
  37476. * Merge animations from this asset container into a scene
  37477. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37478. * @param animatables set of animatables to retarget to a node from the scene
  37479. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37480. */
  37481. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37482. }
  37483. }
  37484. declare module "babylonjs/abstractScene" {
  37485. import { Scene } from "babylonjs/scene";
  37486. import { Nullable } from "babylonjs/types";
  37487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37488. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37489. import { Geometry } from "babylonjs/Meshes/geometry";
  37490. import { Skeleton } from "babylonjs/Bones/skeleton";
  37491. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  37492. import { AssetContainer } from "babylonjs/assetContainer";
  37493. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37494. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37495. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37496. import { Material } from "babylonjs/Materials/material";
  37497. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  37498. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37499. import { Camera } from "babylonjs/Cameras/camera";
  37500. import { Light } from "babylonjs/Lights/light";
  37501. import { Node } from "babylonjs/node";
  37502. import { Animation } from "babylonjs/Animations/animation";
  37503. /**
  37504. * Defines how the parser contract is defined.
  37505. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37506. */
  37507. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37508. /**
  37509. * Defines how the individual parser contract is defined.
  37510. * These parser can parse an individual asset
  37511. */
  37512. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37513. /**
  37514. * Base class of the scene acting as a container for the different elements composing a scene.
  37515. * This class is dynamically extended by the different components of the scene increasing
  37516. * flexibility and reducing coupling
  37517. */
  37518. export abstract class AbstractScene {
  37519. /**
  37520. * Stores the list of available parsers in the application.
  37521. */
  37522. private static _BabylonFileParsers;
  37523. /**
  37524. * Stores the list of available individual parsers in the application.
  37525. */
  37526. private static _IndividualBabylonFileParsers;
  37527. /**
  37528. * Adds a parser in the list of available ones
  37529. * @param name Defines the name of the parser
  37530. * @param parser Defines the parser to add
  37531. */
  37532. static AddParser(name: string, parser: BabylonFileParser): void;
  37533. /**
  37534. * Gets a general parser from the list of avaialble ones
  37535. * @param name Defines the name of the parser
  37536. * @returns the requested parser or null
  37537. */
  37538. static GetParser(name: string): Nullable<BabylonFileParser>;
  37539. /**
  37540. * Adds n individual parser in the list of available ones
  37541. * @param name Defines the name of the parser
  37542. * @param parser Defines the parser to add
  37543. */
  37544. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37545. /**
  37546. * Gets an individual parser from the list of avaialble ones
  37547. * @param name Defines the name of the parser
  37548. * @returns the requested parser or null
  37549. */
  37550. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37551. /**
  37552. * Parser json data and populate both a scene and its associated container object
  37553. * @param jsonData Defines the data to parse
  37554. * @param scene Defines the scene to parse the data for
  37555. * @param container Defines the container attached to the parsing sequence
  37556. * @param rootUrl Defines the root url of the data
  37557. */
  37558. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37559. /**
  37560. * Gets the list of root nodes (ie. nodes with no parent)
  37561. */
  37562. rootNodes: Node[];
  37563. /** All of the cameras added to this scene
  37564. * @see http://doc.babylonjs.com/babylon101/cameras
  37565. */
  37566. cameras: Camera[];
  37567. /**
  37568. * All of the lights added to this scene
  37569. * @see http://doc.babylonjs.com/babylon101/lights
  37570. */
  37571. lights: Light[];
  37572. /**
  37573. * All of the (abstract) meshes added to this scene
  37574. */
  37575. meshes: AbstractMesh[];
  37576. /**
  37577. * The list of skeletons added to the scene
  37578. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37579. */
  37580. skeletons: Skeleton[];
  37581. /**
  37582. * All of the particle systems added to this scene
  37583. * @see http://doc.babylonjs.com/babylon101/particles
  37584. */
  37585. particleSystems: IParticleSystem[];
  37586. /**
  37587. * Gets a list of Animations associated with the scene
  37588. */
  37589. animations: Animation[];
  37590. /**
  37591. * All of the animation groups added to this scene
  37592. * @see http://doc.babylonjs.com/how_to/group
  37593. */
  37594. animationGroups: AnimationGroup[];
  37595. /**
  37596. * All of the multi-materials added to this scene
  37597. * @see http://doc.babylonjs.com/how_to/multi_materials
  37598. */
  37599. multiMaterials: MultiMaterial[];
  37600. /**
  37601. * All of the materials added to this scene
  37602. * In the context of a Scene, it is not supposed to be modified manually.
  37603. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37604. * Note also that the order of the Material within the array is not significant and might change.
  37605. * @see http://doc.babylonjs.com/babylon101/materials
  37606. */
  37607. materials: Material[];
  37608. /**
  37609. * The list of morph target managers added to the scene
  37610. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37611. */
  37612. morphTargetManagers: MorphTargetManager[];
  37613. /**
  37614. * The list of geometries used in the scene.
  37615. */
  37616. geometries: Geometry[];
  37617. /**
  37618. * All of the tranform nodes added to this scene
  37619. * In the context of a Scene, it is not supposed to be modified manually.
  37620. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37621. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37622. * @see http://doc.babylonjs.com/how_to/transformnode
  37623. */
  37624. transformNodes: TransformNode[];
  37625. /**
  37626. * ActionManagers available on the scene.
  37627. */
  37628. actionManagers: AbstractActionManager[];
  37629. /**
  37630. * Textures to keep.
  37631. */
  37632. textures: BaseTexture[];
  37633. /**
  37634. * Environment texture for the scene
  37635. */
  37636. environmentTexture: Nullable<BaseTexture>;
  37637. /**
  37638. * @returns all meshes, lights, cameras, transformNodes and bones
  37639. */
  37640. getNodes(): Array<Node>;
  37641. }
  37642. }
  37643. declare module "babylonjs/Audio/sound" {
  37644. import { Observable } from "babylonjs/Misc/observable";
  37645. import { Vector3 } from "babylonjs/Maths/math.vector";
  37646. import { Nullable } from "babylonjs/types";
  37647. import { Scene } from "babylonjs/scene";
  37648. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37649. /**
  37650. * Interface used to define options for Sound class
  37651. */
  37652. export interface ISoundOptions {
  37653. /**
  37654. * Does the sound autoplay once loaded.
  37655. */
  37656. autoplay?: boolean;
  37657. /**
  37658. * Does the sound loop after it finishes playing once.
  37659. */
  37660. loop?: boolean;
  37661. /**
  37662. * Sound's volume
  37663. */
  37664. volume?: number;
  37665. /**
  37666. * Is it a spatial sound?
  37667. */
  37668. spatialSound?: boolean;
  37669. /**
  37670. * Maximum distance to hear that sound
  37671. */
  37672. maxDistance?: number;
  37673. /**
  37674. * Uses user defined attenuation function
  37675. */
  37676. useCustomAttenuation?: boolean;
  37677. /**
  37678. * Define the roll off factor of spatial sounds.
  37679. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37680. */
  37681. rolloffFactor?: number;
  37682. /**
  37683. * Define the reference distance the sound should be heard perfectly.
  37684. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37685. */
  37686. refDistance?: number;
  37687. /**
  37688. * Define the distance attenuation model the sound will follow.
  37689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37690. */
  37691. distanceModel?: string;
  37692. /**
  37693. * Defines the playback speed (1 by default)
  37694. */
  37695. playbackRate?: number;
  37696. /**
  37697. * Defines if the sound is from a streaming source
  37698. */
  37699. streaming?: boolean;
  37700. /**
  37701. * Defines an optional length (in seconds) inside the sound file
  37702. */
  37703. length?: number;
  37704. /**
  37705. * Defines an optional offset (in seconds) inside the sound file
  37706. */
  37707. offset?: number;
  37708. /**
  37709. * If true, URLs will not be required to state the audio file codec to use.
  37710. */
  37711. skipCodecCheck?: boolean;
  37712. }
  37713. /**
  37714. * Defines a sound that can be played in the application.
  37715. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37716. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37717. */
  37718. export class Sound {
  37719. /**
  37720. * The name of the sound in the scene.
  37721. */
  37722. name: string;
  37723. /**
  37724. * Does the sound autoplay once loaded.
  37725. */
  37726. autoplay: boolean;
  37727. /**
  37728. * Does the sound loop after it finishes playing once.
  37729. */
  37730. loop: boolean;
  37731. /**
  37732. * Does the sound use a custom attenuation curve to simulate the falloff
  37733. * happening when the source gets further away from the camera.
  37734. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37735. */
  37736. useCustomAttenuation: boolean;
  37737. /**
  37738. * The sound track id this sound belongs to.
  37739. */
  37740. soundTrackId: number;
  37741. /**
  37742. * Is this sound currently played.
  37743. */
  37744. isPlaying: boolean;
  37745. /**
  37746. * Is this sound currently paused.
  37747. */
  37748. isPaused: boolean;
  37749. /**
  37750. * Does this sound enables spatial sound.
  37751. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37752. */
  37753. spatialSound: boolean;
  37754. /**
  37755. * Define the reference distance the sound should be heard perfectly.
  37756. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37757. */
  37758. refDistance: number;
  37759. /**
  37760. * Define the roll off factor of spatial sounds.
  37761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37762. */
  37763. rolloffFactor: number;
  37764. /**
  37765. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37767. */
  37768. maxDistance: number;
  37769. /**
  37770. * Define the distance attenuation model the sound will follow.
  37771. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37772. */
  37773. distanceModel: string;
  37774. /**
  37775. * @hidden
  37776. * Back Compat
  37777. **/
  37778. onended: () => any;
  37779. /**
  37780. * Observable event when the current playing sound finishes.
  37781. */
  37782. onEndedObservable: Observable<Sound>;
  37783. private _panningModel;
  37784. private _playbackRate;
  37785. private _streaming;
  37786. private _startTime;
  37787. private _startOffset;
  37788. private _position;
  37789. /** @hidden */
  37790. _positionInEmitterSpace: boolean;
  37791. private _localDirection;
  37792. private _volume;
  37793. private _isReadyToPlay;
  37794. private _isDirectional;
  37795. private _readyToPlayCallback;
  37796. private _audioBuffer;
  37797. private _soundSource;
  37798. private _streamingSource;
  37799. private _soundPanner;
  37800. private _soundGain;
  37801. private _inputAudioNode;
  37802. private _outputAudioNode;
  37803. private _coneInnerAngle;
  37804. private _coneOuterAngle;
  37805. private _coneOuterGain;
  37806. private _scene;
  37807. private _connectedTransformNode;
  37808. private _customAttenuationFunction;
  37809. private _registerFunc;
  37810. private _isOutputConnected;
  37811. private _htmlAudioElement;
  37812. private _urlType;
  37813. private _length?;
  37814. private _offset?;
  37815. /** @hidden */
  37816. static _SceneComponentInitialization: (scene: Scene) => void;
  37817. /**
  37818. * Create a sound and attach it to a scene
  37819. * @param name Name of your sound
  37820. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37821. * @param scene defines the scene the sound belongs to
  37822. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37823. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37824. */
  37825. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37826. /**
  37827. * Release the sound and its associated resources
  37828. */
  37829. dispose(): void;
  37830. /**
  37831. * Gets if the sounds is ready to be played or not.
  37832. * @returns true if ready, otherwise false
  37833. */
  37834. isReady(): boolean;
  37835. private _soundLoaded;
  37836. /**
  37837. * Sets the data of the sound from an audiobuffer
  37838. * @param audioBuffer The audioBuffer containing the data
  37839. */
  37840. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37841. /**
  37842. * Updates the current sounds options such as maxdistance, loop...
  37843. * @param options A JSON object containing values named as the object properties
  37844. */
  37845. updateOptions(options: ISoundOptions): void;
  37846. private _createSpatialParameters;
  37847. private _updateSpatialParameters;
  37848. /**
  37849. * Switch the panning model to HRTF:
  37850. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37851. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37852. */
  37853. switchPanningModelToHRTF(): void;
  37854. /**
  37855. * Switch the panning model to Equal Power:
  37856. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37857. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37858. */
  37859. switchPanningModelToEqualPower(): void;
  37860. private _switchPanningModel;
  37861. /**
  37862. * Connect this sound to a sound track audio node like gain...
  37863. * @param soundTrackAudioNode the sound track audio node to connect to
  37864. */
  37865. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37866. /**
  37867. * Transform this sound into a directional source
  37868. * @param coneInnerAngle Size of the inner cone in degree
  37869. * @param coneOuterAngle Size of the outer cone in degree
  37870. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37871. */
  37872. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37873. /**
  37874. * Gets or sets the inner angle for the directional cone.
  37875. */
  37876. /**
  37877. * Gets or sets the inner angle for the directional cone.
  37878. */
  37879. directionalConeInnerAngle: number;
  37880. /**
  37881. * Gets or sets the outer angle for the directional cone.
  37882. */
  37883. /**
  37884. * Gets or sets the outer angle for the directional cone.
  37885. */
  37886. directionalConeOuterAngle: number;
  37887. /**
  37888. * Sets the position of the emitter if spatial sound is enabled
  37889. * @param newPosition Defines the new posisiton
  37890. */
  37891. setPosition(newPosition: Vector3): void;
  37892. /**
  37893. * Sets the local direction of the emitter if spatial sound is enabled
  37894. * @param newLocalDirection Defines the new local direction
  37895. */
  37896. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37897. private _updateDirection;
  37898. /** @hidden */
  37899. updateDistanceFromListener(): void;
  37900. /**
  37901. * Sets a new custom attenuation function for the sound.
  37902. * @param callback Defines the function used for the attenuation
  37903. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37904. */
  37905. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37906. /**
  37907. * Play the sound
  37908. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37909. * @param offset (optional) Start the sound at a specific time in seconds
  37910. * @param length (optional) Sound duration (in seconds)
  37911. */
  37912. play(time?: number, offset?: number, length?: number): void;
  37913. private _onended;
  37914. /**
  37915. * Stop the sound
  37916. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37917. */
  37918. stop(time?: number): void;
  37919. /**
  37920. * Put the sound in pause
  37921. */
  37922. pause(): void;
  37923. /**
  37924. * Sets a dedicated volume for this sounds
  37925. * @param newVolume Define the new volume of the sound
  37926. * @param time Define time for gradual change to new volume
  37927. */
  37928. setVolume(newVolume: number, time?: number): void;
  37929. /**
  37930. * Set the sound play back rate
  37931. * @param newPlaybackRate Define the playback rate the sound should be played at
  37932. */
  37933. setPlaybackRate(newPlaybackRate: number): void;
  37934. /**
  37935. * Gets the volume of the sound.
  37936. * @returns the volume of the sound
  37937. */
  37938. getVolume(): number;
  37939. /**
  37940. * Attach the sound to a dedicated mesh
  37941. * @param transformNode The transform node to connect the sound with
  37942. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37943. */
  37944. attachToMesh(transformNode: TransformNode): void;
  37945. /**
  37946. * Detach the sound from the previously attached mesh
  37947. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37948. */
  37949. detachFromMesh(): void;
  37950. private _onRegisterAfterWorldMatrixUpdate;
  37951. /**
  37952. * Clone the current sound in the scene.
  37953. * @returns the new sound clone
  37954. */
  37955. clone(): Nullable<Sound>;
  37956. /**
  37957. * Gets the current underlying audio buffer containing the data
  37958. * @returns the audio buffer
  37959. */
  37960. getAudioBuffer(): Nullable<AudioBuffer>;
  37961. /**
  37962. * Serializes the Sound in a JSON representation
  37963. * @returns the JSON representation of the sound
  37964. */
  37965. serialize(): any;
  37966. /**
  37967. * Parse a JSON representation of a sound to innstantiate in a given scene
  37968. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37969. * @param scene Define the scene the new parsed sound should be created in
  37970. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37971. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37972. * @returns the newly parsed sound
  37973. */
  37974. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37975. }
  37976. }
  37977. declare module "babylonjs/Actions/directAudioActions" {
  37978. import { Action } from "babylonjs/Actions/action";
  37979. import { Condition } from "babylonjs/Actions/condition";
  37980. import { Sound } from "babylonjs/Audio/sound";
  37981. /**
  37982. * This defines an action helpful to play a defined sound on a triggered action.
  37983. */
  37984. export class PlaySoundAction extends Action {
  37985. private _sound;
  37986. /**
  37987. * Instantiate the action
  37988. * @param triggerOptions defines the trigger options
  37989. * @param sound defines the sound to play
  37990. * @param condition defines the trigger related conditions
  37991. */
  37992. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37993. /** @hidden */
  37994. _prepare(): void;
  37995. /**
  37996. * Execute the action and play the sound.
  37997. */
  37998. execute(): void;
  37999. /**
  38000. * Serializes the actions and its related information.
  38001. * @param parent defines the object to serialize in
  38002. * @returns the serialized object
  38003. */
  38004. serialize(parent: any): any;
  38005. }
  38006. /**
  38007. * This defines an action helpful to stop a defined sound on a triggered action.
  38008. */
  38009. export class StopSoundAction extends Action {
  38010. private _sound;
  38011. /**
  38012. * Instantiate the action
  38013. * @param triggerOptions defines the trigger options
  38014. * @param sound defines the sound to stop
  38015. * @param condition defines the trigger related conditions
  38016. */
  38017. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38018. /** @hidden */
  38019. _prepare(): void;
  38020. /**
  38021. * Execute the action and stop the sound.
  38022. */
  38023. execute(): void;
  38024. /**
  38025. * Serializes the actions and its related information.
  38026. * @param parent defines the object to serialize in
  38027. * @returns the serialized object
  38028. */
  38029. serialize(parent: any): any;
  38030. }
  38031. }
  38032. declare module "babylonjs/Actions/interpolateValueAction" {
  38033. import { Action } from "babylonjs/Actions/action";
  38034. import { Condition } from "babylonjs/Actions/condition";
  38035. import { Observable } from "babylonjs/Misc/observable";
  38036. /**
  38037. * This defines an action responsible to change the value of a property
  38038. * by interpolating between its current value and the newly set one once triggered.
  38039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38040. */
  38041. export class InterpolateValueAction extends Action {
  38042. /**
  38043. * Defines the path of the property where the value should be interpolated
  38044. */
  38045. propertyPath: string;
  38046. /**
  38047. * Defines the target value at the end of the interpolation.
  38048. */
  38049. value: any;
  38050. /**
  38051. * Defines the time it will take for the property to interpolate to the value.
  38052. */
  38053. duration: number;
  38054. /**
  38055. * Defines if the other scene animations should be stopped when the action has been triggered
  38056. */
  38057. stopOtherAnimations?: boolean;
  38058. /**
  38059. * Defines a callback raised once the interpolation animation has been done.
  38060. */
  38061. onInterpolationDone?: () => void;
  38062. /**
  38063. * Observable triggered once the interpolation animation has been done.
  38064. */
  38065. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38066. private _target;
  38067. private _effectiveTarget;
  38068. private _property;
  38069. /**
  38070. * Instantiate the action
  38071. * @param triggerOptions defines the trigger options
  38072. * @param target defines the object containing the value to interpolate
  38073. * @param propertyPath defines the path to the property in the target object
  38074. * @param value defines the target value at the end of the interpolation
  38075. * @param duration deines the time it will take for the property to interpolate to the value.
  38076. * @param condition defines the trigger related conditions
  38077. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38078. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38079. */
  38080. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38081. /** @hidden */
  38082. _prepare(): void;
  38083. /**
  38084. * Execute the action starts the value interpolation.
  38085. */
  38086. execute(): void;
  38087. /**
  38088. * Serializes the actions and its related information.
  38089. * @param parent defines the object to serialize in
  38090. * @returns the serialized object
  38091. */
  38092. serialize(parent: any): any;
  38093. }
  38094. }
  38095. declare module "babylonjs/Actions/index" {
  38096. export * from "babylonjs/Actions/abstractActionManager";
  38097. export * from "babylonjs/Actions/action";
  38098. export * from "babylonjs/Actions/actionEvent";
  38099. export * from "babylonjs/Actions/actionManager";
  38100. export * from "babylonjs/Actions/condition";
  38101. export * from "babylonjs/Actions/directActions";
  38102. export * from "babylonjs/Actions/directAudioActions";
  38103. export * from "babylonjs/Actions/interpolateValueAction";
  38104. }
  38105. declare module "babylonjs/Animations/index" {
  38106. export * from "babylonjs/Animations/animatable";
  38107. export * from "babylonjs/Animations/animation";
  38108. export * from "babylonjs/Animations/animationGroup";
  38109. export * from "babylonjs/Animations/animationPropertiesOverride";
  38110. export * from "babylonjs/Animations/easing";
  38111. export * from "babylonjs/Animations/runtimeAnimation";
  38112. export * from "babylonjs/Animations/animationEvent";
  38113. export * from "babylonjs/Animations/animationGroup";
  38114. export * from "babylonjs/Animations/animationKey";
  38115. export * from "babylonjs/Animations/animationRange";
  38116. export * from "babylonjs/Animations/animatable.interface";
  38117. }
  38118. declare module "babylonjs/Audio/soundTrack" {
  38119. import { Sound } from "babylonjs/Audio/sound";
  38120. import { Analyser } from "babylonjs/Audio/analyser";
  38121. import { Scene } from "babylonjs/scene";
  38122. /**
  38123. * Options allowed during the creation of a sound track.
  38124. */
  38125. export interface ISoundTrackOptions {
  38126. /**
  38127. * The volume the sound track should take during creation
  38128. */
  38129. volume?: number;
  38130. /**
  38131. * Define if the sound track is the main sound track of the scene
  38132. */
  38133. mainTrack?: boolean;
  38134. }
  38135. /**
  38136. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38137. * It will be also used in a future release to apply effects on a specific track.
  38138. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38139. */
  38140. export class SoundTrack {
  38141. /**
  38142. * The unique identifier of the sound track in the scene.
  38143. */
  38144. id: number;
  38145. /**
  38146. * The list of sounds included in the sound track.
  38147. */
  38148. soundCollection: Array<Sound>;
  38149. private _outputAudioNode;
  38150. private _scene;
  38151. private _connectedAnalyser;
  38152. private _options;
  38153. private _isInitialized;
  38154. /**
  38155. * Creates a new sound track.
  38156. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38157. * @param scene Define the scene the sound track belongs to
  38158. * @param options
  38159. */
  38160. constructor(scene: Scene, options?: ISoundTrackOptions);
  38161. private _initializeSoundTrackAudioGraph;
  38162. /**
  38163. * Release the sound track and its associated resources
  38164. */
  38165. dispose(): void;
  38166. /**
  38167. * Adds a sound to this sound track
  38168. * @param sound define the cound to add
  38169. * @ignoreNaming
  38170. */
  38171. AddSound(sound: Sound): void;
  38172. /**
  38173. * Removes a sound to this sound track
  38174. * @param sound define the cound to remove
  38175. * @ignoreNaming
  38176. */
  38177. RemoveSound(sound: Sound): void;
  38178. /**
  38179. * Set a global volume for the full sound track.
  38180. * @param newVolume Define the new volume of the sound track
  38181. */
  38182. setVolume(newVolume: number): void;
  38183. /**
  38184. * Switch the panning model to HRTF:
  38185. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38186. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38187. */
  38188. switchPanningModelToHRTF(): void;
  38189. /**
  38190. * Switch the panning model to Equal Power:
  38191. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38193. */
  38194. switchPanningModelToEqualPower(): void;
  38195. /**
  38196. * Connect the sound track to an audio analyser allowing some amazing
  38197. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38198. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38199. * @param analyser The analyser to connect to the engine
  38200. */
  38201. connectToAnalyser(analyser: Analyser): void;
  38202. }
  38203. }
  38204. declare module "babylonjs/Audio/audioSceneComponent" {
  38205. import { Sound } from "babylonjs/Audio/sound";
  38206. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38207. import { Nullable } from "babylonjs/types";
  38208. import { Vector3 } from "babylonjs/Maths/math.vector";
  38209. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38210. import { Scene } from "babylonjs/scene";
  38211. import { AbstractScene } from "babylonjs/abstractScene";
  38212. import "babylonjs/Audio/audioEngine";
  38213. module "babylonjs/abstractScene" {
  38214. interface AbstractScene {
  38215. /**
  38216. * The list of sounds used in the scene.
  38217. */
  38218. sounds: Nullable<Array<Sound>>;
  38219. }
  38220. }
  38221. module "babylonjs/scene" {
  38222. interface Scene {
  38223. /**
  38224. * @hidden
  38225. * Backing field
  38226. */
  38227. _mainSoundTrack: SoundTrack;
  38228. /**
  38229. * The main sound track played by the scene.
  38230. * It cotains your primary collection of sounds.
  38231. */
  38232. mainSoundTrack: SoundTrack;
  38233. /**
  38234. * The list of sound tracks added to the scene
  38235. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38236. */
  38237. soundTracks: Nullable<Array<SoundTrack>>;
  38238. /**
  38239. * Gets a sound using a given name
  38240. * @param name defines the name to search for
  38241. * @return the found sound or null if not found at all.
  38242. */
  38243. getSoundByName(name: string): Nullable<Sound>;
  38244. /**
  38245. * Gets or sets if audio support is enabled
  38246. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38247. */
  38248. audioEnabled: boolean;
  38249. /**
  38250. * Gets or sets if audio will be output to headphones
  38251. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38252. */
  38253. headphone: boolean;
  38254. /**
  38255. * Gets or sets custom audio listener position provider
  38256. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38257. */
  38258. audioListenerPositionProvider: Nullable<() => Vector3>;
  38259. /**
  38260. * Gets or sets a refresh rate when using 3D audio positioning
  38261. */
  38262. audioPositioningRefreshRate: number;
  38263. }
  38264. }
  38265. /**
  38266. * Defines the sound scene component responsible to manage any sounds
  38267. * in a given scene.
  38268. */
  38269. export class AudioSceneComponent implements ISceneSerializableComponent {
  38270. /**
  38271. * The component name helpfull to identify the component in the list of scene components.
  38272. */
  38273. readonly name: string;
  38274. /**
  38275. * The scene the component belongs to.
  38276. */
  38277. scene: Scene;
  38278. private _audioEnabled;
  38279. /**
  38280. * Gets whether audio is enabled or not.
  38281. * Please use related enable/disable method to switch state.
  38282. */
  38283. readonly audioEnabled: boolean;
  38284. private _headphone;
  38285. /**
  38286. * Gets whether audio is outputing to headphone or not.
  38287. * Please use the according Switch methods to change output.
  38288. */
  38289. readonly headphone: boolean;
  38290. /**
  38291. * Gets or sets a refresh rate when using 3D audio positioning
  38292. */
  38293. audioPositioningRefreshRate: number;
  38294. private _audioListenerPositionProvider;
  38295. /**
  38296. * Gets the current audio listener position provider
  38297. */
  38298. /**
  38299. * Sets a custom listener position for all sounds in the scene
  38300. * By default, this is the position of the first active camera
  38301. */
  38302. audioListenerPositionProvider: Nullable<() => Vector3>;
  38303. /**
  38304. * Creates a new instance of the component for the given scene
  38305. * @param scene Defines the scene to register the component in
  38306. */
  38307. constructor(scene: Scene);
  38308. /**
  38309. * Registers the component in a given scene
  38310. */
  38311. register(): void;
  38312. /**
  38313. * Rebuilds the elements related to this component in case of
  38314. * context lost for instance.
  38315. */
  38316. rebuild(): void;
  38317. /**
  38318. * Serializes the component data to the specified json object
  38319. * @param serializationObject The object to serialize to
  38320. */
  38321. serialize(serializationObject: any): void;
  38322. /**
  38323. * Adds all the elements from the container to the scene
  38324. * @param container the container holding the elements
  38325. */
  38326. addFromContainer(container: AbstractScene): void;
  38327. /**
  38328. * Removes all the elements in the container from the scene
  38329. * @param container contains the elements to remove
  38330. * @param dispose if the removed element should be disposed (default: false)
  38331. */
  38332. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38333. /**
  38334. * Disposes the component and the associated ressources.
  38335. */
  38336. dispose(): void;
  38337. /**
  38338. * Disables audio in the associated scene.
  38339. */
  38340. disableAudio(): void;
  38341. /**
  38342. * Enables audio in the associated scene.
  38343. */
  38344. enableAudio(): void;
  38345. /**
  38346. * Switch audio to headphone output.
  38347. */
  38348. switchAudioModeForHeadphones(): void;
  38349. /**
  38350. * Switch audio to normal speakers.
  38351. */
  38352. switchAudioModeForNormalSpeakers(): void;
  38353. private _cachedCameraDirection;
  38354. private _cachedCameraPosition;
  38355. private _lastCheck;
  38356. private _afterRender;
  38357. }
  38358. }
  38359. declare module "babylonjs/Audio/weightedsound" {
  38360. import { Sound } from "babylonjs/Audio/sound";
  38361. /**
  38362. * Wraps one or more Sound objects and selects one with random weight for playback.
  38363. */
  38364. export class WeightedSound {
  38365. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38366. loop: boolean;
  38367. private _coneInnerAngle;
  38368. private _coneOuterAngle;
  38369. private _volume;
  38370. /** A Sound is currently playing. */
  38371. isPlaying: boolean;
  38372. /** A Sound is currently paused. */
  38373. isPaused: boolean;
  38374. private _sounds;
  38375. private _weights;
  38376. private _currentIndex?;
  38377. /**
  38378. * Creates a new WeightedSound from the list of sounds given.
  38379. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38380. * @param sounds Array of Sounds that will be selected from.
  38381. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38382. */
  38383. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38384. /**
  38385. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38386. */
  38387. /**
  38388. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38389. */
  38390. directionalConeInnerAngle: number;
  38391. /**
  38392. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38393. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38394. */
  38395. /**
  38396. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38397. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38398. */
  38399. directionalConeOuterAngle: number;
  38400. /**
  38401. * Playback volume.
  38402. */
  38403. /**
  38404. * Playback volume.
  38405. */
  38406. volume: number;
  38407. private _onended;
  38408. /**
  38409. * Suspend playback
  38410. */
  38411. pause(): void;
  38412. /**
  38413. * Stop playback
  38414. */
  38415. stop(): void;
  38416. /**
  38417. * Start playback.
  38418. * @param startOffset Position the clip head at a specific time in seconds.
  38419. */
  38420. play(startOffset?: number): void;
  38421. }
  38422. }
  38423. declare module "babylonjs/Audio/index" {
  38424. export * from "babylonjs/Audio/analyser";
  38425. export * from "babylonjs/Audio/audioEngine";
  38426. export * from "babylonjs/Audio/audioSceneComponent";
  38427. export * from "babylonjs/Audio/sound";
  38428. export * from "babylonjs/Audio/soundTrack";
  38429. export * from "babylonjs/Audio/weightedsound";
  38430. }
  38431. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38432. import { Behavior } from "babylonjs/Behaviors/behavior";
  38433. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38434. import { BackEase } from "babylonjs/Animations/easing";
  38435. /**
  38436. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38437. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38438. */
  38439. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38440. /**
  38441. * Gets the name of the behavior.
  38442. */
  38443. readonly name: string;
  38444. /**
  38445. * The easing function used by animations
  38446. */
  38447. static EasingFunction: BackEase;
  38448. /**
  38449. * The easing mode used by animations
  38450. */
  38451. static EasingMode: number;
  38452. /**
  38453. * The duration of the animation, in milliseconds
  38454. */
  38455. transitionDuration: number;
  38456. /**
  38457. * Length of the distance animated by the transition when lower radius is reached
  38458. */
  38459. lowerRadiusTransitionRange: number;
  38460. /**
  38461. * Length of the distance animated by the transition when upper radius is reached
  38462. */
  38463. upperRadiusTransitionRange: number;
  38464. private _autoTransitionRange;
  38465. /**
  38466. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38467. */
  38468. /**
  38469. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38470. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38471. */
  38472. autoTransitionRange: boolean;
  38473. private _attachedCamera;
  38474. private _onAfterCheckInputsObserver;
  38475. private _onMeshTargetChangedObserver;
  38476. /**
  38477. * Initializes the behavior.
  38478. */
  38479. init(): void;
  38480. /**
  38481. * Attaches the behavior to its arc rotate camera.
  38482. * @param camera Defines the camera to attach the behavior to
  38483. */
  38484. attach(camera: ArcRotateCamera): void;
  38485. /**
  38486. * Detaches the behavior from its current arc rotate camera.
  38487. */
  38488. detach(): void;
  38489. private _radiusIsAnimating;
  38490. private _radiusBounceTransition;
  38491. private _animatables;
  38492. private _cachedWheelPrecision;
  38493. /**
  38494. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38495. * @param radiusLimit The limit to check against.
  38496. * @return Bool to indicate if at limit.
  38497. */
  38498. private _isRadiusAtLimit;
  38499. /**
  38500. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38501. * @param radiusDelta The delta by which to animate to. Can be negative.
  38502. */
  38503. private _applyBoundRadiusAnimation;
  38504. /**
  38505. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38506. */
  38507. protected _clearAnimationLocks(): void;
  38508. /**
  38509. * Stops and removes all animations that have been applied to the camera
  38510. */
  38511. stopAllAnimations(): void;
  38512. }
  38513. }
  38514. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  38515. import { Behavior } from "babylonjs/Behaviors/behavior";
  38516. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38517. import { ExponentialEase } from "babylonjs/Animations/easing";
  38518. import { Nullable } from "babylonjs/types";
  38519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38520. import { Vector3 } from "babylonjs/Maths/math.vector";
  38521. /**
  38522. * 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.
  38523. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38524. */
  38525. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38526. /**
  38527. * Gets the name of the behavior.
  38528. */
  38529. readonly name: string;
  38530. private _mode;
  38531. private _radiusScale;
  38532. private _positionScale;
  38533. private _defaultElevation;
  38534. private _elevationReturnTime;
  38535. private _elevationReturnWaitTime;
  38536. private _zoomStopsAnimation;
  38537. private _framingTime;
  38538. /**
  38539. * The easing function used by animations
  38540. */
  38541. static EasingFunction: ExponentialEase;
  38542. /**
  38543. * The easing mode used by animations
  38544. */
  38545. static EasingMode: number;
  38546. /**
  38547. * Sets the current mode used by the behavior
  38548. */
  38549. /**
  38550. * Gets current mode used by the behavior.
  38551. */
  38552. mode: number;
  38553. /**
  38554. * Sets the scale applied to the radius (1 by default)
  38555. */
  38556. /**
  38557. * Gets the scale applied to the radius
  38558. */
  38559. radiusScale: number;
  38560. /**
  38561. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38562. */
  38563. /**
  38564. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38565. */
  38566. positionScale: number;
  38567. /**
  38568. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38569. * behaviour is triggered, in radians.
  38570. */
  38571. /**
  38572. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38573. * behaviour is triggered, in radians.
  38574. */
  38575. defaultElevation: number;
  38576. /**
  38577. * Sets the time (in milliseconds) taken to return to the default beta position.
  38578. * Negative value indicates camera should not return to default.
  38579. */
  38580. /**
  38581. * Gets the time (in milliseconds) taken to return to the default beta position.
  38582. * Negative value indicates camera should not return to default.
  38583. */
  38584. elevationReturnTime: number;
  38585. /**
  38586. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38587. */
  38588. /**
  38589. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38590. */
  38591. elevationReturnWaitTime: number;
  38592. /**
  38593. * Sets the flag that indicates if user zooming should stop animation.
  38594. */
  38595. /**
  38596. * Gets the flag that indicates if user zooming should stop animation.
  38597. */
  38598. zoomStopsAnimation: boolean;
  38599. /**
  38600. * Sets the transition time when framing the mesh, in milliseconds
  38601. */
  38602. /**
  38603. * Gets the transition time when framing the mesh, in milliseconds
  38604. */
  38605. framingTime: number;
  38606. /**
  38607. * Define if the behavior should automatically change the configured
  38608. * camera limits and sensibilities.
  38609. */
  38610. autoCorrectCameraLimitsAndSensibility: boolean;
  38611. private _onPrePointerObservableObserver;
  38612. private _onAfterCheckInputsObserver;
  38613. private _onMeshTargetChangedObserver;
  38614. private _attachedCamera;
  38615. private _isPointerDown;
  38616. private _lastInteractionTime;
  38617. /**
  38618. * Initializes the behavior.
  38619. */
  38620. init(): void;
  38621. /**
  38622. * Attaches the behavior to its arc rotate camera.
  38623. * @param camera Defines the camera to attach the behavior to
  38624. */
  38625. attach(camera: ArcRotateCamera): void;
  38626. /**
  38627. * Detaches the behavior from its current arc rotate camera.
  38628. */
  38629. detach(): void;
  38630. private _animatables;
  38631. private _betaIsAnimating;
  38632. private _betaTransition;
  38633. private _radiusTransition;
  38634. private _vectorTransition;
  38635. /**
  38636. * Targets the given mesh and updates zoom level accordingly.
  38637. * @param mesh The mesh to target.
  38638. * @param radius Optional. If a cached radius position already exists, overrides default.
  38639. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38640. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38641. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38642. */
  38643. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38644. /**
  38645. * Targets the given mesh with its children and updates zoom level accordingly.
  38646. * @param mesh The mesh to target.
  38647. * @param radius Optional. If a cached radius position already exists, overrides default.
  38648. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38649. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38650. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38651. */
  38652. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38653. /**
  38654. * Targets the given meshes with their children and updates zoom level accordingly.
  38655. * @param meshes The mesh to target.
  38656. * @param radius Optional. If a cached radius position already exists, overrides default.
  38657. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38658. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38659. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38660. */
  38661. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38662. /**
  38663. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38664. * @param minimumWorld Determines the smaller position of the bounding box extend
  38665. * @param maximumWorld Determines the bigger position of the bounding box extend
  38666. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38667. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38668. */
  38669. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38670. /**
  38671. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38672. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38673. * frustum width.
  38674. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38675. * to fully enclose the mesh in the viewing frustum.
  38676. */
  38677. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38678. /**
  38679. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38680. * is automatically returned to its default position (expected to be above ground plane).
  38681. */
  38682. private _maintainCameraAboveGround;
  38683. /**
  38684. * Returns the frustum slope based on the canvas ratio and camera FOV
  38685. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38686. */
  38687. private _getFrustumSlope;
  38688. /**
  38689. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38690. */
  38691. private _clearAnimationLocks;
  38692. /**
  38693. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38694. */
  38695. private _applyUserInteraction;
  38696. /**
  38697. * Stops and removes all animations that have been applied to the camera
  38698. */
  38699. stopAllAnimations(): void;
  38700. /**
  38701. * Gets a value indicating if the user is moving the camera
  38702. */
  38703. readonly isUserIsMoving: boolean;
  38704. /**
  38705. * The camera can move all the way towards the mesh.
  38706. */
  38707. static IgnoreBoundsSizeMode: number;
  38708. /**
  38709. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38710. */
  38711. static FitFrustumSidesMode: number;
  38712. }
  38713. }
  38714. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  38715. import { Nullable } from "babylonjs/types";
  38716. import { Camera } from "babylonjs/Cameras/camera";
  38717. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38718. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38719. /**
  38720. * Base class for Camera Pointer Inputs.
  38721. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38722. * for example usage.
  38723. */
  38724. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38725. /**
  38726. * Defines the camera the input is attached to.
  38727. */
  38728. abstract camera: Camera;
  38729. /**
  38730. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38731. */
  38732. protected _altKey: boolean;
  38733. protected _ctrlKey: boolean;
  38734. protected _metaKey: boolean;
  38735. protected _shiftKey: boolean;
  38736. /**
  38737. * Which mouse buttons were pressed at time of last mouse event.
  38738. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38739. */
  38740. protected _buttonsPressed: number;
  38741. /**
  38742. * Defines the buttons associated with the input to handle camera move.
  38743. */
  38744. buttons: number[];
  38745. /**
  38746. * Attach the input controls to a specific dom element to get the input from.
  38747. * @param element Defines the element the controls should be listened from
  38748. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38749. */
  38750. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38751. /**
  38752. * Detach the current controls from the specified dom element.
  38753. * @param element Defines the element to stop listening the inputs from
  38754. */
  38755. detachControl(element: Nullable<HTMLElement>): void;
  38756. /**
  38757. * Gets the class name of the current input.
  38758. * @returns the class name
  38759. */
  38760. getClassName(): string;
  38761. /**
  38762. * Get the friendly name associated with the input class.
  38763. * @returns the input friendly name
  38764. */
  38765. getSimpleName(): string;
  38766. /**
  38767. * Called on pointer POINTERDOUBLETAP event.
  38768. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38769. */
  38770. protected onDoubleTap(type: string): void;
  38771. /**
  38772. * Called on pointer POINTERMOVE event if only a single touch is active.
  38773. * Override this method to provide functionality.
  38774. */
  38775. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38776. /**
  38777. * Called on pointer POINTERMOVE event if multiple touches are active.
  38778. * Override this method to provide functionality.
  38779. */
  38780. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38781. /**
  38782. * Called on JS contextmenu event.
  38783. * Override this method to provide functionality.
  38784. */
  38785. protected onContextMenu(evt: PointerEvent): void;
  38786. /**
  38787. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38788. * press.
  38789. * Override this method to provide functionality.
  38790. */
  38791. protected onButtonDown(evt: PointerEvent): void;
  38792. /**
  38793. * Called each time a new POINTERUP event occurs. Ie, for each button
  38794. * release.
  38795. * Override this method to provide functionality.
  38796. */
  38797. protected onButtonUp(evt: PointerEvent): void;
  38798. /**
  38799. * Called when window becomes inactive.
  38800. * Override this method to provide functionality.
  38801. */
  38802. protected onLostFocus(): void;
  38803. private _pointerInput;
  38804. private _observer;
  38805. private _onLostFocus;
  38806. private pointA;
  38807. private pointB;
  38808. }
  38809. }
  38810. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  38811. import { Nullable } from "babylonjs/types";
  38812. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38813. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38814. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38815. /**
  38816. * Manage the pointers inputs to control an arc rotate camera.
  38817. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38818. */
  38819. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38820. /**
  38821. * Defines the camera the input is attached to.
  38822. */
  38823. camera: ArcRotateCamera;
  38824. /**
  38825. * Gets the class name of the current input.
  38826. * @returns the class name
  38827. */
  38828. getClassName(): string;
  38829. /**
  38830. * Defines the buttons associated with the input to handle camera move.
  38831. */
  38832. buttons: number[];
  38833. /**
  38834. * Defines the pointer angular sensibility along the X axis or how fast is
  38835. * the camera rotating.
  38836. */
  38837. angularSensibilityX: number;
  38838. /**
  38839. * Defines the pointer angular sensibility along the Y axis or how fast is
  38840. * the camera rotating.
  38841. */
  38842. angularSensibilityY: number;
  38843. /**
  38844. * Defines the pointer pinch precision or how fast is the camera zooming.
  38845. */
  38846. pinchPrecision: number;
  38847. /**
  38848. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38849. * from 0.
  38850. * It defines the percentage of current camera.radius to use as delta when
  38851. * pinch zoom is used.
  38852. */
  38853. pinchDeltaPercentage: number;
  38854. /**
  38855. * Defines the pointer panning sensibility or how fast is the camera moving.
  38856. */
  38857. panningSensibility: number;
  38858. /**
  38859. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38860. */
  38861. multiTouchPanning: boolean;
  38862. /**
  38863. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38864. * zoom (pinch) through multitouch.
  38865. */
  38866. multiTouchPanAndZoom: boolean;
  38867. /**
  38868. * Revers pinch action direction.
  38869. */
  38870. pinchInwards: boolean;
  38871. private _isPanClick;
  38872. private _twoFingerActivityCount;
  38873. private _isPinching;
  38874. /**
  38875. * Called on pointer POINTERMOVE event if only a single touch is active.
  38876. */
  38877. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38878. /**
  38879. * Called on pointer POINTERDOUBLETAP event.
  38880. */
  38881. protected onDoubleTap(type: string): void;
  38882. /**
  38883. * Called on pointer POINTERMOVE event if multiple touches are active.
  38884. */
  38885. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38886. /**
  38887. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38888. * press.
  38889. */
  38890. protected onButtonDown(evt: PointerEvent): void;
  38891. /**
  38892. * Called each time a new POINTERUP event occurs. Ie, for each button
  38893. * release.
  38894. */
  38895. protected onButtonUp(evt: PointerEvent): void;
  38896. /**
  38897. * Called when window becomes inactive.
  38898. */
  38899. protected onLostFocus(): void;
  38900. }
  38901. }
  38902. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  38903. import { Nullable } from "babylonjs/types";
  38904. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38905. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38906. /**
  38907. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38908. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38909. */
  38910. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38911. /**
  38912. * Defines the camera the input is attached to.
  38913. */
  38914. camera: ArcRotateCamera;
  38915. /**
  38916. * Defines the list of key codes associated with the up action (increase alpha)
  38917. */
  38918. keysUp: number[];
  38919. /**
  38920. * Defines the list of key codes associated with the down action (decrease alpha)
  38921. */
  38922. keysDown: number[];
  38923. /**
  38924. * Defines the list of key codes associated with the left action (increase beta)
  38925. */
  38926. keysLeft: number[];
  38927. /**
  38928. * Defines the list of key codes associated with the right action (decrease beta)
  38929. */
  38930. keysRight: number[];
  38931. /**
  38932. * Defines the list of key codes associated with the reset action.
  38933. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38934. */
  38935. keysReset: number[];
  38936. /**
  38937. * Defines the panning sensibility of the inputs.
  38938. * (How fast is the camera paning)
  38939. */
  38940. panningSensibility: number;
  38941. /**
  38942. * Defines the zooming sensibility of the inputs.
  38943. * (How fast is the camera zooming)
  38944. */
  38945. zoomingSensibility: number;
  38946. /**
  38947. * Defines wether maintaining the alt key down switch the movement mode from
  38948. * orientation to zoom.
  38949. */
  38950. useAltToZoom: boolean;
  38951. /**
  38952. * Rotation speed of the camera
  38953. */
  38954. angularSpeed: number;
  38955. private _keys;
  38956. private _ctrlPressed;
  38957. private _altPressed;
  38958. private _onCanvasBlurObserver;
  38959. private _onKeyboardObserver;
  38960. private _engine;
  38961. private _scene;
  38962. /**
  38963. * Attach the input controls to a specific dom element to get the input from.
  38964. * @param element Defines the element the controls should be listened from
  38965. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38966. */
  38967. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38968. /**
  38969. * Detach the current controls from the specified dom element.
  38970. * @param element Defines the element to stop listening the inputs from
  38971. */
  38972. detachControl(element: Nullable<HTMLElement>): void;
  38973. /**
  38974. * Update the current camera state depending on the inputs that have been used this frame.
  38975. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38976. */
  38977. checkInputs(): void;
  38978. /**
  38979. * Gets the class name of the current intput.
  38980. * @returns the class name
  38981. */
  38982. getClassName(): string;
  38983. /**
  38984. * Get the friendly name associated with the input class.
  38985. * @returns the input friendly name
  38986. */
  38987. getSimpleName(): string;
  38988. }
  38989. }
  38990. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  38991. import { Nullable } from "babylonjs/types";
  38992. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38993. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38994. /**
  38995. * Manage the mouse wheel inputs to control an arc rotate camera.
  38996. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38997. */
  38998. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38999. /**
  39000. * Defines the camera the input is attached to.
  39001. */
  39002. camera: ArcRotateCamera;
  39003. /**
  39004. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39005. */
  39006. wheelPrecision: number;
  39007. /**
  39008. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39009. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39010. */
  39011. wheelDeltaPercentage: number;
  39012. private _wheel;
  39013. private _observer;
  39014. private computeDeltaFromMouseWheelLegacyEvent;
  39015. /**
  39016. * Attach the input controls to a specific dom element to get the input from.
  39017. * @param element Defines the element the controls should be listened from
  39018. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39019. */
  39020. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39021. /**
  39022. * Detach the current controls from the specified dom element.
  39023. * @param element Defines the element to stop listening the inputs from
  39024. */
  39025. detachControl(element: Nullable<HTMLElement>): void;
  39026. /**
  39027. * Gets the class name of the current intput.
  39028. * @returns the class name
  39029. */
  39030. getClassName(): string;
  39031. /**
  39032. * Get the friendly name associated with the input class.
  39033. * @returns the input friendly name
  39034. */
  39035. getSimpleName(): string;
  39036. }
  39037. }
  39038. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39039. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39040. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39041. /**
  39042. * Default Inputs manager for the ArcRotateCamera.
  39043. * It groups all the default supported inputs for ease of use.
  39044. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39045. */
  39046. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39047. /**
  39048. * Instantiates a new ArcRotateCameraInputsManager.
  39049. * @param camera Defines the camera the inputs belong to
  39050. */
  39051. constructor(camera: ArcRotateCamera);
  39052. /**
  39053. * Add mouse wheel input support to the input manager.
  39054. * @returns the current input manager
  39055. */
  39056. addMouseWheel(): ArcRotateCameraInputsManager;
  39057. /**
  39058. * Add pointers input support to the input manager.
  39059. * @returns the current input manager
  39060. */
  39061. addPointers(): ArcRotateCameraInputsManager;
  39062. /**
  39063. * Add keyboard input support to the input manager.
  39064. * @returns the current input manager
  39065. */
  39066. addKeyboard(): ArcRotateCameraInputsManager;
  39067. }
  39068. }
  39069. declare module "babylonjs/Cameras/arcRotateCamera" {
  39070. import { Observable } from "babylonjs/Misc/observable";
  39071. import { Nullable } from "babylonjs/types";
  39072. import { Scene } from "babylonjs/scene";
  39073. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39075. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39076. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39077. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39078. import { Camera } from "babylonjs/Cameras/camera";
  39079. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39080. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39081. import { Collider } from "babylonjs/Collisions/collider";
  39082. /**
  39083. * This represents an orbital type of camera.
  39084. *
  39085. * 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.
  39086. * 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.
  39087. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39088. */
  39089. export class ArcRotateCamera extends TargetCamera {
  39090. /**
  39091. * Defines the rotation angle of the camera along the longitudinal axis.
  39092. */
  39093. alpha: number;
  39094. /**
  39095. * Defines the rotation angle of the camera along the latitudinal axis.
  39096. */
  39097. beta: number;
  39098. /**
  39099. * Defines the radius of the camera from it s target point.
  39100. */
  39101. radius: number;
  39102. protected _target: Vector3;
  39103. protected _targetHost: Nullable<AbstractMesh>;
  39104. /**
  39105. * Defines the target point of the camera.
  39106. * The camera looks towards it form the radius distance.
  39107. */
  39108. target: Vector3;
  39109. /**
  39110. * Define the current local position of the camera in the scene
  39111. */
  39112. position: Vector3;
  39113. protected _upVector: Vector3;
  39114. protected _upToYMatrix: Matrix;
  39115. protected _YToUpMatrix: Matrix;
  39116. /**
  39117. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39118. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39119. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39120. */
  39121. upVector: Vector3;
  39122. /**
  39123. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39124. */
  39125. setMatUp(): void;
  39126. /**
  39127. * Current inertia value on the longitudinal axis.
  39128. * The bigger this number the longer it will take for the camera to stop.
  39129. */
  39130. inertialAlphaOffset: number;
  39131. /**
  39132. * Current inertia value on the latitudinal axis.
  39133. * The bigger this number the longer it will take for the camera to stop.
  39134. */
  39135. inertialBetaOffset: number;
  39136. /**
  39137. * Current inertia value on the radius axis.
  39138. * The bigger this number the longer it will take for the camera to stop.
  39139. */
  39140. inertialRadiusOffset: number;
  39141. /**
  39142. * Minimum allowed angle on the longitudinal axis.
  39143. * This can help limiting how the Camera is able to move in the scene.
  39144. */
  39145. lowerAlphaLimit: Nullable<number>;
  39146. /**
  39147. * Maximum allowed angle on the longitudinal axis.
  39148. * This can help limiting how the Camera is able to move in the scene.
  39149. */
  39150. upperAlphaLimit: Nullable<number>;
  39151. /**
  39152. * Minimum allowed angle on the latitudinal axis.
  39153. * This can help limiting how the Camera is able to move in the scene.
  39154. */
  39155. lowerBetaLimit: number;
  39156. /**
  39157. * Maximum allowed angle on the latitudinal axis.
  39158. * This can help limiting how the Camera is able to move in the scene.
  39159. */
  39160. upperBetaLimit: number;
  39161. /**
  39162. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39163. * This can help limiting how the Camera is able to move in the scene.
  39164. */
  39165. lowerRadiusLimit: Nullable<number>;
  39166. /**
  39167. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39168. * This can help limiting how the Camera is able to move in the scene.
  39169. */
  39170. upperRadiusLimit: Nullable<number>;
  39171. /**
  39172. * Defines the current inertia value used during panning of the camera along the X axis.
  39173. */
  39174. inertialPanningX: number;
  39175. /**
  39176. * Defines the current inertia value used during panning of the camera along the Y axis.
  39177. */
  39178. inertialPanningY: number;
  39179. /**
  39180. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39181. * Basically if your fingers moves away from more than this distance you will be considered
  39182. * in pinch mode.
  39183. */
  39184. pinchToPanMaxDistance: number;
  39185. /**
  39186. * Defines the maximum distance the camera can pan.
  39187. * This could help keeping the cammera always in your scene.
  39188. */
  39189. panningDistanceLimit: Nullable<number>;
  39190. /**
  39191. * Defines the target of the camera before paning.
  39192. */
  39193. panningOriginTarget: Vector3;
  39194. /**
  39195. * Defines the value of the inertia used during panning.
  39196. * 0 would mean stop inertia and one would mean no decelleration at all.
  39197. */
  39198. panningInertia: number;
  39199. /**
  39200. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39201. */
  39202. angularSensibilityX: number;
  39203. /**
  39204. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39205. */
  39206. angularSensibilityY: number;
  39207. /**
  39208. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39209. */
  39210. pinchPrecision: number;
  39211. /**
  39212. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39213. * It will be used instead of pinchDeltaPrecision if different from 0.
  39214. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39215. */
  39216. pinchDeltaPercentage: number;
  39217. /**
  39218. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39219. */
  39220. panningSensibility: number;
  39221. /**
  39222. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39223. */
  39224. keysUp: number[];
  39225. /**
  39226. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39227. */
  39228. keysDown: number[];
  39229. /**
  39230. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39231. */
  39232. keysLeft: number[];
  39233. /**
  39234. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39235. */
  39236. keysRight: number[];
  39237. /**
  39238. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39239. */
  39240. wheelPrecision: number;
  39241. /**
  39242. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39243. * It will be used instead of pinchDeltaPrecision if different from 0.
  39244. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39245. */
  39246. wheelDeltaPercentage: number;
  39247. /**
  39248. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39249. */
  39250. zoomOnFactor: number;
  39251. /**
  39252. * Defines a screen offset for the camera position.
  39253. */
  39254. targetScreenOffset: Vector2;
  39255. /**
  39256. * Allows the camera to be completely reversed.
  39257. * If false the camera can not arrive upside down.
  39258. */
  39259. allowUpsideDown: boolean;
  39260. /**
  39261. * Define if double tap/click is used to restore the previously saved state of the camera.
  39262. */
  39263. useInputToRestoreState: boolean;
  39264. /** @hidden */
  39265. _viewMatrix: Matrix;
  39266. /** @hidden */
  39267. _useCtrlForPanning: boolean;
  39268. /** @hidden */
  39269. _panningMouseButton: number;
  39270. /**
  39271. * Defines the input associated to the camera.
  39272. */
  39273. inputs: ArcRotateCameraInputsManager;
  39274. /** @hidden */
  39275. _reset: () => void;
  39276. /**
  39277. * Defines the allowed panning axis.
  39278. */
  39279. panningAxis: Vector3;
  39280. protected _localDirection: Vector3;
  39281. protected _transformedDirection: Vector3;
  39282. private _bouncingBehavior;
  39283. /**
  39284. * Gets the bouncing behavior of the camera if it has been enabled.
  39285. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39286. */
  39287. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  39288. /**
  39289. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39290. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39291. */
  39292. useBouncingBehavior: boolean;
  39293. private _framingBehavior;
  39294. /**
  39295. * Gets the framing behavior of the camera if it has been enabled.
  39296. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39297. */
  39298. readonly framingBehavior: Nullable<FramingBehavior>;
  39299. /**
  39300. * Defines if the framing behavior of the camera is enabled on the camera.
  39301. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39302. */
  39303. useFramingBehavior: boolean;
  39304. private _autoRotationBehavior;
  39305. /**
  39306. * Gets the auto rotation behavior of the camera if it has been enabled.
  39307. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39308. */
  39309. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  39310. /**
  39311. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39312. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39313. */
  39314. useAutoRotationBehavior: boolean;
  39315. /**
  39316. * Observable triggered when the mesh target has been changed on the camera.
  39317. */
  39318. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39319. /**
  39320. * Event raised when the camera is colliding with a mesh.
  39321. */
  39322. onCollide: (collidedMesh: AbstractMesh) => void;
  39323. /**
  39324. * Defines whether the camera should check collision with the objects oh the scene.
  39325. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39326. */
  39327. checkCollisions: boolean;
  39328. /**
  39329. * Defines the collision radius of the camera.
  39330. * This simulates a sphere around the camera.
  39331. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39332. */
  39333. collisionRadius: Vector3;
  39334. protected _collider: Collider;
  39335. protected _previousPosition: Vector3;
  39336. protected _collisionVelocity: Vector3;
  39337. protected _newPosition: Vector3;
  39338. protected _previousAlpha: number;
  39339. protected _previousBeta: number;
  39340. protected _previousRadius: number;
  39341. protected _collisionTriggered: boolean;
  39342. protected _targetBoundingCenter: Nullable<Vector3>;
  39343. private _computationVector;
  39344. /**
  39345. * Instantiates a new ArcRotateCamera in a given scene
  39346. * @param name Defines the name of the camera
  39347. * @param alpha Defines the camera rotation along the logitudinal axis
  39348. * @param beta Defines the camera rotation along the latitudinal axis
  39349. * @param radius Defines the camera distance from its target
  39350. * @param target Defines the camera target
  39351. * @param scene Defines the scene the camera belongs to
  39352. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39353. */
  39354. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39355. /** @hidden */
  39356. _initCache(): void;
  39357. /** @hidden */
  39358. _updateCache(ignoreParentClass?: boolean): void;
  39359. protected _getTargetPosition(): Vector3;
  39360. private _storedAlpha;
  39361. private _storedBeta;
  39362. private _storedRadius;
  39363. private _storedTarget;
  39364. private _storedTargetScreenOffset;
  39365. /**
  39366. * Stores the current state of the camera (alpha, beta, radius and target)
  39367. * @returns the camera itself
  39368. */
  39369. storeState(): Camera;
  39370. /**
  39371. * @hidden
  39372. * Restored camera state. You must call storeState() first
  39373. */
  39374. _restoreStateValues(): boolean;
  39375. /** @hidden */
  39376. _isSynchronizedViewMatrix(): boolean;
  39377. /**
  39378. * Attached controls to the current camera.
  39379. * @param element Defines the element the controls should be listened from
  39380. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39381. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39382. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39383. */
  39384. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39385. /**
  39386. * Detach the current controls from the camera.
  39387. * The camera will stop reacting to inputs.
  39388. * @param element Defines the element to stop listening the inputs from
  39389. */
  39390. detachControl(element: HTMLElement): void;
  39391. /** @hidden */
  39392. _checkInputs(): void;
  39393. protected _checkLimits(): void;
  39394. /**
  39395. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39396. */
  39397. rebuildAnglesAndRadius(): void;
  39398. /**
  39399. * Use a position to define the current camera related information like alpha, beta and radius
  39400. * @param position Defines the position to set the camera at
  39401. */
  39402. setPosition(position: Vector3): void;
  39403. /**
  39404. * Defines the target the camera should look at.
  39405. * This will automatically adapt alpha beta and radius to fit within the new target.
  39406. * @param target Defines the new target as a Vector or a mesh
  39407. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  39408. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39409. */
  39410. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39411. /** @hidden */
  39412. _getViewMatrix(): Matrix;
  39413. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39414. /**
  39415. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39416. * @param meshes Defines the mesh to zoom on
  39417. * @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)
  39418. */
  39419. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39420. /**
  39421. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39422. * The target will be changed but the radius
  39423. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39424. * @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)
  39425. */
  39426. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39427. min: Vector3;
  39428. max: Vector3;
  39429. distance: number;
  39430. }, doNotUpdateMaxZ?: boolean): void;
  39431. /**
  39432. * @override
  39433. * Override Camera.createRigCamera
  39434. */
  39435. createRigCamera(name: string, cameraIndex: number): Camera;
  39436. /**
  39437. * @hidden
  39438. * @override
  39439. * Override Camera._updateRigCameras
  39440. */
  39441. _updateRigCameras(): void;
  39442. /**
  39443. * Destroy the camera and release the current resources hold by it.
  39444. */
  39445. dispose(): void;
  39446. /**
  39447. * Gets the current object class name.
  39448. * @return the class name
  39449. */
  39450. getClassName(): string;
  39451. }
  39452. }
  39453. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  39454. import { Behavior } from "babylonjs/Behaviors/behavior";
  39455. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39456. /**
  39457. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39458. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39459. */
  39460. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39461. /**
  39462. * Gets the name of the behavior.
  39463. */
  39464. readonly name: string;
  39465. private _zoomStopsAnimation;
  39466. private _idleRotationSpeed;
  39467. private _idleRotationWaitTime;
  39468. private _idleRotationSpinupTime;
  39469. /**
  39470. * Sets the flag that indicates if user zooming should stop animation.
  39471. */
  39472. /**
  39473. * Gets the flag that indicates if user zooming should stop animation.
  39474. */
  39475. zoomStopsAnimation: boolean;
  39476. /**
  39477. * Sets the default speed at which the camera rotates around the model.
  39478. */
  39479. /**
  39480. * Gets the default speed at which the camera rotates around the model.
  39481. */
  39482. idleRotationSpeed: number;
  39483. /**
  39484. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39485. */
  39486. /**
  39487. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39488. */
  39489. idleRotationWaitTime: number;
  39490. /**
  39491. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39492. */
  39493. /**
  39494. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39495. */
  39496. idleRotationSpinupTime: number;
  39497. /**
  39498. * Gets a value indicating if the camera is currently rotating because of this behavior
  39499. */
  39500. readonly rotationInProgress: boolean;
  39501. private _onPrePointerObservableObserver;
  39502. private _onAfterCheckInputsObserver;
  39503. private _attachedCamera;
  39504. private _isPointerDown;
  39505. private _lastFrameTime;
  39506. private _lastInteractionTime;
  39507. private _cameraRotationSpeed;
  39508. /**
  39509. * Initializes the behavior.
  39510. */
  39511. init(): void;
  39512. /**
  39513. * Attaches the behavior to its arc rotate camera.
  39514. * @param camera Defines the camera to attach the behavior to
  39515. */
  39516. attach(camera: ArcRotateCamera): void;
  39517. /**
  39518. * Detaches the behavior from its current arc rotate camera.
  39519. */
  39520. detach(): void;
  39521. /**
  39522. * Returns true if user is scrolling.
  39523. * @return true if user is scrolling.
  39524. */
  39525. private _userIsZooming;
  39526. private _lastFrameRadius;
  39527. private _shouldAnimationStopForInteraction;
  39528. /**
  39529. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39530. */
  39531. private _applyUserInteraction;
  39532. private _userIsMoving;
  39533. }
  39534. }
  39535. declare module "babylonjs/Behaviors/Cameras/index" {
  39536. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39537. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39538. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  39539. }
  39540. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  39541. import { Mesh } from "babylonjs/Meshes/mesh";
  39542. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39543. import { Behavior } from "babylonjs/Behaviors/behavior";
  39544. /**
  39545. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39546. */
  39547. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39548. private ui;
  39549. /**
  39550. * The name of the behavior
  39551. */
  39552. name: string;
  39553. /**
  39554. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39555. */
  39556. distanceAwayFromFace: number;
  39557. /**
  39558. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39559. */
  39560. distanceAwayFromBottomOfFace: number;
  39561. private _faceVectors;
  39562. private _target;
  39563. private _scene;
  39564. private _onRenderObserver;
  39565. private _tmpMatrix;
  39566. private _tmpVector;
  39567. /**
  39568. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39569. * @param ui The transform node that should be attched to the mesh
  39570. */
  39571. constructor(ui: TransformNode);
  39572. /**
  39573. * Initializes the behavior
  39574. */
  39575. init(): void;
  39576. private _closestFace;
  39577. private _zeroVector;
  39578. private _lookAtTmpMatrix;
  39579. private _lookAtToRef;
  39580. /**
  39581. * Attaches the AttachToBoxBehavior to the passed in mesh
  39582. * @param target The mesh that the specified node will be attached to
  39583. */
  39584. attach(target: Mesh): void;
  39585. /**
  39586. * Detaches the behavior from the mesh
  39587. */
  39588. detach(): void;
  39589. }
  39590. }
  39591. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  39592. import { Behavior } from "babylonjs/Behaviors/behavior";
  39593. import { Mesh } from "babylonjs/Meshes/mesh";
  39594. /**
  39595. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39596. */
  39597. export class FadeInOutBehavior implements Behavior<Mesh> {
  39598. /**
  39599. * Time in milliseconds to delay before fading in (Default: 0)
  39600. */
  39601. delay: number;
  39602. /**
  39603. * Time in milliseconds for the mesh to fade in (Default: 300)
  39604. */
  39605. fadeInTime: number;
  39606. private _millisecondsPerFrame;
  39607. private _hovered;
  39608. private _hoverValue;
  39609. private _ownerNode;
  39610. /**
  39611. * Instatiates the FadeInOutBehavior
  39612. */
  39613. constructor();
  39614. /**
  39615. * The name of the behavior
  39616. */
  39617. readonly name: string;
  39618. /**
  39619. * Initializes the behavior
  39620. */
  39621. init(): void;
  39622. /**
  39623. * Attaches the fade behavior on the passed in mesh
  39624. * @param ownerNode The mesh that will be faded in/out once attached
  39625. */
  39626. attach(ownerNode: Mesh): void;
  39627. /**
  39628. * Detaches the behavior from the mesh
  39629. */
  39630. detach(): void;
  39631. /**
  39632. * Triggers the mesh to begin fading in or out
  39633. * @param value if the object should fade in or out (true to fade in)
  39634. */
  39635. fadeIn(value: boolean): void;
  39636. private _update;
  39637. private _setAllVisibility;
  39638. }
  39639. }
  39640. declare module "babylonjs/Misc/pivotTools" {
  39641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39642. /**
  39643. * Class containing a set of static utilities functions for managing Pivots
  39644. * @hidden
  39645. */
  39646. export class PivotTools {
  39647. private static _PivotCached;
  39648. private static _OldPivotPoint;
  39649. private static _PivotTranslation;
  39650. private static _PivotTmpVector;
  39651. /** @hidden */
  39652. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39653. /** @hidden */
  39654. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39655. }
  39656. }
  39657. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  39658. import { Scene } from "babylonjs/scene";
  39659. import { Vector4 } from "babylonjs/Maths/math.vector";
  39660. import { Mesh } from "babylonjs/Meshes/mesh";
  39661. import { Nullable } from "babylonjs/types";
  39662. import { Plane } from "babylonjs/Maths/math.plane";
  39663. /**
  39664. * Class containing static functions to help procedurally build meshes
  39665. */
  39666. export class PlaneBuilder {
  39667. /**
  39668. * Creates a plane mesh
  39669. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39670. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39671. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39672. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39673. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39675. * @param name defines the name of the mesh
  39676. * @param options defines the options used to create the mesh
  39677. * @param scene defines the hosting scene
  39678. * @returns the plane mesh
  39679. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39680. */
  39681. static CreatePlane(name: string, options: {
  39682. size?: number;
  39683. width?: number;
  39684. height?: number;
  39685. sideOrientation?: number;
  39686. frontUVs?: Vector4;
  39687. backUVs?: Vector4;
  39688. updatable?: boolean;
  39689. sourcePlane?: Plane;
  39690. }, scene?: Nullable<Scene>): Mesh;
  39691. }
  39692. }
  39693. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  39694. import { Behavior } from "babylonjs/Behaviors/behavior";
  39695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39696. import { Observable } from "babylonjs/Misc/observable";
  39697. import { Vector3 } from "babylonjs/Maths/math.vector";
  39698. import { Ray } from "babylonjs/Culling/ray";
  39699. import "babylonjs/Meshes/Builders/planeBuilder";
  39700. /**
  39701. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39702. */
  39703. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39704. private static _AnyMouseID;
  39705. /**
  39706. * Abstract mesh the behavior is set on
  39707. */
  39708. attachedNode: AbstractMesh;
  39709. private _dragPlane;
  39710. private _scene;
  39711. private _pointerObserver;
  39712. private _beforeRenderObserver;
  39713. private static _planeScene;
  39714. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39715. /**
  39716. * 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)
  39717. */
  39718. maxDragAngle: number;
  39719. /**
  39720. * @hidden
  39721. */
  39722. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39723. /**
  39724. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39725. */
  39726. currentDraggingPointerID: number;
  39727. /**
  39728. * The last position where the pointer hit the drag plane in world space
  39729. */
  39730. lastDragPosition: Vector3;
  39731. /**
  39732. * If the behavior is currently in a dragging state
  39733. */
  39734. dragging: boolean;
  39735. /**
  39736. * 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)
  39737. */
  39738. dragDeltaRatio: number;
  39739. /**
  39740. * If the drag plane orientation should be updated during the dragging (Default: true)
  39741. */
  39742. updateDragPlane: boolean;
  39743. private _debugMode;
  39744. private _moving;
  39745. /**
  39746. * Fires each time the attached mesh is dragged with the pointer
  39747. * * delta between last drag position and current drag position in world space
  39748. * * dragDistance along the drag axis
  39749. * * dragPlaneNormal normal of the current drag plane used during the drag
  39750. * * dragPlanePoint in world space where the drag intersects the drag plane
  39751. */
  39752. onDragObservable: Observable<{
  39753. delta: Vector3;
  39754. dragPlanePoint: Vector3;
  39755. dragPlaneNormal: Vector3;
  39756. dragDistance: number;
  39757. pointerId: number;
  39758. }>;
  39759. /**
  39760. * Fires each time a drag begins (eg. mouse down on mesh)
  39761. */
  39762. onDragStartObservable: Observable<{
  39763. dragPlanePoint: Vector3;
  39764. pointerId: number;
  39765. }>;
  39766. /**
  39767. * Fires each time a drag ends (eg. mouse release after drag)
  39768. */
  39769. onDragEndObservable: Observable<{
  39770. dragPlanePoint: Vector3;
  39771. pointerId: number;
  39772. }>;
  39773. /**
  39774. * If the attached mesh should be moved when dragged
  39775. */
  39776. moveAttached: boolean;
  39777. /**
  39778. * If the drag behavior will react to drag events (Default: true)
  39779. */
  39780. enabled: boolean;
  39781. /**
  39782. * If pointer events should start and release the drag (Default: true)
  39783. */
  39784. startAndReleaseDragOnPointerEvents: boolean;
  39785. /**
  39786. * If camera controls should be detached during the drag
  39787. */
  39788. detachCameraControls: boolean;
  39789. /**
  39790. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39791. */
  39792. useObjectOrienationForDragging: boolean;
  39793. private _options;
  39794. /**
  39795. * Gets the options used by the behavior
  39796. */
  39797. /**
  39798. * Sets the options used by the behavior
  39799. */
  39800. options: {
  39801. dragAxis?: Vector3;
  39802. dragPlaneNormal?: Vector3;
  39803. };
  39804. /**
  39805. * Creates a pointer drag behavior that can be attached to a mesh
  39806. * @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)
  39807. */
  39808. constructor(options?: {
  39809. dragAxis?: Vector3;
  39810. dragPlaneNormal?: Vector3;
  39811. });
  39812. /**
  39813. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39814. */
  39815. validateDrag: (targetPosition: Vector3) => boolean;
  39816. /**
  39817. * The name of the behavior
  39818. */
  39819. readonly name: string;
  39820. /**
  39821. * Initializes the behavior
  39822. */
  39823. init(): void;
  39824. private _tmpVector;
  39825. private _alternatePickedPoint;
  39826. private _worldDragAxis;
  39827. private _targetPosition;
  39828. private _attachedElement;
  39829. /**
  39830. * Attaches the drag behavior the passed in mesh
  39831. * @param ownerNode The mesh that will be dragged around once attached
  39832. * @param predicate Predicate to use for pick filtering
  39833. */
  39834. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39835. /**
  39836. * Force relase the drag action by code.
  39837. */
  39838. releaseDrag(): void;
  39839. private _startDragRay;
  39840. private _lastPointerRay;
  39841. /**
  39842. * Simulates the start of a pointer drag event on the behavior
  39843. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39844. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39845. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39846. */
  39847. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39848. private _startDrag;
  39849. private _dragDelta;
  39850. private _moveDrag;
  39851. private _pickWithRayOnDragPlane;
  39852. private _pointA;
  39853. private _pointB;
  39854. private _pointC;
  39855. private _lineA;
  39856. private _lineB;
  39857. private _localAxis;
  39858. private _lookAt;
  39859. private _updateDragPlanePosition;
  39860. /**
  39861. * Detaches the behavior from the mesh
  39862. */
  39863. detach(): void;
  39864. }
  39865. }
  39866. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  39867. import { Mesh } from "babylonjs/Meshes/mesh";
  39868. import { Behavior } from "babylonjs/Behaviors/behavior";
  39869. /**
  39870. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39871. */
  39872. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39873. private _dragBehaviorA;
  39874. private _dragBehaviorB;
  39875. private _startDistance;
  39876. private _initialScale;
  39877. private _targetScale;
  39878. private _ownerNode;
  39879. private _sceneRenderObserver;
  39880. /**
  39881. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39882. */
  39883. constructor();
  39884. /**
  39885. * The name of the behavior
  39886. */
  39887. readonly name: string;
  39888. /**
  39889. * Initializes the behavior
  39890. */
  39891. init(): void;
  39892. private _getCurrentDistance;
  39893. /**
  39894. * Attaches the scale behavior the passed in mesh
  39895. * @param ownerNode The mesh that will be scaled around once attached
  39896. */
  39897. attach(ownerNode: Mesh): void;
  39898. /**
  39899. * Detaches the behavior from the mesh
  39900. */
  39901. detach(): void;
  39902. }
  39903. }
  39904. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  39905. import { Behavior } from "babylonjs/Behaviors/behavior";
  39906. import { Mesh } from "babylonjs/Meshes/mesh";
  39907. import { Observable } from "babylonjs/Misc/observable";
  39908. /**
  39909. * 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
  39910. */
  39911. export class SixDofDragBehavior implements Behavior<Mesh> {
  39912. private static _virtualScene;
  39913. private _ownerNode;
  39914. private _sceneRenderObserver;
  39915. private _scene;
  39916. private _targetPosition;
  39917. private _virtualOriginMesh;
  39918. private _virtualDragMesh;
  39919. private _pointerObserver;
  39920. private _moving;
  39921. private _startingOrientation;
  39922. /**
  39923. * 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)
  39924. */
  39925. private zDragFactor;
  39926. /**
  39927. * If the object should rotate to face the drag origin
  39928. */
  39929. rotateDraggedObject: boolean;
  39930. /**
  39931. * If the behavior is currently in a dragging state
  39932. */
  39933. dragging: boolean;
  39934. /**
  39935. * 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)
  39936. */
  39937. dragDeltaRatio: number;
  39938. /**
  39939. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39940. */
  39941. currentDraggingPointerID: number;
  39942. /**
  39943. * If camera controls should be detached during the drag
  39944. */
  39945. detachCameraControls: boolean;
  39946. /**
  39947. * Fires each time a drag starts
  39948. */
  39949. onDragStartObservable: Observable<{}>;
  39950. /**
  39951. * Fires each time a drag ends (eg. mouse release after drag)
  39952. */
  39953. onDragEndObservable: Observable<{}>;
  39954. /**
  39955. * 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
  39956. */
  39957. constructor();
  39958. /**
  39959. * The name of the behavior
  39960. */
  39961. readonly name: string;
  39962. /**
  39963. * Initializes the behavior
  39964. */
  39965. init(): void;
  39966. /**
  39967. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39968. */
  39969. private readonly _pointerCamera;
  39970. /**
  39971. * Attaches the scale behavior the passed in mesh
  39972. * @param ownerNode The mesh that will be scaled around once attached
  39973. */
  39974. attach(ownerNode: Mesh): void;
  39975. /**
  39976. * Detaches the behavior from the mesh
  39977. */
  39978. detach(): void;
  39979. }
  39980. }
  39981. declare module "babylonjs/Behaviors/Meshes/index" {
  39982. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  39983. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  39984. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  39985. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  39986. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  39987. }
  39988. declare module "babylonjs/Behaviors/index" {
  39989. export * from "babylonjs/Behaviors/behavior";
  39990. export * from "babylonjs/Behaviors/Cameras/index";
  39991. export * from "babylonjs/Behaviors/Meshes/index";
  39992. }
  39993. declare module "babylonjs/Bones/boneIKController" {
  39994. import { Bone } from "babylonjs/Bones/bone";
  39995. import { Vector3 } from "babylonjs/Maths/math.vector";
  39996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39997. import { Nullable } from "babylonjs/types";
  39998. /**
  39999. * Class used to apply inverse kinematics to bones
  40000. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40001. */
  40002. export class BoneIKController {
  40003. private static _tmpVecs;
  40004. private static _tmpQuat;
  40005. private static _tmpMats;
  40006. /**
  40007. * Gets or sets the target mesh
  40008. */
  40009. targetMesh: AbstractMesh;
  40010. /** Gets or sets the mesh used as pole */
  40011. poleTargetMesh: AbstractMesh;
  40012. /**
  40013. * Gets or sets the bone used as pole
  40014. */
  40015. poleTargetBone: Nullable<Bone>;
  40016. /**
  40017. * Gets or sets the target position
  40018. */
  40019. targetPosition: Vector3;
  40020. /**
  40021. * Gets or sets the pole target position
  40022. */
  40023. poleTargetPosition: Vector3;
  40024. /**
  40025. * Gets or sets the pole target local offset
  40026. */
  40027. poleTargetLocalOffset: Vector3;
  40028. /**
  40029. * Gets or sets the pole angle
  40030. */
  40031. poleAngle: number;
  40032. /**
  40033. * Gets or sets the mesh associated with the controller
  40034. */
  40035. mesh: AbstractMesh;
  40036. /**
  40037. * 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)
  40038. */
  40039. slerpAmount: number;
  40040. private _bone1Quat;
  40041. private _bone1Mat;
  40042. private _bone2Ang;
  40043. private _bone1;
  40044. private _bone2;
  40045. private _bone1Length;
  40046. private _bone2Length;
  40047. private _maxAngle;
  40048. private _maxReach;
  40049. private _rightHandedSystem;
  40050. private _bendAxis;
  40051. private _slerping;
  40052. private _adjustRoll;
  40053. /**
  40054. * Gets or sets maximum allowed angle
  40055. */
  40056. maxAngle: number;
  40057. /**
  40058. * Creates a new BoneIKController
  40059. * @param mesh defines the mesh to control
  40060. * @param bone defines the bone to control
  40061. * @param options defines options to set up the controller
  40062. */
  40063. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40064. targetMesh?: AbstractMesh;
  40065. poleTargetMesh?: AbstractMesh;
  40066. poleTargetBone?: Bone;
  40067. poleTargetLocalOffset?: Vector3;
  40068. poleAngle?: number;
  40069. bendAxis?: Vector3;
  40070. maxAngle?: number;
  40071. slerpAmount?: number;
  40072. });
  40073. private _setMaxAngle;
  40074. /**
  40075. * Force the controller to update the bones
  40076. */
  40077. update(): void;
  40078. }
  40079. }
  40080. declare module "babylonjs/Bones/boneLookController" {
  40081. import { Vector3 } from "babylonjs/Maths/math.vector";
  40082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40083. import { Bone } from "babylonjs/Bones/bone";
  40084. import { Space } from "babylonjs/Maths/math.axis";
  40085. /**
  40086. * Class used to make a bone look toward a point in space
  40087. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40088. */
  40089. export class BoneLookController {
  40090. private static _tmpVecs;
  40091. private static _tmpQuat;
  40092. private static _tmpMats;
  40093. /**
  40094. * The target Vector3 that the bone will look at
  40095. */
  40096. target: Vector3;
  40097. /**
  40098. * The mesh that the bone is attached to
  40099. */
  40100. mesh: AbstractMesh;
  40101. /**
  40102. * The bone that will be looking to the target
  40103. */
  40104. bone: Bone;
  40105. /**
  40106. * The up axis of the coordinate system that is used when the bone is rotated
  40107. */
  40108. upAxis: Vector3;
  40109. /**
  40110. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40111. */
  40112. upAxisSpace: Space;
  40113. /**
  40114. * Used to make an adjustment to the yaw of the bone
  40115. */
  40116. adjustYaw: number;
  40117. /**
  40118. * Used to make an adjustment to the pitch of the bone
  40119. */
  40120. adjustPitch: number;
  40121. /**
  40122. * Used to make an adjustment to the roll of the bone
  40123. */
  40124. adjustRoll: number;
  40125. /**
  40126. * 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)
  40127. */
  40128. slerpAmount: number;
  40129. private _minYaw;
  40130. private _maxYaw;
  40131. private _minPitch;
  40132. private _maxPitch;
  40133. private _minYawSin;
  40134. private _minYawCos;
  40135. private _maxYawSin;
  40136. private _maxYawCos;
  40137. private _midYawConstraint;
  40138. private _minPitchTan;
  40139. private _maxPitchTan;
  40140. private _boneQuat;
  40141. private _slerping;
  40142. private _transformYawPitch;
  40143. private _transformYawPitchInv;
  40144. private _firstFrameSkipped;
  40145. private _yawRange;
  40146. private _fowardAxis;
  40147. /**
  40148. * Gets or sets the minimum yaw angle that the bone can look to
  40149. */
  40150. minYaw: number;
  40151. /**
  40152. * Gets or sets the maximum yaw angle that the bone can look to
  40153. */
  40154. maxYaw: number;
  40155. /**
  40156. * Gets or sets the minimum pitch angle that the bone can look to
  40157. */
  40158. minPitch: number;
  40159. /**
  40160. * Gets or sets the maximum pitch angle that the bone can look to
  40161. */
  40162. maxPitch: number;
  40163. /**
  40164. * Create a BoneLookController
  40165. * @param mesh the mesh that the bone belongs to
  40166. * @param bone the bone that will be looking to the target
  40167. * @param target the target Vector3 to look at
  40168. * @param options optional settings:
  40169. * * maxYaw: the maximum angle the bone will yaw to
  40170. * * minYaw: the minimum angle the bone will yaw to
  40171. * * maxPitch: the maximum angle the bone will pitch to
  40172. * * minPitch: the minimum angle the bone will yaw to
  40173. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40174. * * upAxis: the up axis of the coordinate system
  40175. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40176. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40177. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40178. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40179. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40180. * * adjustRoll: used to make an adjustment to the roll of the bone
  40181. **/
  40182. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40183. maxYaw?: number;
  40184. minYaw?: number;
  40185. maxPitch?: number;
  40186. minPitch?: number;
  40187. slerpAmount?: number;
  40188. upAxis?: Vector3;
  40189. upAxisSpace?: Space;
  40190. yawAxis?: Vector3;
  40191. pitchAxis?: Vector3;
  40192. adjustYaw?: number;
  40193. adjustPitch?: number;
  40194. adjustRoll?: number;
  40195. });
  40196. /**
  40197. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40198. */
  40199. update(): void;
  40200. private _getAngleDiff;
  40201. private _getAngleBetween;
  40202. private _isAngleBetween;
  40203. }
  40204. }
  40205. declare module "babylonjs/Bones/index" {
  40206. export * from "babylonjs/Bones/bone";
  40207. export * from "babylonjs/Bones/boneIKController";
  40208. export * from "babylonjs/Bones/boneLookController";
  40209. export * from "babylonjs/Bones/skeleton";
  40210. }
  40211. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40212. import { Nullable } from "babylonjs/types";
  40213. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40214. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40215. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40216. /**
  40217. * Manage the gamepad inputs to control an arc rotate camera.
  40218. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40219. */
  40220. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40221. /**
  40222. * Defines the camera the input is attached to.
  40223. */
  40224. camera: ArcRotateCamera;
  40225. /**
  40226. * Defines the gamepad the input is gathering event from.
  40227. */
  40228. gamepad: Nullable<Gamepad>;
  40229. /**
  40230. * Defines the gamepad rotation sensiblity.
  40231. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40232. */
  40233. gamepadRotationSensibility: number;
  40234. /**
  40235. * Defines the gamepad move sensiblity.
  40236. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40237. */
  40238. gamepadMoveSensibility: number;
  40239. private _yAxisScale;
  40240. /**
  40241. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40242. */
  40243. invertYAxis: boolean;
  40244. private _onGamepadConnectedObserver;
  40245. private _onGamepadDisconnectedObserver;
  40246. /**
  40247. * Attach the input controls to a specific dom element to get the input from.
  40248. * @param element Defines the element the controls should be listened from
  40249. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40250. */
  40251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40252. /**
  40253. * Detach the current controls from the specified dom element.
  40254. * @param element Defines the element to stop listening the inputs from
  40255. */
  40256. detachControl(element: Nullable<HTMLElement>): void;
  40257. /**
  40258. * Update the current camera state depending on the inputs that have been used this frame.
  40259. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40260. */
  40261. checkInputs(): void;
  40262. /**
  40263. * Gets the class name of the current intput.
  40264. * @returns the class name
  40265. */
  40266. getClassName(): string;
  40267. /**
  40268. * Get the friendly name associated with the input class.
  40269. * @returns the input friendly name
  40270. */
  40271. getSimpleName(): string;
  40272. }
  40273. }
  40274. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40275. import { Nullable } from "babylonjs/types";
  40276. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40277. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40278. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40279. interface ArcRotateCameraInputsManager {
  40280. /**
  40281. * Add orientation input support to the input manager.
  40282. * @returns the current input manager
  40283. */
  40284. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40285. }
  40286. }
  40287. /**
  40288. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40289. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40290. */
  40291. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40292. /**
  40293. * Defines the camera the input is attached to.
  40294. */
  40295. camera: ArcRotateCamera;
  40296. /**
  40297. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40298. */
  40299. alphaCorrection: number;
  40300. /**
  40301. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40302. */
  40303. gammaCorrection: number;
  40304. private _alpha;
  40305. private _gamma;
  40306. private _dirty;
  40307. private _deviceOrientationHandler;
  40308. /**
  40309. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40310. */
  40311. constructor();
  40312. /**
  40313. * Attach the input controls to a specific dom element to get the input from.
  40314. * @param element Defines the element the controls should be listened from
  40315. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40316. */
  40317. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40318. /** @hidden */
  40319. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40320. /**
  40321. * Update the current camera state depending on the inputs that have been used this frame.
  40322. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40323. */
  40324. checkInputs(): void;
  40325. /**
  40326. * Detach the current controls from the specified dom element.
  40327. * @param element Defines the element to stop listening the inputs from
  40328. */
  40329. detachControl(element: Nullable<HTMLElement>): void;
  40330. /**
  40331. * Gets the class name of the current intput.
  40332. * @returns the class name
  40333. */
  40334. getClassName(): string;
  40335. /**
  40336. * Get the friendly name associated with the input class.
  40337. * @returns the input friendly name
  40338. */
  40339. getSimpleName(): string;
  40340. }
  40341. }
  40342. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40343. import { Nullable } from "babylonjs/types";
  40344. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40345. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40346. /**
  40347. * Listen to mouse events to control the camera.
  40348. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40349. */
  40350. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40351. /**
  40352. * Defines the camera the input is attached to.
  40353. */
  40354. camera: FlyCamera;
  40355. /**
  40356. * Defines if touch is enabled. (Default is true.)
  40357. */
  40358. touchEnabled: boolean;
  40359. /**
  40360. * Defines the buttons associated with the input to handle camera rotation.
  40361. */
  40362. buttons: number[];
  40363. /**
  40364. * Assign buttons for Yaw control.
  40365. */
  40366. buttonsYaw: number[];
  40367. /**
  40368. * Assign buttons for Pitch control.
  40369. */
  40370. buttonsPitch: number[];
  40371. /**
  40372. * Assign buttons for Roll control.
  40373. */
  40374. buttonsRoll: number[];
  40375. /**
  40376. * Detect if any button is being pressed while mouse is moved.
  40377. * -1 = Mouse locked.
  40378. * 0 = Left button.
  40379. * 1 = Middle Button.
  40380. * 2 = Right Button.
  40381. */
  40382. activeButton: number;
  40383. /**
  40384. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40385. * Higher values reduce its sensitivity.
  40386. */
  40387. angularSensibility: number;
  40388. private _mousemoveCallback;
  40389. private _observer;
  40390. private _rollObserver;
  40391. private previousPosition;
  40392. private noPreventDefault;
  40393. private element;
  40394. /**
  40395. * Listen to mouse events to control the camera.
  40396. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40397. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40398. */
  40399. constructor(touchEnabled?: boolean);
  40400. /**
  40401. * Attach the mouse control to the HTML DOM element.
  40402. * @param element Defines the element that listens to the input events.
  40403. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40404. */
  40405. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40406. /**
  40407. * Detach the current controls from the specified dom element.
  40408. * @param element Defines the element to stop listening the inputs from
  40409. */
  40410. detachControl(element: Nullable<HTMLElement>): void;
  40411. /**
  40412. * Gets the class name of the current input.
  40413. * @returns the class name.
  40414. */
  40415. getClassName(): string;
  40416. /**
  40417. * Get the friendly name associated with the input class.
  40418. * @returns the input's friendly name.
  40419. */
  40420. getSimpleName(): string;
  40421. private _pointerInput;
  40422. private _onMouseMove;
  40423. /**
  40424. * Rotate camera by mouse offset.
  40425. */
  40426. private rotateCamera;
  40427. }
  40428. }
  40429. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  40430. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40431. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40432. /**
  40433. * Default Inputs manager for the FlyCamera.
  40434. * It groups all the default supported inputs for ease of use.
  40435. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40436. */
  40437. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40438. /**
  40439. * Instantiates a new FlyCameraInputsManager.
  40440. * @param camera Defines the camera the inputs belong to.
  40441. */
  40442. constructor(camera: FlyCamera);
  40443. /**
  40444. * Add keyboard input support to the input manager.
  40445. * @returns the new FlyCameraKeyboardMoveInput().
  40446. */
  40447. addKeyboard(): FlyCameraInputsManager;
  40448. /**
  40449. * Add mouse input support to the input manager.
  40450. * @param touchEnabled Enable touch screen support.
  40451. * @returns the new FlyCameraMouseInput().
  40452. */
  40453. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40454. }
  40455. }
  40456. declare module "babylonjs/Cameras/flyCamera" {
  40457. import { Scene } from "babylonjs/scene";
  40458. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  40459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40460. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40461. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  40462. /**
  40463. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40464. * such as in a 3D Space Shooter or a Flight Simulator.
  40465. */
  40466. export class FlyCamera extends TargetCamera {
  40467. /**
  40468. * Define the collision ellipsoid of the camera.
  40469. * This is helpful for simulating a camera body, like a player's body.
  40470. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40471. */
  40472. ellipsoid: Vector3;
  40473. /**
  40474. * Define an offset for the position of the ellipsoid around the camera.
  40475. * This can be helpful if the camera is attached away from the player's body center,
  40476. * such as at its head.
  40477. */
  40478. ellipsoidOffset: Vector3;
  40479. /**
  40480. * Enable or disable collisions of the camera with the rest of the scene objects.
  40481. */
  40482. checkCollisions: boolean;
  40483. /**
  40484. * Enable or disable gravity on the camera.
  40485. */
  40486. applyGravity: boolean;
  40487. /**
  40488. * Define the current direction the camera is moving to.
  40489. */
  40490. cameraDirection: Vector3;
  40491. /**
  40492. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40493. * This overrides and empties cameraRotation.
  40494. */
  40495. rotationQuaternion: Quaternion;
  40496. /**
  40497. * Track Roll to maintain the wanted Rolling when looking around.
  40498. */
  40499. _trackRoll: number;
  40500. /**
  40501. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40502. */
  40503. rollCorrect: number;
  40504. /**
  40505. * Mimic a banked turn, Rolling the camera when Yawing.
  40506. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40507. */
  40508. bankedTurn: boolean;
  40509. /**
  40510. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40511. */
  40512. bankedTurnLimit: number;
  40513. /**
  40514. * Value of 0 disables the banked Roll.
  40515. * Value of 1 is equal to the Yaw angle in radians.
  40516. */
  40517. bankedTurnMultiplier: number;
  40518. /**
  40519. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40520. */
  40521. inputs: FlyCameraInputsManager;
  40522. /**
  40523. * Gets the input sensibility for mouse input.
  40524. * Higher values reduce sensitivity.
  40525. */
  40526. /**
  40527. * Sets the input sensibility for a mouse input.
  40528. * Higher values reduce sensitivity.
  40529. */
  40530. angularSensibility: number;
  40531. /**
  40532. * Get the keys for camera movement forward.
  40533. */
  40534. /**
  40535. * Set the keys for camera movement forward.
  40536. */
  40537. keysForward: number[];
  40538. /**
  40539. * Get the keys for camera movement backward.
  40540. */
  40541. keysBackward: number[];
  40542. /**
  40543. * Get the keys for camera movement up.
  40544. */
  40545. /**
  40546. * Set the keys for camera movement up.
  40547. */
  40548. keysUp: number[];
  40549. /**
  40550. * Get the keys for camera movement down.
  40551. */
  40552. /**
  40553. * Set the keys for camera movement down.
  40554. */
  40555. keysDown: number[];
  40556. /**
  40557. * Get the keys for camera movement left.
  40558. */
  40559. /**
  40560. * Set the keys for camera movement left.
  40561. */
  40562. keysLeft: number[];
  40563. /**
  40564. * Set the keys for camera movement right.
  40565. */
  40566. /**
  40567. * Set the keys for camera movement right.
  40568. */
  40569. keysRight: number[];
  40570. /**
  40571. * Event raised when the camera collides with a mesh in the scene.
  40572. */
  40573. onCollide: (collidedMesh: AbstractMesh) => void;
  40574. private _collider;
  40575. private _needMoveForGravity;
  40576. private _oldPosition;
  40577. private _diffPosition;
  40578. private _newPosition;
  40579. /** @hidden */
  40580. _localDirection: Vector3;
  40581. /** @hidden */
  40582. _transformedDirection: Vector3;
  40583. /**
  40584. * Instantiates a FlyCamera.
  40585. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40586. * such as in a 3D Space Shooter or a Flight Simulator.
  40587. * @param name Define the name of the camera in the scene.
  40588. * @param position Define the starting position of the camera in the scene.
  40589. * @param scene Define the scene the camera belongs to.
  40590. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40591. */
  40592. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40593. /**
  40594. * Attach a control to the HTML DOM element.
  40595. * @param element Defines the element that listens to the input events.
  40596. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40597. */
  40598. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40599. /**
  40600. * Detach a control from the HTML DOM element.
  40601. * The camera will stop reacting to that input.
  40602. * @param element Defines the element that listens to the input events.
  40603. */
  40604. detachControl(element: HTMLElement): void;
  40605. private _collisionMask;
  40606. /**
  40607. * Get the mask that the camera ignores in collision events.
  40608. */
  40609. /**
  40610. * Set the mask that the camera ignores in collision events.
  40611. */
  40612. collisionMask: number;
  40613. /** @hidden */
  40614. _collideWithWorld(displacement: Vector3): void;
  40615. /** @hidden */
  40616. private _onCollisionPositionChange;
  40617. /** @hidden */
  40618. _checkInputs(): void;
  40619. /** @hidden */
  40620. _decideIfNeedsToMove(): boolean;
  40621. /** @hidden */
  40622. _updatePosition(): void;
  40623. /**
  40624. * Restore the Roll to its target value at the rate specified.
  40625. * @param rate - Higher means slower restoring.
  40626. * @hidden
  40627. */
  40628. restoreRoll(rate: number): void;
  40629. /**
  40630. * Destroy the camera and release the current resources held by it.
  40631. */
  40632. dispose(): void;
  40633. /**
  40634. * Get the current object class name.
  40635. * @returns the class name.
  40636. */
  40637. getClassName(): string;
  40638. }
  40639. }
  40640. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  40641. import { Nullable } from "babylonjs/types";
  40642. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40643. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40644. /**
  40645. * Listen to keyboard events to control the camera.
  40646. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40647. */
  40648. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40649. /**
  40650. * Defines the camera the input is attached to.
  40651. */
  40652. camera: FlyCamera;
  40653. /**
  40654. * The list of keyboard keys used to control the forward move of the camera.
  40655. */
  40656. keysForward: number[];
  40657. /**
  40658. * The list of keyboard keys used to control the backward move of the camera.
  40659. */
  40660. keysBackward: number[];
  40661. /**
  40662. * The list of keyboard keys used to control the forward move of the camera.
  40663. */
  40664. keysUp: number[];
  40665. /**
  40666. * The list of keyboard keys used to control the backward move of the camera.
  40667. */
  40668. keysDown: number[];
  40669. /**
  40670. * The list of keyboard keys used to control the right strafe move of the camera.
  40671. */
  40672. keysRight: number[];
  40673. /**
  40674. * The list of keyboard keys used to control the left strafe move of the camera.
  40675. */
  40676. keysLeft: number[];
  40677. private _keys;
  40678. private _onCanvasBlurObserver;
  40679. private _onKeyboardObserver;
  40680. private _engine;
  40681. private _scene;
  40682. /**
  40683. * Attach the input controls to a specific dom element to get the input from.
  40684. * @param element Defines the element the controls should be listened from
  40685. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40686. */
  40687. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40688. /**
  40689. * Detach the current controls from the specified dom element.
  40690. * @param element Defines the element to stop listening the inputs from
  40691. */
  40692. detachControl(element: Nullable<HTMLElement>): void;
  40693. /**
  40694. * Gets the class name of the current intput.
  40695. * @returns the class name
  40696. */
  40697. getClassName(): string;
  40698. /** @hidden */
  40699. _onLostFocus(e: FocusEvent): void;
  40700. /**
  40701. * Get the friendly name associated with the input class.
  40702. * @returns the input friendly name
  40703. */
  40704. getSimpleName(): string;
  40705. /**
  40706. * Update the current camera state depending on the inputs that have been used this frame.
  40707. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40708. */
  40709. checkInputs(): void;
  40710. }
  40711. }
  40712. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  40713. import { Nullable } from "babylonjs/types";
  40714. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40715. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40716. /**
  40717. * Manage the mouse wheel inputs to control a follow camera.
  40718. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40719. */
  40720. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40721. /**
  40722. * Defines the camera the input is attached to.
  40723. */
  40724. camera: FollowCamera;
  40725. /**
  40726. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40727. */
  40728. axisControlRadius: boolean;
  40729. /**
  40730. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40731. */
  40732. axisControlHeight: boolean;
  40733. /**
  40734. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40735. */
  40736. axisControlRotation: boolean;
  40737. /**
  40738. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40739. * relation to mouseWheel events.
  40740. */
  40741. wheelPrecision: number;
  40742. /**
  40743. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40744. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40745. */
  40746. wheelDeltaPercentage: number;
  40747. private _wheel;
  40748. private _observer;
  40749. /**
  40750. * Attach the input controls to a specific dom element to get the input from.
  40751. * @param element Defines the element the controls should be listened from
  40752. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40753. */
  40754. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40755. /**
  40756. * Detach the current controls from the specified dom element.
  40757. * @param element Defines the element to stop listening the inputs from
  40758. */
  40759. detachControl(element: Nullable<HTMLElement>): void;
  40760. /**
  40761. * Gets the class name of the current intput.
  40762. * @returns the class name
  40763. */
  40764. getClassName(): string;
  40765. /**
  40766. * Get the friendly name associated with the input class.
  40767. * @returns the input friendly name
  40768. */
  40769. getSimpleName(): string;
  40770. }
  40771. }
  40772. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  40773. import { Nullable } from "babylonjs/types";
  40774. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40775. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  40776. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  40777. /**
  40778. * Manage the pointers inputs to control an follow camera.
  40779. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40780. */
  40781. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40782. /**
  40783. * Defines the camera the input is attached to.
  40784. */
  40785. camera: FollowCamera;
  40786. /**
  40787. * Gets the class name of the current input.
  40788. * @returns the class name
  40789. */
  40790. getClassName(): string;
  40791. /**
  40792. * Defines the pointer angular sensibility along the X axis or how fast is
  40793. * the camera rotating.
  40794. * A negative number will reverse the axis direction.
  40795. */
  40796. angularSensibilityX: number;
  40797. /**
  40798. * Defines the pointer angular sensibility along the Y axis or how fast is
  40799. * the camera rotating.
  40800. * A negative number will reverse the axis direction.
  40801. */
  40802. angularSensibilityY: number;
  40803. /**
  40804. * Defines the pointer pinch precision or how fast is the camera zooming.
  40805. * A negative number will reverse the axis direction.
  40806. */
  40807. pinchPrecision: number;
  40808. /**
  40809. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40810. * from 0.
  40811. * It defines the percentage of current camera.radius to use as delta when
  40812. * pinch zoom is used.
  40813. */
  40814. pinchDeltaPercentage: number;
  40815. /**
  40816. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40817. */
  40818. axisXControlRadius: boolean;
  40819. /**
  40820. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40821. */
  40822. axisXControlHeight: boolean;
  40823. /**
  40824. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40825. */
  40826. axisXControlRotation: boolean;
  40827. /**
  40828. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40829. */
  40830. axisYControlRadius: boolean;
  40831. /**
  40832. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40833. */
  40834. axisYControlHeight: boolean;
  40835. /**
  40836. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40837. */
  40838. axisYControlRotation: boolean;
  40839. /**
  40840. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40841. */
  40842. axisPinchControlRadius: boolean;
  40843. /**
  40844. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40845. */
  40846. axisPinchControlHeight: boolean;
  40847. /**
  40848. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40849. */
  40850. axisPinchControlRotation: boolean;
  40851. /**
  40852. * Log error messages if basic misconfiguration has occurred.
  40853. */
  40854. warningEnable: boolean;
  40855. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40856. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40857. private _warningCounter;
  40858. private _warning;
  40859. }
  40860. }
  40861. declare module "babylonjs/Cameras/followCameraInputsManager" {
  40862. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40863. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40864. /**
  40865. * Default Inputs manager for the FollowCamera.
  40866. * It groups all the default supported inputs for ease of use.
  40867. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40868. */
  40869. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40870. /**
  40871. * Instantiates a new FollowCameraInputsManager.
  40872. * @param camera Defines the camera the inputs belong to
  40873. */
  40874. constructor(camera: FollowCamera);
  40875. /**
  40876. * Add keyboard input support to the input manager.
  40877. * @returns the current input manager
  40878. */
  40879. addKeyboard(): FollowCameraInputsManager;
  40880. /**
  40881. * Add mouse wheel input support to the input manager.
  40882. * @returns the current input manager
  40883. */
  40884. addMouseWheel(): FollowCameraInputsManager;
  40885. /**
  40886. * Add pointers input support to the input manager.
  40887. * @returns the current input manager
  40888. */
  40889. addPointers(): FollowCameraInputsManager;
  40890. /**
  40891. * Add orientation input support to the input manager.
  40892. * @returns the current input manager
  40893. */
  40894. addVRDeviceOrientation(): FollowCameraInputsManager;
  40895. }
  40896. }
  40897. declare module "babylonjs/Cameras/followCamera" {
  40898. import { Nullable } from "babylonjs/types";
  40899. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40900. import { Scene } from "babylonjs/scene";
  40901. import { Vector3 } from "babylonjs/Maths/math.vector";
  40902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40903. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  40904. /**
  40905. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40906. * an arc rotate version arcFollowCamera are available.
  40907. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40908. */
  40909. export class FollowCamera extends TargetCamera {
  40910. /**
  40911. * Distance the follow camera should follow an object at
  40912. */
  40913. radius: number;
  40914. /**
  40915. * Minimum allowed distance of the camera to the axis of rotation
  40916. * (The camera can not get closer).
  40917. * This can help limiting how the Camera is able to move in the scene.
  40918. */
  40919. lowerRadiusLimit: Nullable<number>;
  40920. /**
  40921. * Maximum allowed distance of the camera to the axis of rotation
  40922. * (The camera can not get further).
  40923. * This can help limiting how the Camera is able to move in the scene.
  40924. */
  40925. upperRadiusLimit: Nullable<number>;
  40926. /**
  40927. * Define a rotation offset between the camera and the object it follows
  40928. */
  40929. rotationOffset: number;
  40930. /**
  40931. * Minimum allowed angle to camera position relative to target object.
  40932. * This can help limiting how the Camera is able to move in the scene.
  40933. */
  40934. lowerRotationOffsetLimit: Nullable<number>;
  40935. /**
  40936. * Maximum allowed angle to camera position relative to target object.
  40937. * This can help limiting how the Camera is able to move in the scene.
  40938. */
  40939. upperRotationOffsetLimit: Nullable<number>;
  40940. /**
  40941. * Define a height offset between the camera and the object it follows.
  40942. * It can help following an object from the top (like a car chaing a plane)
  40943. */
  40944. heightOffset: number;
  40945. /**
  40946. * Minimum allowed height of camera position relative to target object.
  40947. * This can help limiting how the Camera is able to move in the scene.
  40948. */
  40949. lowerHeightOffsetLimit: Nullable<number>;
  40950. /**
  40951. * Maximum allowed height of camera position relative to target object.
  40952. * This can help limiting how the Camera is able to move in the scene.
  40953. */
  40954. upperHeightOffsetLimit: Nullable<number>;
  40955. /**
  40956. * Define how fast the camera can accelerate to follow it s target.
  40957. */
  40958. cameraAcceleration: number;
  40959. /**
  40960. * Define the speed limit of the camera following an object.
  40961. */
  40962. maxCameraSpeed: number;
  40963. /**
  40964. * Define the target of the camera.
  40965. */
  40966. lockedTarget: Nullable<AbstractMesh>;
  40967. /**
  40968. * Defines the input associated with the camera.
  40969. */
  40970. inputs: FollowCameraInputsManager;
  40971. /**
  40972. * Instantiates the follow camera.
  40973. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40974. * @param name Define the name of the camera in the scene
  40975. * @param position Define the position of the camera
  40976. * @param scene Define the scene the camera belong to
  40977. * @param lockedTarget Define the target of the camera
  40978. */
  40979. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40980. private _follow;
  40981. /**
  40982. * Attached controls to the current camera.
  40983. * @param element Defines the element the controls should be listened from
  40984. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40985. */
  40986. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40987. /**
  40988. * Detach the current controls from the camera.
  40989. * The camera will stop reacting to inputs.
  40990. * @param element Defines the element to stop listening the inputs from
  40991. */
  40992. detachControl(element: HTMLElement): void;
  40993. /** @hidden */
  40994. _checkInputs(): void;
  40995. private _checkLimits;
  40996. /**
  40997. * Gets the camera class name.
  40998. * @returns the class name
  40999. */
  41000. getClassName(): string;
  41001. }
  41002. /**
  41003. * Arc Rotate version of the follow camera.
  41004. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41005. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41006. */
  41007. export class ArcFollowCamera extends TargetCamera {
  41008. /** The longitudinal angle of the camera */
  41009. alpha: number;
  41010. /** The latitudinal angle of the camera */
  41011. beta: number;
  41012. /** The radius of the camera from its target */
  41013. radius: number;
  41014. /** Define the camera target (the messh it should follow) */
  41015. target: Nullable<AbstractMesh>;
  41016. private _cartesianCoordinates;
  41017. /**
  41018. * Instantiates a new ArcFollowCamera
  41019. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41020. * @param name Define the name of the camera
  41021. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41022. * @param beta Define the rotation angle of the camera around the elevation axis
  41023. * @param radius Define the radius of the camera from its target point
  41024. * @param target Define the target of the camera
  41025. * @param scene Define the scene the camera belongs to
  41026. */
  41027. constructor(name: string,
  41028. /** The longitudinal angle of the camera */
  41029. alpha: number,
  41030. /** The latitudinal angle of the camera */
  41031. beta: number,
  41032. /** The radius of the camera from its target */
  41033. radius: number,
  41034. /** Define the camera target (the messh it should follow) */
  41035. target: Nullable<AbstractMesh>, scene: Scene);
  41036. private _follow;
  41037. /** @hidden */
  41038. _checkInputs(): void;
  41039. /**
  41040. * Returns the class name of the object.
  41041. * It is mostly used internally for serialization purposes.
  41042. */
  41043. getClassName(): string;
  41044. }
  41045. }
  41046. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41047. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41048. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41049. import { Nullable } from "babylonjs/types";
  41050. /**
  41051. * Manage the keyboard inputs to control the movement of a follow camera.
  41052. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41053. */
  41054. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41055. /**
  41056. * Defines the camera the input is attached to.
  41057. */
  41058. camera: FollowCamera;
  41059. /**
  41060. * Defines the list of key codes associated with the up action (increase heightOffset)
  41061. */
  41062. keysHeightOffsetIncr: number[];
  41063. /**
  41064. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41065. */
  41066. keysHeightOffsetDecr: number[];
  41067. /**
  41068. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41069. */
  41070. keysHeightOffsetModifierAlt: boolean;
  41071. /**
  41072. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41073. */
  41074. keysHeightOffsetModifierCtrl: boolean;
  41075. /**
  41076. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41077. */
  41078. keysHeightOffsetModifierShift: boolean;
  41079. /**
  41080. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41081. */
  41082. keysRotationOffsetIncr: number[];
  41083. /**
  41084. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41085. */
  41086. keysRotationOffsetDecr: number[];
  41087. /**
  41088. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41089. */
  41090. keysRotationOffsetModifierAlt: boolean;
  41091. /**
  41092. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41093. */
  41094. keysRotationOffsetModifierCtrl: boolean;
  41095. /**
  41096. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41097. */
  41098. keysRotationOffsetModifierShift: boolean;
  41099. /**
  41100. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41101. */
  41102. keysRadiusIncr: number[];
  41103. /**
  41104. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41105. */
  41106. keysRadiusDecr: number[];
  41107. /**
  41108. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41109. */
  41110. keysRadiusModifierAlt: boolean;
  41111. /**
  41112. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41113. */
  41114. keysRadiusModifierCtrl: boolean;
  41115. /**
  41116. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41117. */
  41118. keysRadiusModifierShift: boolean;
  41119. /**
  41120. * Defines the rate of change of heightOffset.
  41121. */
  41122. heightSensibility: number;
  41123. /**
  41124. * Defines the rate of change of rotationOffset.
  41125. */
  41126. rotationSensibility: number;
  41127. /**
  41128. * Defines the rate of change of radius.
  41129. */
  41130. radiusSensibility: number;
  41131. private _keys;
  41132. private _ctrlPressed;
  41133. private _altPressed;
  41134. private _shiftPressed;
  41135. private _onCanvasBlurObserver;
  41136. private _onKeyboardObserver;
  41137. private _engine;
  41138. private _scene;
  41139. /**
  41140. * Attach the input controls to a specific dom element to get the input from.
  41141. * @param element Defines the element the controls should be listened from
  41142. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41143. */
  41144. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41145. /**
  41146. * Detach the current controls from the specified dom element.
  41147. * @param element Defines the element to stop listening the inputs from
  41148. */
  41149. detachControl(element: Nullable<HTMLElement>): void;
  41150. /**
  41151. * Update the current camera state depending on the inputs that have been used this frame.
  41152. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41153. */
  41154. checkInputs(): void;
  41155. /**
  41156. * Gets the class name of the current input.
  41157. * @returns the class name
  41158. */
  41159. getClassName(): string;
  41160. /**
  41161. * Get the friendly name associated with the input class.
  41162. * @returns the input friendly name
  41163. */
  41164. getSimpleName(): string;
  41165. /**
  41166. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41167. * allow modification of the heightOffset value.
  41168. */
  41169. private _modifierHeightOffset;
  41170. /**
  41171. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41172. * allow modification of the rotationOffset value.
  41173. */
  41174. private _modifierRotationOffset;
  41175. /**
  41176. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41177. * allow modification of the radius value.
  41178. */
  41179. private _modifierRadius;
  41180. }
  41181. }
  41182. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41183. import { Nullable } from "babylonjs/types";
  41184. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41185. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41186. import { Observable } from "babylonjs/Misc/observable";
  41187. module "babylonjs/Cameras/freeCameraInputsManager" {
  41188. interface FreeCameraInputsManager {
  41189. /**
  41190. * @hidden
  41191. */
  41192. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41193. /**
  41194. * Add orientation input support to the input manager.
  41195. * @returns the current input manager
  41196. */
  41197. addDeviceOrientation(): FreeCameraInputsManager;
  41198. }
  41199. }
  41200. /**
  41201. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41202. * Screen rotation is taken into account.
  41203. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41204. */
  41205. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41206. private _camera;
  41207. private _screenOrientationAngle;
  41208. private _constantTranform;
  41209. private _screenQuaternion;
  41210. private _alpha;
  41211. private _beta;
  41212. private _gamma;
  41213. /**
  41214. * Can be used to detect if a device orientation sensor is available on a device
  41215. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41216. * @returns a promise that will resolve on orientation change
  41217. */
  41218. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41219. /**
  41220. * @hidden
  41221. */
  41222. _onDeviceOrientationChangedObservable: Observable<void>;
  41223. /**
  41224. * Instantiates a new input
  41225. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41226. */
  41227. constructor();
  41228. /**
  41229. * Define the camera controlled by the input.
  41230. */
  41231. camera: FreeCamera;
  41232. /**
  41233. * Attach the input controls to a specific dom element to get the input from.
  41234. * @param element Defines the element the controls should be listened from
  41235. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41236. */
  41237. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41238. private _orientationChanged;
  41239. private _deviceOrientation;
  41240. /**
  41241. * Detach the current controls from the specified dom element.
  41242. * @param element Defines the element to stop listening the inputs from
  41243. */
  41244. detachControl(element: Nullable<HTMLElement>): void;
  41245. /**
  41246. * Update the current camera state depending on the inputs that have been used this frame.
  41247. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41248. */
  41249. checkInputs(): void;
  41250. /**
  41251. * Gets the class name of the current intput.
  41252. * @returns the class name
  41253. */
  41254. getClassName(): string;
  41255. /**
  41256. * Get the friendly name associated with the input class.
  41257. * @returns the input friendly name
  41258. */
  41259. getSimpleName(): string;
  41260. }
  41261. }
  41262. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41263. import { Nullable } from "babylonjs/types";
  41264. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41265. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41266. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41267. /**
  41268. * Manage the gamepad inputs to control a free camera.
  41269. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41270. */
  41271. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41272. /**
  41273. * Define the camera the input is attached to.
  41274. */
  41275. camera: FreeCamera;
  41276. /**
  41277. * Define the Gamepad controlling the input
  41278. */
  41279. gamepad: Nullable<Gamepad>;
  41280. /**
  41281. * Defines the gamepad rotation sensiblity.
  41282. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41283. */
  41284. gamepadAngularSensibility: number;
  41285. /**
  41286. * Defines the gamepad move sensiblity.
  41287. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41288. */
  41289. gamepadMoveSensibility: number;
  41290. private _yAxisScale;
  41291. /**
  41292. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41293. */
  41294. invertYAxis: boolean;
  41295. private _onGamepadConnectedObserver;
  41296. private _onGamepadDisconnectedObserver;
  41297. private _cameraTransform;
  41298. private _deltaTransform;
  41299. private _vector3;
  41300. private _vector2;
  41301. /**
  41302. * Attach the input controls to a specific dom element to get the input from.
  41303. * @param element Defines the element the controls should be listened from
  41304. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41305. */
  41306. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41307. /**
  41308. * Detach the current controls from the specified dom element.
  41309. * @param element Defines the element to stop listening the inputs from
  41310. */
  41311. detachControl(element: Nullable<HTMLElement>): void;
  41312. /**
  41313. * Update the current camera state depending on the inputs that have been used this frame.
  41314. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41315. */
  41316. checkInputs(): void;
  41317. /**
  41318. * Gets the class name of the current intput.
  41319. * @returns the class name
  41320. */
  41321. getClassName(): string;
  41322. /**
  41323. * Get the friendly name associated with the input class.
  41324. * @returns the input friendly name
  41325. */
  41326. getSimpleName(): string;
  41327. }
  41328. }
  41329. declare module "babylonjs/Misc/virtualJoystick" {
  41330. import { Nullable } from "babylonjs/types";
  41331. import { Vector3 } from "babylonjs/Maths/math.vector";
  41332. /**
  41333. * Defines the potential axis of a Joystick
  41334. */
  41335. export enum JoystickAxis {
  41336. /** X axis */
  41337. X = 0,
  41338. /** Y axis */
  41339. Y = 1,
  41340. /** Z axis */
  41341. Z = 2
  41342. }
  41343. /**
  41344. * Class used to define virtual joystick (used in touch mode)
  41345. */
  41346. export class VirtualJoystick {
  41347. /**
  41348. * Gets or sets a boolean indicating that left and right values must be inverted
  41349. */
  41350. reverseLeftRight: boolean;
  41351. /**
  41352. * Gets or sets a boolean indicating that up and down values must be inverted
  41353. */
  41354. reverseUpDown: boolean;
  41355. /**
  41356. * Gets the offset value for the position (ie. the change of the position value)
  41357. */
  41358. deltaPosition: Vector3;
  41359. /**
  41360. * Gets a boolean indicating if the virtual joystick was pressed
  41361. */
  41362. pressed: boolean;
  41363. /**
  41364. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41365. */
  41366. static Canvas: Nullable<HTMLCanvasElement>;
  41367. private static _globalJoystickIndex;
  41368. private static vjCanvasContext;
  41369. private static vjCanvasWidth;
  41370. private static vjCanvasHeight;
  41371. private static halfWidth;
  41372. private _action;
  41373. private _axisTargetedByLeftAndRight;
  41374. private _axisTargetedByUpAndDown;
  41375. private _joystickSensibility;
  41376. private _inversedSensibility;
  41377. private _joystickPointerID;
  41378. private _joystickColor;
  41379. private _joystickPointerPos;
  41380. private _joystickPreviousPointerPos;
  41381. private _joystickPointerStartPos;
  41382. private _deltaJoystickVector;
  41383. private _leftJoystick;
  41384. private _touches;
  41385. private _onPointerDownHandlerRef;
  41386. private _onPointerMoveHandlerRef;
  41387. private _onPointerUpHandlerRef;
  41388. private _onResize;
  41389. /**
  41390. * Creates a new virtual joystick
  41391. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41392. */
  41393. constructor(leftJoystick?: boolean);
  41394. /**
  41395. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41396. * @param newJoystickSensibility defines the new sensibility
  41397. */
  41398. setJoystickSensibility(newJoystickSensibility: number): void;
  41399. private _onPointerDown;
  41400. private _onPointerMove;
  41401. private _onPointerUp;
  41402. /**
  41403. * Change the color of the virtual joystick
  41404. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41405. */
  41406. setJoystickColor(newColor: string): void;
  41407. /**
  41408. * Defines a callback to call when the joystick is touched
  41409. * @param action defines the callback
  41410. */
  41411. setActionOnTouch(action: () => any): void;
  41412. /**
  41413. * Defines which axis you'd like to control for left & right
  41414. * @param axis defines the axis to use
  41415. */
  41416. setAxisForLeftRight(axis: JoystickAxis): void;
  41417. /**
  41418. * Defines which axis you'd like to control for up & down
  41419. * @param axis defines the axis to use
  41420. */
  41421. setAxisForUpDown(axis: JoystickAxis): void;
  41422. private _drawVirtualJoystick;
  41423. /**
  41424. * Release internal HTML canvas
  41425. */
  41426. releaseCanvas(): void;
  41427. }
  41428. }
  41429. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  41430. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  41431. import { Nullable } from "babylonjs/types";
  41432. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41433. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41434. module "babylonjs/Cameras/freeCameraInputsManager" {
  41435. interface FreeCameraInputsManager {
  41436. /**
  41437. * Add virtual joystick input support to the input manager.
  41438. * @returns the current input manager
  41439. */
  41440. addVirtualJoystick(): FreeCameraInputsManager;
  41441. }
  41442. }
  41443. /**
  41444. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41445. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41446. */
  41447. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41448. /**
  41449. * Defines the camera the input is attached to.
  41450. */
  41451. camera: FreeCamera;
  41452. private _leftjoystick;
  41453. private _rightjoystick;
  41454. /**
  41455. * Gets the left stick of the virtual joystick.
  41456. * @returns The virtual Joystick
  41457. */
  41458. getLeftJoystick(): VirtualJoystick;
  41459. /**
  41460. * Gets the right stick of the virtual joystick.
  41461. * @returns The virtual Joystick
  41462. */
  41463. getRightJoystick(): VirtualJoystick;
  41464. /**
  41465. * Update the current camera state depending on the inputs that have been used this frame.
  41466. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41467. */
  41468. checkInputs(): void;
  41469. /**
  41470. * Attach the input controls to a specific dom element to get the input from.
  41471. * @param element Defines the element the controls should be listened from
  41472. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41473. */
  41474. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41475. /**
  41476. * Detach the current controls from the specified dom element.
  41477. * @param element Defines the element to stop listening the inputs from
  41478. */
  41479. detachControl(element: Nullable<HTMLElement>): void;
  41480. /**
  41481. * Gets the class name of the current intput.
  41482. * @returns the class name
  41483. */
  41484. getClassName(): string;
  41485. /**
  41486. * Get the friendly name associated with the input class.
  41487. * @returns the input friendly name
  41488. */
  41489. getSimpleName(): string;
  41490. }
  41491. }
  41492. declare module "babylonjs/Cameras/Inputs/index" {
  41493. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  41494. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  41495. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  41496. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  41497. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41498. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  41499. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  41500. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  41501. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  41502. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  41503. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41504. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  41505. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  41506. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  41507. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  41508. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41509. }
  41510. declare module "babylonjs/Cameras/touchCamera" {
  41511. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41512. import { Scene } from "babylonjs/scene";
  41513. import { Vector3 } from "babylonjs/Maths/math.vector";
  41514. /**
  41515. * This represents a FPS type of camera controlled by touch.
  41516. * This is like a universal camera minus the Gamepad controls.
  41517. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41518. */
  41519. export class TouchCamera extends FreeCamera {
  41520. /**
  41521. * Defines the touch sensibility for rotation.
  41522. * The higher the faster.
  41523. */
  41524. touchAngularSensibility: number;
  41525. /**
  41526. * Defines the touch sensibility for move.
  41527. * The higher the faster.
  41528. */
  41529. touchMoveSensibility: number;
  41530. /**
  41531. * Instantiates a new touch camera.
  41532. * This represents a FPS type of camera controlled by touch.
  41533. * This is like a universal camera minus the Gamepad controls.
  41534. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41535. * @param name Define the name of the camera in the scene
  41536. * @param position Define the start position of the camera in the scene
  41537. * @param scene Define the scene the camera belongs to
  41538. */
  41539. constructor(name: string, position: Vector3, scene: Scene);
  41540. /**
  41541. * Gets the current object class name.
  41542. * @return the class name
  41543. */
  41544. getClassName(): string;
  41545. /** @hidden */
  41546. _setupInputs(): void;
  41547. }
  41548. }
  41549. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  41550. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41551. import { Scene } from "babylonjs/scene";
  41552. import { Vector3 } from "babylonjs/Maths/math.vector";
  41553. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41554. import { Axis } from "babylonjs/Maths/math.axis";
  41555. /**
  41556. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41557. * being tilted forward or back and left or right.
  41558. */
  41559. export class DeviceOrientationCamera extends FreeCamera {
  41560. private _initialQuaternion;
  41561. private _quaternionCache;
  41562. private _tmpDragQuaternion;
  41563. private _disablePointerInputWhenUsingDeviceOrientation;
  41564. /**
  41565. * Creates a new device orientation camera
  41566. * @param name The name of the camera
  41567. * @param position The start position camera
  41568. * @param scene The scene the camera belongs to
  41569. */
  41570. constructor(name: string, position: Vector3, scene: Scene);
  41571. /**
  41572. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41573. */
  41574. disablePointerInputWhenUsingDeviceOrientation: boolean;
  41575. private _dragFactor;
  41576. /**
  41577. * Enabled turning on the y axis when the orientation sensor is active
  41578. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41579. */
  41580. enableHorizontalDragging(dragFactor?: number): void;
  41581. /**
  41582. * Gets the current instance class name ("DeviceOrientationCamera").
  41583. * This helps avoiding instanceof at run time.
  41584. * @returns the class name
  41585. */
  41586. getClassName(): string;
  41587. /**
  41588. * @hidden
  41589. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41590. */
  41591. _checkInputs(): void;
  41592. /**
  41593. * Reset the camera to its default orientation on the specified axis only.
  41594. * @param axis The axis to reset
  41595. */
  41596. resetToCurrentRotation(axis?: Axis): void;
  41597. }
  41598. }
  41599. declare module "babylonjs/Gamepads/xboxGamepad" {
  41600. import { Observable } from "babylonjs/Misc/observable";
  41601. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41602. /**
  41603. * Defines supported buttons for XBox360 compatible gamepads
  41604. */
  41605. export enum Xbox360Button {
  41606. /** A */
  41607. A = 0,
  41608. /** B */
  41609. B = 1,
  41610. /** X */
  41611. X = 2,
  41612. /** Y */
  41613. Y = 3,
  41614. /** Start */
  41615. Start = 4,
  41616. /** Back */
  41617. Back = 5,
  41618. /** Left button */
  41619. LB = 6,
  41620. /** Right button */
  41621. RB = 7,
  41622. /** Left stick */
  41623. LeftStick = 8,
  41624. /** Right stick */
  41625. RightStick = 9
  41626. }
  41627. /** Defines values for XBox360 DPad */
  41628. export enum Xbox360Dpad {
  41629. /** Up */
  41630. Up = 0,
  41631. /** Down */
  41632. Down = 1,
  41633. /** Left */
  41634. Left = 2,
  41635. /** Right */
  41636. Right = 3
  41637. }
  41638. /**
  41639. * Defines a XBox360 gamepad
  41640. */
  41641. export class Xbox360Pad extends Gamepad {
  41642. private _leftTrigger;
  41643. private _rightTrigger;
  41644. private _onlefttriggerchanged;
  41645. private _onrighttriggerchanged;
  41646. private _onbuttondown;
  41647. private _onbuttonup;
  41648. private _ondpaddown;
  41649. private _ondpadup;
  41650. /** Observable raised when a button is pressed */
  41651. onButtonDownObservable: Observable<Xbox360Button>;
  41652. /** Observable raised when a button is released */
  41653. onButtonUpObservable: Observable<Xbox360Button>;
  41654. /** Observable raised when a pad is pressed */
  41655. onPadDownObservable: Observable<Xbox360Dpad>;
  41656. /** Observable raised when a pad is released */
  41657. onPadUpObservable: Observable<Xbox360Dpad>;
  41658. private _buttonA;
  41659. private _buttonB;
  41660. private _buttonX;
  41661. private _buttonY;
  41662. private _buttonBack;
  41663. private _buttonStart;
  41664. private _buttonLB;
  41665. private _buttonRB;
  41666. private _buttonLeftStick;
  41667. private _buttonRightStick;
  41668. private _dPadUp;
  41669. private _dPadDown;
  41670. private _dPadLeft;
  41671. private _dPadRight;
  41672. private _isXboxOnePad;
  41673. /**
  41674. * Creates a new XBox360 gamepad object
  41675. * @param id defines the id of this gamepad
  41676. * @param index defines its index
  41677. * @param gamepad defines the internal HTML gamepad object
  41678. * @param xboxOne defines if it is a XBox One gamepad
  41679. */
  41680. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41681. /**
  41682. * Defines the callback to call when left trigger is pressed
  41683. * @param callback defines the callback to use
  41684. */
  41685. onlefttriggerchanged(callback: (value: number) => void): void;
  41686. /**
  41687. * Defines the callback to call when right trigger is pressed
  41688. * @param callback defines the callback to use
  41689. */
  41690. onrighttriggerchanged(callback: (value: number) => void): void;
  41691. /**
  41692. * Gets the left trigger value
  41693. */
  41694. /**
  41695. * Sets the left trigger value
  41696. */
  41697. leftTrigger: number;
  41698. /**
  41699. * Gets the right trigger value
  41700. */
  41701. /**
  41702. * Sets the right trigger value
  41703. */
  41704. rightTrigger: number;
  41705. /**
  41706. * Defines the callback to call when a button is pressed
  41707. * @param callback defines the callback to use
  41708. */
  41709. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41710. /**
  41711. * Defines the callback to call when a button is released
  41712. * @param callback defines the callback to use
  41713. */
  41714. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41715. /**
  41716. * Defines the callback to call when a pad is pressed
  41717. * @param callback defines the callback to use
  41718. */
  41719. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41720. /**
  41721. * Defines the callback to call when a pad is released
  41722. * @param callback defines the callback to use
  41723. */
  41724. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41725. private _setButtonValue;
  41726. private _setDPadValue;
  41727. /**
  41728. * Gets the value of the `A` button
  41729. */
  41730. /**
  41731. * Sets the value of the `A` button
  41732. */
  41733. buttonA: number;
  41734. /**
  41735. * Gets the value of the `B` button
  41736. */
  41737. /**
  41738. * Sets the value of the `B` button
  41739. */
  41740. buttonB: number;
  41741. /**
  41742. * Gets the value of the `X` button
  41743. */
  41744. /**
  41745. * Sets the value of the `X` button
  41746. */
  41747. buttonX: number;
  41748. /**
  41749. * Gets the value of the `Y` button
  41750. */
  41751. /**
  41752. * Sets the value of the `Y` button
  41753. */
  41754. buttonY: number;
  41755. /**
  41756. * Gets the value of the `Start` button
  41757. */
  41758. /**
  41759. * Sets the value of the `Start` button
  41760. */
  41761. buttonStart: number;
  41762. /**
  41763. * Gets the value of the `Back` button
  41764. */
  41765. /**
  41766. * Sets the value of the `Back` button
  41767. */
  41768. buttonBack: number;
  41769. /**
  41770. * Gets the value of the `Left` button
  41771. */
  41772. /**
  41773. * Sets the value of the `Left` button
  41774. */
  41775. buttonLB: number;
  41776. /**
  41777. * Gets the value of the `Right` button
  41778. */
  41779. /**
  41780. * Sets the value of the `Right` button
  41781. */
  41782. buttonRB: number;
  41783. /**
  41784. * Gets the value of the Left joystick
  41785. */
  41786. /**
  41787. * Sets the value of the Left joystick
  41788. */
  41789. buttonLeftStick: number;
  41790. /**
  41791. * Gets the value of the Right joystick
  41792. */
  41793. /**
  41794. * Sets the value of the Right joystick
  41795. */
  41796. buttonRightStick: number;
  41797. /**
  41798. * Gets the value of D-pad up
  41799. */
  41800. /**
  41801. * Sets the value of D-pad up
  41802. */
  41803. dPadUp: number;
  41804. /**
  41805. * Gets the value of D-pad down
  41806. */
  41807. /**
  41808. * Sets the value of D-pad down
  41809. */
  41810. dPadDown: number;
  41811. /**
  41812. * Gets the value of D-pad left
  41813. */
  41814. /**
  41815. * Sets the value of D-pad left
  41816. */
  41817. dPadLeft: number;
  41818. /**
  41819. * Gets the value of D-pad right
  41820. */
  41821. /**
  41822. * Sets the value of D-pad right
  41823. */
  41824. dPadRight: number;
  41825. /**
  41826. * Force the gamepad to synchronize with device values
  41827. */
  41828. update(): void;
  41829. /**
  41830. * Disposes the gamepad
  41831. */
  41832. dispose(): void;
  41833. }
  41834. }
  41835. declare module "babylonjs/Gamepads/dualShockGamepad" {
  41836. import { Observable } from "babylonjs/Misc/observable";
  41837. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41838. /**
  41839. * Defines supported buttons for DualShock compatible gamepads
  41840. */
  41841. export enum DualShockButton {
  41842. /** Cross */
  41843. Cross = 0,
  41844. /** Circle */
  41845. Circle = 1,
  41846. /** Square */
  41847. Square = 2,
  41848. /** Triangle */
  41849. Triangle = 3,
  41850. /** Options */
  41851. Options = 4,
  41852. /** Share */
  41853. Share = 5,
  41854. /** L1 */
  41855. L1 = 6,
  41856. /** R1 */
  41857. R1 = 7,
  41858. /** Left stick */
  41859. LeftStick = 8,
  41860. /** Right stick */
  41861. RightStick = 9
  41862. }
  41863. /** Defines values for DualShock DPad */
  41864. export enum DualShockDpad {
  41865. /** Up */
  41866. Up = 0,
  41867. /** Down */
  41868. Down = 1,
  41869. /** Left */
  41870. Left = 2,
  41871. /** Right */
  41872. Right = 3
  41873. }
  41874. /**
  41875. * Defines a DualShock gamepad
  41876. */
  41877. export class DualShockPad extends Gamepad {
  41878. private _leftTrigger;
  41879. private _rightTrigger;
  41880. private _onlefttriggerchanged;
  41881. private _onrighttriggerchanged;
  41882. private _onbuttondown;
  41883. private _onbuttonup;
  41884. private _ondpaddown;
  41885. private _ondpadup;
  41886. /** Observable raised when a button is pressed */
  41887. onButtonDownObservable: Observable<DualShockButton>;
  41888. /** Observable raised when a button is released */
  41889. onButtonUpObservable: Observable<DualShockButton>;
  41890. /** Observable raised when a pad is pressed */
  41891. onPadDownObservable: Observable<DualShockDpad>;
  41892. /** Observable raised when a pad is released */
  41893. onPadUpObservable: Observable<DualShockDpad>;
  41894. private _buttonCross;
  41895. private _buttonCircle;
  41896. private _buttonSquare;
  41897. private _buttonTriangle;
  41898. private _buttonShare;
  41899. private _buttonOptions;
  41900. private _buttonL1;
  41901. private _buttonR1;
  41902. private _buttonLeftStick;
  41903. private _buttonRightStick;
  41904. private _dPadUp;
  41905. private _dPadDown;
  41906. private _dPadLeft;
  41907. private _dPadRight;
  41908. /**
  41909. * Creates a new DualShock gamepad object
  41910. * @param id defines the id of this gamepad
  41911. * @param index defines its index
  41912. * @param gamepad defines the internal HTML gamepad object
  41913. */
  41914. constructor(id: string, index: number, gamepad: any);
  41915. /**
  41916. * Defines the callback to call when left trigger is pressed
  41917. * @param callback defines the callback to use
  41918. */
  41919. onlefttriggerchanged(callback: (value: number) => void): void;
  41920. /**
  41921. * Defines the callback to call when right trigger is pressed
  41922. * @param callback defines the callback to use
  41923. */
  41924. onrighttriggerchanged(callback: (value: number) => void): void;
  41925. /**
  41926. * Gets the left trigger value
  41927. */
  41928. /**
  41929. * Sets the left trigger value
  41930. */
  41931. leftTrigger: number;
  41932. /**
  41933. * Gets the right trigger value
  41934. */
  41935. /**
  41936. * Sets the right trigger value
  41937. */
  41938. rightTrigger: number;
  41939. /**
  41940. * Defines the callback to call when a button is pressed
  41941. * @param callback defines the callback to use
  41942. */
  41943. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41944. /**
  41945. * Defines the callback to call when a button is released
  41946. * @param callback defines the callback to use
  41947. */
  41948. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41949. /**
  41950. * Defines the callback to call when a pad is pressed
  41951. * @param callback defines the callback to use
  41952. */
  41953. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41954. /**
  41955. * Defines the callback to call when a pad is released
  41956. * @param callback defines the callback to use
  41957. */
  41958. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41959. private _setButtonValue;
  41960. private _setDPadValue;
  41961. /**
  41962. * Gets the value of the `Cross` button
  41963. */
  41964. /**
  41965. * Sets the value of the `Cross` button
  41966. */
  41967. buttonCross: number;
  41968. /**
  41969. * Gets the value of the `Circle` button
  41970. */
  41971. /**
  41972. * Sets the value of the `Circle` button
  41973. */
  41974. buttonCircle: number;
  41975. /**
  41976. * Gets the value of the `Square` button
  41977. */
  41978. /**
  41979. * Sets the value of the `Square` button
  41980. */
  41981. buttonSquare: number;
  41982. /**
  41983. * Gets the value of the `Triangle` button
  41984. */
  41985. /**
  41986. * Sets the value of the `Triangle` button
  41987. */
  41988. buttonTriangle: number;
  41989. /**
  41990. * Gets the value of the `Options` button
  41991. */
  41992. /**
  41993. * Sets the value of the `Options` button
  41994. */
  41995. buttonOptions: number;
  41996. /**
  41997. * Gets the value of the `Share` button
  41998. */
  41999. /**
  42000. * Sets the value of the `Share` button
  42001. */
  42002. buttonShare: number;
  42003. /**
  42004. * Gets the value of the `L1` button
  42005. */
  42006. /**
  42007. * Sets the value of the `L1` button
  42008. */
  42009. buttonL1: number;
  42010. /**
  42011. * Gets the value of the `R1` button
  42012. */
  42013. /**
  42014. * Sets the value of the `R1` button
  42015. */
  42016. buttonR1: number;
  42017. /**
  42018. * Gets the value of the Left joystick
  42019. */
  42020. /**
  42021. * Sets the value of the Left joystick
  42022. */
  42023. buttonLeftStick: number;
  42024. /**
  42025. * Gets the value of the Right joystick
  42026. */
  42027. /**
  42028. * Sets the value of the Right joystick
  42029. */
  42030. buttonRightStick: number;
  42031. /**
  42032. * Gets the value of D-pad up
  42033. */
  42034. /**
  42035. * Sets the value of D-pad up
  42036. */
  42037. dPadUp: number;
  42038. /**
  42039. * Gets the value of D-pad down
  42040. */
  42041. /**
  42042. * Sets the value of D-pad down
  42043. */
  42044. dPadDown: number;
  42045. /**
  42046. * Gets the value of D-pad left
  42047. */
  42048. /**
  42049. * Sets the value of D-pad left
  42050. */
  42051. dPadLeft: number;
  42052. /**
  42053. * Gets the value of D-pad right
  42054. */
  42055. /**
  42056. * Sets the value of D-pad right
  42057. */
  42058. dPadRight: number;
  42059. /**
  42060. * Force the gamepad to synchronize with device values
  42061. */
  42062. update(): void;
  42063. /**
  42064. * Disposes the gamepad
  42065. */
  42066. dispose(): void;
  42067. }
  42068. }
  42069. declare module "babylonjs/Gamepads/gamepadManager" {
  42070. import { Observable } from "babylonjs/Misc/observable";
  42071. import { Nullable } from "babylonjs/types";
  42072. import { Scene } from "babylonjs/scene";
  42073. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42074. /**
  42075. * Manager for handling gamepads
  42076. */
  42077. export class GamepadManager {
  42078. private _scene?;
  42079. private _babylonGamepads;
  42080. private _oneGamepadConnected;
  42081. /** @hidden */
  42082. _isMonitoring: boolean;
  42083. private _gamepadEventSupported;
  42084. private _gamepadSupport;
  42085. /**
  42086. * observable to be triggered when the gamepad controller has been connected
  42087. */
  42088. onGamepadConnectedObservable: Observable<Gamepad>;
  42089. /**
  42090. * observable to be triggered when the gamepad controller has been disconnected
  42091. */
  42092. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42093. private _onGamepadConnectedEvent;
  42094. private _onGamepadDisconnectedEvent;
  42095. /**
  42096. * Initializes the gamepad manager
  42097. * @param _scene BabylonJS scene
  42098. */
  42099. constructor(_scene?: Scene | undefined);
  42100. /**
  42101. * The gamepads in the game pad manager
  42102. */
  42103. readonly gamepads: Gamepad[];
  42104. /**
  42105. * Get the gamepad controllers based on type
  42106. * @param type The type of gamepad controller
  42107. * @returns Nullable gamepad
  42108. */
  42109. getGamepadByType(type?: number): Nullable<Gamepad>;
  42110. /**
  42111. * Disposes the gamepad manager
  42112. */
  42113. dispose(): void;
  42114. private _addNewGamepad;
  42115. private _startMonitoringGamepads;
  42116. private _stopMonitoringGamepads;
  42117. /** @hidden */
  42118. _checkGamepadsStatus(): void;
  42119. private _updateGamepadObjects;
  42120. }
  42121. }
  42122. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42123. import { Nullable } from "babylonjs/types";
  42124. import { Scene } from "babylonjs/scene";
  42125. import { ISceneComponent } from "babylonjs/sceneComponent";
  42126. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42127. module "babylonjs/scene" {
  42128. interface Scene {
  42129. /** @hidden */
  42130. _gamepadManager: Nullable<GamepadManager>;
  42131. /**
  42132. * Gets the gamepad manager associated with the scene
  42133. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42134. */
  42135. gamepadManager: GamepadManager;
  42136. }
  42137. }
  42138. module "babylonjs/Cameras/freeCameraInputsManager" {
  42139. /**
  42140. * Interface representing a free camera inputs manager
  42141. */
  42142. interface FreeCameraInputsManager {
  42143. /**
  42144. * Adds gamepad input support to the FreeCameraInputsManager.
  42145. * @returns the FreeCameraInputsManager
  42146. */
  42147. addGamepad(): FreeCameraInputsManager;
  42148. }
  42149. }
  42150. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42151. /**
  42152. * Interface representing an arc rotate camera inputs manager
  42153. */
  42154. interface ArcRotateCameraInputsManager {
  42155. /**
  42156. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42157. * @returns the camera inputs manager
  42158. */
  42159. addGamepad(): ArcRotateCameraInputsManager;
  42160. }
  42161. }
  42162. /**
  42163. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42164. */
  42165. export class GamepadSystemSceneComponent implements ISceneComponent {
  42166. /**
  42167. * The component name helpfull to identify the component in the list of scene components.
  42168. */
  42169. readonly name: string;
  42170. /**
  42171. * The scene the component belongs to.
  42172. */
  42173. scene: Scene;
  42174. /**
  42175. * Creates a new instance of the component for the given scene
  42176. * @param scene Defines the scene to register the component in
  42177. */
  42178. constructor(scene: Scene);
  42179. /**
  42180. * Registers the component in a given scene
  42181. */
  42182. register(): void;
  42183. /**
  42184. * Rebuilds the elements related to this component in case of
  42185. * context lost for instance.
  42186. */
  42187. rebuild(): void;
  42188. /**
  42189. * Disposes the component and the associated ressources
  42190. */
  42191. dispose(): void;
  42192. private _beforeCameraUpdate;
  42193. }
  42194. }
  42195. declare module "babylonjs/Cameras/universalCamera" {
  42196. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42197. import { Scene } from "babylonjs/scene";
  42198. import { Vector3 } from "babylonjs/Maths/math.vector";
  42199. import "babylonjs/Gamepads/gamepadSceneComponent";
  42200. /**
  42201. * 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,
  42202. * which still works and will still be found in many Playgrounds.
  42203. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42204. */
  42205. export class UniversalCamera extends TouchCamera {
  42206. /**
  42207. * Defines the gamepad rotation sensiblity.
  42208. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42209. */
  42210. gamepadAngularSensibility: number;
  42211. /**
  42212. * Defines the gamepad move sensiblity.
  42213. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42214. */
  42215. gamepadMoveSensibility: number;
  42216. /**
  42217. * 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,
  42218. * which still works and will still be found in many Playgrounds.
  42219. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42220. * @param name Define the name of the camera in the scene
  42221. * @param position Define the start position of the camera in the scene
  42222. * @param scene Define the scene the camera belongs to
  42223. */
  42224. constructor(name: string, position: Vector3, scene: Scene);
  42225. /**
  42226. * Gets the current object class name.
  42227. * @return the class name
  42228. */
  42229. getClassName(): string;
  42230. }
  42231. }
  42232. declare module "babylonjs/Cameras/gamepadCamera" {
  42233. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42234. import { Scene } from "babylonjs/scene";
  42235. import { Vector3 } from "babylonjs/Maths/math.vector";
  42236. /**
  42237. * This represents a FPS type of camera. This is only here for back compat purpose.
  42238. * Please use the UniversalCamera instead as both are identical.
  42239. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42240. */
  42241. export class GamepadCamera extends UniversalCamera {
  42242. /**
  42243. * Instantiates a new Gamepad Camera
  42244. * This represents a FPS type of camera. This is only here for back compat purpose.
  42245. * Please use the UniversalCamera instead as both are identical.
  42246. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42247. * @param name Define the name of the camera in the scene
  42248. * @param position Define the start position of the camera in the scene
  42249. * @param scene Define the scene the camera belongs to
  42250. */
  42251. constructor(name: string, position: Vector3, scene: Scene);
  42252. /**
  42253. * Gets the current object class name.
  42254. * @return the class name
  42255. */
  42256. getClassName(): string;
  42257. }
  42258. }
  42259. declare module "babylonjs/Shaders/pass.fragment" {
  42260. /** @hidden */
  42261. export var passPixelShader: {
  42262. name: string;
  42263. shader: string;
  42264. };
  42265. }
  42266. declare module "babylonjs/Shaders/passCube.fragment" {
  42267. /** @hidden */
  42268. export var passCubePixelShader: {
  42269. name: string;
  42270. shader: string;
  42271. };
  42272. }
  42273. declare module "babylonjs/PostProcesses/passPostProcess" {
  42274. import { Nullable } from "babylonjs/types";
  42275. import { Camera } from "babylonjs/Cameras/camera";
  42276. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42277. import { Engine } from "babylonjs/Engines/engine";
  42278. import "babylonjs/Shaders/pass.fragment";
  42279. import "babylonjs/Shaders/passCube.fragment";
  42280. /**
  42281. * PassPostProcess which produces an output the same as it's input
  42282. */
  42283. export class PassPostProcess extends PostProcess {
  42284. /**
  42285. * Creates the PassPostProcess
  42286. * @param name The name of the effect.
  42287. * @param options The required width/height ratio to downsize to before computing the render pass.
  42288. * @param camera The camera to apply the render pass to.
  42289. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42290. * @param engine The engine which the post process will be applied. (default: current engine)
  42291. * @param reusable If the post process can be reused on the same frame. (default: false)
  42292. * @param textureType The type of texture to be used when performing the post processing.
  42293. * @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)
  42294. */
  42295. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42296. }
  42297. /**
  42298. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42299. */
  42300. export class PassCubePostProcess extends PostProcess {
  42301. private _face;
  42302. /**
  42303. * Gets or sets the cube face to display.
  42304. * * 0 is +X
  42305. * * 1 is -X
  42306. * * 2 is +Y
  42307. * * 3 is -Y
  42308. * * 4 is +Z
  42309. * * 5 is -Z
  42310. */
  42311. face: number;
  42312. /**
  42313. * Creates the PassCubePostProcess
  42314. * @param name The name of the effect.
  42315. * @param options The required width/height ratio to downsize to before computing the render pass.
  42316. * @param camera The camera to apply the render pass to.
  42317. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42318. * @param engine The engine which the post process will be applied. (default: current engine)
  42319. * @param reusable If the post process can be reused on the same frame. (default: false)
  42320. * @param textureType The type of texture to be used when performing the post processing.
  42321. * @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)
  42322. */
  42323. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42324. }
  42325. }
  42326. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42327. /** @hidden */
  42328. export var anaglyphPixelShader: {
  42329. name: string;
  42330. shader: string;
  42331. };
  42332. }
  42333. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42334. import { Engine } from "babylonjs/Engines/engine";
  42335. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42336. import { Camera } from "babylonjs/Cameras/camera";
  42337. import "babylonjs/Shaders/anaglyph.fragment";
  42338. /**
  42339. * Postprocess used to generate anaglyphic rendering
  42340. */
  42341. export class AnaglyphPostProcess extends PostProcess {
  42342. private _passedProcess;
  42343. /**
  42344. * Creates a new AnaglyphPostProcess
  42345. * @param name defines postprocess name
  42346. * @param options defines creation options or target ratio scale
  42347. * @param rigCameras defines cameras using this postprocess
  42348. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42349. * @param engine defines hosting engine
  42350. * @param reusable defines if the postprocess will be reused multiple times per frame
  42351. */
  42352. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42353. }
  42354. }
  42355. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42356. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42357. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42358. import { Scene } from "babylonjs/scene";
  42359. import { Vector3 } from "babylonjs/Maths/math.vector";
  42360. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42361. /**
  42362. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42363. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42364. */
  42365. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42366. /**
  42367. * Creates a new AnaglyphArcRotateCamera
  42368. * @param name defines camera name
  42369. * @param alpha defines alpha angle (in radians)
  42370. * @param beta defines beta angle (in radians)
  42371. * @param radius defines radius
  42372. * @param target defines camera target
  42373. * @param interaxialDistance defines distance between each color axis
  42374. * @param scene defines the hosting scene
  42375. */
  42376. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42377. /**
  42378. * Gets camera class name
  42379. * @returns AnaglyphArcRotateCamera
  42380. */
  42381. getClassName(): string;
  42382. }
  42383. }
  42384. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  42385. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42386. import { Scene } from "babylonjs/scene";
  42387. import { Vector3 } from "babylonjs/Maths/math.vector";
  42388. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42389. /**
  42390. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42391. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42392. */
  42393. export class AnaglyphFreeCamera extends FreeCamera {
  42394. /**
  42395. * Creates a new AnaglyphFreeCamera
  42396. * @param name defines camera name
  42397. * @param position defines initial position
  42398. * @param interaxialDistance defines distance between each color axis
  42399. * @param scene defines the hosting scene
  42400. */
  42401. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42402. /**
  42403. * Gets camera class name
  42404. * @returns AnaglyphFreeCamera
  42405. */
  42406. getClassName(): string;
  42407. }
  42408. }
  42409. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  42410. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42411. import { Scene } from "babylonjs/scene";
  42412. import { Vector3 } from "babylonjs/Maths/math.vector";
  42413. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42414. /**
  42415. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42416. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42417. */
  42418. export class AnaglyphGamepadCamera extends GamepadCamera {
  42419. /**
  42420. * Creates a new AnaglyphGamepadCamera
  42421. * @param name defines camera name
  42422. * @param position defines initial position
  42423. * @param interaxialDistance defines distance between each color axis
  42424. * @param scene defines the hosting scene
  42425. */
  42426. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42427. /**
  42428. * Gets camera class name
  42429. * @returns AnaglyphGamepadCamera
  42430. */
  42431. getClassName(): string;
  42432. }
  42433. }
  42434. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  42435. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42436. import { Scene } from "babylonjs/scene";
  42437. import { Vector3 } from "babylonjs/Maths/math.vector";
  42438. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42439. /**
  42440. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42441. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42442. */
  42443. export class AnaglyphUniversalCamera extends UniversalCamera {
  42444. /**
  42445. * Creates a new AnaglyphUniversalCamera
  42446. * @param name defines camera name
  42447. * @param position defines initial position
  42448. * @param interaxialDistance defines distance between each color axis
  42449. * @param scene defines the hosting scene
  42450. */
  42451. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42452. /**
  42453. * Gets camera class name
  42454. * @returns AnaglyphUniversalCamera
  42455. */
  42456. getClassName(): string;
  42457. }
  42458. }
  42459. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  42460. /** @hidden */
  42461. export var stereoscopicInterlacePixelShader: {
  42462. name: string;
  42463. shader: string;
  42464. };
  42465. }
  42466. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  42467. import { Camera } from "babylonjs/Cameras/camera";
  42468. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42469. import { Engine } from "babylonjs/Engines/engine";
  42470. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  42471. /**
  42472. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42473. */
  42474. export class StereoscopicInterlacePostProcess extends PostProcess {
  42475. private _stepSize;
  42476. private _passedProcess;
  42477. /**
  42478. * Initializes a StereoscopicInterlacePostProcess
  42479. * @param name The name of the effect.
  42480. * @param rigCameras The rig cameras to be appled to the post process
  42481. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42482. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42483. * @param engine The engine which the post process will be applied. (default: current engine)
  42484. * @param reusable If the post process can be reused on the same frame. (default: false)
  42485. */
  42486. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42487. }
  42488. }
  42489. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  42490. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  42491. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42492. import { Scene } from "babylonjs/scene";
  42493. import { Vector3 } from "babylonjs/Maths/math.vector";
  42494. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42495. /**
  42496. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42497. * @see http://doc.babylonjs.com/features/cameras
  42498. */
  42499. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42500. /**
  42501. * Creates a new StereoscopicArcRotateCamera
  42502. * @param name defines camera name
  42503. * @param alpha defines alpha angle (in radians)
  42504. * @param beta defines beta angle (in radians)
  42505. * @param radius defines radius
  42506. * @param target defines camera target
  42507. * @param interaxialDistance defines distance between each color axis
  42508. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42509. * @param scene defines the hosting scene
  42510. */
  42511. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42512. /**
  42513. * Gets camera class name
  42514. * @returns StereoscopicArcRotateCamera
  42515. */
  42516. getClassName(): string;
  42517. }
  42518. }
  42519. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  42520. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42521. import { Scene } from "babylonjs/scene";
  42522. import { Vector3 } from "babylonjs/Maths/math.vector";
  42523. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42524. /**
  42525. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42526. * @see http://doc.babylonjs.com/features/cameras
  42527. */
  42528. export class StereoscopicFreeCamera extends FreeCamera {
  42529. /**
  42530. * Creates a new StereoscopicFreeCamera
  42531. * @param name defines camera name
  42532. * @param position defines initial position
  42533. * @param interaxialDistance defines distance between each color axis
  42534. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42535. * @param scene defines the hosting scene
  42536. */
  42537. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42538. /**
  42539. * Gets camera class name
  42540. * @returns StereoscopicFreeCamera
  42541. */
  42542. getClassName(): string;
  42543. }
  42544. }
  42545. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  42546. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42547. import { Scene } from "babylonjs/scene";
  42548. import { Vector3 } from "babylonjs/Maths/math.vector";
  42549. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42550. /**
  42551. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42552. * @see http://doc.babylonjs.com/features/cameras
  42553. */
  42554. export class StereoscopicGamepadCamera extends GamepadCamera {
  42555. /**
  42556. * Creates a new StereoscopicGamepadCamera
  42557. * @param name defines camera name
  42558. * @param position defines initial position
  42559. * @param interaxialDistance defines distance between each color axis
  42560. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42561. * @param scene defines the hosting scene
  42562. */
  42563. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42564. /**
  42565. * Gets camera class name
  42566. * @returns StereoscopicGamepadCamera
  42567. */
  42568. getClassName(): string;
  42569. }
  42570. }
  42571. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  42572. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42573. import { Scene } from "babylonjs/scene";
  42574. import { Vector3 } from "babylonjs/Maths/math.vector";
  42575. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42576. /**
  42577. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42578. * @see http://doc.babylonjs.com/features/cameras
  42579. */
  42580. export class StereoscopicUniversalCamera extends UniversalCamera {
  42581. /**
  42582. * Creates a new StereoscopicUniversalCamera
  42583. * @param name defines camera name
  42584. * @param position defines initial position
  42585. * @param interaxialDistance defines distance between each color axis
  42586. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42587. * @param scene defines the hosting scene
  42588. */
  42589. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42590. /**
  42591. * Gets camera class name
  42592. * @returns StereoscopicUniversalCamera
  42593. */
  42594. getClassName(): string;
  42595. }
  42596. }
  42597. declare module "babylonjs/Cameras/Stereoscopic/index" {
  42598. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  42599. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  42600. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  42601. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  42602. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  42603. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  42604. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  42605. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  42606. }
  42607. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  42608. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42609. import { Scene } from "babylonjs/scene";
  42610. import { Vector3 } from "babylonjs/Maths/math.vector";
  42611. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42612. /**
  42613. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42614. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42615. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42616. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42617. */
  42618. export class VirtualJoysticksCamera extends FreeCamera {
  42619. /**
  42620. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42621. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42622. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42623. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42624. * @param name Define the name of the camera in the scene
  42625. * @param position Define the start position of the camera in the scene
  42626. * @param scene Define the scene the camera belongs to
  42627. */
  42628. constructor(name: string, position: Vector3, scene: Scene);
  42629. /**
  42630. * Gets the current object class name.
  42631. * @return the class name
  42632. */
  42633. getClassName(): string;
  42634. }
  42635. }
  42636. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  42637. import { Matrix } from "babylonjs/Maths/math.vector";
  42638. /**
  42639. * This represents all the required metrics to create a VR camera.
  42640. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42641. */
  42642. export class VRCameraMetrics {
  42643. /**
  42644. * Define the horizontal resolution off the screen.
  42645. */
  42646. hResolution: number;
  42647. /**
  42648. * Define the vertical resolution off the screen.
  42649. */
  42650. vResolution: number;
  42651. /**
  42652. * Define the horizontal screen size.
  42653. */
  42654. hScreenSize: number;
  42655. /**
  42656. * Define the vertical screen size.
  42657. */
  42658. vScreenSize: number;
  42659. /**
  42660. * Define the vertical screen center position.
  42661. */
  42662. vScreenCenter: number;
  42663. /**
  42664. * Define the distance of the eyes to the screen.
  42665. */
  42666. eyeToScreenDistance: number;
  42667. /**
  42668. * Define the distance between both lenses
  42669. */
  42670. lensSeparationDistance: number;
  42671. /**
  42672. * Define the distance between both viewer's eyes.
  42673. */
  42674. interpupillaryDistance: number;
  42675. /**
  42676. * Define the distortion factor of the VR postprocess.
  42677. * Please, touch with care.
  42678. */
  42679. distortionK: number[];
  42680. /**
  42681. * Define the chromatic aberration correction factors for the VR post process.
  42682. */
  42683. chromaAbCorrection: number[];
  42684. /**
  42685. * Define the scale factor of the post process.
  42686. * The smaller the better but the slower.
  42687. */
  42688. postProcessScaleFactor: number;
  42689. /**
  42690. * Define an offset for the lens center.
  42691. */
  42692. lensCenterOffset: number;
  42693. /**
  42694. * Define if the current vr camera should compensate the distortion of the lense or not.
  42695. */
  42696. compensateDistortion: boolean;
  42697. /**
  42698. * Defines if multiview should be enabled when rendering (Default: false)
  42699. */
  42700. multiviewEnabled: boolean;
  42701. /**
  42702. * Gets the rendering aspect ratio based on the provided resolutions.
  42703. */
  42704. readonly aspectRatio: number;
  42705. /**
  42706. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42707. */
  42708. readonly aspectRatioFov: number;
  42709. /**
  42710. * @hidden
  42711. */
  42712. readonly leftHMatrix: Matrix;
  42713. /**
  42714. * @hidden
  42715. */
  42716. readonly rightHMatrix: Matrix;
  42717. /**
  42718. * @hidden
  42719. */
  42720. readonly leftPreViewMatrix: Matrix;
  42721. /**
  42722. * @hidden
  42723. */
  42724. readonly rightPreViewMatrix: Matrix;
  42725. /**
  42726. * Get the default VRMetrics based on the most generic setup.
  42727. * @returns the default vr metrics
  42728. */
  42729. static GetDefault(): VRCameraMetrics;
  42730. }
  42731. }
  42732. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  42733. /** @hidden */
  42734. export var vrDistortionCorrectionPixelShader: {
  42735. name: string;
  42736. shader: string;
  42737. };
  42738. }
  42739. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  42740. import { Camera } from "babylonjs/Cameras/camera";
  42741. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42742. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42743. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  42744. /**
  42745. * VRDistortionCorrectionPostProcess used for mobile VR
  42746. */
  42747. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42748. private _isRightEye;
  42749. private _distortionFactors;
  42750. private _postProcessScaleFactor;
  42751. private _lensCenterOffset;
  42752. private _scaleIn;
  42753. private _scaleFactor;
  42754. private _lensCenter;
  42755. /**
  42756. * Initializes the VRDistortionCorrectionPostProcess
  42757. * @param name The name of the effect.
  42758. * @param camera The camera to apply the render pass to.
  42759. * @param isRightEye If this is for the right eye distortion
  42760. * @param vrMetrics All the required metrics for the VR camera
  42761. */
  42762. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42763. }
  42764. }
  42765. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  42766. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  42767. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42768. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42769. import { Scene } from "babylonjs/scene";
  42770. import { Vector3 } from "babylonjs/Maths/math.vector";
  42771. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42772. import "babylonjs/Cameras/RigModes/vrRigMode";
  42773. /**
  42774. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42775. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42776. */
  42777. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42778. /**
  42779. * Creates a new VRDeviceOrientationArcRotateCamera
  42780. * @param name defines camera name
  42781. * @param alpha defines the camera rotation along the logitudinal axis
  42782. * @param beta defines the camera rotation along the latitudinal axis
  42783. * @param radius defines the camera distance from its target
  42784. * @param target defines the camera target
  42785. * @param scene defines the scene the camera belongs to
  42786. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42787. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42788. */
  42789. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42790. /**
  42791. * Gets camera class name
  42792. * @returns VRDeviceOrientationArcRotateCamera
  42793. */
  42794. getClassName(): string;
  42795. }
  42796. }
  42797. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  42798. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42799. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42800. import { Scene } from "babylonjs/scene";
  42801. import { Vector3 } from "babylonjs/Maths/math.vector";
  42802. import "babylonjs/Cameras/RigModes/vrRigMode";
  42803. /**
  42804. * Camera used to simulate VR rendering (based on FreeCamera)
  42805. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42806. */
  42807. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42808. /**
  42809. * Creates a new VRDeviceOrientationFreeCamera
  42810. * @param name defines camera name
  42811. * @param position defines the start position of the camera
  42812. * @param scene defines the scene the camera belongs to
  42813. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42814. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42815. */
  42816. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42817. /**
  42818. * Gets camera class name
  42819. * @returns VRDeviceOrientationFreeCamera
  42820. */
  42821. getClassName(): string;
  42822. }
  42823. }
  42824. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  42825. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42826. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42827. import { Scene } from "babylonjs/scene";
  42828. import { Vector3 } from "babylonjs/Maths/math.vector";
  42829. import "babylonjs/Gamepads/gamepadSceneComponent";
  42830. /**
  42831. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42832. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42833. */
  42834. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42835. /**
  42836. * Creates a new VRDeviceOrientationGamepadCamera
  42837. * @param name defines camera name
  42838. * @param position defines the start position of the camera
  42839. * @param scene defines the scene the camera belongs to
  42840. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42841. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42842. */
  42843. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42844. /**
  42845. * Gets camera class name
  42846. * @returns VRDeviceOrientationGamepadCamera
  42847. */
  42848. getClassName(): string;
  42849. }
  42850. }
  42851. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42852. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42853. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42854. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42855. /** @hidden */
  42856. export var imageProcessingPixelShader: {
  42857. name: string;
  42858. shader: string;
  42859. };
  42860. }
  42861. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42862. import { Nullable } from "babylonjs/types";
  42863. import { Color4 } from "babylonjs/Maths/math.color";
  42864. import { Camera } from "babylonjs/Cameras/camera";
  42865. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42866. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42867. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42868. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42869. import { Engine } from "babylonjs/Engines/engine";
  42870. import "babylonjs/Shaders/imageProcessing.fragment";
  42871. import "babylonjs/Shaders/postprocess.vertex";
  42872. /**
  42873. * ImageProcessingPostProcess
  42874. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42875. */
  42876. export class ImageProcessingPostProcess extends PostProcess {
  42877. /**
  42878. * Default configuration related to image processing available in the PBR Material.
  42879. */
  42880. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42881. /**
  42882. * Gets the image processing configuration used either in this material.
  42883. */
  42884. /**
  42885. * Sets the Default image processing configuration used either in the this material.
  42886. *
  42887. * If sets to null, the scene one is in use.
  42888. */
  42889. imageProcessingConfiguration: ImageProcessingConfiguration;
  42890. /**
  42891. * Keep track of the image processing observer to allow dispose and replace.
  42892. */
  42893. private _imageProcessingObserver;
  42894. /**
  42895. * Attaches a new image processing configuration to the PBR Material.
  42896. * @param configuration
  42897. */
  42898. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42899. /**
  42900. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42901. */
  42902. /**
  42903. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42904. */
  42905. colorCurves: Nullable<ColorCurves>;
  42906. /**
  42907. * Gets wether the color curves effect is enabled.
  42908. */
  42909. /**
  42910. * Sets wether the color curves effect is enabled.
  42911. */
  42912. colorCurvesEnabled: boolean;
  42913. /**
  42914. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42915. */
  42916. /**
  42917. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42918. */
  42919. colorGradingTexture: Nullable<BaseTexture>;
  42920. /**
  42921. * Gets wether the color grading effect is enabled.
  42922. */
  42923. /**
  42924. * Gets wether the color grading effect is enabled.
  42925. */
  42926. colorGradingEnabled: boolean;
  42927. /**
  42928. * Gets exposure used in the effect.
  42929. */
  42930. /**
  42931. * Sets exposure used in the effect.
  42932. */
  42933. exposure: number;
  42934. /**
  42935. * Gets wether tonemapping is enabled or not.
  42936. */
  42937. /**
  42938. * Sets wether tonemapping is enabled or not
  42939. */
  42940. toneMappingEnabled: boolean;
  42941. /**
  42942. * Gets the type of tone mapping effect.
  42943. */
  42944. /**
  42945. * Sets the type of tone mapping effect.
  42946. */
  42947. toneMappingType: number;
  42948. /**
  42949. * Gets contrast used in the effect.
  42950. */
  42951. /**
  42952. * Sets contrast used in the effect.
  42953. */
  42954. contrast: number;
  42955. /**
  42956. * Gets Vignette stretch size.
  42957. */
  42958. /**
  42959. * Sets Vignette stretch size.
  42960. */
  42961. vignetteStretch: number;
  42962. /**
  42963. * Gets Vignette centre X Offset.
  42964. */
  42965. /**
  42966. * Sets Vignette centre X Offset.
  42967. */
  42968. vignetteCentreX: number;
  42969. /**
  42970. * Gets Vignette centre Y Offset.
  42971. */
  42972. /**
  42973. * Sets Vignette centre Y Offset.
  42974. */
  42975. vignetteCentreY: number;
  42976. /**
  42977. * Gets Vignette weight or intensity of the vignette effect.
  42978. */
  42979. /**
  42980. * Sets Vignette weight or intensity of the vignette effect.
  42981. */
  42982. vignetteWeight: number;
  42983. /**
  42984. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42985. * if vignetteEnabled is set to true.
  42986. */
  42987. /**
  42988. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42989. * if vignetteEnabled is set to true.
  42990. */
  42991. vignetteColor: Color4;
  42992. /**
  42993. * Gets Camera field of view used by the Vignette effect.
  42994. */
  42995. /**
  42996. * Sets Camera field of view used by the Vignette effect.
  42997. */
  42998. vignetteCameraFov: number;
  42999. /**
  43000. * Gets the vignette blend mode allowing different kind of effect.
  43001. */
  43002. /**
  43003. * Sets the vignette blend mode allowing different kind of effect.
  43004. */
  43005. vignetteBlendMode: number;
  43006. /**
  43007. * Gets wether the vignette effect is enabled.
  43008. */
  43009. /**
  43010. * Sets wether the vignette effect is enabled.
  43011. */
  43012. vignetteEnabled: boolean;
  43013. private _fromLinearSpace;
  43014. /**
  43015. * Gets wether the input of the processing is in Gamma or Linear Space.
  43016. */
  43017. /**
  43018. * Sets wether the input of the processing is in Gamma or Linear Space.
  43019. */
  43020. fromLinearSpace: boolean;
  43021. /**
  43022. * Defines cache preventing GC.
  43023. */
  43024. private _defines;
  43025. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43026. /**
  43027. * "ImageProcessingPostProcess"
  43028. * @returns "ImageProcessingPostProcess"
  43029. */
  43030. getClassName(): string;
  43031. protected _updateParameters(): void;
  43032. dispose(camera?: Camera): void;
  43033. }
  43034. }
  43035. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43036. import { Scene } from "babylonjs/scene";
  43037. import { Color3 } from "babylonjs/Maths/math.color";
  43038. import { Mesh } from "babylonjs/Meshes/mesh";
  43039. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43040. import { Nullable } from "babylonjs/types";
  43041. /**
  43042. * Class containing static functions to help procedurally build meshes
  43043. */
  43044. export class GroundBuilder {
  43045. /**
  43046. * Creates a ground mesh
  43047. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43048. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43050. * @param name defines the name of the mesh
  43051. * @param options defines the options used to create the mesh
  43052. * @param scene defines the hosting scene
  43053. * @returns the ground mesh
  43054. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43055. */
  43056. static CreateGround(name: string, options: {
  43057. width?: number;
  43058. height?: number;
  43059. subdivisions?: number;
  43060. subdivisionsX?: number;
  43061. subdivisionsY?: number;
  43062. updatable?: boolean;
  43063. }, scene: any): Mesh;
  43064. /**
  43065. * Creates a tiled ground mesh
  43066. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43067. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43068. * * 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
  43069. * * 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
  43070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43071. * @param name defines the name of the mesh
  43072. * @param options defines the options used to create the mesh
  43073. * @param scene defines the hosting scene
  43074. * @returns the tiled ground mesh
  43075. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43076. */
  43077. static CreateTiledGround(name: string, options: {
  43078. xmin: number;
  43079. zmin: number;
  43080. xmax: number;
  43081. zmax: number;
  43082. subdivisions?: {
  43083. w: number;
  43084. h: number;
  43085. };
  43086. precision?: {
  43087. w: number;
  43088. h: number;
  43089. };
  43090. updatable?: boolean;
  43091. }, scene?: Nullable<Scene>): Mesh;
  43092. /**
  43093. * Creates a ground mesh from a height map
  43094. * * The parameter `url` sets the URL of the height map image resource.
  43095. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43096. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43097. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43098. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43099. * * 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.
  43100. * * 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).
  43101. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43103. * @param name defines the name of the mesh
  43104. * @param url defines the url to the height map
  43105. * @param options defines the options used to create the mesh
  43106. * @param scene defines the hosting scene
  43107. * @returns the ground mesh
  43108. * @see https://doc.babylonjs.com/babylon101/height_map
  43109. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43110. */
  43111. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43112. width?: number;
  43113. height?: number;
  43114. subdivisions?: number;
  43115. minHeight?: number;
  43116. maxHeight?: number;
  43117. colorFilter?: Color3;
  43118. alphaFilter?: number;
  43119. updatable?: boolean;
  43120. onReady?: (mesh: GroundMesh) => void;
  43121. }, scene?: Nullable<Scene>): GroundMesh;
  43122. }
  43123. }
  43124. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43125. import { Vector4 } from "babylonjs/Maths/math.vector";
  43126. import { Mesh } from "babylonjs/Meshes/mesh";
  43127. /**
  43128. * Class containing static functions to help procedurally build meshes
  43129. */
  43130. export class TorusBuilder {
  43131. /**
  43132. * Creates a torus mesh
  43133. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43134. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43135. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43136. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43137. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43139. * @param name defines the name of the mesh
  43140. * @param options defines the options used to create the mesh
  43141. * @param scene defines the hosting scene
  43142. * @returns the torus mesh
  43143. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43144. */
  43145. static CreateTorus(name: string, options: {
  43146. diameter?: number;
  43147. thickness?: number;
  43148. tessellation?: number;
  43149. updatable?: boolean;
  43150. sideOrientation?: number;
  43151. frontUVs?: Vector4;
  43152. backUVs?: Vector4;
  43153. }, scene: any): Mesh;
  43154. }
  43155. }
  43156. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43157. import { Vector4 } from "babylonjs/Maths/math.vector";
  43158. import { Color4 } from "babylonjs/Maths/math.color";
  43159. import { Mesh } from "babylonjs/Meshes/mesh";
  43160. /**
  43161. * Class containing static functions to help procedurally build meshes
  43162. */
  43163. export class CylinderBuilder {
  43164. /**
  43165. * Creates a cylinder or a cone mesh
  43166. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43167. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43168. * * 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.
  43169. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43170. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43171. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43172. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43173. * * 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).
  43174. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43175. * * 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).
  43176. * * 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
  43177. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43178. * * 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
  43179. * * 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.
  43180. * * If `enclose` is false, a ring surface is one element.
  43181. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43182. * * 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
  43183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43184. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43186. * @param name defines the name of the mesh
  43187. * @param options defines the options used to create the mesh
  43188. * @param scene defines the hosting scene
  43189. * @returns the cylinder mesh
  43190. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43191. */
  43192. static CreateCylinder(name: string, options: {
  43193. height?: number;
  43194. diameterTop?: number;
  43195. diameterBottom?: number;
  43196. diameter?: number;
  43197. tessellation?: number;
  43198. subdivisions?: number;
  43199. arc?: number;
  43200. faceColors?: Color4[];
  43201. faceUV?: Vector4[];
  43202. updatable?: boolean;
  43203. hasRings?: boolean;
  43204. enclose?: boolean;
  43205. cap?: number;
  43206. sideOrientation?: number;
  43207. frontUVs?: Vector4;
  43208. backUVs?: Vector4;
  43209. }, scene: any): Mesh;
  43210. }
  43211. }
  43212. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43213. import { Nullable } from "babylonjs/types";
  43214. import { IDisposable } from "babylonjs/scene";
  43215. /**
  43216. * States of the webXR experience
  43217. */
  43218. export enum WebXRState {
  43219. /**
  43220. * Transitioning to being in XR mode
  43221. */
  43222. ENTERING_XR = 0,
  43223. /**
  43224. * Transitioning to non XR mode
  43225. */
  43226. EXITING_XR = 1,
  43227. /**
  43228. * In XR mode and presenting
  43229. */
  43230. IN_XR = 2,
  43231. /**
  43232. * Not entered XR mode
  43233. */
  43234. NOT_IN_XR = 3
  43235. }
  43236. /**
  43237. * Abstraction of the XR render target
  43238. */
  43239. export interface WebXRRenderTarget extends IDisposable {
  43240. /**
  43241. * xrpresent context of the canvas which can be used to display/mirror xr content
  43242. */
  43243. canvasContext: WebGLRenderingContext;
  43244. /**
  43245. * xr layer for the canvas
  43246. */
  43247. xrLayer: Nullable<XRWebGLLayer>;
  43248. /**
  43249. * Initializes the xr layer for the session
  43250. * @param xrSession xr session
  43251. * @returns a promise that will resolve once the XR Layer has been created
  43252. */
  43253. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43254. }
  43255. }
  43256. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43257. import { Nullable } from "babylonjs/types";
  43258. import { Observable } from "babylonjs/Misc/observable";
  43259. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43260. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43261. /**
  43262. * COnfiguration object for WebXR output canvas
  43263. */
  43264. export class WebXRManagedOutputCanvasOptions {
  43265. /**
  43266. * Options for this XR Layer output
  43267. */
  43268. canvasOptions: XRWebGLLayerOptions;
  43269. /**
  43270. * CSS styling for a newly created canvas (if not provided)
  43271. */
  43272. newCanvasCssStyle?: string;
  43273. /**
  43274. * Get the default values of the configuration object
  43275. * @returns default values of this configuration object
  43276. */
  43277. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43278. }
  43279. /**
  43280. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43281. */
  43282. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43283. private configuration;
  43284. private _engine;
  43285. private _canvas;
  43286. /**
  43287. * xrpresent context of the canvas which can be used to display/mirror xr content
  43288. */
  43289. canvasContext: WebGLRenderingContext;
  43290. /**
  43291. * xr layer for the canvas
  43292. */
  43293. xrLayer: Nullable<XRWebGLLayer>;
  43294. /**
  43295. * Initializes the xr layer for the session
  43296. * @param xrSession xr session
  43297. * @returns a promise that will resolve once the XR Layer has been created
  43298. */
  43299. initializeXRLayerAsync(xrSession: any): any;
  43300. /**
  43301. * Initializes the canvas to be added/removed upon entering/exiting xr
  43302. * @param engine the Babylon engine
  43303. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43304. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43305. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43306. */
  43307. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43308. /**
  43309. * Disposes of the object
  43310. */
  43311. dispose(): void;
  43312. private _setManagedOutputCanvas;
  43313. private _addCanvas;
  43314. private _removeCanvas;
  43315. }
  43316. }
  43317. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43318. import { Observable } from "babylonjs/Misc/observable";
  43319. import { Nullable } from "babylonjs/types";
  43320. import { IDisposable, Scene } from "babylonjs/scene";
  43321. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43322. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43323. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43324. /**
  43325. * Manages an XRSession to work with Babylon's engine
  43326. * @see https://doc.babylonjs.com/how_to/webxr
  43327. */
  43328. export class WebXRSessionManager implements IDisposable {
  43329. /** The scene which the session should be created for */
  43330. scene: Scene;
  43331. /**
  43332. * Fires every time a new xrFrame arrives which can be used to update the camera
  43333. */
  43334. onXRFrameObservable: Observable<XRFrame>;
  43335. /**
  43336. * Fires when the xr session is ended either by the device or manually done
  43337. */
  43338. onXRSessionEnded: Observable<any>;
  43339. /**
  43340. * Fires when the xr session is ended either by the device or manually done
  43341. */
  43342. onXRSessionInit: Observable<XRSession>;
  43343. /**
  43344. * Underlying xr session
  43345. */
  43346. session: XRSession;
  43347. /**
  43348. * Type of reference space used when creating the session
  43349. */
  43350. referenceSpace: XRReferenceSpace;
  43351. /**
  43352. * Current XR frame
  43353. */
  43354. currentFrame: Nullable<XRFrame>;
  43355. private _xrNavigator;
  43356. private baseLayer;
  43357. private _rttProvider;
  43358. private _sessionEnded;
  43359. /**
  43360. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43361. * @param scene The scene which the session should be created for
  43362. */
  43363. constructor(
  43364. /** The scene which the session should be created for */
  43365. scene: Scene);
  43366. /**
  43367. * Initializes the manager
  43368. * After initialization enterXR can be called to start an XR session
  43369. * @returns Promise which resolves after it is initialized
  43370. */
  43371. initializeAsync(): Promise<void>;
  43372. /**
  43373. * Initializes an xr session
  43374. * @param xrSessionMode mode to initialize
  43375. * @param optionalFeatures defines optional values to pass to the session builder
  43376. * @returns a promise which will resolve once the session has been initialized
  43377. */
  43378. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  43379. /**
  43380. * Sets the reference space on the xr session
  43381. * @param referenceSpace space to set
  43382. * @returns a promise that will resolve once the reference space has been set
  43383. */
  43384. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43385. /**
  43386. * Updates the render state of the session
  43387. * @param state state to set
  43388. * @returns a promise that resolves once the render state has been updated
  43389. */
  43390. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43391. /**
  43392. * Starts rendering to the xr layer
  43393. * @returns a promise that will resolve once rendering has started
  43394. */
  43395. startRenderingToXRAsync(): Promise<void>;
  43396. /**
  43397. * Gets the correct render target texture to be rendered this frame for this eye
  43398. * @param eye the eye for which to get the render target
  43399. * @returns the render target for the specified eye
  43400. */
  43401. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43402. /**
  43403. * Stops the xrSession and restores the renderloop
  43404. * @returns Promise which resolves after it exits XR
  43405. */
  43406. exitXRAsync(): Promise<void>;
  43407. /**
  43408. * Checks if a session would be supported for the creation options specified
  43409. * @param sessionMode session mode to check if supported eg. immersive-vr
  43410. * @returns true if supported
  43411. */
  43412. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43413. /**
  43414. * Creates a WebXRRenderTarget object for the XR session
  43415. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43416. * @param options optional options to provide when creating a new render target
  43417. * @returns a WebXR render target to which the session can render
  43418. */
  43419. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43420. /**
  43421. * @hidden
  43422. * Converts the render layer of xrSession to a render target
  43423. * @param session session to create render target for
  43424. * @param scene scene the new render target should be created for
  43425. * @param baseLayer the webgl layer to create the render target for
  43426. */
  43427. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43428. /**
  43429. * Disposes of the session manager
  43430. */
  43431. dispose(): void;
  43432. /**
  43433. * Gets a promise returning true when fullfiled if the given session mode is supported
  43434. * @param sessionMode defines the session to test
  43435. * @returns a promise
  43436. */
  43437. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43438. }
  43439. }
  43440. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43441. import { Scene } from "babylonjs/scene";
  43442. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43443. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43444. /**
  43445. * WebXR Camera which holds the views for the xrSession
  43446. * @see https://doc.babylonjs.com/how_to/webxr
  43447. */
  43448. export class WebXRCamera extends FreeCamera {
  43449. /**
  43450. * Is the camera in debug mode. Used when using an emulator
  43451. */
  43452. debugMode: boolean;
  43453. /**
  43454. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43455. * @param name the name of the camera
  43456. * @param scene the scene to add the camera to
  43457. */
  43458. constructor(name: string, scene: Scene);
  43459. private _updateNumberOfRigCameras;
  43460. /** @hidden */
  43461. _updateForDualEyeDebugging(): void;
  43462. /**
  43463. * Updates the cameras position from the current pose information of the XR session
  43464. * @param xrSessionManager the session containing pose information
  43465. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43466. */
  43467. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43468. }
  43469. }
  43470. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43471. import { Observable } from "babylonjs/Misc/observable";
  43472. import { IDisposable, Scene } from "babylonjs/scene";
  43473. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43475. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43476. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43477. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43478. /**
  43479. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43480. * @see https://doc.babylonjs.com/how_to/webxr
  43481. */
  43482. export class WebXRExperienceHelper implements IDisposable {
  43483. private scene;
  43484. /**
  43485. * 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
  43486. */
  43487. container: AbstractMesh;
  43488. /**
  43489. * Camera used to render xr content
  43490. */
  43491. camera: WebXRCamera;
  43492. /**
  43493. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43494. */
  43495. state: WebXRState;
  43496. private _setState;
  43497. private static _TmpVector;
  43498. /**
  43499. * Fires when the state of the experience helper has changed
  43500. */
  43501. onStateChangedObservable: Observable<WebXRState>;
  43502. /** Session manager used to keep track of xr session */
  43503. sessionManager: WebXRSessionManager;
  43504. private _nonVRCamera;
  43505. private _originalSceneAutoClear;
  43506. private _supported;
  43507. /**
  43508. * Creates the experience helper
  43509. * @param scene the scene to attach the experience helper to
  43510. * @returns a promise for the experience helper
  43511. */
  43512. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43513. /**
  43514. * Creates a WebXRExperienceHelper
  43515. * @param scene The scene the helper should be created in
  43516. */
  43517. private constructor();
  43518. /**
  43519. * Exits XR mode and returns the scene to its original state
  43520. * @returns promise that resolves after xr mode has exited
  43521. */
  43522. exitXRAsync(): Promise<void>;
  43523. /**
  43524. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43525. * @param sessionMode options for the XR session
  43526. * @param referenceSpaceType frame of reference of the XR session
  43527. * @param renderTarget the output canvas that will be used to enter XR mode
  43528. * @returns promise that resolves after xr mode has entered
  43529. */
  43530. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43531. /**
  43532. * Updates the global position of the camera by moving the camera's container
  43533. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43534. * @param position The desired global position of the camera
  43535. */
  43536. setPositionOfCameraUsingContainer(position: Vector3): void;
  43537. /**
  43538. * Rotates the xr camera by rotating the camera's container around the camera's position
  43539. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43540. * @param rotation the desired quaternion rotation to apply to the camera
  43541. */
  43542. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43543. /**
  43544. * Disposes of the experience helper
  43545. */
  43546. dispose(): void;
  43547. }
  43548. }
  43549. declare module "babylonjs/Cameras/XR/webXRController" {
  43550. import { Nullable } from "babylonjs/types";
  43551. import { Observable } from "babylonjs/Misc/observable";
  43552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43553. import { Ray } from "babylonjs/Culling/ray";
  43554. import { Scene } from "babylonjs/scene";
  43555. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43556. /**
  43557. * Represents an XR input
  43558. */
  43559. export class WebXRController {
  43560. private scene;
  43561. /** The underlying input source for the controller */
  43562. inputSource: XRInputSource;
  43563. private parentContainer;
  43564. /**
  43565. * 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
  43566. */
  43567. grip?: AbstractMesh;
  43568. /**
  43569. * Pointer which can be used to select objects or attach a visible laser to
  43570. */
  43571. pointer: AbstractMesh;
  43572. private _gamepadMode;
  43573. /**
  43574. * If available, this is the gamepad object related to this controller.
  43575. * Using this object it is possible to get click events and trackpad changes of the
  43576. * webxr controller that is currently being used.
  43577. */
  43578. gamepadController?: WebVRController;
  43579. /**
  43580. * Event that fires when the controller is removed/disposed
  43581. */
  43582. onDisposeObservable: Observable<{}>;
  43583. private _tmpQuaternion;
  43584. private _tmpVector;
  43585. /**
  43586. * Creates the controller
  43587. * @see https://doc.babylonjs.com/how_to/webxr
  43588. * @param scene the scene which the controller should be associated to
  43589. * @param inputSource the underlying input source for the controller
  43590. * @param parentContainer parent that the controller meshes should be children of
  43591. */
  43592. constructor(scene: Scene,
  43593. /** The underlying input source for the controller */
  43594. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43595. /**
  43596. * Updates the controller pose based on the given XRFrame
  43597. * @param xrFrame xr frame to update the pose with
  43598. * @param referenceSpace reference space to use
  43599. */
  43600. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43601. /**
  43602. * Gets a world space ray coming from the controller
  43603. * @param result the resulting ray
  43604. */
  43605. getWorldPointerRayToRef(result: Ray): void;
  43606. /**
  43607. * Get the scene associated with this controller
  43608. * @returns the scene object
  43609. */
  43610. getScene(): Scene;
  43611. /**
  43612. * Disposes of the object
  43613. */
  43614. dispose(): void;
  43615. }
  43616. }
  43617. declare module "babylonjs/Cameras/XR/webXRInput" {
  43618. import { Observable } from "babylonjs/Misc/observable";
  43619. import { IDisposable } from "babylonjs/scene";
  43620. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43621. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43622. /**
  43623. * XR input used to track XR inputs such as controllers/rays
  43624. */
  43625. export class WebXRInput implements IDisposable {
  43626. /**
  43627. * Base experience the input listens to
  43628. */
  43629. baseExperience: WebXRExperienceHelper;
  43630. /**
  43631. * XR controllers being tracked
  43632. */
  43633. controllers: Array<WebXRController>;
  43634. private _frameObserver;
  43635. private _stateObserver;
  43636. /**
  43637. * Event when a controller has been connected/added
  43638. */
  43639. onControllerAddedObservable: Observable<WebXRController>;
  43640. /**
  43641. * Event when a controller has been removed/disconnected
  43642. */
  43643. onControllerRemovedObservable: Observable<WebXRController>;
  43644. /**
  43645. * Initializes the WebXRInput
  43646. * @param baseExperience experience helper which the input should be created for
  43647. */
  43648. constructor(
  43649. /**
  43650. * Base experience the input listens to
  43651. */
  43652. baseExperience: WebXRExperienceHelper);
  43653. private _onInputSourcesChange;
  43654. private _addAndRemoveControllers;
  43655. /**
  43656. * Disposes of the object
  43657. */
  43658. dispose(): void;
  43659. }
  43660. }
  43661. declare module "babylonjs/Loading/sceneLoader" {
  43662. import { Observable } from "babylonjs/Misc/observable";
  43663. import { Nullable } from "babylonjs/types";
  43664. import { Scene } from "babylonjs/scene";
  43665. import { Engine } from "babylonjs/Engines/engine";
  43666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43667. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43668. import { AssetContainer } from "babylonjs/assetContainer";
  43669. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43670. import { Skeleton } from "babylonjs/Bones/skeleton";
  43671. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43672. import { WebRequest } from "babylonjs/Misc/webRequest";
  43673. /**
  43674. * Class used to represent data loading progression
  43675. */
  43676. export class SceneLoaderProgressEvent {
  43677. /** defines if data length to load can be evaluated */
  43678. readonly lengthComputable: boolean;
  43679. /** defines the loaded data length */
  43680. readonly loaded: number;
  43681. /** defines the data length to load */
  43682. readonly total: number;
  43683. /**
  43684. * Create a new progress event
  43685. * @param lengthComputable defines if data length to load can be evaluated
  43686. * @param loaded defines the loaded data length
  43687. * @param total defines the data length to load
  43688. */
  43689. constructor(
  43690. /** defines if data length to load can be evaluated */
  43691. lengthComputable: boolean,
  43692. /** defines the loaded data length */
  43693. loaded: number,
  43694. /** defines the data length to load */
  43695. total: number);
  43696. /**
  43697. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43698. * @param event defines the source event
  43699. * @returns a new SceneLoaderProgressEvent
  43700. */
  43701. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43702. }
  43703. /**
  43704. * Interface used by SceneLoader plugins to define supported file extensions
  43705. */
  43706. export interface ISceneLoaderPluginExtensions {
  43707. /**
  43708. * Defines the list of supported extensions
  43709. */
  43710. [extension: string]: {
  43711. isBinary: boolean;
  43712. };
  43713. }
  43714. /**
  43715. * Interface used by SceneLoader plugin factory
  43716. */
  43717. export interface ISceneLoaderPluginFactory {
  43718. /**
  43719. * Defines the name of the factory
  43720. */
  43721. name: string;
  43722. /**
  43723. * Function called to create a new plugin
  43724. * @return the new plugin
  43725. */
  43726. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43727. /**
  43728. * The callback that returns true if the data can be directly loaded.
  43729. * @param data string containing the file data
  43730. * @returns if the data can be loaded directly
  43731. */
  43732. canDirectLoad?(data: string): boolean;
  43733. }
  43734. /**
  43735. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43736. */
  43737. export interface ISceneLoaderPluginBase {
  43738. /**
  43739. * The friendly name of this plugin.
  43740. */
  43741. name: string;
  43742. /**
  43743. * The file extensions supported by this plugin.
  43744. */
  43745. extensions: string | ISceneLoaderPluginExtensions;
  43746. /**
  43747. * The callback called when loading from a url.
  43748. * @param scene scene loading this url
  43749. * @param url url to load
  43750. * @param onSuccess callback called when the file successfully loads
  43751. * @param onProgress callback called while file is loading (if the server supports this mode)
  43752. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43753. * @param onError callback called when the file fails to load
  43754. * @returns a file request object
  43755. */
  43756. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43757. /**
  43758. * The callback called when loading from a file object.
  43759. * @param scene scene loading this file
  43760. * @param file defines the file to load
  43761. * @param onSuccess defines the callback to call when data is loaded
  43762. * @param onProgress defines the callback to call during loading process
  43763. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43764. * @param onError defines the callback to call when an error occurs
  43765. * @returns a file request object
  43766. */
  43767. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43768. /**
  43769. * The callback that returns true if the data can be directly loaded.
  43770. * @param data string containing the file data
  43771. * @returns if the data can be loaded directly
  43772. */
  43773. canDirectLoad?(data: string): boolean;
  43774. /**
  43775. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43776. * @param scene scene loading this data
  43777. * @param data string containing the data
  43778. * @returns data to pass to the plugin
  43779. */
  43780. directLoad?(scene: Scene, data: string): any;
  43781. /**
  43782. * The callback that allows custom handling of the root url based on the response url.
  43783. * @param rootUrl the original root url
  43784. * @param responseURL the response url if available
  43785. * @returns the new root url
  43786. */
  43787. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43788. }
  43789. /**
  43790. * Interface used to define a SceneLoader plugin
  43791. */
  43792. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43793. /**
  43794. * Import meshes into a scene.
  43795. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43796. * @param scene The scene to import into
  43797. * @param data The data to import
  43798. * @param rootUrl The root url for scene and resources
  43799. * @param meshes The meshes array to import into
  43800. * @param particleSystems The particle systems array to import into
  43801. * @param skeletons The skeletons array to import into
  43802. * @param onError The callback when import fails
  43803. * @returns True if successful or false otherwise
  43804. */
  43805. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43806. /**
  43807. * Load into a scene.
  43808. * @param scene The scene to load into
  43809. * @param data The data to import
  43810. * @param rootUrl The root url for scene and resources
  43811. * @param onError The callback when import fails
  43812. * @returns True if successful or false otherwise
  43813. */
  43814. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43815. /**
  43816. * Load into an asset container.
  43817. * @param scene The scene to load into
  43818. * @param data The data to import
  43819. * @param rootUrl The root url for scene and resources
  43820. * @param onError The callback when import fails
  43821. * @returns The loaded asset container
  43822. */
  43823. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43824. }
  43825. /**
  43826. * Interface used to define an async SceneLoader plugin
  43827. */
  43828. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43829. /**
  43830. * Import meshes into a scene.
  43831. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43832. * @param scene The scene to import into
  43833. * @param data The data to import
  43834. * @param rootUrl The root url for scene and resources
  43835. * @param onProgress The callback when the load progresses
  43836. * @param fileName Defines the name of the file to load
  43837. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43838. */
  43839. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43840. meshes: AbstractMesh[];
  43841. particleSystems: IParticleSystem[];
  43842. skeletons: Skeleton[];
  43843. animationGroups: AnimationGroup[];
  43844. }>;
  43845. /**
  43846. * Load into a scene.
  43847. * @param scene The scene to load into
  43848. * @param data The data to import
  43849. * @param rootUrl The root url for scene and resources
  43850. * @param onProgress The callback when the load progresses
  43851. * @param fileName Defines the name of the file to load
  43852. * @returns Nothing
  43853. */
  43854. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43855. /**
  43856. * Load into an asset container.
  43857. * @param scene The scene to load into
  43858. * @param data The data to import
  43859. * @param rootUrl The root url for scene and resources
  43860. * @param onProgress The callback when the load progresses
  43861. * @param fileName Defines the name of the file to load
  43862. * @returns The loaded asset container
  43863. */
  43864. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43865. }
  43866. /**
  43867. * Mode that determines how to handle old animation groups before loading new ones.
  43868. */
  43869. export enum SceneLoaderAnimationGroupLoadingMode {
  43870. /**
  43871. * Reset all old animations to initial state then dispose them.
  43872. */
  43873. Clean = 0,
  43874. /**
  43875. * Stop all old animations.
  43876. */
  43877. Stop = 1,
  43878. /**
  43879. * Restart old animations from first frame.
  43880. */
  43881. Sync = 2,
  43882. /**
  43883. * Old animations remains untouched.
  43884. */
  43885. NoSync = 3
  43886. }
  43887. /**
  43888. * Class used to load scene from various file formats using registered plugins
  43889. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43890. */
  43891. export class SceneLoader {
  43892. /**
  43893. * No logging while loading
  43894. */
  43895. static readonly NO_LOGGING: number;
  43896. /**
  43897. * Minimal logging while loading
  43898. */
  43899. static readonly MINIMAL_LOGGING: number;
  43900. /**
  43901. * Summary logging while loading
  43902. */
  43903. static readonly SUMMARY_LOGGING: number;
  43904. /**
  43905. * Detailled logging while loading
  43906. */
  43907. static readonly DETAILED_LOGGING: number;
  43908. /**
  43909. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43910. */
  43911. static ForceFullSceneLoadingForIncremental: boolean;
  43912. /**
  43913. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43914. */
  43915. static ShowLoadingScreen: boolean;
  43916. /**
  43917. * Defines the current logging level (while loading the scene)
  43918. * @ignorenaming
  43919. */
  43920. static loggingLevel: number;
  43921. /**
  43922. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43923. */
  43924. static CleanBoneMatrixWeights: boolean;
  43925. /**
  43926. * Event raised when a plugin is used to load a scene
  43927. */
  43928. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43929. private static _registeredPlugins;
  43930. private static _getDefaultPlugin;
  43931. private static _getPluginForExtension;
  43932. private static _getPluginForDirectLoad;
  43933. private static _getPluginForFilename;
  43934. private static _getDirectLoad;
  43935. private static _loadData;
  43936. private static _getFileInfo;
  43937. /**
  43938. * Gets a plugin that can load the given extension
  43939. * @param extension defines the extension to load
  43940. * @returns a plugin or null if none works
  43941. */
  43942. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43943. /**
  43944. * Gets a boolean indicating that the given extension can be loaded
  43945. * @param extension defines the extension to load
  43946. * @returns true if the extension is supported
  43947. */
  43948. static IsPluginForExtensionAvailable(extension: string): boolean;
  43949. /**
  43950. * Adds a new plugin to the list of registered plugins
  43951. * @param plugin defines the plugin to add
  43952. */
  43953. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43954. /**
  43955. * Import meshes into a scene
  43956. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43957. * @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)
  43958. * @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)
  43959. * @param scene the instance of BABYLON.Scene to append to
  43960. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43961. * @param onProgress a callback with a progress event for each file being loaded
  43962. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43963. * @param pluginExtension the extension used to determine the plugin
  43964. * @returns The loaded plugin
  43965. */
  43966. 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>;
  43967. /**
  43968. * Import meshes into a scene
  43969. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43970. * @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)
  43971. * @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)
  43972. * @param scene the instance of BABYLON.Scene to append to
  43973. * @param onProgress a callback with a progress event for each file being loaded
  43974. * @param pluginExtension the extension used to determine the plugin
  43975. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43976. */
  43977. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43978. meshes: AbstractMesh[];
  43979. particleSystems: IParticleSystem[];
  43980. skeletons: Skeleton[];
  43981. animationGroups: AnimationGroup[];
  43982. }>;
  43983. /**
  43984. * Load a scene
  43985. * @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)
  43986. * @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)
  43987. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43988. * @param onSuccess a callback with the scene when import succeeds
  43989. * @param onProgress a callback with a progress event for each file being loaded
  43990. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43991. * @param pluginExtension the extension used to determine the plugin
  43992. * @returns The loaded plugin
  43993. */
  43994. 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>;
  43995. /**
  43996. * Load a scene
  43997. * @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)
  43998. * @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)
  43999. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44000. * @param onProgress a callback with a progress event for each file being loaded
  44001. * @param pluginExtension the extension used to determine the plugin
  44002. * @returns The loaded scene
  44003. */
  44004. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44005. /**
  44006. * Append a scene
  44007. * @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)
  44008. * @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)
  44009. * @param scene is the instance of BABYLON.Scene to append to
  44010. * @param onSuccess a callback with the scene when import succeeds
  44011. * @param onProgress a callback with a progress event for each file being loaded
  44012. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44013. * @param pluginExtension the extension used to determine the plugin
  44014. * @returns The loaded plugin
  44015. */
  44016. 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>;
  44017. /**
  44018. * Append a scene
  44019. * @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)
  44020. * @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)
  44021. * @param scene is the instance of BABYLON.Scene to append to
  44022. * @param onProgress a callback with a progress event for each file being loaded
  44023. * @param pluginExtension the extension used to determine the plugin
  44024. * @returns The given scene
  44025. */
  44026. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44027. /**
  44028. * Load a scene into an asset container
  44029. * @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)
  44030. * @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)
  44031. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44032. * @param onSuccess a callback with the scene when import succeeds
  44033. * @param onProgress a callback with a progress event for each file being loaded
  44034. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44035. * @param pluginExtension the extension used to determine the plugin
  44036. * @returns The loaded plugin
  44037. */
  44038. 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>;
  44039. /**
  44040. * Load a scene into an asset container
  44041. * @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)
  44042. * @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)
  44043. * @param scene is the instance of Scene to append to
  44044. * @param onProgress a callback with a progress event for each file being loaded
  44045. * @param pluginExtension the extension used to determine the plugin
  44046. * @returns The loaded asset container
  44047. */
  44048. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44049. /**
  44050. * Import animations from a file into a scene
  44051. * @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)
  44052. * @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)
  44053. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44054. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44055. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44056. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44057. * @param onSuccess a callback with the scene when import succeeds
  44058. * @param onProgress a callback with a progress event for each file being loaded
  44059. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44060. */
  44061. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  44062. /**
  44063. * Import animations from a file into a scene
  44064. * @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)
  44065. * @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)
  44066. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44067. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44068. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44069. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44070. * @param onSuccess a callback with the scene when import succeeds
  44071. * @param onProgress a callback with a progress event for each file being loaded
  44072. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44073. * @returns the updated scene with imported animations
  44074. */
  44075. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  44076. }
  44077. }
  44078. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44079. import { Scene } from "babylonjs/scene";
  44080. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44081. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44082. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44083. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44084. /**
  44085. * Generic Controller
  44086. */
  44087. export class GenericController extends WebVRController {
  44088. /**
  44089. * Base Url for the controller model.
  44090. */
  44091. static readonly MODEL_BASE_URL: string;
  44092. /**
  44093. * File name for the controller model.
  44094. */
  44095. static readonly MODEL_FILENAME: string;
  44096. /**
  44097. * Creates a new GenericController from a gamepad
  44098. * @param vrGamepad the gamepad that the controller should be created from
  44099. */
  44100. constructor(vrGamepad: any);
  44101. /**
  44102. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44103. * @param scene scene in which to add meshes
  44104. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44105. */
  44106. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44107. /**
  44108. * Called once for each button that changed state since the last frame
  44109. * @param buttonIdx Which button index changed
  44110. * @param state New state of the button
  44111. * @param changes Which properties on the state changed since last frame
  44112. */
  44113. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44114. }
  44115. }
  44116. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44117. import { Observable } from "babylonjs/Misc/observable";
  44118. import { Scene } from "babylonjs/scene";
  44119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44120. import { Ray } from "babylonjs/Culling/ray";
  44121. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44122. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44123. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44124. /**
  44125. * Defines the WindowsMotionController object that the state of the windows motion controller
  44126. */
  44127. export class WindowsMotionController extends WebVRController {
  44128. /**
  44129. * The base url used to load the left and right controller models
  44130. */
  44131. static MODEL_BASE_URL: string;
  44132. /**
  44133. * The name of the left controller model file
  44134. */
  44135. static MODEL_LEFT_FILENAME: string;
  44136. /**
  44137. * The name of the right controller model file
  44138. */
  44139. static MODEL_RIGHT_FILENAME: string;
  44140. /**
  44141. * The controller name prefix for this controller type
  44142. */
  44143. static readonly GAMEPAD_ID_PREFIX: string;
  44144. /**
  44145. * The controller id pattern for this controller type
  44146. */
  44147. private static readonly GAMEPAD_ID_PATTERN;
  44148. private _loadedMeshInfo;
  44149. protected readonly _mapping: {
  44150. buttons: string[];
  44151. buttonMeshNames: {
  44152. 'trigger': string;
  44153. 'menu': string;
  44154. 'grip': string;
  44155. 'thumbstick': string;
  44156. 'trackpad': string;
  44157. };
  44158. buttonObservableNames: {
  44159. 'trigger': string;
  44160. 'menu': string;
  44161. 'grip': string;
  44162. 'thumbstick': string;
  44163. 'trackpad': string;
  44164. };
  44165. axisMeshNames: string[];
  44166. pointingPoseMeshName: string;
  44167. };
  44168. /**
  44169. * Fired when the trackpad on this controller is clicked
  44170. */
  44171. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44172. /**
  44173. * Fired when the trackpad on this controller is modified
  44174. */
  44175. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44176. /**
  44177. * The current x and y values of this controller's trackpad
  44178. */
  44179. trackpad: StickValues;
  44180. /**
  44181. * Creates a new WindowsMotionController from a gamepad
  44182. * @param vrGamepad the gamepad that the controller should be created from
  44183. */
  44184. constructor(vrGamepad: any);
  44185. /**
  44186. * Fired when the trigger on this controller is modified
  44187. */
  44188. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44189. /**
  44190. * Fired when the menu button on this controller is modified
  44191. */
  44192. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44193. /**
  44194. * Fired when the grip button on this controller is modified
  44195. */
  44196. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44197. /**
  44198. * Fired when the thumbstick button on this controller is modified
  44199. */
  44200. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44201. /**
  44202. * Fired when the touchpad button on this controller is modified
  44203. */
  44204. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44205. /**
  44206. * Fired when the touchpad values on this controller are modified
  44207. */
  44208. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44209. protected _updateTrackpad(): void;
  44210. /**
  44211. * Called once per frame by the engine.
  44212. */
  44213. update(): void;
  44214. /**
  44215. * Called once for each button that changed state since the last frame
  44216. * @param buttonIdx Which button index changed
  44217. * @param state New state of the button
  44218. * @param changes Which properties on the state changed since last frame
  44219. */
  44220. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44221. /**
  44222. * Moves the buttons on the controller mesh based on their current state
  44223. * @param buttonName the name of the button to move
  44224. * @param buttonValue the value of the button which determines the buttons new position
  44225. */
  44226. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44227. /**
  44228. * Moves the axis on the controller mesh based on its current state
  44229. * @param axis the index of the axis
  44230. * @param axisValue the value of the axis which determines the meshes new position
  44231. * @hidden
  44232. */
  44233. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44234. /**
  44235. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44236. * @param scene scene in which to add meshes
  44237. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44238. */
  44239. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44240. /**
  44241. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44242. * can be transformed by button presses and axes values, based on this._mapping.
  44243. *
  44244. * @param scene scene in which the meshes exist
  44245. * @param meshes list of meshes that make up the controller model to process
  44246. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44247. */
  44248. private processModel;
  44249. private createMeshInfo;
  44250. /**
  44251. * Gets the ray of the controller in the direction the controller is pointing
  44252. * @param length the length the resulting ray should be
  44253. * @returns a ray in the direction the controller is pointing
  44254. */
  44255. getForwardRay(length?: number): Ray;
  44256. /**
  44257. * Disposes of the controller
  44258. */
  44259. dispose(): void;
  44260. }
  44261. /**
  44262. * This class represents a new windows motion controller in XR.
  44263. */
  44264. export class XRWindowsMotionController extends WindowsMotionController {
  44265. /**
  44266. * Changing the original WIndowsMotionController mapping to fir the new mapping
  44267. */
  44268. protected readonly _mapping: {
  44269. buttons: string[];
  44270. buttonMeshNames: {
  44271. 'trigger': string;
  44272. 'menu': string;
  44273. 'grip': string;
  44274. 'thumbstick': string;
  44275. 'trackpad': string;
  44276. };
  44277. buttonObservableNames: {
  44278. 'trigger': string;
  44279. 'menu': string;
  44280. 'grip': string;
  44281. 'thumbstick': string;
  44282. 'trackpad': string;
  44283. };
  44284. axisMeshNames: string[];
  44285. pointingPoseMeshName: string;
  44286. };
  44287. /**
  44288. * Construct a new XR-Based windows motion controller
  44289. *
  44290. * @param gamepadInfo the gamepad object from the browser
  44291. */
  44292. constructor(gamepadInfo: any);
  44293. /**
  44294. * holds the thumbstick values (X,Y)
  44295. */
  44296. thumbstickValues: StickValues;
  44297. /**
  44298. * Fired when the thumbstick on this controller is clicked
  44299. */
  44300. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  44301. /**
  44302. * Fired when the thumbstick on this controller is modified
  44303. */
  44304. onThumbstickValuesChangedObservable: Observable<StickValues>;
  44305. /**
  44306. * Fired when the touchpad button on this controller is modified
  44307. */
  44308. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44309. /**
  44310. * Fired when the touchpad values on this controller are modified
  44311. */
  44312. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44313. /**
  44314. * Fired when the thumbstick button on this controller is modified
  44315. * here to prevent breaking changes
  44316. */
  44317. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44318. /**
  44319. * updating the thumbstick(!) and not the trackpad.
  44320. * This is named this way due to the difference between WebVR and XR and to avoid
  44321. * changing the parent class.
  44322. */
  44323. protected _updateTrackpad(): void;
  44324. /**
  44325. * Disposes the class with joy
  44326. */
  44327. dispose(): void;
  44328. }
  44329. }
  44330. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44331. import { Observable } from "babylonjs/Misc/observable";
  44332. import { Scene } from "babylonjs/scene";
  44333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44334. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44335. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44336. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44337. /**
  44338. * Oculus Touch Controller
  44339. */
  44340. export class OculusTouchController extends WebVRController {
  44341. /**
  44342. * Base Url for the controller model.
  44343. */
  44344. static MODEL_BASE_URL: string;
  44345. /**
  44346. * File name for the left controller model.
  44347. */
  44348. static MODEL_LEFT_FILENAME: string;
  44349. /**
  44350. * File name for the right controller model.
  44351. */
  44352. static MODEL_RIGHT_FILENAME: string;
  44353. /**
  44354. * Base Url for the Quest controller model.
  44355. */
  44356. static QUEST_MODEL_BASE_URL: string;
  44357. /**
  44358. * @hidden
  44359. * If the controllers are running on a device that needs the updated Quest controller models
  44360. */
  44361. static _IsQuest: boolean;
  44362. /**
  44363. * Fired when the secondary trigger on this controller is modified
  44364. */
  44365. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44366. /**
  44367. * Fired when the thumb rest on this controller is modified
  44368. */
  44369. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44370. /**
  44371. * Creates a new OculusTouchController from a gamepad
  44372. * @param vrGamepad the gamepad that the controller should be created from
  44373. */
  44374. constructor(vrGamepad: any);
  44375. /**
  44376. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44377. * @param scene scene in which to add meshes
  44378. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44379. */
  44380. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44381. /**
  44382. * Fired when the A button on this controller is modified
  44383. */
  44384. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44385. /**
  44386. * Fired when the B button on this controller is modified
  44387. */
  44388. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44389. /**
  44390. * Fired when the X button on this controller is modified
  44391. */
  44392. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44393. /**
  44394. * Fired when the Y button on this controller is modified
  44395. */
  44396. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44397. /**
  44398. * Called once for each button that changed state since the last frame
  44399. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44400. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44401. * 2) secondary trigger (same)
  44402. * 3) A (right) X (left), touch, pressed = value
  44403. * 4) B / Y
  44404. * 5) thumb rest
  44405. * @param buttonIdx Which button index changed
  44406. * @param state New state of the button
  44407. * @param changes Which properties on the state changed since last frame
  44408. */
  44409. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44410. }
  44411. }
  44412. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44413. import { Scene } from "babylonjs/scene";
  44414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44415. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44416. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44417. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44418. import { Observable } from "babylonjs/Misc/observable";
  44419. /**
  44420. * Vive Controller
  44421. */
  44422. export class ViveController extends WebVRController {
  44423. /**
  44424. * Base Url for the controller model.
  44425. */
  44426. static MODEL_BASE_URL: string;
  44427. /**
  44428. * File name for the controller model.
  44429. */
  44430. static MODEL_FILENAME: string;
  44431. /**
  44432. * Creates a new ViveController from a gamepad
  44433. * @param vrGamepad the gamepad that the controller should be created from
  44434. */
  44435. constructor(vrGamepad: any);
  44436. /**
  44437. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44438. * @param scene scene in which to add meshes
  44439. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44440. */
  44441. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44442. /**
  44443. * Fired when the left button on this controller is modified
  44444. */
  44445. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44446. /**
  44447. * Fired when the right button on this controller is modified
  44448. */
  44449. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44450. /**
  44451. * Fired when the menu button on this controller is modified
  44452. */
  44453. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44454. /**
  44455. * Called once for each button that changed state since the last frame
  44456. * Vive mapping:
  44457. * 0: touchpad
  44458. * 1: trigger
  44459. * 2: left AND right buttons
  44460. * 3: menu button
  44461. * @param buttonIdx Which button index changed
  44462. * @param state New state of the button
  44463. * @param changes Which properties on the state changed since last frame
  44464. */
  44465. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44466. }
  44467. }
  44468. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44469. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44470. import { Observable } from "babylonjs/Misc/observable";
  44471. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  44472. /**
  44473. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44474. */
  44475. export class WebXRControllerModelLoader {
  44476. /**
  44477. * an observable that triggers when a new model (the mesh itself) was initialized.
  44478. * To know when the mesh was loaded use the controller's own modelLoaded() method
  44479. */
  44480. onControllerModelLoaded: Observable<WebXRController>;
  44481. /**
  44482. * Creates the WebXRControllerModelLoader
  44483. * @param input xr input that creates the controllers
  44484. */
  44485. constructor(input: WebXRInput);
  44486. }
  44487. }
  44488. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  44489. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44490. /**
  44491. * Handles pointer input automatically for the pointer of XR controllers
  44492. */
  44493. export class WebXRControllerPointerSelection {
  44494. private static _idCounter;
  44495. private _tmpRay;
  44496. /**
  44497. * Creates a WebXRControllerPointerSelection
  44498. * @param input input manager to setup pointer selection
  44499. */
  44500. constructor(input: WebXRInput);
  44501. private _convertNormalToDirectionOfRay;
  44502. private _updatePointerDistance;
  44503. }
  44504. }
  44505. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  44506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44507. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44508. /**
  44509. * Enables teleportation
  44510. */
  44511. export class WebXRControllerTeleportation {
  44512. private _teleportationFillColor;
  44513. private _teleportationBorderColor;
  44514. private _tmpRay;
  44515. private _tmpVector;
  44516. /**
  44517. * when set to true (default) teleportation will wait for thumbstick changes.
  44518. * When set to false teleportation will be disabled.
  44519. *
  44520. * If set to false while teleporting results can be unexpected.
  44521. */
  44522. enabled: boolean;
  44523. /**
  44524. * Creates a WebXRControllerTeleportation
  44525. * @param input input manager to add teleportation to
  44526. * @param floorMeshes floormeshes which can be teleported to
  44527. */
  44528. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  44529. }
  44530. }
  44531. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  44532. import { Nullable } from "babylonjs/types";
  44533. import { Observable } from "babylonjs/Misc/observable";
  44534. import { IDisposable, Scene } from "babylonjs/scene";
  44535. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44536. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44537. /**
  44538. * Button which can be used to enter a different mode of XR
  44539. */
  44540. export class WebXREnterExitUIButton {
  44541. /** button element */
  44542. element: HTMLElement;
  44543. /** XR initialization options for the button */
  44544. sessionMode: XRSessionMode;
  44545. /** Reference space type */
  44546. referenceSpaceType: XRReferenceSpaceType;
  44547. /**
  44548. * Creates a WebXREnterExitUIButton
  44549. * @param element button element
  44550. * @param sessionMode XR initialization session mode
  44551. * @param referenceSpaceType the type of reference space to be used
  44552. */
  44553. constructor(
  44554. /** button element */
  44555. element: HTMLElement,
  44556. /** XR initialization options for the button */
  44557. sessionMode: XRSessionMode,
  44558. /** Reference space type */
  44559. referenceSpaceType: XRReferenceSpaceType);
  44560. /**
  44561. * Overwritable function which can be used to update the button's visuals when the state changes
  44562. * @param activeButton the current active button in the UI
  44563. */
  44564. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44565. }
  44566. /**
  44567. * Options to create the webXR UI
  44568. */
  44569. export class WebXREnterExitUIOptions {
  44570. /**
  44571. * Context to enter xr with
  44572. */
  44573. renderTarget?: Nullable<WebXRRenderTarget>;
  44574. /**
  44575. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44576. */
  44577. customButtons?: Array<WebXREnterExitUIButton>;
  44578. /**
  44579. * A session mode to use when creating the default button.
  44580. * Default is immersive-vr
  44581. */
  44582. sessionMode?: XRSessionMode;
  44583. /**
  44584. * A reference space type to use when creating the default button.
  44585. * Default is local-floor
  44586. */
  44587. referenceSpaceType?: XRReferenceSpaceType;
  44588. }
  44589. /**
  44590. * UI to allow the user to enter/exit XR mode
  44591. */
  44592. export class WebXREnterExitUI implements IDisposable {
  44593. private scene;
  44594. /** version of the options passed to this UI */
  44595. options: WebXREnterExitUIOptions;
  44596. private _overlay;
  44597. private _buttons;
  44598. private _activeButton;
  44599. /**
  44600. * Fired every time the active button is changed.
  44601. *
  44602. * When xr is entered via a button that launches xr that button will be the callback parameter
  44603. *
  44604. * When exiting xr the callback parameter will be null)
  44605. */
  44606. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44607. /**
  44608. * Creates UI to allow the user to enter/exit XR mode
  44609. * @param scene the scene to add the ui to
  44610. * @param helper the xr experience helper to enter/exit xr with
  44611. * @param options options to configure the UI
  44612. * @returns the created ui
  44613. */
  44614. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44615. /**
  44616. *
  44617. * @param scene babylon scene object to use
  44618. * @param options (read-only) version of the options passed to this UI
  44619. */
  44620. private constructor();
  44621. private _updateButtons;
  44622. /**
  44623. * Disposes of the object
  44624. */
  44625. dispose(): void;
  44626. }
  44627. }
  44628. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  44629. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44630. import { Scene } from "babylonjs/scene";
  44631. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44632. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44633. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44634. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44635. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44636. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/Cameras/XR/webXREnterExitUI";
  44637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44638. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44639. /**
  44640. * Options for the default xr helper
  44641. */
  44642. export class WebXRDefaultExperienceOptions {
  44643. /**
  44644. * Floor meshes that should be used for teleporting
  44645. */
  44646. floorMeshes: Array<AbstractMesh>;
  44647. /**
  44648. * Enable or disable default UI to enter XR
  44649. */
  44650. disableDefaultUI?: boolean;
  44651. /**
  44652. * optional configuration for the output canvas
  44653. */
  44654. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44655. /**
  44656. * optional UI options. This can be used among other to change session mode and reference space type
  44657. */
  44658. uiOptions?: WebXREnterExitUIOptions;
  44659. }
  44660. /**
  44661. * Default experience which provides a similar setup to the previous webVRExperience
  44662. */
  44663. export class WebXRDefaultExperience {
  44664. /**
  44665. * Base experience
  44666. */
  44667. baseExperience: WebXRExperienceHelper;
  44668. /**
  44669. * Input experience extension
  44670. */
  44671. input: WebXRInput;
  44672. /**
  44673. * Loads the controller models
  44674. */
  44675. controllerModelLoader: WebXRControllerModelLoader;
  44676. /**
  44677. * Enables laser pointer and selection
  44678. */
  44679. pointerSelection: WebXRControllerPointerSelection;
  44680. /**
  44681. * Enables teleportation
  44682. */
  44683. teleportation: WebXRControllerTeleportation;
  44684. /**
  44685. * Enables ui for entering/exiting xr
  44686. */
  44687. enterExitUI: WebXREnterExitUI;
  44688. /**
  44689. * Default target xr should render to
  44690. */
  44691. renderTarget: WebXRRenderTarget;
  44692. /**
  44693. * Creates the default xr experience
  44694. * @param scene scene
  44695. * @param options options for basic configuration
  44696. * @returns resulting WebXRDefaultExperience
  44697. */
  44698. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  44699. private constructor();
  44700. /**
  44701. * DIsposes of the experience helper
  44702. */
  44703. dispose(): void;
  44704. }
  44705. }
  44706. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  44707. import { Observable } from "babylonjs/Misc/observable";
  44708. import { Nullable } from "babylonjs/types";
  44709. import { Camera } from "babylonjs/Cameras/camera";
  44710. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  44711. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  44712. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  44713. import { Scene } from "babylonjs/scene";
  44714. import { Vector3 } from "babylonjs/Maths/math.vector";
  44715. import { Color3 } from "babylonjs/Maths/math.color";
  44716. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44718. import { Mesh } from "babylonjs/Meshes/mesh";
  44719. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  44720. import { EasingFunction } from "babylonjs/Animations/easing";
  44721. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44722. import "babylonjs/Meshes/Builders/groundBuilder";
  44723. import "babylonjs/Meshes/Builders/torusBuilder";
  44724. import "babylonjs/Meshes/Builders/cylinderBuilder";
  44725. import "babylonjs/Gamepads/gamepadSceneComponent";
  44726. import "babylonjs/Animations/animatable";
  44727. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  44728. /**
  44729. * Options to modify the vr teleportation behavior.
  44730. */
  44731. export interface VRTeleportationOptions {
  44732. /**
  44733. * The name of the mesh which should be used as the teleportation floor. (default: null)
  44734. */
  44735. floorMeshName?: string;
  44736. /**
  44737. * A list of meshes to be used as the teleportation floor. (default: empty)
  44738. */
  44739. floorMeshes?: Mesh[];
  44740. /**
  44741. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  44742. */
  44743. teleportationMode?: number;
  44744. /**
  44745. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  44746. */
  44747. teleportationTime?: number;
  44748. /**
  44749. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  44750. */
  44751. teleportationSpeed?: number;
  44752. /**
  44753. * The easing function used in the animation or null for Linear. (default CircleEase)
  44754. */
  44755. easingFunction?: EasingFunction;
  44756. }
  44757. /**
  44758. * Options to modify the vr experience helper's behavior.
  44759. */
  44760. export interface VRExperienceHelperOptions extends WebVROptions {
  44761. /**
  44762. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  44763. */
  44764. createDeviceOrientationCamera?: boolean;
  44765. /**
  44766. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  44767. */
  44768. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  44769. /**
  44770. * Uses the main button on the controller to toggle the laser casted. (default: true)
  44771. */
  44772. laserToggle?: boolean;
  44773. /**
  44774. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  44775. */
  44776. floorMeshes?: Mesh[];
  44777. /**
  44778. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  44779. */
  44780. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  44781. /**
  44782. * Defines if WebXR should be used instead of WebVR (if available)
  44783. */
  44784. useXR?: boolean;
  44785. }
  44786. /**
  44787. * Event containing information after VR has been entered
  44788. */
  44789. export class OnAfterEnteringVRObservableEvent {
  44790. /**
  44791. * If entering vr was successful
  44792. */
  44793. success: boolean;
  44794. }
  44795. /**
  44796. * Helps to quickly add VR support to an existing scene.
  44797. * See http://doc.babylonjs.com/how_to/webvr_helper
  44798. */
  44799. export class VRExperienceHelper {
  44800. /** Options to modify the vr experience helper's behavior. */
  44801. webVROptions: VRExperienceHelperOptions;
  44802. private _scene;
  44803. private _position;
  44804. private _btnVR;
  44805. private _btnVRDisplayed;
  44806. private _webVRsupported;
  44807. private _webVRready;
  44808. private _webVRrequesting;
  44809. private _webVRpresenting;
  44810. private _hasEnteredVR;
  44811. private _fullscreenVRpresenting;
  44812. private _inputElement;
  44813. private _webVRCamera;
  44814. private _vrDeviceOrientationCamera;
  44815. private _deviceOrientationCamera;
  44816. private _existingCamera;
  44817. private _onKeyDown;
  44818. private _onVrDisplayPresentChange;
  44819. private _onVRDisplayChanged;
  44820. private _onVRRequestPresentStart;
  44821. private _onVRRequestPresentComplete;
  44822. /**
  44823. * 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)
  44824. */
  44825. enableGazeEvenWhenNoPointerLock: boolean;
  44826. /**
  44827. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  44828. */
  44829. exitVROnDoubleTap: boolean;
  44830. /**
  44831. * Observable raised right before entering VR.
  44832. */
  44833. onEnteringVRObservable: Observable<VRExperienceHelper>;
  44834. /**
  44835. * Observable raised when entering VR has completed.
  44836. */
  44837. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  44838. /**
  44839. * Observable raised when exiting VR.
  44840. */
  44841. onExitingVRObservable: Observable<VRExperienceHelper>;
  44842. /**
  44843. * Observable raised when controller mesh is loaded.
  44844. */
  44845. onControllerMeshLoadedObservable: Observable<WebVRController>;
  44846. /** Return this.onEnteringVRObservable
  44847. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  44848. */
  44849. readonly onEnteringVR: Observable<VRExperienceHelper>;
  44850. /** Return this.onExitingVRObservable
  44851. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  44852. */
  44853. readonly onExitingVR: Observable<VRExperienceHelper>;
  44854. /** Return this.onControllerMeshLoadedObservable
  44855. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  44856. */
  44857. readonly onControllerMeshLoaded: Observable<WebVRController>;
  44858. private _rayLength;
  44859. private _useCustomVRButton;
  44860. private _teleportationRequested;
  44861. private _teleportActive;
  44862. private _floorMeshName;
  44863. private _floorMeshesCollection;
  44864. private _teleportationMode;
  44865. private _teleportationTime;
  44866. private _teleportationSpeed;
  44867. private _teleportationEasing;
  44868. private _rotationAllowed;
  44869. private _teleportBackwardsVector;
  44870. private _teleportationTarget;
  44871. private _isDefaultTeleportationTarget;
  44872. private _postProcessMove;
  44873. private _teleportationFillColor;
  44874. private _teleportationBorderColor;
  44875. private _rotationAngle;
  44876. private _haloCenter;
  44877. private _cameraGazer;
  44878. private _padSensibilityUp;
  44879. private _padSensibilityDown;
  44880. private _leftController;
  44881. private _rightController;
  44882. /**
  44883. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  44884. */
  44885. onNewMeshSelected: Observable<AbstractMesh>;
  44886. /**
  44887. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  44888. * This observable will provide the mesh and the controller used to select the mesh
  44889. */
  44890. onMeshSelectedWithController: Observable<{
  44891. mesh: AbstractMesh;
  44892. controller: WebVRController;
  44893. }>;
  44894. /**
  44895. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  44896. */
  44897. onNewMeshPicked: Observable<PickingInfo>;
  44898. private _circleEase;
  44899. /**
  44900. * Observable raised before camera teleportation
  44901. */
  44902. onBeforeCameraTeleport: Observable<Vector3>;
  44903. /**
  44904. * Observable raised after camera teleportation
  44905. */
  44906. onAfterCameraTeleport: Observable<Vector3>;
  44907. /**
  44908. * Observable raised when current selected mesh gets unselected
  44909. */
  44910. onSelectedMeshUnselected: Observable<AbstractMesh>;
  44911. private _raySelectionPredicate;
  44912. /**
  44913. * To be optionaly changed by user to define custom ray selection
  44914. */
  44915. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44916. /**
  44917. * To be optionaly changed by user to define custom selection logic (after ray selection)
  44918. */
  44919. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  44920. /**
  44921. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  44922. */
  44923. teleportationEnabled: boolean;
  44924. private _defaultHeight;
  44925. private _teleportationInitialized;
  44926. private _interactionsEnabled;
  44927. private _interactionsRequested;
  44928. private _displayGaze;
  44929. private _displayLaserPointer;
  44930. /**
  44931. * The mesh used to display where the user is going to teleport.
  44932. */
  44933. /**
  44934. * Sets the mesh to be used to display where the user is going to teleport.
  44935. */
  44936. teleportationTarget: Mesh;
  44937. /**
  44938. * 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
  44939. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  44940. * See http://doc.babylonjs.com/resources/baking_transformations
  44941. */
  44942. gazeTrackerMesh: Mesh;
  44943. /**
  44944. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  44945. */
  44946. updateGazeTrackerScale: boolean;
  44947. /**
  44948. * If the gaze trackers color should be updated when selecting meshes
  44949. */
  44950. updateGazeTrackerColor: boolean;
  44951. /**
  44952. * If the controller laser color should be updated when selecting meshes
  44953. */
  44954. updateControllerLaserColor: boolean;
  44955. /**
  44956. * The gaze tracking mesh corresponding to the left controller
  44957. */
  44958. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  44959. /**
  44960. * The gaze tracking mesh corresponding to the right controller
  44961. */
  44962. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  44963. /**
  44964. * If the ray of the gaze should be displayed.
  44965. */
  44966. /**
  44967. * Sets if the ray of the gaze should be displayed.
  44968. */
  44969. displayGaze: boolean;
  44970. /**
  44971. * If the ray of the LaserPointer should be displayed.
  44972. */
  44973. /**
  44974. * Sets if the ray of the LaserPointer should be displayed.
  44975. */
  44976. displayLaserPointer: boolean;
  44977. /**
  44978. * The deviceOrientationCamera used as the camera when not in VR.
  44979. */
  44980. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  44981. /**
  44982. * Based on the current WebVR support, returns the current VR camera used.
  44983. */
  44984. readonly currentVRCamera: Nullable<Camera>;
  44985. /**
  44986. * The webVRCamera which is used when in VR.
  44987. */
  44988. readonly webVRCamera: WebVRFreeCamera;
  44989. /**
  44990. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  44991. */
  44992. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  44993. /**
  44994. * The html button that is used to trigger entering into VR.
  44995. */
  44996. readonly vrButton: Nullable<HTMLButtonElement>;
  44997. private readonly _teleportationRequestInitiated;
  44998. /**
  44999. * Defines wether or not Pointer lock should be requested when switching to
  45000. * full screen.
  45001. */
  45002. requestPointerLockOnFullScreen: boolean;
  45003. /**
  45004. * If asking to force XR, this will be populated with the default xr experience
  45005. */
  45006. xr: WebXRDefaultExperience;
  45007. /**
  45008. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45009. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45010. */
  45011. xrTestDone: boolean;
  45012. /**
  45013. * Instantiates a VRExperienceHelper.
  45014. * Helps to quickly add VR support to an existing scene.
  45015. * @param scene The scene the VRExperienceHelper belongs to.
  45016. * @param webVROptions Options to modify the vr experience helper's behavior.
  45017. */
  45018. constructor(scene: Scene,
  45019. /** Options to modify the vr experience helper's behavior. */
  45020. webVROptions?: VRExperienceHelperOptions);
  45021. private completeVRInit;
  45022. private _onDefaultMeshLoaded;
  45023. private _onResize;
  45024. private _onFullscreenChange;
  45025. /**
  45026. * Gets a value indicating if we are currently in VR mode.
  45027. */
  45028. readonly isInVRMode: boolean;
  45029. private onVrDisplayPresentChange;
  45030. private onVRDisplayChanged;
  45031. private moveButtonToBottomRight;
  45032. private displayVRButton;
  45033. private updateButtonVisibility;
  45034. private _cachedAngularSensibility;
  45035. /**
  45036. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45037. * Otherwise, will use the fullscreen API.
  45038. */
  45039. enterVR(): void;
  45040. /**
  45041. * Attempt to exit VR, or fullscreen.
  45042. */
  45043. exitVR(): void;
  45044. /**
  45045. * The position of the vr experience helper.
  45046. */
  45047. /**
  45048. * Sets the position of the vr experience helper.
  45049. */
  45050. position: Vector3;
  45051. /**
  45052. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45053. */
  45054. enableInteractions(): void;
  45055. private readonly _noControllerIsActive;
  45056. private beforeRender;
  45057. private _isTeleportationFloor;
  45058. /**
  45059. * Adds a floor mesh to be used for teleportation.
  45060. * @param floorMesh the mesh to be used for teleportation.
  45061. */
  45062. addFloorMesh(floorMesh: Mesh): void;
  45063. /**
  45064. * Removes a floor mesh from being used for teleportation.
  45065. * @param floorMesh the mesh to be removed.
  45066. */
  45067. removeFloorMesh(floorMesh: Mesh): void;
  45068. /**
  45069. * Enables interactions and teleportation using the VR controllers and gaze.
  45070. * @param vrTeleportationOptions options to modify teleportation behavior.
  45071. */
  45072. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45073. private _onNewGamepadConnected;
  45074. private _tryEnableInteractionOnController;
  45075. private _onNewGamepadDisconnected;
  45076. private _enableInteractionOnController;
  45077. private _checkTeleportWithRay;
  45078. private _checkRotate;
  45079. private _checkTeleportBackwards;
  45080. private _enableTeleportationOnController;
  45081. private _createTeleportationCircles;
  45082. private _displayTeleportationTarget;
  45083. private _hideTeleportationTarget;
  45084. private _rotateCamera;
  45085. private _moveTeleportationSelectorTo;
  45086. private _workingVector;
  45087. private _workingQuaternion;
  45088. private _workingMatrix;
  45089. /**
  45090. * Time Constant Teleportation Mode
  45091. */
  45092. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45093. /**
  45094. * Speed Constant Teleportation Mode
  45095. */
  45096. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45097. /**
  45098. * Teleports the users feet to the desired location
  45099. * @param location The location where the user's feet should be placed
  45100. */
  45101. teleportCamera(location: Vector3): void;
  45102. private _convertNormalToDirectionOfRay;
  45103. private _castRayAndSelectObject;
  45104. private _notifySelectedMeshUnselected;
  45105. /**
  45106. * Sets the color of the laser ray from the vr controllers.
  45107. * @param color new color for the ray.
  45108. */
  45109. changeLaserColor(color: Color3): void;
  45110. /**
  45111. * Sets the color of the ray from the vr headsets gaze.
  45112. * @param color new color for the ray.
  45113. */
  45114. changeGazeColor(color: Color3): void;
  45115. /**
  45116. * Exits VR and disposes of the vr experience helper
  45117. */
  45118. dispose(): void;
  45119. /**
  45120. * Gets the name of the VRExperienceHelper class
  45121. * @returns "VRExperienceHelper"
  45122. */
  45123. getClassName(): string;
  45124. }
  45125. }
  45126. declare module "babylonjs/Cameras/VR/index" {
  45127. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  45128. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  45129. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45130. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  45131. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  45132. export * from "babylonjs/Cameras/VR/webVRCamera";
  45133. }
  45134. declare module "babylonjs/Cameras/XR/index" {
  45135. export * from "babylonjs/Cameras/XR/webXRCamera";
  45136. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  45137. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45138. export * from "babylonjs/Cameras/XR/webXRInput";
  45139. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  45140. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  45141. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  45142. export * from "babylonjs/Cameras/XR/webXRController";
  45143. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  45144. export * from "babylonjs/Cameras/XR/webXRTypes";
  45145. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  45146. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  45147. }
  45148. declare module "babylonjs/Cameras/RigModes/index" {
  45149. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  45150. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  45151. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  45152. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  45153. }
  45154. declare module "babylonjs/Cameras/index" {
  45155. export * from "babylonjs/Cameras/Inputs/index";
  45156. export * from "babylonjs/Cameras/cameraInputsManager";
  45157. export * from "babylonjs/Cameras/camera";
  45158. export * from "babylonjs/Cameras/targetCamera";
  45159. export * from "babylonjs/Cameras/freeCamera";
  45160. export * from "babylonjs/Cameras/freeCameraInputsManager";
  45161. export * from "babylonjs/Cameras/touchCamera";
  45162. export * from "babylonjs/Cameras/arcRotateCamera";
  45163. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  45164. export * from "babylonjs/Cameras/deviceOrientationCamera";
  45165. export * from "babylonjs/Cameras/flyCamera";
  45166. export * from "babylonjs/Cameras/flyCameraInputsManager";
  45167. export * from "babylonjs/Cameras/followCamera";
  45168. export * from "babylonjs/Cameras/followCameraInputsManager";
  45169. export * from "babylonjs/Cameras/gamepadCamera";
  45170. export * from "babylonjs/Cameras/Stereoscopic/index";
  45171. export * from "babylonjs/Cameras/universalCamera";
  45172. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  45173. export * from "babylonjs/Cameras/VR/index";
  45174. export * from "babylonjs/Cameras/XR/index";
  45175. export * from "babylonjs/Cameras/RigModes/index";
  45176. }
  45177. declare module "babylonjs/Collisions/index" {
  45178. export * from "babylonjs/Collisions/collider";
  45179. export * from "babylonjs/Collisions/collisionCoordinator";
  45180. export * from "babylonjs/Collisions/pickingInfo";
  45181. export * from "babylonjs/Collisions/intersectionInfo";
  45182. export * from "babylonjs/Collisions/meshCollisionData";
  45183. }
  45184. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  45185. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  45186. import { Vector3 } from "babylonjs/Maths/math.vector";
  45187. import { Ray } from "babylonjs/Culling/ray";
  45188. import { Plane } from "babylonjs/Maths/math.plane";
  45189. /**
  45190. * Contains an array of blocks representing the octree
  45191. */
  45192. export interface IOctreeContainer<T> {
  45193. /**
  45194. * Blocks within the octree
  45195. */
  45196. blocks: Array<OctreeBlock<T>>;
  45197. }
  45198. /**
  45199. * Class used to store a cell in an octree
  45200. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45201. */
  45202. export class OctreeBlock<T> {
  45203. /**
  45204. * Gets the content of the current block
  45205. */
  45206. entries: T[];
  45207. /**
  45208. * Gets the list of block children
  45209. */
  45210. blocks: Array<OctreeBlock<T>>;
  45211. private _depth;
  45212. private _maxDepth;
  45213. private _capacity;
  45214. private _minPoint;
  45215. private _maxPoint;
  45216. private _boundingVectors;
  45217. private _creationFunc;
  45218. /**
  45219. * Creates a new block
  45220. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45221. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45222. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45223. * @param depth defines the current depth of this block in the octree
  45224. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45225. * @param creationFunc defines a callback to call when an element is added to the block
  45226. */
  45227. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45228. /**
  45229. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45230. */
  45231. readonly capacity: number;
  45232. /**
  45233. * Gets the minimum vector (in world space) of the block's bounding box
  45234. */
  45235. readonly minPoint: Vector3;
  45236. /**
  45237. * Gets the maximum vector (in world space) of the block's bounding box
  45238. */
  45239. readonly maxPoint: Vector3;
  45240. /**
  45241. * Add a new element to this block
  45242. * @param entry defines the element to add
  45243. */
  45244. addEntry(entry: T): void;
  45245. /**
  45246. * Remove an element from this block
  45247. * @param entry defines the element to remove
  45248. */
  45249. removeEntry(entry: T): void;
  45250. /**
  45251. * Add an array of elements to this block
  45252. * @param entries defines the array of elements to add
  45253. */
  45254. addEntries(entries: T[]): void;
  45255. /**
  45256. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45257. * @param frustumPlanes defines the frustum planes to test
  45258. * @param selection defines the array to store current content if selection is positive
  45259. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45260. */
  45261. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45262. /**
  45263. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45264. * @param sphereCenter defines the bounding sphere center
  45265. * @param sphereRadius defines the bounding sphere radius
  45266. * @param selection defines the array to store current content if selection is positive
  45267. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45268. */
  45269. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45270. /**
  45271. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45272. * @param ray defines the ray to test with
  45273. * @param selection defines the array to store current content if selection is positive
  45274. */
  45275. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45276. /**
  45277. * Subdivide the content into child blocks (this block will then be empty)
  45278. */
  45279. createInnerBlocks(): void;
  45280. /**
  45281. * @hidden
  45282. */
  45283. 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;
  45284. }
  45285. }
  45286. declare module "babylonjs/Culling/Octrees/octree" {
  45287. import { SmartArray } from "babylonjs/Misc/smartArray";
  45288. import { Vector3 } from "babylonjs/Maths/math.vector";
  45289. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45291. import { Ray } from "babylonjs/Culling/ray";
  45292. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  45293. import { Plane } from "babylonjs/Maths/math.plane";
  45294. /**
  45295. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45296. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45297. */
  45298. export class Octree<T> {
  45299. /** 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.) */
  45300. maxDepth: number;
  45301. /**
  45302. * Blocks within the octree containing objects
  45303. */
  45304. blocks: Array<OctreeBlock<T>>;
  45305. /**
  45306. * Content stored in the octree
  45307. */
  45308. dynamicContent: T[];
  45309. private _maxBlockCapacity;
  45310. private _selectionContent;
  45311. private _creationFunc;
  45312. /**
  45313. * Creates a octree
  45314. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45315. * @param creationFunc function to be used to instatiate the octree
  45316. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45317. * @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.)
  45318. */
  45319. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45320. /** 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.) */
  45321. maxDepth?: number);
  45322. /**
  45323. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45324. * @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);
  45325. * @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);
  45326. * @param entries meshes to be added to the octree blocks
  45327. */
  45328. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45329. /**
  45330. * Adds a mesh to the octree
  45331. * @param entry Mesh to add to the octree
  45332. */
  45333. addMesh(entry: T): void;
  45334. /**
  45335. * Remove an element from the octree
  45336. * @param entry defines the element to remove
  45337. */
  45338. removeMesh(entry: T): void;
  45339. /**
  45340. * Selects an array of meshes within the frustum
  45341. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45342. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45343. * @returns array of meshes within the frustum
  45344. */
  45345. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45346. /**
  45347. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45348. * @param sphereCenter defines the bounding sphere center
  45349. * @param sphereRadius defines the bounding sphere radius
  45350. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45351. * @returns an array of objects that intersect the sphere
  45352. */
  45353. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45354. /**
  45355. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45356. * @param ray defines the ray to test with
  45357. * @returns array of intersected objects
  45358. */
  45359. intersectsRay(ray: Ray): SmartArray<T>;
  45360. /**
  45361. * Adds a mesh into the octree block if it intersects the block
  45362. */
  45363. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45364. /**
  45365. * Adds a submesh into the octree block if it intersects the block
  45366. */
  45367. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45368. }
  45369. }
  45370. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  45371. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  45372. import { Scene } from "babylonjs/scene";
  45373. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45375. import { Ray } from "babylonjs/Culling/ray";
  45376. import { Octree } from "babylonjs/Culling/Octrees/octree";
  45377. import { Collider } from "babylonjs/Collisions/collider";
  45378. module "babylonjs/scene" {
  45379. interface Scene {
  45380. /**
  45381. * @hidden
  45382. * Backing Filed
  45383. */
  45384. _selectionOctree: Octree<AbstractMesh>;
  45385. /**
  45386. * Gets the octree used to boost mesh selection (picking)
  45387. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45388. */
  45389. selectionOctree: Octree<AbstractMesh>;
  45390. /**
  45391. * Creates or updates the octree used to boost selection (picking)
  45392. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45393. * @param maxCapacity defines the maximum capacity per leaf
  45394. * @param maxDepth defines the maximum depth of the octree
  45395. * @returns an octree of AbstractMesh
  45396. */
  45397. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45398. }
  45399. }
  45400. module "babylonjs/Meshes/abstractMesh" {
  45401. interface AbstractMesh {
  45402. /**
  45403. * @hidden
  45404. * Backing Field
  45405. */
  45406. _submeshesOctree: Octree<SubMesh>;
  45407. /**
  45408. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45409. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45410. * @param maxCapacity defines the maximum size of each block (64 by default)
  45411. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45412. * @returns the new octree
  45413. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45414. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45415. */
  45416. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45417. }
  45418. }
  45419. /**
  45420. * Defines the octree scene component responsible to manage any octrees
  45421. * in a given scene.
  45422. */
  45423. export class OctreeSceneComponent {
  45424. /**
  45425. * The component name help to identify the component in the list of scene components.
  45426. */
  45427. readonly name: string;
  45428. /**
  45429. * The scene the component belongs to.
  45430. */
  45431. scene: Scene;
  45432. /**
  45433. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45434. */
  45435. readonly checksIsEnabled: boolean;
  45436. /**
  45437. * Creates a new instance of the component for the given scene
  45438. * @param scene Defines the scene to register the component in
  45439. */
  45440. constructor(scene: Scene);
  45441. /**
  45442. * Registers the component in a given scene
  45443. */
  45444. register(): void;
  45445. /**
  45446. * Return the list of active meshes
  45447. * @returns the list of active meshes
  45448. */
  45449. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45450. /**
  45451. * Return the list of active sub meshes
  45452. * @param mesh The mesh to get the candidates sub meshes from
  45453. * @returns the list of active sub meshes
  45454. */
  45455. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45456. private _tempRay;
  45457. /**
  45458. * Return the list of sub meshes intersecting with a given local ray
  45459. * @param mesh defines the mesh to find the submesh for
  45460. * @param localRay defines the ray in local space
  45461. * @returns the list of intersecting sub meshes
  45462. */
  45463. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45464. /**
  45465. * Return the list of sub meshes colliding with a collider
  45466. * @param mesh defines the mesh to find the submesh for
  45467. * @param collider defines the collider to evaluate the collision against
  45468. * @returns the list of colliding sub meshes
  45469. */
  45470. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45471. /**
  45472. * Rebuilds the elements related to this component in case of
  45473. * context lost for instance.
  45474. */
  45475. rebuild(): void;
  45476. /**
  45477. * Disposes the component and the associated ressources.
  45478. */
  45479. dispose(): void;
  45480. }
  45481. }
  45482. declare module "babylonjs/Culling/Octrees/index" {
  45483. export * from "babylonjs/Culling/Octrees/octree";
  45484. export * from "babylonjs/Culling/Octrees/octreeBlock";
  45485. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  45486. }
  45487. declare module "babylonjs/Culling/index" {
  45488. export * from "babylonjs/Culling/boundingBox";
  45489. export * from "babylonjs/Culling/boundingInfo";
  45490. export * from "babylonjs/Culling/boundingSphere";
  45491. export * from "babylonjs/Culling/Octrees/index";
  45492. export * from "babylonjs/Culling/ray";
  45493. }
  45494. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45495. import { IDisposable, Scene } from "babylonjs/scene";
  45496. import { Nullable } from "babylonjs/types";
  45497. import { Observable } from "babylonjs/Misc/observable";
  45498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45499. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45500. import { Camera } from "babylonjs/Cameras/camera";
  45501. /**
  45502. * Renders a layer on top of an existing scene
  45503. */
  45504. export class UtilityLayerRenderer implements IDisposable {
  45505. /** the original scene that will be rendered on top of */
  45506. originalScene: Scene;
  45507. private _pointerCaptures;
  45508. private _lastPointerEvents;
  45509. private static _DefaultUtilityLayer;
  45510. private static _DefaultKeepDepthUtilityLayer;
  45511. private _sharedGizmoLight;
  45512. private _renderCamera;
  45513. /**
  45514. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45515. * @returns the camera that is used when rendering the utility layer
  45516. */
  45517. getRenderCamera(): Nullable<Camera>;
  45518. /**
  45519. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45520. * @param cam the camera that should be used when rendering the utility layer
  45521. */
  45522. setRenderCamera(cam: Nullable<Camera>): void;
  45523. /**
  45524. * @hidden
  45525. * Light which used by gizmos to get light shading
  45526. */
  45527. _getSharedGizmoLight(): HemisphericLight;
  45528. /**
  45529. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45530. */
  45531. pickUtilitySceneFirst: boolean;
  45532. /**
  45533. * 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)
  45534. */
  45535. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  45536. /**
  45537. * 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)
  45538. */
  45539. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  45540. /**
  45541. * The scene that is rendered on top of the original scene
  45542. */
  45543. utilityLayerScene: Scene;
  45544. /**
  45545. * If the utility layer should automatically be rendered on top of existing scene
  45546. */
  45547. shouldRender: boolean;
  45548. /**
  45549. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45550. */
  45551. onlyCheckPointerDownEvents: boolean;
  45552. /**
  45553. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45554. */
  45555. processAllEvents: boolean;
  45556. /**
  45557. * Observable raised when the pointer move from the utility layer scene to the main scene
  45558. */
  45559. onPointerOutObservable: Observable<number>;
  45560. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45561. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45562. private _afterRenderObserver;
  45563. private _sceneDisposeObserver;
  45564. private _originalPointerObserver;
  45565. /**
  45566. * Instantiates a UtilityLayerRenderer
  45567. * @param originalScene the original scene that will be rendered on top of
  45568. * @param handleEvents boolean indicating if the utility layer should handle events
  45569. */
  45570. constructor(
  45571. /** the original scene that will be rendered on top of */
  45572. originalScene: Scene, handleEvents?: boolean);
  45573. private _notifyObservers;
  45574. /**
  45575. * Renders the utility layers scene on top of the original scene
  45576. */
  45577. render(): void;
  45578. /**
  45579. * Disposes of the renderer
  45580. */
  45581. dispose(): void;
  45582. private _updateCamera;
  45583. }
  45584. }
  45585. declare module "babylonjs/Gizmos/gizmo" {
  45586. import { Nullable } from "babylonjs/types";
  45587. import { IDisposable } from "babylonjs/scene";
  45588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45589. import { Mesh } from "babylonjs/Meshes/mesh";
  45590. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45591. /**
  45592. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45593. */
  45594. export class Gizmo implements IDisposable {
  45595. /** The utility layer the gizmo will be added to */
  45596. gizmoLayer: UtilityLayerRenderer;
  45597. /**
  45598. * The root mesh of the gizmo
  45599. */
  45600. _rootMesh: Mesh;
  45601. private _attachedMesh;
  45602. /**
  45603. * Ratio for the scale of the gizmo (Default: 1)
  45604. */
  45605. scaleRatio: number;
  45606. /**
  45607. * If a custom mesh has been set (Default: false)
  45608. */
  45609. protected _customMeshSet: boolean;
  45610. /**
  45611. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45612. * * When set, interactions will be enabled
  45613. */
  45614. attachedMesh: Nullable<AbstractMesh>;
  45615. /**
  45616. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45617. * @param mesh The mesh to replace the default mesh of the gizmo
  45618. */
  45619. setCustomMesh(mesh: Mesh): void;
  45620. /**
  45621. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45622. */
  45623. updateGizmoRotationToMatchAttachedMesh: boolean;
  45624. /**
  45625. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45626. */
  45627. updateGizmoPositionToMatchAttachedMesh: boolean;
  45628. /**
  45629. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45630. */
  45631. updateScale: boolean;
  45632. protected _interactionsEnabled: boolean;
  45633. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45634. private _beforeRenderObserver;
  45635. private _tempVector;
  45636. /**
  45637. * Creates a gizmo
  45638. * @param gizmoLayer The utility layer the gizmo will be added to
  45639. */
  45640. constructor(
  45641. /** The utility layer the gizmo will be added to */
  45642. gizmoLayer?: UtilityLayerRenderer);
  45643. /**
  45644. * Updates the gizmo to match the attached mesh's position/rotation
  45645. */
  45646. protected _update(): void;
  45647. /**
  45648. * Disposes of the gizmo
  45649. */
  45650. dispose(): void;
  45651. }
  45652. }
  45653. declare module "babylonjs/Gizmos/planeDragGizmo" {
  45654. import { Observable } from "babylonjs/Misc/observable";
  45655. import { Nullable } from "babylonjs/types";
  45656. import { Vector3 } from "babylonjs/Maths/math.vector";
  45657. import { Color3 } from "babylonjs/Maths/math.color";
  45658. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45660. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45661. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45662. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45663. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45664. import { Scene } from "babylonjs/scene";
  45665. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45666. /**
  45667. * Single plane drag gizmo
  45668. */
  45669. export class PlaneDragGizmo extends Gizmo {
  45670. /**
  45671. * Drag behavior responsible for the gizmos dragging interactions
  45672. */
  45673. dragBehavior: PointerDragBehavior;
  45674. private _pointerObserver;
  45675. /**
  45676. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45677. */
  45678. snapDistance: number;
  45679. /**
  45680. * Event that fires each time the gizmo snaps to a new location.
  45681. * * snapDistance is the the change in distance
  45682. */
  45683. onSnapObservable: Observable<{
  45684. snapDistance: number;
  45685. }>;
  45686. private _plane;
  45687. private _coloredMaterial;
  45688. private _hoverMaterial;
  45689. private _isEnabled;
  45690. private _parent;
  45691. /** @hidden */
  45692. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45693. /** @hidden */
  45694. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45695. /**
  45696. * Creates a PlaneDragGizmo
  45697. * @param gizmoLayer The utility layer the gizmo will be added to
  45698. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45699. * @param color The color of the gizmo
  45700. */
  45701. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45702. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45703. /**
  45704. * If the gizmo is enabled
  45705. */
  45706. isEnabled: boolean;
  45707. /**
  45708. * Disposes of the gizmo
  45709. */
  45710. dispose(): void;
  45711. }
  45712. }
  45713. declare module "babylonjs/Gizmos/positionGizmo" {
  45714. import { Observable } from "babylonjs/Misc/observable";
  45715. import { Nullable } from "babylonjs/types";
  45716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45717. import { Mesh } from "babylonjs/Meshes/mesh";
  45718. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45719. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  45720. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  45721. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45722. /**
  45723. * Gizmo that enables dragging a mesh along 3 axis
  45724. */
  45725. export class PositionGizmo extends Gizmo {
  45726. /**
  45727. * Internal gizmo used for interactions on the x axis
  45728. */
  45729. xGizmo: AxisDragGizmo;
  45730. /**
  45731. * Internal gizmo used for interactions on the y axis
  45732. */
  45733. yGizmo: AxisDragGizmo;
  45734. /**
  45735. * Internal gizmo used for interactions on the z axis
  45736. */
  45737. zGizmo: AxisDragGizmo;
  45738. /**
  45739. * Internal gizmo used for interactions on the yz plane
  45740. */
  45741. xPlaneGizmo: PlaneDragGizmo;
  45742. /**
  45743. * Internal gizmo used for interactions on the xz plane
  45744. */
  45745. yPlaneGizmo: PlaneDragGizmo;
  45746. /**
  45747. * Internal gizmo used for interactions on the xy plane
  45748. */
  45749. zPlaneGizmo: PlaneDragGizmo;
  45750. /**
  45751. * private variables
  45752. */
  45753. private _meshAttached;
  45754. private _updateGizmoRotationToMatchAttachedMesh;
  45755. private _snapDistance;
  45756. private _scaleRatio;
  45757. /** Fires an event when any of it's sub gizmos are dragged */
  45758. onDragStartObservable: Observable<unknown>;
  45759. /** Fires an event when any of it's sub gizmos are released from dragging */
  45760. onDragEndObservable: Observable<unknown>;
  45761. /**
  45762. * If set to true, planar drag is enabled
  45763. */
  45764. private _planarGizmoEnabled;
  45765. attachedMesh: Nullable<AbstractMesh>;
  45766. /**
  45767. * Creates a PositionGizmo
  45768. * @param gizmoLayer The utility layer the gizmo will be added to
  45769. */
  45770. constructor(gizmoLayer?: UtilityLayerRenderer);
  45771. /**
  45772. * If the planar drag gizmo is enabled
  45773. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45774. */
  45775. planarGizmoEnabled: boolean;
  45776. updateGizmoRotationToMatchAttachedMesh: boolean;
  45777. /**
  45778. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45779. */
  45780. snapDistance: number;
  45781. /**
  45782. * Ratio for the scale of the gizmo (Default: 1)
  45783. */
  45784. scaleRatio: number;
  45785. /**
  45786. * Disposes of the gizmo
  45787. */
  45788. dispose(): void;
  45789. /**
  45790. * CustomMeshes are not supported by this gizmo
  45791. * @param mesh The mesh to replace the default mesh of the gizmo
  45792. */
  45793. setCustomMesh(mesh: Mesh): void;
  45794. }
  45795. }
  45796. declare module "babylonjs/Gizmos/axisDragGizmo" {
  45797. import { Observable } from "babylonjs/Misc/observable";
  45798. import { Nullable } from "babylonjs/types";
  45799. import { Vector3 } from "babylonjs/Maths/math.vector";
  45800. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45802. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45803. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45804. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45805. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45806. import { Scene } from "babylonjs/scene";
  45807. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45808. import { Color3 } from "babylonjs/Maths/math.color";
  45809. /**
  45810. * Single axis drag gizmo
  45811. */
  45812. export class AxisDragGizmo extends Gizmo {
  45813. /**
  45814. * Drag behavior responsible for the gizmos dragging interactions
  45815. */
  45816. dragBehavior: PointerDragBehavior;
  45817. private _pointerObserver;
  45818. /**
  45819. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45820. */
  45821. snapDistance: number;
  45822. /**
  45823. * Event that fires each time the gizmo snaps to a new location.
  45824. * * snapDistance is the the change in distance
  45825. */
  45826. onSnapObservable: Observable<{
  45827. snapDistance: number;
  45828. }>;
  45829. private _isEnabled;
  45830. private _parent;
  45831. private _arrow;
  45832. private _coloredMaterial;
  45833. private _hoverMaterial;
  45834. /** @hidden */
  45835. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45836. /** @hidden */
  45837. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45838. /**
  45839. * Creates an AxisDragGizmo
  45840. * @param gizmoLayer The utility layer the gizmo will be added to
  45841. * @param dragAxis The axis which the gizmo will be able to drag on
  45842. * @param color The color of the gizmo
  45843. */
  45844. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45845. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45846. /**
  45847. * If the gizmo is enabled
  45848. */
  45849. isEnabled: boolean;
  45850. /**
  45851. * Disposes of the gizmo
  45852. */
  45853. dispose(): void;
  45854. }
  45855. }
  45856. declare module "babylonjs/Debug/axesViewer" {
  45857. import { Vector3 } from "babylonjs/Maths/math.vector";
  45858. import { Nullable } from "babylonjs/types";
  45859. import { Scene } from "babylonjs/scene";
  45860. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45861. /**
  45862. * The Axes viewer will show 3 axes in a specific point in space
  45863. */
  45864. export class AxesViewer {
  45865. private _xAxis;
  45866. private _yAxis;
  45867. private _zAxis;
  45868. private _scaleLinesFactor;
  45869. private _instanced;
  45870. /**
  45871. * Gets the hosting scene
  45872. */
  45873. scene: Scene;
  45874. /**
  45875. * Gets or sets a number used to scale line length
  45876. */
  45877. scaleLines: number;
  45878. /** Gets the node hierarchy used to render x-axis */
  45879. readonly xAxis: TransformNode;
  45880. /** Gets the node hierarchy used to render y-axis */
  45881. readonly yAxis: TransformNode;
  45882. /** Gets the node hierarchy used to render z-axis */
  45883. readonly zAxis: TransformNode;
  45884. /**
  45885. * Creates a new AxesViewer
  45886. * @param scene defines the hosting scene
  45887. * @param scaleLines defines a number used to scale line length (1 by default)
  45888. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45889. * @param xAxis defines the node hierarchy used to render the x-axis
  45890. * @param yAxis defines the node hierarchy used to render the y-axis
  45891. * @param zAxis defines the node hierarchy used to render the z-axis
  45892. */
  45893. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45894. /**
  45895. * Force the viewer to update
  45896. * @param position defines the position of the viewer
  45897. * @param xaxis defines the x axis of the viewer
  45898. * @param yaxis defines the y axis of the viewer
  45899. * @param zaxis defines the z axis of the viewer
  45900. */
  45901. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45902. /**
  45903. * Creates an instance of this axes viewer.
  45904. * @returns a new axes viewer with instanced meshes
  45905. */
  45906. createInstance(): AxesViewer;
  45907. /** Releases resources */
  45908. dispose(): void;
  45909. private static _SetRenderingGroupId;
  45910. }
  45911. }
  45912. declare module "babylonjs/Debug/boneAxesViewer" {
  45913. import { Nullable } from "babylonjs/types";
  45914. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  45915. import { Vector3 } from "babylonjs/Maths/math.vector";
  45916. import { Mesh } from "babylonjs/Meshes/mesh";
  45917. import { Bone } from "babylonjs/Bones/bone";
  45918. import { Scene } from "babylonjs/scene";
  45919. /**
  45920. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45921. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45922. */
  45923. export class BoneAxesViewer extends AxesViewer {
  45924. /**
  45925. * Gets or sets the target mesh where to display the axes viewer
  45926. */
  45927. mesh: Nullable<Mesh>;
  45928. /**
  45929. * Gets or sets the target bone where to display the axes viewer
  45930. */
  45931. bone: Nullable<Bone>;
  45932. /** Gets current position */
  45933. pos: Vector3;
  45934. /** Gets direction of X axis */
  45935. xaxis: Vector3;
  45936. /** Gets direction of Y axis */
  45937. yaxis: Vector3;
  45938. /** Gets direction of Z axis */
  45939. zaxis: Vector3;
  45940. /**
  45941. * Creates a new BoneAxesViewer
  45942. * @param scene defines the hosting scene
  45943. * @param bone defines the target bone
  45944. * @param mesh defines the target mesh
  45945. * @param scaleLines defines a scaling factor for line length (1 by default)
  45946. */
  45947. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45948. /**
  45949. * Force the viewer to update
  45950. */
  45951. update(): void;
  45952. /** Releases resources */
  45953. dispose(): void;
  45954. }
  45955. }
  45956. declare module "babylonjs/Debug/debugLayer" {
  45957. import { Scene } from "babylonjs/scene";
  45958. /**
  45959. * Interface used to define scene explorer extensibility option
  45960. */
  45961. export interface IExplorerExtensibilityOption {
  45962. /**
  45963. * Define the option label
  45964. */
  45965. label: string;
  45966. /**
  45967. * Defines the action to execute on click
  45968. */
  45969. action: (entity: any) => void;
  45970. }
  45971. /**
  45972. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45973. */
  45974. export interface IExplorerExtensibilityGroup {
  45975. /**
  45976. * Defines a predicate to test if a given type mut be extended
  45977. */
  45978. predicate: (entity: any) => boolean;
  45979. /**
  45980. * Gets the list of options added to a type
  45981. */
  45982. entries: IExplorerExtensibilityOption[];
  45983. }
  45984. /**
  45985. * Interface used to define the options to use to create the Inspector
  45986. */
  45987. export interface IInspectorOptions {
  45988. /**
  45989. * Display in overlay mode (default: false)
  45990. */
  45991. overlay?: boolean;
  45992. /**
  45993. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45994. */
  45995. globalRoot?: HTMLElement;
  45996. /**
  45997. * Display the Scene explorer
  45998. */
  45999. showExplorer?: boolean;
  46000. /**
  46001. * Display the property inspector
  46002. */
  46003. showInspector?: boolean;
  46004. /**
  46005. * Display in embed mode (both panes on the right)
  46006. */
  46007. embedMode?: boolean;
  46008. /**
  46009. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46010. */
  46011. handleResize?: boolean;
  46012. /**
  46013. * Allow the panes to popup (default: true)
  46014. */
  46015. enablePopup?: boolean;
  46016. /**
  46017. * Allow the panes to be closed by users (default: true)
  46018. */
  46019. enableClose?: boolean;
  46020. /**
  46021. * Optional list of extensibility entries
  46022. */
  46023. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46024. /**
  46025. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46026. */
  46027. inspectorURL?: string;
  46028. /**
  46029. * Optional initial tab (default to DebugLayerTab.Properties)
  46030. */
  46031. initialTab?: DebugLayerTab;
  46032. }
  46033. module "babylonjs/scene" {
  46034. interface Scene {
  46035. /**
  46036. * @hidden
  46037. * Backing field
  46038. */
  46039. _debugLayer: DebugLayer;
  46040. /**
  46041. * Gets the debug layer (aka Inspector) associated with the scene
  46042. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46043. */
  46044. debugLayer: DebugLayer;
  46045. }
  46046. }
  46047. /**
  46048. * Enum of inspector action tab
  46049. */
  46050. export enum DebugLayerTab {
  46051. /**
  46052. * Properties tag (default)
  46053. */
  46054. Properties = 0,
  46055. /**
  46056. * Debug tab
  46057. */
  46058. Debug = 1,
  46059. /**
  46060. * Statistics tab
  46061. */
  46062. Statistics = 2,
  46063. /**
  46064. * Tools tab
  46065. */
  46066. Tools = 3,
  46067. /**
  46068. * Settings tab
  46069. */
  46070. Settings = 4
  46071. }
  46072. /**
  46073. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46074. * what is happening in your scene
  46075. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46076. */
  46077. export class DebugLayer {
  46078. /**
  46079. * Define the url to get the inspector script from.
  46080. * By default it uses the babylonjs CDN.
  46081. * @ignoreNaming
  46082. */
  46083. static InspectorURL: string;
  46084. private _scene;
  46085. private BJSINSPECTOR;
  46086. private _onPropertyChangedObservable?;
  46087. /**
  46088. * Observable triggered when a property is changed through the inspector.
  46089. */
  46090. readonly onPropertyChangedObservable: any;
  46091. /**
  46092. * Instantiates a new debug layer.
  46093. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46094. * what is happening in your scene
  46095. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46096. * @param scene Defines the scene to inspect
  46097. */
  46098. constructor(scene: Scene);
  46099. /** Creates the inspector window. */
  46100. private _createInspector;
  46101. /**
  46102. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46103. * @param entity defines the entity to select
  46104. * @param lineContainerTitle defines the specific block to highlight
  46105. */
  46106. select(entity: any, lineContainerTitle?: string): void;
  46107. /** Get the inspector from bundle or global */
  46108. private _getGlobalInspector;
  46109. /**
  46110. * Get if the inspector is visible or not.
  46111. * @returns true if visible otherwise, false
  46112. */
  46113. isVisible(): boolean;
  46114. /**
  46115. * Hide the inspector and close its window.
  46116. */
  46117. hide(): void;
  46118. /**
  46119. * Launch the debugLayer.
  46120. * @param config Define the configuration of the inspector
  46121. * @return a promise fulfilled when the debug layer is visible
  46122. */
  46123. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46124. }
  46125. }
  46126. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  46127. import { Nullable } from "babylonjs/types";
  46128. import { Scene } from "babylonjs/scene";
  46129. import { Vector4 } from "babylonjs/Maths/math.vector";
  46130. import { Color4 } from "babylonjs/Maths/math.color";
  46131. import { Mesh } from "babylonjs/Meshes/mesh";
  46132. /**
  46133. * Class containing static functions to help procedurally build meshes
  46134. */
  46135. export class BoxBuilder {
  46136. /**
  46137. * Creates a box mesh
  46138. * * The parameter `size` sets the size (float) of each box side (default 1)
  46139. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46140. * * 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)
  46141. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46143. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46145. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46146. * @param name defines the name of the mesh
  46147. * @param options defines the options used to create the mesh
  46148. * @param scene defines the hosting scene
  46149. * @returns the box mesh
  46150. */
  46151. static CreateBox(name: string, options: {
  46152. size?: number;
  46153. width?: number;
  46154. height?: number;
  46155. depth?: number;
  46156. faceUV?: Vector4[];
  46157. faceColors?: Color4[];
  46158. sideOrientation?: number;
  46159. frontUVs?: Vector4;
  46160. backUVs?: Vector4;
  46161. wrap?: boolean;
  46162. topBaseAt?: number;
  46163. bottomBaseAt?: number;
  46164. updatable?: boolean;
  46165. }, scene?: Nullable<Scene>): Mesh;
  46166. }
  46167. }
  46168. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  46169. import { Vector4 } from "babylonjs/Maths/math.vector";
  46170. import { Mesh } from "babylonjs/Meshes/mesh";
  46171. import { Scene } from "babylonjs/scene";
  46172. import { Nullable } from "babylonjs/types";
  46173. /**
  46174. * Class containing static functions to help procedurally build meshes
  46175. */
  46176. export class SphereBuilder {
  46177. /**
  46178. * Creates a sphere mesh
  46179. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  46180. * * 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`)
  46181. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  46182. * * 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
  46183. * * 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)
  46184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46185. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46187. * @param name defines the name of the mesh
  46188. * @param options defines the options used to create the mesh
  46189. * @param scene defines the hosting scene
  46190. * @returns the sphere mesh
  46191. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  46192. */
  46193. static CreateSphere(name: string, options: {
  46194. segments?: number;
  46195. diameter?: number;
  46196. diameterX?: number;
  46197. diameterY?: number;
  46198. diameterZ?: number;
  46199. arc?: number;
  46200. slice?: number;
  46201. sideOrientation?: number;
  46202. frontUVs?: Vector4;
  46203. backUVs?: Vector4;
  46204. updatable?: boolean;
  46205. }, scene?: Nullable<Scene>): Mesh;
  46206. }
  46207. }
  46208. declare module "babylonjs/Debug/physicsViewer" {
  46209. import { Nullable } from "babylonjs/types";
  46210. import { Scene } from "babylonjs/scene";
  46211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46212. import { Mesh } from "babylonjs/Meshes/mesh";
  46213. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  46214. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  46215. /**
  46216. * Used to show the physics impostor around the specific mesh
  46217. */
  46218. export class PhysicsViewer {
  46219. /** @hidden */
  46220. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46221. /** @hidden */
  46222. protected _meshes: Array<Nullable<AbstractMesh>>;
  46223. /** @hidden */
  46224. protected _scene: Nullable<Scene>;
  46225. /** @hidden */
  46226. protected _numMeshes: number;
  46227. /** @hidden */
  46228. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46229. private _renderFunction;
  46230. private _utilityLayer;
  46231. private _debugBoxMesh;
  46232. private _debugSphereMesh;
  46233. private _debugCylinderMesh;
  46234. private _debugMaterial;
  46235. private _debugMeshMeshes;
  46236. /**
  46237. * Creates a new PhysicsViewer
  46238. * @param scene defines the hosting scene
  46239. */
  46240. constructor(scene: Scene);
  46241. /** @hidden */
  46242. protected _updateDebugMeshes(): void;
  46243. /**
  46244. * Renders a specified physic impostor
  46245. * @param impostor defines the impostor to render
  46246. * @param targetMesh defines the mesh represented by the impostor
  46247. * @returns the new debug mesh used to render the impostor
  46248. */
  46249. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46250. /**
  46251. * Hides a specified physic impostor
  46252. * @param impostor defines the impostor to hide
  46253. */
  46254. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46255. private _getDebugMaterial;
  46256. private _getDebugBoxMesh;
  46257. private _getDebugSphereMesh;
  46258. private _getDebugCylinderMesh;
  46259. private _getDebugMeshMesh;
  46260. private _getDebugMesh;
  46261. /** Releases all resources */
  46262. dispose(): void;
  46263. }
  46264. }
  46265. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46266. import { Vector3 } from "babylonjs/Maths/math.vector";
  46267. import { Color4 } from "babylonjs/Maths/math.color";
  46268. import { Nullable } from "babylonjs/types";
  46269. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46270. import { Scene } from "babylonjs/scene";
  46271. /**
  46272. * Class containing static functions to help procedurally build meshes
  46273. */
  46274. export class LinesBuilder {
  46275. /**
  46276. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46277. * * 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
  46278. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46279. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46280. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46281. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46282. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46283. * * 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
  46284. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46286. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46287. * @param name defines the name of the new line system
  46288. * @param options defines the options used to create the line system
  46289. * @param scene defines the hosting scene
  46290. * @returns a new line system mesh
  46291. */
  46292. static CreateLineSystem(name: string, options: {
  46293. lines: Vector3[][];
  46294. updatable?: boolean;
  46295. instance?: Nullable<LinesMesh>;
  46296. colors?: Nullable<Color4[][]>;
  46297. useVertexAlpha?: boolean;
  46298. }, scene: Nullable<Scene>): LinesMesh;
  46299. /**
  46300. * Creates a line mesh
  46301. * 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
  46302. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46303. * * The parameter `points` is an array successive Vector3
  46304. * * 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
  46305. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46306. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46307. * * When updating an instance, remember that only point positions can change, not the number of points
  46308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46309. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46310. * @param name defines the name of the new line system
  46311. * @param options defines the options used to create the line system
  46312. * @param scene defines the hosting scene
  46313. * @returns a new line mesh
  46314. */
  46315. static CreateLines(name: string, options: {
  46316. points: Vector3[];
  46317. updatable?: boolean;
  46318. instance?: Nullable<LinesMesh>;
  46319. colors?: Color4[];
  46320. useVertexAlpha?: boolean;
  46321. }, scene?: Nullable<Scene>): LinesMesh;
  46322. /**
  46323. * Creates a dashed line mesh
  46324. * * 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
  46325. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46326. * * The parameter `points` is an array successive Vector3
  46327. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46328. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46329. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46330. * * 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
  46331. * * When updating an instance, remember that only point positions can change, not the number of points
  46332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46333. * @param name defines the name of the mesh
  46334. * @param options defines the options used to create the mesh
  46335. * @param scene defines the hosting scene
  46336. * @returns the dashed line mesh
  46337. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46338. */
  46339. static CreateDashedLines(name: string, options: {
  46340. points: Vector3[];
  46341. dashSize?: number;
  46342. gapSize?: number;
  46343. dashNb?: number;
  46344. updatable?: boolean;
  46345. instance?: LinesMesh;
  46346. }, scene?: Nullable<Scene>): LinesMesh;
  46347. }
  46348. }
  46349. declare module "babylonjs/Debug/rayHelper" {
  46350. import { Nullable } from "babylonjs/types";
  46351. import { Ray } from "babylonjs/Culling/ray";
  46352. import { Vector3 } from "babylonjs/Maths/math.vector";
  46353. import { Color3 } from "babylonjs/Maths/math.color";
  46354. import { Scene } from "babylonjs/scene";
  46355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46356. import "babylonjs/Meshes/Builders/linesBuilder";
  46357. /**
  46358. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46359. * in order to better appreciate the issue one might have.
  46360. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46361. */
  46362. export class RayHelper {
  46363. /**
  46364. * Defines the ray we are currently tryin to visualize.
  46365. */
  46366. ray: Nullable<Ray>;
  46367. private _renderPoints;
  46368. private _renderLine;
  46369. private _renderFunction;
  46370. private _scene;
  46371. private _updateToMeshFunction;
  46372. private _attachedToMesh;
  46373. private _meshSpaceDirection;
  46374. private _meshSpaceOrigin;
  46375. /**
  46376. * Helper function to create a colored helper in a scene in one line.
  46377. * @param ray Defines the ray we are currently tryin to visualize
  46378. * @param scene Defines the scene the ray is used in
  46379. * @param color Defines the color we want to see the ray in
  46380. * @returns The newly created ray helper.
  46381. */
  46382. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46383. /**
  46384. * Instantiate a new ray helper.
  46385. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46386. * in order to better appreciate the issue one might have.
  46387. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46388. * @param ray Defines the ray we are currently tryin to visualize
  46389. */
  46390. constructor(ray: Ray);
  46391. /**
  46392. * Shows the ray we are willing to debug.
  46393. * @param scene Defines the scene the ray needs to be rendered in
  46394. * @param color Defines the color the ray needs to be rendered in
  46395. */
  46396. show(scene: Scene, color?: Color3): void;
  46397. /**
  46398. * Hides the ray we are debugging.
  46399. */
  46400. hide(): void;
  46401. private _render;
  46402. /**
  46403. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46404. * @param mesh Defines the mesh we want the helper attached to
  46405. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46406. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46407. * @param length Defines the length of the ray
  46408. */
  46409. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46410. /**
  46411. * Detach the ray helper from the mesh it has previously been attached to.
  46412. */
  46413. detachFromMesh(): void;
  46414. private _updateToMesh;
  46415. /**
  46416. * Dispose the helper and release its associated resources.
  46417. */
  46418. dispose(): void;
  46419. }
  46420. }
  46421. declare module "babylonjs/Debug/skeletonViewer" {
  46422. import { Color3 } from "babylonjs/Maths/math.color";
  46423. import { Scene } from "babylonjs/scene";
  46424. import { Nullable } from "babylonjs/types";
  46425. import { Skeleton } from "babylonjs/Bones/skeleton";
  46426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46427. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46428. /**
  46429. * Class used to render a debug view of a given skeleton
  46430. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46431. */
  46432. export class SkeletonViewer {
  46433. /** defines the skeleton to render */
  46434. skeleton: Skeleton;
  46435. /** defines the mesh attached to the skeleton */
  46436. mesh: AbstractMesh;
  46437. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46438. autoUpdateBonesMatrices: boolean;
  46439. /** defines the rendering group id to use with the viewer */
  46440. renderingGroupId: number;
  46441. /** Gets or sets the color used to render the skeleton */
  46442. color: Color3;
  46443. private _scene;
  46444. private _debugLines;
  46445. private _debugMesh;
  46446. private _isEnabled;
  46447. private _renderFunction;
  46448. private _utilityLayer;
  46449. /**
  46450. * Returns the mesh used to render the bones
  46451. */
  46452. readonly debugMesh: Nullable<LinesMesh>;
  46453. /**
  46454. * Creates a new SkeletonViewer
  46455. * @param skeleton defines the skeleton to render
  46456. * @param mesh defines the mesh attached to the skeleton
  46457. * @param scene defines the hosting scene
  46458. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46459. * @param renderingGroupId defines the rendering group id to use with the viewer
  46460. */
  46461. constructor(
  46462. /** defines the skeleton to render */
  46463. skeleton: Skeleton,
  46464. /** defines the mesh attached to the skeleton */
  46465. mesh: AbstractMesh, scene: Scene,
  46466. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46467. autoUpdateBonesMatrices?: boolean,
  46468. /** defines the rendering group id to use with the viewer */
  46469. renderingGroupId?: number);
  46470. /** Gets or sets a boolean indicating if the viewer is enabled */
  46471. isEnabled: boolean;
  46472. private _getBonePosition;
  46473. private _getLinesForBonesWithLength;
  46474. private _getLinesForBonesNoLength;
  46475. /** Update the viewer to sync with current skeleton state */
  46476. update(): void;
  46477. /** Release associated resources */
  46478. dispose(): void;
  46479. }
  46480. }
  46481. declare module "babylonjs/Debug/index" {
  46482. export * from "babylonjs/Debug/axesViewer";
  46483. export * from "babylonjs/Debug/boneAxesViewer";
  46484. export * from "babylonjs/Debug/debugLayer";
  46485. export * from "babylonjs/Debug/physicsViewer";
  46486. export * from "babylonjs/Debug/rayHelper";
  46487. export * from "babylonjs/Debug/skeletonViewer";
  46488. }
  46489. declare module "babylonjs/Engines/nullEngine" {
  46490. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  46491. import { Scene } from "babylonjs/scene";
  46492. import { Engine } from "babylonjs/Engines/engine";
  46493. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46494. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46495. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46496. import { Effect } from "babylonjs/Materials/effect";
  46497. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46498. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46499. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  46500. /**
  46501. * Options to create the null engine
  46502. */
  46503. export class NullEngineOptions {
  46504. /**
  46505. * Render width (Default: 512)
  46506. */
  46507. renderWidth: number;
  46508. /**
  46509. * Render height (Default: 256)
  46510. */
  46511. renderHeight: number;
  46512. /**
  46513. * Texture size (Default: 512)
  46514. */
  46515. textureSize: number;
  46516. /**
  46517. * If delta time between frames should be constant
  46518. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46519. */
  46520. deterministicLockstep: boolean;
  46521. /**
  46522. * Maximum about of steps between frames (Default: 4)
  46523. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46524. */
  46525. lockstepMaxSteps: number;
  46526. }
  46527. /**
  46528. * The null engine class provides support for headless version of babylon.js.
  46529. * This can be used in server side scenario or for testing purposes
  46530. */
  46531. export class NullEngine extends Engine {
  46532. private _options;
  46533. /**
  46534. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46535. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46536. * @returns true if engine is in deterministic lock step mode
  46537. */
  46538. isDeterministicLockStep(): boolean;
  46539. /**
  46540. * Gets the max steps when engine is running in deterministic lock step
  46541. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46542. * @returns the max steps
  46543. */
  46544. getLockstepMaxSteps(): number;
  46545. /**
  46546. * Gets the current hardware scaling level.
  46547. * By default the hardware scaling level is computed from the window device ratio.
  46548. * 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.
  46549. * @returns a number indicating the current hardware scaling level
  46550. */
  46551. getHardwareScalingLevel(): number;
  46552. constructor(options?: NullEngineOptions);
  46553. /**
  46554. * Creates a vertex buffer
  46555. * @param vertices the data for the vertex buffer
  46556. * @returns the new WebGL static buffer
  46557. */
  46558. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46559. /**
  46560. * Creates a new index buffer
  46561. * @param indices defines the content of the index buffer
  46562. * @param updatable defines if the index buffer must be updatable
  46563. * @returns a new webGL buffer
  46564. */
  46565. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46566. /**
  46567. * Clear the current render buffer or the current render target (if any is set up)
  46568. * @param color defines the color to use
  46569. * @param backBuffer defines if the back buffer must be cleared
  46570. * @param depth defines if the depth buffer must be cleared
  46571. * @param stencil defines if the stencil buffer must be cleared
  46572. */
  46573. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46574. /**
  46575. * Gets the current render width
  46576. * @param useScreen defines if screen size must be used (or the current render target if any)
  46577. * @returns a number defining the current render width
  46578. */
  46579. getRenderWidth(useScreen?: boolean): number;
  46580. /**
  46581. * Gets the current render height
  46582. * @param useScreen defines if screen size must be used (or the current render target if any)
  46583. * @returns a number defining the current render height
  46584. */
  46585. getRenderHeight(useScreen?: boolean): number;
  46586. /**
  46587. * Set the WebGL's viewport
  46588. * @param viewport defines the viewport element to be used
  46589. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46590. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46591. */
  46592. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46593. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46594. /**
  46595. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46596. * @param pipelineContext defines the pipeline context to use
  46597. * @param uniformsNames defines the list of uniform names
  46598. * @returns an array of webGL uniform locations
  46599. */
  46600. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46601. /**
  46602. * Gets the lsit of active attributes for a given webGL program
  46603. * @param pipelineContext defines the pipeline context to use
  46604. * @param attributesNames defines the list of attribute names to get
  46605. * @returns an array of indices indicating the offset of each attribute
  46606. */
  46607. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46608. /**
  46609. * Binds an effect to the webGL context
  46610. * @param effect defines the effect to bind
  46611. */
  46612. bindSamplers(effect: Effect): void;
  46613. /**
  46614. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46615. * @param effect defines the effect to activate
  46616. */
  46617. enableEffect(effect: Effect): void;
  46618. /**
  46619. * Set various states to the webGL context
  46620. * @param culling defines backface culling state
  46621. * @param zOffset defines the value to apply to zOffset (0 by default)
  46622. * @param force defines if states must be applied even if cache is up to date
  46623. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46624. */
  46625. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46626. /**
  46627. * Set the value of an uniform to an array of int32
  46628. * @param uniform defines the webGL uniform location where to store the value
  46629. * @param array defines the array of int32 to store
  46630. */
  46631. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46632. /**
  46633. * Set the value of an uniform to an array of int32 (stored as vec2)
  46634. * @param uniform defines the webGL uniform location where to store the value
  46635. * @param array defines the array of int32 to store
  46636. */
  46637. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46638. /**
  46639. * Set the value of an uniform to an array of int32 (stored as vec3)
  46640. * @param uniform defines the webGL uniform location where to store the value
  46641. * @param array defines the array of int32 to store
  46642. */
  46643. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46644. /**
  46645. * Set the value of an uniform to an array of int32 (stored as vec4)
  46646. * @param uniform defines the webGL uniform location where to store the value
  46647. * @param array defines the array of int32 to store
  46648. */
  46649. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46650. /**
  46651. * Set the value of an uniform to an array of float32
  46652. * @param uniform defines the webGL uniform location where to store the value
  46653. * @param array defines the array of float32 to store
  46654. */
  46655. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46656. /**
  46657. * Set the value of an uniform to an array of float32 (stored as vec2)
  46658. * @param uniform defines the webGL uniform location where to store the value
  46659. * @param array defines the array of float32 to store
  46660. */
  46661. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46662. /**
  46663. * Set the value of an uniform to an array of float32 (stored as vec3)
  46664. * @param uniform defines the webGL uniform location where to store the value
  46665. * @param array defines the array of float32 to store
  46666. */
  46667. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46668. /**
  46669. * Set the value of an uniform to an array of float32 (stored as vec4)
  46670. * @param uniform defines the webGL uniform location where to store the value
  46671. * @param array defines the array of float32 to store
  46672. */
  46673. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46674. /**
  46675. * Set the value of an uniform to an array of number
  46676. * @param uniform defines the webGL uniform location where to store the value
  46677. * @param array defines the array of number to store
  46678. */
  46679. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46680. /**
  46681. * Set the value of an uniform to an array of number (stored as vec2)
  46682. * @param uniform defines the webGL uniform location where to store the value
  46683. * @param array defines the array of number to store
  46684. */
  46685. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46686. /**
  46687. * Set the value of an uniform to an array of number (stored as vec3)
  46688. * @param uniform defines the webGL uniform location where to store the value
  46689. * @param array defines the array of number to store
  46690. */
  46691. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46692. /**
  46693. * Set the value of an uniform to an array of number (stored as vec4)
  46694. * @param uniform defines the webGL uniform location where to store the value
  46695. * @param array defines the array of number to store
  46696. */
  46697. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46698. /**
  46699. * Set the value of an uniform to an array of float32 (stored as matrices)
  46700. * @param uniform defines the webGL uniform location where to store the value
  46701. * @param matrices defines the array of float32 to store
  46702. */
  46703. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46704. /**
  46705. * Set the value of an uniform to a matrix (3x3)
  46706. * @param uniform defines the webGL uniform location where to store the value
  46707. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46708. */
  46709. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46710. /**
  46711. * Set the value of an uniform to a matrix (2x2)
  46712. * @param uniform defines the webGL uniform location where to store the value
  46713. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46714. */
  46715. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46716. /**
  46717. * Set the value of an uniform to a number (float)
  46718. * @param uniform defines the webGL uniform location where to store the value
  46719. * @param value defines the float number to store
  46720. */
  46721. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46722. /**
  46723. * Set the value of an uniform to a vec2
  46724. * @param uniform defines the webGL uniform location where to store the value
  46725. * @param x defines the 1st component of the value
  46726. * @param y defines the 2nd component of the value
  46727. */
  46728. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46729. /**
  46730. * Set the value of an uniform to a vec3
  46731. * @param uniform defines the webGL uniform location where to store the value
  46732. * @param x defines the 1st component of the value
  46733. * @param y defines the 2nd component of the value
  46734. * @param z defines the 3rd component of the value
  46735. */
  46736. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46737. /**
  46738. * Set the value of an uniform to a boolean
  46739. * @param uniform defines the webGL uniform location where to store the value
  46740. * @param bool defines the boolean to store
  46741. */
  46742. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46743. /**
  46744. * Set the value of an uniform to a vec4
  46745. * @param uniform defines the webGL uniform location where to store the value
  46746. * @param x defines the 1st component of the value
  46747. * @param y defines the 2nd component of the value
  46748. * @param z defines the 3rd component of the value
  46749. * @param w defines the 4th component of the value
  46750. */
  46751. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46752. /**
  46753. * Sets the current alpha mode
  46754. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46755. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46756. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46757. */
  46758. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46759. /**
  46760. * Bind webGl buffers directly to the webGL context
  46761. * @param vertexBuffers defines the vertex buffer to bind
  46762. * @param indexBuffer defines the index buffer to bind
  46763. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46764. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46765. * @param effect defines the effect associated with the vertex buffer
  46766. */
  46767. bindBuffers(vertexBuffers: {
  46768. [key: string]: VertexBuffer;
  46769. }, indexBuffer: DataBuffer, effect: Effect): void;
  46770. /**
  46771. * Force the entire cache to be cleared
  46772. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46773. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46774. */
  46775. wipeCaches(bruteForce?: boolean): void;
  46776. /**
  46777. * Send a draw order
  46778. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46779. * @param indexStart defines the starting index
  46780. * @param indexCount defines the number of index to draw
  46781. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46782. */
  46783. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46784. /**
  46785. * Draw a list of indexed primitives
  46786. * @param fillMode defines the primitive to use
  46787. * @param indexStart defines the starting index
  46788. * @param indexCount defines the number of index to draw
  46789. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46790. */
  46791. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46792. /**
  46793. * Draw a list of unindexed primitives
  46794. * @param fillMode defines the primitive to use
  46795. * @param verticesStart defines the index of first vertex to draw
  46796. * @param verticesCount defines the count of vertices to draw
  46797. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46798. */
  46799. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46800. /** @hidden */
  46801. _createTexture(): WebGLTexture;
  46802. /** @hidden */
  46803. _releaseTexture(texture: InternalTexture): void;
  46804. /**
  46805. * Usually called from Texture.ts.
  46806. * Passed information to create a WebGLTexture
  46807. * @param urlArg defines a value which contains one of the following:
  46808. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46809. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46810. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46811. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46812. * @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)
  46813. * @param scene needed for loading to the correct scene
  46814. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46815. * @param onLoad optional callback to be called upon successful completion
  46816. * @param onError optional callback to be called upon failure
  46817. * @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
  46818. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46819. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46820. * @param forcedExtension defines the extension to use to pick the right loader
  46821. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46822. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46823. */
  46824. 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;
  46825. /**
  46826. * Creates a new render target texture
  46827. * @param size defines the size of the texture
  46828. * @param options defines the options used to create the texture
  46829. * @returns a new render target texture stored in an InternalTexture
  46830. */
  46831. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46832. /**
  46833. * Update the sampling mode of a given texture
  46834. * @param samplingMode defines the required sampling mode
  46835. * @param texture defines the texture to update
  46836. */
  46837. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46838. /**
  46839. * Binds the frame buffer to the specified texture.
  46840. * @param texture The texture to render to or null for the default canvas
  46841. * @param faceIndex The face of the texture to render to in case of cube texture
  46842. * @param requiredWidth The width of the target to render to
  46843. * @param requiredHeight The height of the target to render to
  46844. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46845. * @param depthStencilTexture The depth stencil texture to use to render
  46846. * @param lodLevel defines le lod level to bind to the frame buffer
  46847. */
  46848. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46849. /**
  46850. * Unbind the current render target texture from the webGL context
  46851. * @param texture defines the render target texture to unbind
  46852. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46853. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46854. */
  46855. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46856. /**
  46857. * Creates a dynamic vertex buffer
  46858. * @param vertices the data for the dynamic vertex buffer
  46859. * @returns the new WebGL dynamic buffer
  46860. */
  46861. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46862. /**
  46863. * Update the content of a dynamic texture
  46864. * @param texture defines the texture to update
  46865. * @param canvas defines the canvas containing the source
  46866. * @param invertY defines if data must be stored with Y axis inverted
  46867. * @param premulAlpha defines if alpha is stored as premultiplied
  46868. * @param format defines the format of the data
  46869. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46870. */
  46871. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46872. /**
  46873. * Gets a boolean indicating if all created effects are ready
  46874. * @returns true if all effects are ready
  46875. */
  46876. areAllEffectsReady(): boolean;
  46877. /**
  46878. * @hidden
  46879. * Get the current error code of the webGL context
  46880. * @returns the error code
  46881. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46882. */
  46883. getError(): number;
  46884. /** @hidden */
  46885. _getUnpackAlignement(): number;
  46886. /** @hidden */
  46887. _unpackFlipY(value: boolean): void;
  46888. /**
  46889. * Update a dynamic index buffer
  46890. * @param indexBuffer defines the target index buffer
  46891. * @param indices defines the data to update
  46892. * @param offset defines the offset in the target index buffer where update should start
  46893. */
  46894. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46895. /**
  46896. * Updates a dynamic vertex buffer.
  46897. * @param vertexBuffer the vertex buffer to update
  46898. * @param vertices the data used to update the vertex buffer
  46899. * @param byteOffset the byte offset of the data (optional)
  46900. * @param byteLength the byte length of the data (optional)
  46901. */
  46902. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46903. /** @hidden */
  46904. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46905. /** @hidden */
  46906. _bindTexture(channel: number, texture: InternalTexture): void;
  46907. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46908. /**
  46909. * 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
  46910. */
  46911. releaseEffects(): void;
  46912. displayLoadingUI(): void;
  46913. hideLoadingUI(): void;
  46914. /** @hidden */
  46915. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46916. /** @hidden */
  46917. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46918. /** @hidden */
  46919. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46920. /** @hidden */
  46921. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46922. }
  46923. }
  46924. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  46925. import { Nullable, int } from "babylonjs/types";
  46926. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  46927. /** @hidden */
  46928. export class _OcclusionDataStorage {
  46929. /** @hidden */
  46930. occlusionInternalRetryCounter: number;
  46931. /** @hidden */
  46932. isOcclusionQueryInProgress: boolean;
  46933. /** @hidden */
  46934. isOccluded: boolean;
  46935. /** @hidden */
  46936. occlusionRetryCount: number;
  46937. /** @hidden */
  46938. occlusionType: number;
  46939. /** @hidden */
  46940. occlusionQueryAlgorithmType: number;
  46941. }
  46942. module "babylonjs/Engines/engine" {
  46943. interface Engine {
  46944. /**
  46945. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46946. * @return the new query
  46947. */
  46948. createQuery(): WebGLQuery;
  46949. /**
  46950. * Delete and release a webGL query
  46951. * @param query defines the query to delete
  46952. * @return the current engine
  46953. */
  46954. deleteQuery(query: WebGLQuery): Engine;
  46955. /**
  46956. * Check if a given query has resolved and got its value
  46957. * @param query defines the query to check
  46958. * @returns true if the query got its value
  46959. */
  46960. isQueryResultAvailable(query: WebGLQuery): boolean;
  46961. /**
  46962. * Gets the value of a given query
  46963. * @param query defines the query to check
  46964. * @returns the value of the query
  46965. */
  46966. getQueryResult(query: WebGLQuery): number;
  46967. /**
  46968. * Initiates an occlusion query
  46969. * @param algorithmType defines the algorithm to use
  46970. * @param query defines the query to use
  46971. * @returns the current engine
  46972. * @see http://doc.babylonjs.com/features/occlusionquery
  46973. */
  46974. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46975. /**
  46976. * Ends an occlusion query
  46977. * @see http://doc.babylonjs.com/features/occlusionquery
  46978. * @param algorithmType defines the algorithm to use
  46979. * @returns the current engine
  46980. */
  46981. endOcclusionQuery(algorithmType: number): Engine;
  46982. /**
  46983. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46984. * Please note that only one query can be issued at a time
  46985. * @returns a time token used to track the time span
  46986. */
  46987. startTimeQuery(): Nullable<_TimeToken>;
  46988. /**
  46989. * Ends a time query
  46990. * @param token defines the token used to measure the time span
  46991. * @returns the time spent (in ns)
  46992. */
  46993. endTimeQuery(token: _TimeToken): int;
  46994. /** @hidden */
  46995. _currentNonTimestampToken: Nullable<_TimeToken>;
  46996. /** @hidden */
  46997. _createTimeQuery(): WebGLQuery;
  46998. /** @hidden */
  46999. _deleteTimeQuery(query: WebGLQuery): void;
  47000. /** @hidden */
  47001. _getGlAlgorithmType(algorithmType: number): number;
  47002. /** @hidden */
  47003. _getTimeQueryResult(query: WebGLQuery): any;
  47004. /** @hidden */
  47005. _getTimeQueryAvailability(query: WebGLQuery): any;
  47006. }
  47007. }
  47008. module "babylonjs/Meshes/abstractMesh" {
  47009. interface AbstractMesh {
  47010. /**
  47011. * Backing filed
  47012. * @hidden
  47013. */
  47014. __occlusionDataStorage: _OcclusionDataStorage;
  47015. /**
  47016. * Access property
  47017. * @hidden
  47018. */
  47019. _occlusionDataStorage: _OcclusionDataStorage;
  47020. /**
  47021. * 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.
  47022. * The default value is -1 which means don't break the query and wait till the result
  47023. * @see http://doc.babylonjs.com/features/occlusionquery
  47024. */
  47025. occlusionRetryCount: number;
  47026. /**
  47027. * 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:
  47028. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47029. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47030. * * 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.
  47031. * @see http://doc.babylonjs.com/features/occlusionquery
  47032. */
  47033. occlusionType: number;
  47034. /**
  47035. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47036. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47037. * * 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.
  47038. * @see http://doc.babylonjs.com/features/occlusionquery
  47039. */
  47040. occlusionQueryAlgorithmType: number;
  47041. /**
  47042. * 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
  47043. * @see http://doc.babylonjs.com/features/occlusionquery
  47044. */
  47045. isOccluded: boolean;
  47046. /**
  47047. * Flag to check the progress status of the query
  47048. * @see http://doc.babylonjs.com/features/occlusionquery
  47049. */
  47050. isOcclusionQueryInProgress: boolean;
  47051. }
  47052. }
  47053. }
  47054. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  47055. import { Nullable } from "babylonjs/types";
  47056. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47057. /** @hidden */
  47058. export var _forceTransformFeedbackToBundle: boolean;
  47059. module "babylonjs/Engines/engine" {
  47060. interface Engine {
  47061. /**
  47062. * Creates a webGL transform feedback object
  47063. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47064. * @returns the webGL transform feedback object
  47065. */
  47066. createTransformFeedback(): WebGLTransformFeedback;
  47067. /**
  47068. * Delete a webGL transform feedback object
  47069. * @param value defines the webGL transform feedback object to delete
  47070. */
  47071. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47072. /**
  47073. * Bind a webGL transform feedback object to the webgl context
  47074. * @param value defines the webGL transform feedback object to bind
  47075. */
  47076. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47077. /**
  47078. * Begins a transform feedback operation
  47079. * @param usePoints defines if points or triangles must be used
  47080. */
  47081. beginTransformFeedback(usePoints: boolean): void;
  47082. /**
  47083. * Ends a transform feedback operation
  47084. */
  47085. endTransformFeedback(): void;
  47086. /**
  47087. * Specify the varyings to use with transform feedback
  47088. * @param program defines the associated webGL program
  47089. * @param value defines the list of strings representing the varying names
  47090. */
  47091. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47092. /**
  47093. * Bind a webGL buffer for a transform feedback operation
  47094. * @param value defines the webGL buffer to bind
  47095. */
  47096. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47097. }
  47098. }
  47099. }
  47100. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  47101. import { Scene } from "babylonjs/scene";
  47102. import { Engine } from "babylonjs/Engines/engine";
  47103. import { Texture } from "babylonjs/Materials/Textures/texture";
  47104. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47105. import "babylonjs/Engines/Extensions/engine.multiRender";
  47106. /**
  47107. * Creation options of the multi render target texture.
  47108. */
  47109. export interface IMultiRenderTargetOptions {
  47110. /**
  47111. * Define if the texture needs to create mip maps after render.
  47112. */
  47113. generateMipMaps?: boolean;
  47114. /**
  47115. * Define the types of all the draw buffers we want to create
  47116. */
  47117. types?: number[];
  47118. /**
  47119. * Define the sampling modes of all the draw buffers we want to create
  47120. */
  47121. samplingModes?: number[];
  47122. /**
  47123. * Define if a depth buffer is required
  47124. */
  47125. generateDepthBuffer?: boolean;
  47126. /**
  47127. * Define if a stencil buffer is required
  47128. */
  47129. generateStencilBuffer?: boolean;
  47130. /**
  47131. * Define if a depth texture is required instead of a depth buffer
  47132. */
  47133. generateDepthTexture?: boolean;
  47134. /**
  47135. * Define the number of desired draw buffers
  47136. */
  47137. textureCount?: number;
  47138. /**
  47139. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47140. */
  47141. doNotChangeAspectRatio?: boolean;
  47142. /**
  47143. * Define the default type of the buffers we are creating
  47144. */
  47145. defaultType?: number;
  47146. }
  47147. /**
  47148. * A multi render target, like a render target provides the ability to render to a texture.
  47149. * Unlike the render target, it can render to several draw buffers in one draw.
  47150. * This is specially interesting in deferred rendering or for any effects requiring more than
  47151. * just one color from a single pass.
  47152. */
  47153. export class MultiRenderTarget extends RenderTargetTexture {
  47154. private _internalTextures;
  47155. private _textures;
  47156. private _multiRenderTargetOptions;
  47157. /**
  47158. * Get if draw buffers are currently supported by the used hardware and browser.
  47159. */
  47160. readonly isSupported: boolean;
  47161. /**
  47162. * Get the list of textures generated by the multi render target.
  47163. */
  47164. readonly textures: Texture[];
  47165. /**
  47166. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47167. */
  47168. readonly depthTexture: Texture;
  47169. /**
  47170. * Set the wrapping mode on U of all the textures we are rendering to.
  47171. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47172. */
  47173. wrapU: number;
  47174. /**
  47175. * Set the wrapping mode on V of all the textures we are rendering to.
  47176. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47177. */
  47178. wrapV: number;
  47179. /**
  47180. * Instantiate a new multi render target texture.
  47181. * A multi render target, like a render target provides the ability to render to a texture.
  47182. * Unlike the render target, it can render to several draw buffers in one draw.
  47183. * This is specially interesting in deferred rendering or for any effects requiring more than
  47184. * just one color from a single pass.
  47185. * @param name Define the name of the texture
  47186. * @param size Define the size of the buffers to render to
  47187. * @param count Define the number of target we are rendering into
  47188. * @param scene Define the scene the texture belongs to
  47189. * @param options Define the options used to create the multi render target
  47190. */
  47191. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47192. /** @hidden */
  47193. _rebuild(): void;
  47194. private _createInternalTextures;
  47195. private _createTextures;
  47196. /**
  47197. * Define the number of samples used if MSAA is enabled.
  47198. */
  47199. samples: number;
  47200. /**
  47201. * Resize all the textures in the multi render target.
  47202. * Be carrefull as it will recreate all the data in the new texture.
  47203. * @param size Define the new size
  47204. */
  47205. resize(size: any): void;
  47206. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47207. /**
  47208. * Dispose the render targets and their associated resources
  47209. */
  47210. dispose(): void;
  47211. /**
  47212. * Release all the underlying texture used as draw buffers.
  47213. */
  47214. releaseInternalTextures(): void;
  47215. }
  47216. }
  47217. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  47218. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47219. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  47220. import { Nullable } from "babylonjs/types";
  47221. module "babylonjs/Engines/thinEngine" {
  47222. interface ThinEngine {
  47223. /**
  47224. * Unbind a list of render target textures from the webGL context
  47225. * This is used only when drawBuffer extension or webGL2 are active
  47226. * @param textures defines the render target textures to unbind
  47227. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47228. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47229. */
  47230. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47231. /**
  47232. * Create a multi render target texture
  47233. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47234. * @param size defines the size of the texture
  47235. * @param options defines the creation options
  47236. * @returns the cube texture as an InternalTexture
  47237. */
  47238. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47239. /**
  47240. * Update the sample count for a given multiple render target texture
  47241. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47242. * @param textures defines the textures to update
  47243. * @param samples defines the sample count to set
  47244. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47245. */
  47246. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47247. }
  47248. }
  47249. }
  47250. declare module "babylonjs/Engines/Extensions/engine.views" {
  47251. import { Camera } from "babylonjs/Cameras/camera";
  47252. import { Nullable } from "babylonjs/types";
  47253. /**
  47254. * Class used to define an additional view for the engine
  47255. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47256. */
  47257. export class EngineView {
  47258. /** Defines the canvas where to render the view */
  47259. target: HTMLCanvasElement;
  47260. /** Defines an optional camera used to render the view (will use active camera else) */
  47261. camera?: Camera;
  47262. }
  47263. module "babylonjs/Engines/engine" {
  47264. interface Engine {
  47265. /**
  47266. * Gets or sets the HTML element to use for attaching events
  47267. */
  47268. inputElement: Nullable<HTMLElement>;
  47269. /**
  47270. * Gets the current engine view
  47271. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47272. */
  47273. activeView: Nullable<EngineView>;
  47274. /** Gets or sets the list of views */
  47275. views: EngineView[];
  47276. /**
  47277. * Register a new child canvas
  47278. * @param canvas defines the canvas to register
  47279. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47280. * @returns the associated view
  47281. */
  47282. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47283. /**
  47284. * Remove a registered child canvas
  47285. * @param canvas defines the canvas to remove
  47286. * @returns the current engine
  47287. */
  47288. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47289. }
  47290. }
  47291. }
  47292. declare module "babylonjs/Engines/Extensions/index" {
  47293. export * from "babylonjs/Engines/Extensions/engine.alpha";
  47294. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  47295. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  47296. export * from "babylonjs/Engines/Extensions/engine.multiview";
  47297. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  47298. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  47299. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  47300. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  47301. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  47302. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  47303. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  47304. export * from "babylonjs/Engines/Extensions/engine.webVR";
  47305. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  47306. export * from "babylonjs/Engines/Extensions/engine.views";
  47307. }
  47308. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  47309. import { Nullable } from "babylonjs/types";
  47310. /**
  47311. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47312. */
  47313. export interface CubeMapInfo {
  47314. /**
  47315. * The pixel array for the front face.
  47316. * This is stored in format, left to right, up to down format.
  47317. */
  47318. front: Nullable<ArrayBufferView>;
  47319. /**
  47320. * The pixel array for the back face.
  47321. * This is stored in format, left to right, up to down format.
  47322. */
  47323. back: Nullable<ArrayBufferView>;
  47324. /**
  47325. * The pixel array for the left face.
  47326. * This is stored in format, left to right, up to down format.
  47327. */
  47328. left: Nullable<ArrayBufferView>;
  47329. /**
  47330. * The pixel array for the right face.
  47331. * This is stored in format, left to right, up to down format.
  47332. */
  47333. right: Nullable<ArrayBufferView>;
  47334. /**
  47335. * The pixel array for the up face.
  47336. * This is stored in format, left to right, up to down format.
  47337. */
  47338. up: Nullable<ArrayBufferView>;
  47339. /**
  47340. * The pixel array for the down face.
  47341. * This is stored in format, left to right, up to down format.
  47342. */
  47343. down: Nullable<ArrayBufferView>;
  47344. /**
  47345. * The size of the cubemap stored.
  47346. *
  47347. * Each faces will be size * size pixels.
  47348. */
  47349. size: number;
  47350. /**
  47351. * The format of the texture.
  47352. *
  47353. * RGBA, RGB.
  47354. */
  47355. format: number;
  47356. /**
  47357. * The type of the texture data.
  47358. *
  47359. * UNSIGNED_INT, FLOAT.
  47360. */
  47361. type: number;
  47362. /**
  47363. * Specifies whether the texture is in gamma space.
  47364. */
  47365. gammaSpace: boolean;
  47366. }
  47367. /**
  47368. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47369. */
  47370. export class PanoramaToCubeMapTools {
  47371. private static FACE_FRONT;
  47372. private static FACE_BACK;
  47373. private static FACE_RIGHT;
  47374. private static FACE_LEFT;
  47375. private static FACE_DOWN;
  47376. private static FACE_UP;
  47377. /**
  47378. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47379. *
  47380. * @param float32Array The source data.
  47381. * @param inputWidth The width of the input panorama.
  47382. * @param inputHeight The height of the input panorama.
  47383. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47384. * @return The cubemap data
  47385. */
  47386. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47387. private static CreateCubemapTexture;
  47388. private static CalcProjectionSpherical;
  47389. }
  47390. }
  47391. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  47392. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47393. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47394. import { Nullable } from "babylonjs/types";
  47395. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  47396. /**
  47397. * Helper class dealing with the extraction of spherical polynomial dataArray
  47398. * from a cube map.
  47399. */
  47400. export class CubeMapToSphericalPolynomialTools {
  47401. private static FileFaces;
  47402. /**
  47403. * Converts a texture to the according Spherical Polynomial data.
  47404. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47405. *
  47406. * @param texture The texture to extract the information from.
  47407. * @return The Spherical Polynomial data.
  47408. */
  47409. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47410. /**
  47411. * Converts a cubemap to the according Spherical Polynomial data.
  47412. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47413. *
  47414. * @param cubeInfo The Cube map to extract the information from.
  47415. * @return The Spherical Polynomial data.
  47416. */
  47417. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47418. }
  47419. }
  47420. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  47421. import { Nullable } from "babylonjs/types";
  47422. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47423. module "babylonjs/Materials/Textures/baseTexture" {
  47424. interface BaseTexture {
  47425. /**
  47426. * Get the polynomial representation of the texture data.
  47427. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47428. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47429. */
  47430. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47431. }
  47432. }
  47433. }
  47434. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47435. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47436. /** @hidden */
  47437. export var rgbdEncodePixelShader: {
  47438. name: string;
  47439. shader: string;
  47440. };
  47441. }
  47442. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47443. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47444. /** @hidden */
  47445. export var rgbdDecodePixelShader: {
  47446. name: string;
  47447. shader: string;
  47448. };
  47449. }
  47450. declare module "babylonjs/Misc/environmentTextureTools" {
  47451. import { Nullable } from "babylonjs/types";
  47452. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47453. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47454. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47455. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  47456. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  47457. import "babylonjs/Shaders/rgbdEncode.fragment";
  47458. import "babylonjs/Shaders/rgbdDecode.fragment";
  47459. /**
  47460. * Raw texture data and descriptor sufficient for WebGL texture upload
  47461. */
  47462. export interface EnvironmentTextureInfo {
  47463. /**
  47464. * Version of the environment map
  47465. */
  47466. version: number;
  47467. /**
  47468. * Width of image
  47469. */
  47470. width: number;
  47471. /**
  47472. * Irradiance information stored in the file.
  47473. */
  47474. irradiance: any;
  47475. /**
  47476. * Specular information stored in the file.
  47477. */
  47478. specular: any;
  47479. }
  47480. /**
  47481. * Defines One Image in the file. It requires only the position in the file
  47482. * as well as the length.
  47483. */
  47484. interface BufferImageData {
  47485. /**
  47486. * Length of the image data.
  47487. */
  47488. length: number;
  47489. /**
  47490. * Position of the data from the null terminator delimiting the end of the JSON.
  47491. */
  47492. position: number;
  47493. }
  47494. /**
  47495. * Defines the specular data enclosed in the file.
  47496. * This corresponds to the version 1 of the data.
  47497. */
  47498. export interface EnvironmentTextureSpecularInfoV1 {
  47499. /**
  47500. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47501. */
  47502. specularDataPosition?: number;
  47503. /**
  47504. * This contains all the images data needed to reconstruct the cubemap.
  47505. */
  47506. mipmaps: Array<BufferImageData>;
  47507. /**
  47508. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47509. */
  47510. lodGenerationScale: number;
  47511. }
  47512. /**
  47513. * Sets of helpers addressing the serialization and deserialization of environment texture
  47514. * stored in a BabylonJS env file.
  47515. * Those files are usually stored as .env files.
  47516. */
  47517. export class EnvironmentTextureTools {
  47518. /**
  47519. * Magic number identifying the env file.
  47520. */
  47521. private static _MagicBytes;
  47522. /**
  47523. * Gets the environment info from an env file.
  47524. * @param data The array buffer containing the .env bytes.
  47525. * @returns the environment file info (the json header) if successfully parsed.
  47526. */
  47527. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47528. /**
  47529. * Creates an environment texture from a loaded cube texture.
  47530. * @param texture defines the cube texture to convert in env file
  47531. * @return a promise containing the environment data if succesfull.
  47532. */
  47533. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47534. /**
  47535. * Creates a JSON representation of the spherical data.
  47536. * @param texture defines the texture containing the polynomials
  47537. * @return the JSON representation of the spherical info
  47538. */
  47539. private static _CreateEnvTextureIrradiance;
  47540. /**
  47541. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47542. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  47543. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47544. * @return the views described by info providing access to the underlying buffer
  47545. */
  47546. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47547. /**
  47548. * Uploads the texture info contained in the env file to the GPU.
  47549. * @param texture defines the internal texture to upload to
  47550. * @param arrayBuffer defines the buffer cotaining the data to load
  47551. * @param info defines the texture info retrieved through the GetEnvInfo method
  47552. * @returns a promise
  47553. */
  47554. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47555. private static _OnImageReadyAsync;
  47556. /**
  47557. * Uploads the levels of image data to the GPU.
  47558. * @param texture defines the internal texture to upload to
  47559. * @param imageData defines the array buffer views of image data [mipmap][face]
  47560. * @returns a promise
  47561. */
  47562. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47563. /**
  47564. * Uploads spherical polynomials information to the texture.
  47565. * @param texture defines the texture we are trying to upload the information to
  47566. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47567. */
  47568. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47569. /** @hidden */
  47570. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47571. }
  47572. }
  47573. declare module "babylonjs/Maths/math.vertexFormat" {
  47574. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47575. /**
  47576. * Contains position and normal vectors for a vertex
  47577. */
  47578. export class PositionNormalVertex {
  47579. /** the position of the vertex (defaut: 0,0,0) */
  47580. position: Vector3;
  47581. /** the normal of the vertex (defaut: 0,1,0) */
  47582. normal: Vector3;
  47583. /**
  47584. * Creates a PositionNormalVertex
  47585. * @param position the position of the vertex (defaut: 0,0,0)
  47586. * @param normal the normal of the vertex (defaut: 0,1,0)
  47587. */
  47588. constructor(
  47589. /** the position of the vertex (defaut: 0,0,0) */
  47590. position?: Vector3,
  47591. /** the normal of the vertex (defaut: 0,1,0) */
  47592. normal?: Vector3);
  47593. /**
  47594. * Clones the PositionNormalVertex
  47595. * @returns the cloned PositionNormalVertex
  47596. */
  47597. clone(): PositionNormalVertex;
  47598. }
  47599. /**
  47600. * Contains position, normal and uv vectors for a vertex
  47601. */
  47602. export class PositionNormalTextureVertex {
  47603. /** the position of the vertex (defaut: 0,0,0) */
  47604. position: Vector3;
  47605. /** the normal of the vertex (defaut: 0,1,0) */
  47606. normal: Vector3;
  47607. /** the uv of the vertex (default: 0,0) */
  47608. uv: Vector2;
  47609. /**
  47610. * Creates a PositionNormalTextureVertex
  47611. * @param position the position of the vertex (defaut: 0,0,0)
  47612. * @param normal the normal of the vertex (defaut: 0,1,0)
  47613. * @param uv the uv of the vertex (default: 0,0)
  47614. */
  47615. constructor(
  47616. /** the position of the vertex (defaut: 0,0,0) */
  47617. position?: Vector3,
  47618. /** the normal of the vertex (defaut: 0,1,0) */
  47619. normal?: Vector3,
  47620. /** the uv of the vertex (default: 0,0) */
  47621. uv?: Vector2);
  47622. /**
  47623. * Clones the PositionNormalTextureVertex
  47624. * @returns the cloned PositionNormalTextureVertex
  47625. */
  47626. clone(): PositionNormalTextureVertex;
  47627. }
  47628. }
  47629. declare module "babylonjs/Maths/math" {
  47630. export * from "babylonjs/Maths/math.axis";
  47631. export * from "babylonjs/Maths/math.color";
  47632. export * from "babylonjs/Maths/math.constants";
  47633. export * from "babylonjs/Maths/math.frustum";
  47634. export * from "babylonjs/Maths/math.path";
  47635. export * from "babylonjs/Maths/math.plane";
  47636. export * from "babylonjs/Maths/math.size";
  47637. export * from "babylonjs/Maths/math.vector";
  47638. export * from "babylonjs/Maths/math.vertexFormat";
  47639. export * from "babylonjs/Maths/math.viewport";
  47640. }
  47641. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  47642. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47643. /** @hidden */
  47644. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47645. private _genericAttributeLocation;
  47646. private _varyingLocationCount;
  47647. private _varyingLocationMap;
  47648. private _replacements;
  47649. private _textureCount;
  47650. private _uniforms;
  47651. lineProcessor(line: string): string;
  47652. attributeProcessor(attribute: string): string;
  47653. varyingProcessor(varying: string, isFragment: boolean): string;
  47654. uniformProcessor(uniform: string): string;
  47655. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47656. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47657. }
  47658. }
  47659. declare module "babylonjs/Engines/nativeEngine" {
  47660. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  47661. import { Engine } from "babylonjs/Engines/engine";
  47662. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47663. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47664. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47665. import { Effect } from "babylonjs/Materials/effect";
  47666. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47667. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  47668. import { IColor4Like } from "babylonjs/Maths/math.like";
  47669. import { Scene } from "babylonjs/scene";
  47670. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47671. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47672. /**
  47673. * Container for accessors for natively-stored mesh data buffers.
  47674. */
  47675. class NativeDataBuffer extends DataBuffer {
  47676. /**
  47677. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47678. */
  47679. nativeIndexBuffer?: any;
  47680. /**
  47681. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47682. */
  47683. nativeVertexBuffer?: any;
  47684. }
  47685. /** @hidden */
  47686. class NativeTexture extends InternalTexture {
  47687. getInternalTexture(): InternalTexture;
  47688. getViewCount(): number;
  47689. }
  47690. /** @hidden */
  47691. export class NativeEngine extends Engine {
  47692. private readonly _native;
  47693. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47694. private readonly INVALID_HANDLE;
  47695. getHardwareScalingLevel(): number;
  47696. constructor();
  47697. /**
  47698. * Can be used to override the current requestAnimationFrame requester.
  47699. * @hidden
  47700. */
  47701. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47702. /**
  47703. * Override default engine behavior.
  47704. * @param color
  47705. * @param backBuffer
  47706. * @param depth
  47707. * @param stencil
  47708. */
  47709. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47710. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47711. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47712. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47713. recordVertexArrayObject(vertexBuffers: {
  47714. [key: string]: VertexBuffer;
  47715. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47716. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47717. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47718. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47719. /**
  47720. * Draw a list of indexed primitives
  47721. * @param fillMode defines the primitive to use
  47722. * @param indexStart defines the starting index
  47723. * @param indexCount defines the number of index to draw
  47724. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47725. */
  47726. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47727. /**
  47728. * Draw a list of unindexed primitives
  47729. * @param fillMode defines the primitive to use
  47730. * @param verticesStart defines the index of first vertex to draw
  47731. * @param verticesCount defines the count of vertices to draw
  47732. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47733. */
  47734. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47735. createPipelineContext(): IPipelineContext;
  47736. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47737. /** @hidden */
  47738. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47739. /** @hidden */
  47740. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47741. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47742. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47743. protected _setProgram(program: WebGLProgram): void;
  47744. _releaseEffect(effect: Effect): void;
  47745. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47746. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47747. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47748. bindSamplers(effect: Effect): void;
  47749. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47750. getRenderWidth(useScreen?: boolean): number;
  47751. getRenderHeight(useScreen?: boolean): number;
  47752. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47753. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47754. /**
  47755. * Set the z offset to apply to current rendering
  47756. * @param value defines the offset to apply
  47757. */
  47758. setZOffset(value: number): void;
  47759. /**
  47760. * Gets the current value of the zOffset
  47761. * @returns the current zOffset state
  47762. */
  47763. getZOffset(): number;
  47764. /**
  47765. * Enable or disable depth buffering
  47766. * @param enable defines the state to set
  47767. */
  47768. setDepthBuffer(enable: boolean): void;
  47769. /**
  47770. * Gets a boolean indicating if depth writing is enabled
  47771. * @returns the current depth writing state
  47772. */
  47773. getDepthWrite(): boolean;
  47774. /**
  47775. * Enable or disable depth writing
  47776. * @param enable defines the state to set
  47777. */
  47778. setDepthWrite(enable: boolean): void;
  47779. /**
  47780. * Enable or disable color writing
  47781. * @param enable defines the state to set
  47782. */
  47783. setColorWrite(enable: boolean): void;
  47784. /**
  47785. * Gets a boolean indicating if color writing is enabled
  47786. * @returns the current color writing state
  47787. */
  47788. getColorWrite(): boolean;
  47789. /**
  47790. * Sets alpha constants used by some alpha blending modes
  47791. * @param r defines the red component
  47792. * @param g defines the green component
  47793. * @param b defines the blue component
  47794. * @param a defines the alpha component
  47795. */
  47796. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47797. /**
  47798. * Sets the current alpha mode
  47799. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47800. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47801. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47802. */
  47803. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47804. /**
  47805. * Gets the current alpha mode
  47806. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47807. * @returns the current alpha mode
  47808. */
  47809. getAlphaMode(): number;
  47810. setInt(uniform: WebGLUniformLocation, int: number): void;
  47811. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47812. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47813. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47814. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47815. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47816. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47817. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47818. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47819. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47820. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47821. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47822. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47823. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47824. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47825. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47826. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47827. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47828. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47829. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47830. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47831. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47832. wipeCaches(bruteForce?: boolean): void;
  47833. _createTexture(): WebGLTexture;
  47834. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47835. /**
  47836. * Usually called from BABYLON.Texture.ts.
  47837. * Passed information to create a WebGLTexture
  47838. * @param urlArg defines a value which contains one of the following:
  47839. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47840. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47841. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47842. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47843. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47844. * @param scene needed for loading to the correct scene
  47845. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47846. * @param onLoad optional callback to be called upon successful completion
  47847. * @param onError optional callback to be called upon failure
  47848. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47849. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47850. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47851. * @param forcedExtension defines the extension to use to pick the right loader
  47852. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47853. */
  47854. 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;
  47855. /**
  47856. * Creates a cube texture
  47857. * @param rootUrl defines the url where the files to load is located
  47858. * @param scene defines the current scene
  47859. * @param files defines the list of files to load (1 per face)
  47860. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47861. * @param onLoad defines an optional callback raised when the texture is loaded
  47862. * @param onError defines an optional callback raised if there is an issue to load the texture
  47863. * @param format defines the format of the data
  47864. * @param forcedExtension defines the extension to use to pick the right loader
  47865. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47866. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47867. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47868. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47869. * @returns the cube texture as an InternalTexture
  47870. */
  47871. 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;
  47872. private _getSamplingFilter;
  47873. private static _GetNativeTextureFormat;
  47874. createRenderTargetTexture(size: number | {
  47875. width: number;
  47876. height: number;
  47877. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47878. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47879. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47880. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47881. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47882. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47883. /**
  47884. * Updates a dynamic vertex buffer.
  47885. * @param vertexBuffer the vertex buffer to update
  47886. * @param data the data used to update the vertex buffer
  47887. * @param byteOffset the byte offset of the data (optional)
  47888. * @param byteLength the byte length of the data (optional)
  47889. */
  47890. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47891. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47892. private _updateAnisotropicLevel;
  47893. private _getAddressMode;
  47894. /** @hidden */
  47895. _bindTexture(channel: number, texture: InternalTexture): void;
  47896. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47897. releaseEffects(): void;
  47898. /** @hidden */
  47899. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47900. /** @hidden */
  47901. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47902. /** @hidden */
  47903. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47904. /** @hidden */
  47905. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47906. }
  47907. }
  47908. declare module "babylonjs/Engines/index" {
  47909. export * from "babylonjs/Engines/constants";
  47910. export * from "babylonjs/Engines/engineCapabilities";
  47911. export * from "babylonjs/Engines/instancingAttributeInfo";
  47912. export * from "babylonjs/Engines/thinEngine";
  47913. export * from "babylonjs/Engines/engine";
  47914. export * from "babylonjs/Engines/engineStore";
  47915. export * from "babylonjs/Engines/nullEngine";
  47916. export * from "babylonjs/Engines/Extensions/index";
  47917. export * from "babylonjs/Engines/IPipelineContext";
  47918. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  47919. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47920. export * from "babylonjs/Engines/nativeEngine";
  47921. }
  47922. declare module "babylonjs/Events/clipboardEvents" {
  47923. /**
  47924. * Gather the list of clipboard event types as constants.
  47925. */
  47926. export class ClipboardEventTypes {
  47927. /**
  47928. * The clipboard event is fired when a copy command is active (pressed).
  47929. */
  47930. static readonly COPY: number;
  47931. /**
  47932. * The clipboard event is fired when a cut command is active (pressed).
  47933. */
  47934. static readonly CUT: number;
  47935. /**
  47936. * The clipboard event is fired when a paste command is active (pressed).
  47937. */
  47938. static readonly PASTE: number;
  47939. }
  47940. /**
  47941. * This class is used to store clipboard related info for the onClipboardObservable event.
  47942. */
  47943. export class ClipboardInfo {
  47944. /**
  47945. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47946. */
  47947. type: number;
  47948. /**
  47949. * Defines the related dom event
  47950. */
  47951. event: ClipboardEvent;
  47952. /**
  47953. *Creates an instance of ClipboardInfo.
  47954. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47955. * @param event Defines the related dom event
  47956. */
  47957. constructor(
  47958. /**
  47959. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47960. */
  47961. type: number,
  47962. /**
  47963. * Defines the related dom event
  47964. */
  47965. event: ClipboardEvent);
  47966. /**
  47967. * Get the clipboard event's type from the keycode.
  47968. * @param keyCode Defines the keyCode for the current keyboard event.
  47969. * @return {number}
  47970. */
  47971. static GetTypeFromCharacter(keyCode: number): number;
  47972. }
  47973. }
  47974. declare module "babylonjs/Events/index" {
  47975. export * from "babylonjs/Events/keyboardEvents";
  47976. export * from "babylonjs/Events/pointerEvents";
  47977. export * from "babylonjs/Events/clipboardEvents";
  47978. }
  47979. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  47980. import { Scene } from "babylonjs/scene";
  47981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47982. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47983. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47984. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47985. /**
  47986. * Google Daydream controller
  47987. */
  47988. export class DaydreamController extends WebVRController {
  47989. /**
  47990. * Base Url for the controller model.
  47991. */
  47992. static MODEL_BASE_URL: string;
  47993. /**
  47994. * File name for the controller model.
  47995. */
  47996. static MODEL_FILENAME: string;
  47997. /**
  47998. * Gamepad Id prefix used to identify Daydream Controller.
  47999. */
  48000. static readonly GAMEPAD_ID_PREFIX: string;
  48001. /**
  48002. * Creates a new DaydreamController from a gamepad
  48003. * @param vrGamepad the gamepad that the controller should be created from
  48004. */
  48005. constructor(vrGamepad: any);
  48006. /**
  48007. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48008. * @param scene scene in which to add meshes
  48009. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48010. */
  48011. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48012. /**
  48013. * Called once for each button that changed state since the last frame
  48014. * @param buttonIdx Which button index changed
  48015. * @param state New state of the button
  48016. * @param changes Which properties on the state changed since last frame
  48017. */
  48018. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48019. }
  48020. }
  48021. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  48022. import { Scene } from "babylonjs/scene";
  48023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48024. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  48025. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  48026. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  48027. /**
  48028. * Gear VR Controller
  48029. */
  48030. export class GearVRController extends WebVRController {
  48031. /**
  48032. * Base Url for the controller model.
  48033. */
  48034. static MODEL_BASE_URL: string;
  48035. /**
  48036. * File name for the controller model.
  48037. */
  48038. static MODEL_FILENAME: string;
  48039. /**
  48040. * Gamepad Id prefix used to identify this controller.
  48041. */
  48042. static readonly GAMEPAD_ID_PREFIX: string;
  48043. private readonly _buttonIndexToObservableNameMap;
  48044. /**
  48045. * Creates a new GearVRController from a gamepad
  48046. * @param vrGamepad the gamepad that the controller should be created from
  48047. */
  48048. constructor(vrGamepad: any);
  48049. /**
  48050. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48051. * @param scene scene in which to add meshes
  48052. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48053. */
  48054. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48055. /**
  48056. * Called once for each button that changed state since the last frame
  48057. * @param buttonIdx Which button index changed
  48058. * @param state New state of the button
  48059. * @param changes Which properties on the state changed since last frame
  48060. */
  48061. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48062. }
  48063. }
  48064. declare module "babylonjs/Gamepads/Controllers/index" {
  48065. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  48066. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  48067. export * from "babylonjs/Gamepads/Controllers/genericController";
  48068. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  48069. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  48070. export * from "babylonjs/Gamepads/Controllers/viveController";
  48071. export * from "babylonjs/Gamepads/Controllers/webVRController";
  48072. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  48073. }
  48074. declare module "babylonjs/Gamepads/index" {
  48075. export * from "babylonjs/Gamepads/Controllers/index";
  48076. export * from "babylonjs/Gamepads/gamepad";
  48077. export * from "babylonjs/Gamepads/gamepadManager";
  48078. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  48079. export * from "babylonjs/Gamepads/xboxGamepad";
  48080. export * from "babylonjs/Gamepads/dualShockGamepad";
  48081. }
  48082. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  48083. import { Scene } from "babylonjs/scene";
  48084. import { Vector4 } from "babylonjs/Maths/math.vector";
  48085. import { Color4 } from "babylonjs/Maths/math.color";
  48086. import { Mesh } from "babylonjs/Meshes/mesh";
  48087. import { Nullable } from "babylonjs/types";
  48088. /**
  48089. * Class containing static functions to help procedurally build meshes
  48090. */
  48091. export class PolyhedronBuilder {
  48092. /**
  48093. * Creates a polyhedron mesh
  48094. * * 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
  48095. * * The parameter `size` (positive float, default 1) sets the polygon size
  48096. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48097. * * 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`
  48098. * * 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
  48099. * * 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)`)
  48100. * * 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
  48101. * * 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
  48102. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48103. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48105. * @param name defines the name of the mesh
  48106. * @param options defines the options used to create the mesh
  48107. * @param scene defines the hosting scene
  48108. * @returns the polyhedron mesh
  48109. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48110. */
  48111. static CreatePolyhedron(name: string, options: {
  48112. type?: number;
  48113. size?: number;
  48114. sizeX?: number;
  48115. sizeY?: number;
  48116. sizeZ?: number;
  48117. custom?: any;
  48118. faceUV?: Vector4[];
  48119. faceColors?: Color4[];
  48120. flat?: boolean;
  48121. updatable?: boolean;
  48122. sideOrientation?: number;
  48123. frontUVs?: Vector4;
  48124. backUVs?: Vector4;
  48125. }, scene?: Nullable<Scene>): Mesh;
  48126. }
  48127. }
  48128. declare module "babylonjs/Gizmos/scaleGizmo" {
  48129. import { Observable } from "babylonjs/Misc/observable";
  48130. import { Nullable } from "babylonjs/types";
  48131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48132. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48133. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  48134. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48135. /**
  48136. * Gizmo that enables scaling a mesh along 3 axis
  48137. */
  48138. export class ScaleGizmo extends Gizmo {
  48139. /**
  48140. * Internal gizmo used for interactions on the x axis
  48141. */
  48142. xGizmo: AxisScaleGizmo;
  48143. /**
  48144. * Internal gizmo used for interactions on the y axis
  48145. */
  48146. yGizmo: AxisScaleGizmo;
  48147. /**
  48148. * Internal gizmo used for interactions on the z axis
  48149. */
  48150. zGizmo: AxisScaleGizmo;
  48151. /**
  48152. * Internal gizmo used to scale all axis equally
  48153. */
  48154. uniformScaleGizmo: AxisScaleGizmo;
  48155. private _meshAttached;
  48156. private _updateGizmoRotationToMatchAttachedMesh;
  48157. private _snapDistance;
  48158. private _scaleRatio;
  48159. private _uniformScalingMesh;
  48160. private _octahedron;
  48161. private _sensitivity;
  48162. /** Fires an event when any of it's sub gizmos are dragged */
  48163. onDragStartObservable: Observable<unknown>;
  48164. /** Fires an event when any of it's sub gizmos are released from dragging */
  48165. onDragEndObservable: Observable<unknown>;
  48166. attachedMesh: Nullable<AbstractMesh>;
  48167. /**
  48168. * Creates a ScaleGizmo
  48169. * @param gizmoLayer The utility layer the gizmo will be added to
  48170. */
  48171. constructor(gizmoLayer?: UtilityLayerRenderer);
  48172. updateGizmoRotationToMatchAttachedMesh: boolean;
  48173. /**
  48174. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48175. */
  48176. snapDistance: number;
  48177. /**
  48178. * Ratio for the scale of the gizmo (Default: 1)
  48179. */
  48180. scaleRatio: number;
  48181. /**
  48182. * Sensitivity factor for dragging (Default: 1)
  48183. */
  48184. sensitivity: number;
  48185. /**
  48186. * Disposes of the gizmo
  48187. */
  48188. dispose(): void;
  48189. }
  48190. }
  48191. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  48192. import { Observable } from "babylonjs/Misc/observable";
  48193. import { Nullable } from "babylonjs/types";
  48194. import { Vector3 } from "babylonjs/Maths/math.vector";
  48195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48196. import { Mesh } from "babylonjs/Meshes/mesh";
  48197. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48198. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48199. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48200. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  48201. import { Color3 } from "babylonjs/Maths/math.color";
  48202. /**
  48203. * Single axis scale gizmo
  48204. */
  48205. export class AxisScaleGizmo extends Gizmo {
  48206. /**
  48207. * Drag behavior responsible for the gizmos dragging interactions
  48208. */
  48209. dragBehavior: PointerDragBehavior;
  48210. private _pointerObserver;
  48211. /**
  48212. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48213. */
  48214. snapDistance: number;
  48215. /**
  48216. * Event that fires each time the gizmo snaps to a new location.
  48217. * * snapDistance is the the change in distance
  48218. */
  48219. onSnapObservable: Observable<{
  48220. snapDistance: number;
  48221. }>;
  48222. /**
  48223. * If the scaling operation should be done on all axis (default: false)
  48224. */
  48225. uniformScaling: boolean;
  48226. /**
  48227. * Custom sensitivity value for the drag strength
  48228. */
  48229. sensitivity: number;
  48230. private _isEnabled;
  48231. private _parent;
  48232. private _arrow;
  48233. private _coloredMaterial;
  48234. private _hoverMaterial;
  48235. /**
  48236. * Creates an AxisScaleGizmo
  48237. * @param gizmoLayer The utility layer the gizmo will be added to
  48238. * @param dragAxis The axis which the gizmo will be able to scale on
  48239. * @param color The color of the gizmo
  48240. */
  48241. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48242. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48243. /**
  48244. * If the gizmo is enabled
  48245. */
  48246. isEnabled: boolean;
  48247. /**
  48248. * Disposes of the gizmo
  48249. */
  48250. dispose(): void;
  48251. /**
  48252. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48253. * @param mesh The mesh to replace the default mesh of the gizmo
  48254. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48255. */
  48256. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48257. }
  48258. }
  48259. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  48260. import { Observable } from "babylonjs/Misc/observable";
  48261. import { Nullable } from "babylonjs/types";
  48262. import { Vector3 } from "babylonjs/Maths/math.vector";
  48263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48264. import { Mesh } from "babylonjs/Meshes/mesh";
  48265. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48266. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48267. import { Color3 } from "babylonjs/Maths/math.color";
  48268. import "babylonjs/Meshes/Builders/boxBuilder";
  48269. /**
  48270. * Bounding box gizmo
  48271. */
  48272. export class BoundingBoxGizmo extends Gizmo {
  48273. private _lineBoundingBox;
  48274. private _rotateSpheresParent;
  48275. private _scaleBoxesParent;
  48276. private _boundingDimensions;
  48277. private _renderObserver;
  48278. private _pointerObserver;
  48279. private _scaleDragSpeed;
  48280. private _tmpQuaternion;
  48281. private _tmpVector;
  48282. private _tmpRotationMatrix;
  48283. /**
  48284. * 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)
  48285. */
  48286. ignoreChildren: boolean;
  48287. /**
  48288. * 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)
  48289. */
  48290. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48291. /**
  48292. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48293. */
  48294. rotationSphereSize: number;
  48295. /**
  48296. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48297. */
  48298. scaleBoxSize: number;
  48299. /**
  48300. * 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)
  48301. */
  48302. fixedDragMeshScreenSize: boolean;
  48303. /**
  48304. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48305. */
  48306. fixedDragMeshScreenSizeDistanceFactor: number;
  48307. /**
  48308. * Fired when a rotation sphere or scale box is dragged
  48309. */
  48310. onDragStartObservable: Observable<{}>;
  48311. /**
  48312. * Fired when a scale box is dragged
  48313. */
  48314. onScaleBoxDragObservable: Observable<{}>;
  48315. /**
  48316. * Fired when a scale box drag is ended
  48317. */
  48318. onScaleBoxDragEndObservable: Observable<{}>;
  48319. /**
  48320. * Fired when a rotation sphere is dragged
  48321. */
  48322. onRotationSphereDragObservable: Observable<{}>;
  48323. /**
  48324. * Fired when a rotation sphere drag is ended
  48325. */
  48326. onRotationSphereDragEndObservable: Observable<{}>;
  48327. /**
  48328. * 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)
  48329. */
  48330. scalePivot: Nullable<Vector3>;
  48331. /**
  48332. * Mesh used as a pivot to rotate the attached mesh
  48333. */
  48334. private _anchorMesh;
  48335. private _existingMeshScale;
  48336. private _dragMesh;
  48337. private pointerDragBehavior;
  48338. private coloredMaterial;
  48339. private hoverColoredMaterial;
  48340. /**
  48341. * Sets the color of the bounding box gizmo
  48342. * @param color the color to set
  48343. */
  48344. setColor(color: Color3): void;
  48345. /**
  48346. * Creates an BoundingBoxGizmo
  48347. * @param gizmoLayer The utility layer the gizmo will be added to
  48348. * @param color The color of the gizmo
  48349. */
  48350. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48351. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48352. private _selectNode;
  48353. /**
  48354. * Updates the bounding box information for the Gizmo
  48355. */
  48356. updateBoundingBox(): void;
  48357. private _updateRotationSpheres;
  48358. private _updateScaleBoxes;
  48359. /**
  48360. * Enables rotation on the specified axis and disables rotation on the others
  48361. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48362. */
  48363. setEnabledRotationAxis(axis: string): void;
  48364. /**
  48365. * Enables/disables scaling
  48366. * @param enable if scaling should be enabled
  48367. */
  48368. setEnabledScaling(enable: boolean): void;
  48369. private _updateDummy;
  48370. /**
  48371. * Enables a pointer drag behavior on the bounding box of the gizmo
  48372. */
  48373. enableDragBehavior(): void;
  48374. /**
  48375. * Disposes of the gizmo
  48376. */
  48377. dispose(): void;
  48378. /**
  48379. * 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)
  48380. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48381. * @returns the bounding box mesh with the passed in mesh as a child
  48382. */
  48383. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48384. /**
  48385. * CustomMeshes are not supported by this gizmo
  48386. * @param mesh The mesh to replace the default mesh of the gizmo
  48387. */
  48388. setCustomMesh(mesh: Mesh): void;
  48389. }
  48390. }
  48391. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  48392. import { Observable } from "babylonjs/Misc/observable";
  48393. import { Nullable } from "babylonjs/types";
  48394. import { Vector3 } from "babylonjs/Maths/math.vector";
  48395. import { Color3 } from "babylonjs/Maths/math.color";
  48396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48397. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48398. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48399. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48400. import "babylonjs/Meshes/Builders/linesBuilder";
  48401. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  48402. /**
  48403. * Single plane rotation gizmo
  48404. */
  48405. export class PlaneRotationGizmo extends Gizmo {
  48406. /**
  48407. * Drag behavior responsible for the gizmos dragging interactions
  48408. */
  48409. dragBehavior: PointerDragBehavior;
  48410. private _pointerObserver;
  48411. /**
  48412. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48413. */
  48414. snapDistance: number;
  48415. /**
  48416. * Event that fires each time the gizmo snaps to a new location.
  48417. * * snapDistance is the the change in distance
  48418. */
  48419. onSnapObservable: Observable<{
  48420. snapDistance: number;
  48421. }>;
  48422. private _isEnabled;
  48423. private _parent;
  48424. /**
  48425. * Creates a PlaneRotationGizmo
  48426. * @param gizmoLayer The utility layer the gizmo will be added to
  48427. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48428. * @param color The color of the gizmo
  48429. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48430. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48431. */
  48432. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48433. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48434. /**
  48435. * If the gizmo is enabled
  48436. */
  48437. isEnabled: boolean;
  48438. /**
  48439. * Disposes of the gizmo
  48440. */
  48441. dispose(): void;
  48442. }
  48443. }
  48444. declare module "babylonjs/Gizmos/rotationGizmo" {
  48445. import { Observable } from "babylonjs/Misc/observable";
  48446. import { Nullable } from "babylonjs/types";
  48447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48448. import { Mesh } from "babylonjs/Meshes/mesh";
  48449. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48450. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  48451. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48452. /**
  48453. * Gizmo that enables rotating a mesh along 3 axis
  48454. */
  48455. export class RotationGizmo extends Gizmo {
  48456. /**
  48457. * Internal gizmo used for interactions on the x axis
  48458. */
  48459. xGizmo: PlaneRotationGizmo;
  48460. /**
  48461. * Internal gizmo used for interactions on the y axis
  48462. */
  48463. yGizmo: PlaneRotationGizmo;
  48464. /**
  48465. * Internal gizmo used for interactions on the z axis
  48466. */
  48467. zGizmo: PlaneRotationGizmo;
  48468. /** Fires an event when any of it's sub gizmos are dragged */
  48469. onDragStartObservable: Observable<unknown>;
  48470. /** Fires an event when any of it's sub gizmos are released from dragging */
  48471. onDragEndObservable: Observable<unknown>;
  48472. private _meshAttached;
  48473. attachedMesh: Nullable<AbstractMesh>;
  48474. /**
  48475. * Creates a RotationGizmo
  48476. * @param gizmoLayer The utility layer the gizmo will be added to
  48477. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48478. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48479. */
  48480. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48481. updateGizmoRotationToMatchAttachedMesh: boolean;
  48482. /**
  48483. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48484. */
  48485. snapDistance: number;
  48486. /**
  48487. * Ratio for the scale of the gizmo (Default: 1)
  48488. */
  48489. scaleRatio: number;
  48490. /**
  48491. * Disposes of the gizmo
  48492. */
  48493. dispose(): void;
  48494. /**
  48495. * CustomMeshes are not supported by this gizmo
  48496. * @param mesh The mesh to replace the default mesh of the gizmo
  48497. */
  48498. setCustomMesh(mesh: Mesh): void;
  48499. }
  48500. }
  48501. declare module "babylonjs/Gizmos/gizmoManager" {
  48502. import { Observable } from "babylonjs/Misc/observable";
  48503. import { Nullable } from "babylonjs/types";
  48504. import { Scene, IDisposable } from "babylonjs/scene";
  48505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48506. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48507. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  48508. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  48509. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48510. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  48511. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  48512. /**
  48513. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48514. */
  48515. export class GizmoManager implements IDisposable {
  48516. private scene;
  48517. /**
  48518. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48519. */
  48520. gizmos: {
  48521. positionGizmo: Nullable<PositionGizmo>;
  48522. rotationGizmo: Nullable<RotationGizmo>;
  48523. scaleGizmo: Nullable<ScaleGizmo>;
  48524. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48525. };
  48526. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48527. clearGizmoOnEmptyPointerEvent: boolean;
  48528. /** Fires an event when the manager is attached to a mesh */
  48529. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48530. private _gizmosEnabled;
  48531. private _pointerObserver;
  48532. private _attachedMesh;
  48533. private _boundingBoxColor;
  48534. private _defaultUtilityLayer;
  48535. private _defaultKeepDepthUtilityLayer;
  48536. /**
  48537. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48538. */
  48539. boundingBoxDragBehavior: SixDofDragBehavior;
  48540. /**
  48541. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48542. */
  48543. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48544. /**
  48545. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48546. */
  48547. usePointerToAttachGizmos: boolean;
  48548. /**
  48549. * Utility layer that the bounding box gizmo belongs to
  48550. */
  48551. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  48552. /**
  48553. * Utility layer that all gizmos besides bounding box belong to
  48554. */
  48555. readonly utilityLayer: UtilityLayerRenderer;
  48556. /**
  48557. * Instatiates a gizmo manager
  48558. * @param scene the scene to overlay the gizmos on top of
  48559. */
  48560. constructor(scene: Scene);
  48561. /**
  48562. * Attaches a set of gizmos to the specified mesh
  48563. * @param mesh The mesh the gizmo's should be attached to
  48564. */
  48565. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48566. /**
  48567. * If the position gizmo is enabled
  48568. */
  48569. positionGizmoEnabled: boolean;
  48570. /**
  48571. * If the rotation gizmo is enabled
  48572. */
  48573. rotationGizmoEnabled: boolean;
  48574. /**
  48575. * If the scale gizmo is enabled
  48576. */
  48577. scaleGizmoEnabled: boolean;
  48578. /**
  48579. * If the boundingBox gizmo is enabled
  48580. */
  48581. boundingBoxGizmoEnabled: boolean;
  48582. /**
  48583. * Disposes of the gizmo manager
  48584. */
  48585. dispose(): void;
  48586. }
  48587. }
  48588. declare module "babylonjs/Lights/directionalLight" {
  48589. import { Camera } from "babylonjs/Cameras/camera";
  48590. import { Scene } from "babylonjs/scene";
  48591. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48592. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48593. import { Light } from "babylonjs/Lights/light";
  48594. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48595. import { Effect } from "babylonjs/Materials/effect";
  48596. /**
  48597. * A directional light is defined by a direction (what a surprise!).
  48598. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48599. * 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.
  48600. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48601. */
  48602. export class DirectionalLight extends ShadowLight {
  48603. private _shadowFrustumSize;
  48604. /**
  48605. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48606. */
  48607. /**
  48608. * Specifies a fix frustum size for the shadow generation.
  48609. */
  48610. shadowFrustumSize: number;
  48611. private _shadowOrthoScale;
  48612. /**
  48613. * Gets the shadow projection scale against the optimal computed one.
  48614. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48615. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48616. */
  48617. /**
  48618. * Sets the shadow projection scale against the optimal computed one.
  48619. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48620. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48621. */
  48622. shadowOrthoScale: number;
  48623. /**
  48624. * Automatically compute the projection matrix to best fit (including all the casters)
  48625. * on each frame.
  48626. */
  48627. autoUpdateExtends: boolean;
  48628. private _orthoLeft;
  48629. private _orthoRight;
  48630. private _orthoTop;
  48631. private _orthoBottom;
  48632. /**
  48633. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48634. * The directional light is emitted from everywhere in the given direction.
  48635. * It can cast shadows.
  48636. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48637. * @param name The friendly name of the light
  48638. * @param direction The direction of the light
  48639. * @param scene The scene the light belongs to
  48640. */
  48641. constructor(name: string, direction: Vector3, scene: Scene);
  48642. /**
  48643. * Returns the string "DirectionalLight".
  48644. * @return The class name
  48645. */
  48646. getClassName(): string;
  48647. /**
  48648. * Returns the integer 1.
  48649. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48650. */
  48651. getTypeID(): number;
  48652. /**
  48653. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48654. * Returns the DirectionalLight Shadow projection matrix.
  48655. */
  48656. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48657. /**
  48658. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48659. * Returns the DirectionalLight Shadow projection matrix.
  48660. */
  48661. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48662. /**
  48663. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48664. * Returns the DirectionalLight Shadow projection matrix.
  48665. */
  48666. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48667. protected _buildUniformLayout(): void;
  48668. /**
  48669. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48670. * @param effect The effect to update
  48671. * @param lightIndex The index of the light in the effect to update
  48672. * @returns The directional light
  48673. */
  48674. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48675. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48676. /**
  48677. * Gets the minZ used for shadow according to both the scene and the light.
  48678. *
  48679. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48680. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48681. * @param activeCamera The camera we are returning the min for
  48682. * @returns the depth min z
  48683. */
  48684. getDepthMinZ(activeCamera: Camera): number;
  48685. /**
  48686. * Gets the maxZ used for shadow according to both the scene and the light.
  48687. *
  48688. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48689. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48690. * @param activeCamera The camera we are returning the max for
  48691. * @returns the depth max z
  48692. */
  48693. getDepthMaxZ(activeCamera: Camera): number;
  48694. /**
  48695. * Prepares the list of defines specific to the light type.
  48696. * @param defines the list of defines
  48697. * @param lightIndex defines the index of the light for the effect
  48698. */
  48699. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48700. }
  48701. }
  48702. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  48703. import { Mesh } from "babylonjs/Meshes/mesh";
  48704. /**
  48705. * Class containing static functions to help procedurally build meshes
  48706. */
  48707. export class HemisphereBuilder {
  48708. /**
  48709. * Creates a hemisphere mesh
  48710. * @param name defines the name of the mesh
  48711. * @param options defines the options used to create the mesh
  48712. * @param scene defines the hosting scene
  48713. * @returns the hemisphere mesh
  48714. */
  48715. static CreateHemisphere(name: string, options: {
  48716. segments?: number;
  48717. diameter?: number;
  48718. sideOrientation?: number;
  48719. }, scene: any): Mesh;
  48720. }
  48721. }
  48722. declare module "babylonjs/Lights/spotLight" {
  48723. import { Nullable } from "babylonjs/types";
  48724. import { Scene } from "babylonjs/scene";
  48725. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48727. import { Effect } from "babylonjs/Materials/effect";
  48728. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48729. import { Light } from "babylonjs/Lights/light";
  48730. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48731. /**
  48732. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48733. * These values define a cone of light starting from the position, emitting toward the direction.
  48734. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48735. * and the exponent defines the speed of the decay of the light with distance (reach).
  48736. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48737. */
  48738. export class SpotLight extends ShadowLight {
  48739. private _angle;
  48740. private _innerAngle;
  48741. private _cosHalfAngle;
  48742. private _lightAngleScale;
  48743. private _lightAngleOffset;
  48744. /**
  48745. * Gets the cone angle of the spot light in Radians.
  48746. */
  48747. /**
  48748. * Sets the cone angle of the spot light in Radians.
  48749. */
  48750. angle: number;
  48751. /**
  48752. * Only used in gltf falloff mode, this defines the angle where
  48753. * the directional falloff will start before cutting at angle which could be seen
  48754. * as outer angle.
  48755. */
  48756. /**
  48757. * Only used in gltf falloff mode, this defines the angle where
  48758. * the directional falloff will start before cutting at angle which could be seen
  48759. * as outer angle.
  48760. */
  48761. innerAngle: number;
  48762. private _shadowAngleScale;
  48763. /**
  48764. * Allows scaling the angle of the light for shadow generation only.
  48765. */
  48766. /**
  48767. * Allows scaling the angle of the light for shadow generation only.
  48768. */
  48769. shadowAngleScale: number;
  48770. /**
  48771. * The light decay speed with the distance from the emission spot.
  48772. */
  48773. exponent: number;
  48774. private _projectionTextureMatrix;
  48775. /**
  48776. * Allows reading the projecton texture
  48777. */
  48778. readonly projectionTextureMatrix: Matrix;
  48779. protected _projectionTextureLightNear: number;
  48780. /**
  48781. * Gets the near clip of the Spotlight for texture projection.
  48782. */
  48783. /**
  48784. * Sets the near clip of the Spotlight for texture projection.
  48785. */
  48786. projectionTextureLightNear: number;
  48787. protected _projectionTextureLightFar: number;
  48788. /**
  48789. * Gets the far clip of the Spotlight for texture projection.
  48790. */
  48791. /**
  48792. * Sets the far clip of the Spotlight for texture projection.
  48793. */
  48794. projectionTextureLightFar: number;
  48795. protected _projectionTextureUpDirection: Vector3;
  48796. /**
  48797. * Gets the Up vector of the Spotlight for texture projection.
  48798. */
  48799. /**
  48800. * Sets the Up vector of the Spotlight for texture projection.
  48801. */
  48802. projectionTextureUpDirection: Vector3;
  48803. private _projectionTexture;
  48804. /**
  48805. * Gets the projection texture of the light.
  48806. */
  48807. /**
  48808. * Sets the projection texture of the light.
  48809. */
  48810. projectionTexture: Nullable<BaseTexture>;
  48811. private _projectionTextureViewLightDirty;
  48812. private _projectionTextureProjectionLightDirty;
  48813. private _projectionTextureDirty;
  48814. private _projectionTextureViewTargetVector;
  48815. private _projectionTextureViewLightMatrix;
  48816. private _projectionTextureProjectionLightMatrix;
  48817. private _projectionTextureScalingMatrix;
  48818. /**
  48819. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48820. * It can cast shadows.
  48821. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48822. * @param name The light friendly name
  48823. * @param position The position of the spot light in the scene
  48824. * @param direction The direction of the light in the scene
  48825. * @param angle The cone angle of the light in Radians
  48826. * @param exponent The light decay speed with the distance from the emission spot
  48827. * @param scene The scene the lights belongs to
  48828. */
  48829. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48830. /**
  48831. * Returns the string "SpotLight".
  48832. * @returns the class name
  48833. */
  48834. getClassName(): string;
  48835. /**
  48836. * Returns the integer 2.
  48837. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48838. */
  48839. getTypeID(): number;
  48840. /**
  48841. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48842. */
  48843. protected _setDirection(value: Vector3): void;
  48844. /**
  48845. * Overrides the position setter to recompute the projection texture view light Matrix.
  48846. */
  48847. protected _setPosition(value: Vector3): void;
  48848. /**
  48849. * 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.
  48850. * Returns the SpotLight.
  48851. */
  48852. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48853. protected _computeProjectionTextureViewLightMatrix(): void;
  48854. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48855. /**
  48856. * Main function for light texture projection matrix computing.
  48857. */
  48858. protected _computeProjectionTextureMatrix(): void;
  48859. protected _buildUniformLayout(): void;
  48860. private _computeAngleValues;
  48861. /**
  48862. * Sets the passed Effect "effect" with the Light textures.
  48863. * @param effect The effect to update
  48864. * @param lightIndex The index of the light in the effect to update
  48865. * @returns The light
  48866. */
  48867. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  48868. /**
  48869. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48870. * @param effect The effect to update
  48871. * @param lightIndex The index of the light in the effect to update
  48872. * @returns The spot light
  48873. */
  48874. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48875. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48876. /**
  48877. * Disposes the light and the associated resources.
  48878. */
  48879. dispose(): void;
  48880. /**
  48881. * Prepares the list of defines specific to the light type.
  48882. * @param defines the list of defines
  48883. * @param lightIndex defines the index of the light for the effect
  48884. */
  48885. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48886. }
  48887. }
  48888. declare module "babylonjs/Gizmos/lightGizmo" {
  48889. import { Nullable } from "babylonjs/types";
  48890. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48891. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48892. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48893. import { Light } from "babylonjs/Lights/light";
  48894. /**
  48895. * Gizmo that enables viewing a light
  48896. */
  48897. export class LightGizmo extends Gizmo {
  48898. private _lightMesh;
  48899. private _material;
  48900. private _cachedPosition;
  48901. private _cachedForward;
  48902. private _attachedMeshParent;
  48903. /**
  48904. * Creates a LightGizmo
  48905. * @param gizmoLayer The utility layer the gizmo will be added to
  48906. */
  48907. constructor(gizmoLayer?: UtilityLayerRenderer);
  48908. private _light;
  48909. /**
  48910. * The light that the gizmo is attached to
  48911. */
  48912. light: Nullable<Light>;
  48913. /**
  48914. * Gets the material used to render the light gizmo
  48915. */
  48916. readonly material: StandardMaterial;
  48917. /**
  48918. * @hidden
  48919. * Updates the gizmo to match the attached mesh's position/rotation
  48920. */
  48921. protected _update(): void;
  48922. private static _Scale;
  48923. /**
  48924. * Creates the lines for a light mesh
  48925. */
  48926. private static _CreateLightLines;
  48927. /**
  48928. * Disposes of the light gizmo
  48929. */
  48930. dispose(): void;
  48931. private static _CreateHemisphericLightMesh;
  48932. private static _CreatePointLightMesh;
  48933. private static _CreateSpotLightMesh;
  48934. private static _CreateDirectionalLightMesh;
  48935. }
  48936. }
  48937. declare module "babylonjs/Gizmos/index" {
  48938. export * from "babylonjs/Gizmos/axisDragGizmo";
  48939. export * from "babylonjs/Gizmos/axisScaleGizmo";
  48940. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  48941. export * from "babylonjs/Gizmos/gizmo";
  48942. export * from "babylonjs/Gizmos/gizmoManager";
  48943. export * from "babylonjs/Gizmos/planeRotationGizmo";
  48944. export * from "babylonjs/Gizmos/positionGizmo";
  48945. export * from "babylonjs/Gizmos/rotationGizmo";
  48946. export * from "babylonjs/Gizmos/scaleGizmo";
  48947. export * from "babylonjs/Gizmos/lightGizmo";
  48948. export * from "babylonjs/Gizmos/planeDragGizmo";
  48949. }
  48950. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  48951. /** @hidden */
  48952. export var backgroundFragmentDeclaration: {
  48953. name: string;
  48954. shader: string;
  48955. };
  48956. }
  48957. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  48958. /** @hidden */
  48959. export var backgroundUboDeclaration: {
  48960. name: string;
  48961. shader: string;
  48962. };
  48963. }
  48964. declare module "babylonjs/Shaders/background.fragment" {
  48965. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  48966. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48967. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48968. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48969. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48970. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48971. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48972. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  48973. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48974. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48975. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48976. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48977. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48978. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48979. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48980. /** @hidden */
  48981. export var backgroundPixelShader: {
  48982. name: string;
  48983. shader: string;
  48984. };
  48985. }
  48986. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  48987. /** @hidden */
  48988. export var backgroundVertexDeclaration: {
  48989. name: string;
  48990. shader: string;
  48991. };
  48992. }
  48993. declare module "babylonjs/Shaders/background.vertex" {
  48994. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  48995. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48996. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48997. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48998. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48999. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49000. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49001. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49002. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49003. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49004. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49005. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49006. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49007. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49008. /** @hidden */
  49009. export var backgroundVertexShader: {
  49010. name: string;
  49011. shader: string;
  49012. };
  49013. }
  49014. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  49015. import { Nullable, int, float } from "babylonjs/types";
  49016. import { Scene } from "babylonjs/scene";
  49017. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  49018. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49020. import { Mesh } from "babylonjs/Meshes/mesh";
  49021. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49022. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  49023. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  49024. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49025. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  49026. import { Color3 } from "babylonjs/Maths/math.color";
  49027. import "babylonjs/Shaders/background.fragment";
  49028. import "babylonjs/Shaders/background.vertex";
  49029. /**
  49030. * Background material used to create an efficient environement around your scene.
  49031. */
  49032. export class BackgroundMaterial extends PushMaterial {
  49033. /**
  49034. * Standard reflectance value at parallel view angle.
  49035. */
  49036. static StandardReflectance0: number;
  49037. /**
  49038. * Standard reflectance value at grazing angle.
  49039. */
  49040. static StandardReflectance90: number;
  49041. protected _primaryColor: Color3;
  49042. /**
  49043. * Key light Color (multiply against the environement texture)
  49044. */
  49045. primaryColor: Color3;
  49046. protected __perceptualColor: Nullable<Color3>;
  49047. /**
  49048. * Experimental Internal Use Only.
  49049. *
  49050. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49051. * This acts as a helper to set the primary color to a more "human friendly" value.
  49052. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49053. * output color as close as possible from the chosen value.
  49054. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49055. * part of lighting setup.)
  49056. */
  49057. _perceptualColor: Nullable<Color3>;
  49058. protected _primaryColorShadowLevel: float;
  49059. /**
  49060. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49061. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49062. */
  49063. primaryColorShadowLevel: float;
  49064. protected _primaryColorHighlightLevel: float;
  49065. /**
  49066. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49067. * The primary color is used at the level chosen to define what the white area would look.
  49068. */
  49069. primaryColorHighlightLevel: float;
  49070. protected _reflectionTexture: Nullable<BaseTexture>;
  49071. /**
  49072. * Reflection Texture used in the material.
  49073. * Should be author in a specific way for the best result (refer to the documentation).
  49074. */
  49075. reflectionTexture: Nullable<BaseTexture>;
  49076. protected _reflectionBlur: float;
  49077. /**
  49078. * Reflection Texture level of blur.
  49079. *
  49080. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49081. * texture twice.
  49082. */
  49083. reflectionBlur: float;
  49084. protected _diffuseTexture: Nullable<BaseTexture>;
  49085. /**
  49086. * Diffuse Texture used in the material.
  49087. * Should be author in a specific way for the best result (refer to the documentation).
  49088. */
  49089. diffuseTexture: Nullable<BaseTexture>;
  49090. protected _shadowLights: Nullable<IShadowLight[]>;
  49091. /**
  49092. * Specify the list of lights casting shadow on the material.
  49093. * All scene shadow lights will be included if null.
  49094. */
  49095. shadowLights: Nullable<IShadowLight[]>;
  49096. protected _shadowLevel: float;
  49097. /**
  49098. * Helps adjusting the shadow to a softer level if required.
  49099. * 0 means black shadows and 1 means no shadows.
  49100. */
  49101. shadowLevel: float;
  49102. protected _sceneCenter: Vector3;
  49103. /**
  49104. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49105. * It is usually zero but might be interesting to modify according to your setup.
  49106. */
  49107. sceneCenter: Vector3;
  49108. protected _opacityFresnel: boolean;
  49109. /**
  49110. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49111. * This helps ensuring a nice transition when the camera goes under the ground.
  49112. */
  49113. opacityFresnel: boolean;
  49114. protected _reflectionFresnel: boolean;
  49115. /**
  49116. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49117. * This helps adding a mirror texture on the ground.
  49118. */
  49119. reflectionFresnel: boolean;
  49120. protected _reflectionFalloffDistance: number;
  49121. /**
  49122. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49123. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49124. */
  49125. reflectionFalloffDistance: number;
  49126. protected _reflectionAmount: number;
  49127. /**
  49128. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49129. */
  49130. reflectionAmount: number;
  49131. protected _reflectionReflectance0: number;
  49132. /**
  49133. * This specifies the weight of the reflection at grazing angle.
  49134. */
  49135. reflectionReflectance0: number;
  49136. protected _reflectionReflectance90: number;
  49137. /**
  49138. * This specifies the weight of the reflection at a perpendicular point of view.
  49139. */
  49140. reflectionReflectance90: number;
  49141. /**
  49142. * Sets the reflection reflectance fresnel values according to the default standard
  49143. * empirically know to work well :-)
  49144. */
  49145. reflectionStandardFresnelWeight: number;
  49146. protected _useRGBColor: boolean;
  49147. /**
  49148. * Helps to directly use the maps channels instead of their level.
  49149. */
  49150. useRGBColor: boolean;
  49151. protected _enableNoise: boolean;
  49152. /**
  49153. * This helps reducing the banding effect that could occur on the background.
  49154. */
  49155. enableNoise: boolean;
  49156. /**
  49157. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49158. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49159. * Recommended to be keep at 1.0 except for special cases.
  49160. */
  49161. fovMultiplier: number;
  49162. private _fovMultiplier;
  49163. /**
  49164. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49165. */
  49166. useEquirectangularFOV: boolean;
  49167. private _maxSimultaneousLights;
  49168. /**
  49169. * Number of Simultaneous lights allowed on the material.
  49170. */
  49171. maxSimultaneousLights: int;
  49172. /**
  49173. * Default configuration related to image processing available in the Background Material.
  49174. */
  49175. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49176. /**
  49177. * Keep track of the image processing observer to allow dispose and replace.
  49178. */
  49179. private _imageProcessingObserver;
  49180. /**
  49181. * Attaches a new image processing configuration to the PBR Material.
  49182. * @param configuration (if null the scene configuration will be use)
  49183. */
  49184. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49185. /**
  49186. * Gets the image processing configuration used either in this material.
  49187. */
  49188. /**
  49189. * Sets the Default image processing configuration used either in the this material.
  49190. *
  49191. * If sets to null, the scene one is in use.
  49192. */
  49193. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  49194. /**
  49195. * Gets wether the color curves effect is enabled.
  49196. */
  49197. /**
  49198. * Sets wether the color curves effect is enabled.
  49199. */
  49200. cameraColorCurvesEnabled: boolean;
  49201. /**
  49202. * Gets wether the color grading effect is enabled.
  49203. */
  49204. /**
  49205. * Gets wether the color grading effect is enabled.
  49206. */
  49207. cameraColorGradingEnabled: boolean;
  49208. /**
  49209. * Gets wether tonemapping is enabled or not.
  49210. */
  49211. /**
  49212. * Sets wether tonemapping is enabled or not
  49213. */
  49214. cameraToneMappingEnabled: boolean;
  49215. /**
  49216. * The camera exposure used on this material.
  49217. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49218. * This corresponds to a photographic exposure.
  49219. */
  49220. /**
  49221. * The camera exposure used on this material.
  49222. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49223. * This corresponds to a photographic exposure.
  49224. */
  49225. cameraExposure: float;
  49226. /**
  49227. * Gets The camera contrast used on this material.
  49228. */
  49229. /**
  49230. * Sets The camera contrast used on this material.
  49231. */
  49232. cameraContrast: float;
  49233. /**
  49234. * Gets the Color Grading 2D Lookup Texture.
  49235. */
  49236. /**
  49237. * Sets the Color Grading 2D Lookup Texture.
  49238. */
  49239. cameraColorGradingTexture: Nullable<BaseTexture>;
  49240. /**
  49241. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49242. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49243. * 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;
  49244. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49245. */
  49246. /**
  49247. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49248. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49249. * 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;
  49250. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49251. */
  49252. cameraColorCurves: Nullable<ColorCurves>;
  49253. /**
  49254. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49255. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49256. */
  49257. switchToBGR: boolean;
  49258. private _renderTargets;
  49259. private _reflectionControls;
  49260. private _white;
  49261. private _primaryShadowColor;
  49262. private _primaryHighlightColor;
  49263. /**
  49264. * Instantiates a Background Material in the given scene
  49265. * @param name The friendly name of the material
  49266. * @param scene The scene to add the material to
  49267. */
  49268. constructor(name: string, scene: Scene);
  49269. /**
  49270. * Gets a boolean indicating that current material needs to register RTT
  49271. */
  49272. readonly hasRenderTargetTextures: boolean;
  49273. /**
  49274. * The entire material has been created in order to prevent overdraw.
  49275. * @returns false
  49276. */
  49277. needAlphaTesting(): boolean;
  49278. /**
  49279. * The entire material has been created in order to prevent overdraw.
  49280. * @returns true if blending is enable
  49281. */
  49282. needAlphaBlending(): boolean;
  49283. /**
  49284. * Checks wether the material is ready to be rendered for a given mesh.
  49285. * @param mesh The mesh to render
  49286. * @param subMesh The submesh to check against
  49287. * @param useInstances Specify wether or not the material is used with instances
  49288. * @returns true if all the dependencies are ready (Textures, Effects...)
  49289. */
  49290. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49291. /**
  49292. * Compute the primary color according to the chosen perceptual color.
  49293. */
  49294. private _computePrimaryColorFromPerceptualColor;
  49295. /**
  49296. * Compute the highlights and shadow colors according to their chosen levels.
  49297. */
  49298. private _computePrimaryColors;
  49299. /**
  49300. * Build the uniform buffer used in the material.
  49301. */
  49302. buildUniformLayout(): void;
  49303. /**
  49304. * Unbind the material.
  49305. */
  49306. unbind(): void;
  49307. /**
  49308. * Bind only the world matrix to the material.
  49309. * @param world The world matrix to bind.
  49310. */
  49311. bindOnlyWorldMatrix(world: Matrix): void;
  49312. /**
  49313. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49314. * @param world The world matrix to bind.
  49315. * @param subMesh The submesh to bind for.
  49316. */
  49317. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49318. /**
  49319. * Checks to see if a texture is used in the material.
  49320. * @param texture - Base texture to use.
  49321. * @returns - Boolean specifying if a texture is used in the material.
  49322. */
  49323. hasTexture(texture: BaseTexture): boolean;
  49324. /**
  49325. * Dispose the material.
  49326. * @param forceDisposeEffect Force disposal of the associated effect.
  49327. * @param forceDisposeTextures Force disposal of the associated textures.
  49328. */
  49329. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49330. /**
  49331. * Clones the material.
  49332. * @param name The cloned name.
  49333. * @returns The cloned material.
  49334. */
  49335. clone(name: string): BackgroundMaterial;
  49336. /**
  49337. * Serializes the current material to its JSON representation.
  49338. * @returns The JSON representation.
  49339. */
  49340. serialize(): any;
  49341. /**
  49342. * Gets the class name of the material
  49343. * @returns "BackgroundMaterial"
  49344. */
  49345. getClassName(): string;
  49346. /**
  49347. * Parse a JSON input to create back a background material.
  49348. * @param source The JSON data to parse
  49349. * @param scene The scene to create the parsed material in
  49350. * @param rootUrl The root url of the assets the material depends upon
  49351. * @returns the instantiated BackgroundMaterial.
  49352. */
  49353. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49354. }
  49355. }
  49356. declare module "babylonjs/Helpers/environmentHelper" {
  49357. import { Observable } from "babylonjs/Misc/observable";
  49358. import { Nullable } from "babylonjs/types";
  49359. import { Scene } from "babylonjs/scene";
  49360. import { Vector3 } from "babylonjs/Maths/math.vector";
  49361. import { Color3 } from "babylonjs/Maths/math.color";
  49362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49363. import { Mesh } from "babylonjs/Meshes/mesh";
  49364. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49365. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  49366. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49367. import "babylonjs/Meshes/Builders/planeBuilder";
  49368. import "babylonjs/Meshes/Builders/boxBuilder";
  49369. /**
  49370. * Represents the different options available during the creation of
  49371. * a Environment helper.
  49372. *
  49373. * This can control the default ground, skybox and image processing setup of your scene.
  49374. */
  49375. export interface IEnvironmentHelperOptions {
  49376. /**
  49377. * Specifies wether or not to create a ground.
  49378. * True by default.
  49379. */
  49380. createGround: boolean;
  49381. /**
  49382. * Specifies the ground size.
  49383. * 15 by default.
  49384. */
  49385. groundSize: number;
  49386. /**
  49387. * The texture used on the ground for the main color.
  49388. * Comes from the BabylonJS CDN by default.
  49389. *
  49390. * Remarks: Can be either a texture or a url.
  49391. */
  49392. groundTexture: string | BaseTexture;
  49393. /**
  49394. * The color mixed in the ground texture by default.
  49395. * BabylonJS clearColor by default.
  49396. */
  49397. groundColor: Color3;
  49398. /**
  49399. * Specifies the ground opacity.
  49400. * 1 by default.
  49401. */
  49402. groundOpacity: number;
  49403. /**
  49404. * Enables the ground to receive shadows.
  49405. * True by default.
  49406. */
  49407. enableGroundShadow: boolean;
  49408. /**
  49409. * Helps preventing the shadow to be fully black on the ground.
  49410. * 0.5 by default.
  49411. */
  49412. groundShadowLevel: number;
  49413. /**
  49414. * Creates a mirror texture attach to the ground.
  49415. * false by default.
  49416. */
  49417. enableGroundMirror: boolean;
  49418. /**
  49419. * Specifies the ground mirror size ratio.
  49420. * 0.3 by default as the default kernel is 64.
  49421. */
  49422. groundMirrorSizeRatio: number;
  49423. /**
  49424. * Specifies the ground mirror blur kernel size.
  49425. * 64 by default.
  49426. */
  49427. groundMirrorBlurKernel: number;
  49428. /**
  49429. * Specifies the ground mirror visibility amount.
  49430. * 1 by default
  49431. */
  49432. groundMirrorAmount: number;
  49433. /**
  49434. * Specifies the ground mirror reflectance weight.
  49435. * This uses the standard weight of the background material to setup the fresnel effect
  49436. * of the mirror.
  49437. * 1 by default.
  49438. */
  49439. groundMirrorFresnelWeight: number;
  49440. /**
  49441. * Specifies the ground mirror Falloff distance.
  49442. * This can helps reducing the size of the reflection.
  49443. * 0 by Default.
  49444. */
  49445. groundMirrorFallOffDistance: number;
  49446. /**
  49447. * Specifies the ground mirror texture type.
  49448. * Unsigned Int by Default.
  49449. */
  49450. groundMirrorTextureType: number;
  49451. /**
  49452. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49453. * the shown objects.
  49454. */
  49455. groundYBias: number;
  49456. /**
  49457. * Specifies wether or not to create a skybox.
  49458. * True by default.
  49459. */
  49460. createSkybox: boolean;
  49461. /**
  49462. * Specifies the skybox size.
  49463. * 20 by default.
  49464. */
  49465. skyboxSize: number;
  49466. /**
  49467. * The texture used on the skybox for the main color.
  49468. * Comes from the BabylonJS CDN by default.
  49469. *
  49470. * Remarks: Can be either a texture or a url.
  49471. */
  49472. skyboxTexture: string | BaseTexture;
  49473. /**
  49474. * The color mixed in the skybox texture by default.
  49475. * BabylonJS clearColor by default.
  49476. */
  49477. skyboxColor: Color3;
  49478. /**
  49479. * The background rotation around the Y axis of the scene.
  49480. * This helps aligning the key lights of your scene with the background.
  49481. * 0 by default.
  49482. */
  49483. backgroundYRotation: number;
  49484. /**
  49485. * Compute automatically the size of the elements to best fit with the scene.
  49486. */
  49487. sizeAuto: boolean;
  49488. /**
  49489. * Default position of the rootMesh if autoSize is not true.
  49490. */
  49491. rootPosition: Vector3;
  49492. /**
  49493. * Sets up the image processing in the scene.
  49494. * true by default.
  49495. */
  49496. setupImageProcessing: boolean;
  49497. /**
  49498. * The texture used as your environment texture in the scene.
  49499. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49500. *
  49501. * Remarks: Can be either a texture or a url.
  49502. */
  49503. environmentTexture: string | BaseTexture;
  49504. /**
  49505. * The value of the exposure to apply to the scene.
  49506. * 0.6 by default if setupImageProcessing is true.
  49507. */
  49508. cameraExposure: number;
  49509. /**
  49510. * The value of the contrast to apply to the scene.
  49511. * 1.6 by default if setupImageProcessing is true.
  49512. */
  49513. cameraContrast: number;
  49514. /**
  49515. * Specifies wether or not tonemapping should be enabled in the scene.
  49516. * true by default if setupImageProcessing is true.
  49517. */
  49518. toneMappingEnabled: boolean;
  49519. }
  49520. /**
  49521. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49522. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49523. * It also helps with the default setup of your imageProcessing configuration.
  49524. */
  49525. export class EnvironmentHelper {
  49526. /**
  49527. * Default ground texture URL.
  49528. */
  49529. private static _groundTextureCDNUrl;
  49530. /**
  49531. * Default skybox texture URL.
  49532. */
  49533. private static _skyboxTextureCDNUrl;
  49534. /**
  49535. * Default environment texture URL.
  49536. */
  49537. private static _environmentTextureCDNUrl;
  49538. /**
  49539. * Creates the default options for the helper.
  49540. */
  49541. private static _getDefaultOptions;
  49542. private _rootMesh;
  49543. /**
  49544. * Gets the root mesh created by the helper.
  49545. */
  49546. readonly rootMesh: Mesh;
  49547. private _skybox;
  49548. /**
  49549. * Gets the skybox created by the helper.
  49550. */
  49551. readonly skybox: Nullable<Mesh>;
  49552. private _skyboxTexture;
  49553. /**
  49554. * Gets the skybox texture created by the helper.
  49555. */
  49556. readonly skyboxTexture: Nullable<BaseTexture>;
  49557. private _skyboxMaterial;
  49558. /**
  49559. * Gets the skybox material created by the helper.
  49560. */
  49561. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  49562. private _ground;
  49563. /**
  49564. * Gets the ground mesh created by the helper.
  49565. */
  49566. readonly ground: Nullable<Mesh>;
  49567. private _groundTexture;
  49568. /**
  49569. * Gets the ground texture created by the helper.
  49570. */
  49571. readonly groundTexture: Nullable<BaseTexture>;
  49572. private _groundMirror;
  49573. /**
  49574. * Gets the ground mirror created by the helper.
  49575. */
  49576. readonly groundMirror: Nullable<MirrorTexture>;
  49577. /**
  49578. * Gets the ground mirror render list to helps pushing the meshes
  49579. * you wish in the ground reflection.
  49580. */
  49581. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  49582. private _groundMaterial;
  49583. /**
  49584. * Gets the ground material created by the helper.
  49585. */
  49586. readonly groundMaterial: Nullable<BackgroundMaterial>;
  49587. /**
  49588. * Stores the creation options.
  49589. */
  49590. private readonly _scene;
  49591. private _options;
  49592. /**
  49593. * This observable will be notified with any error during the creation of the environment,
  49594. * mainly texture creation errors.
  49595. */
  49596. onErrorObservable: Observable<{
  49597. message?: string;
  49598. exception?: any;
  49599. }>;
  49600. /**
  49601. * constructor
  49602. * @param options Defines the options we want to customize the helper
  49603. * @param scene The scene to add the material to
  49604. */
  49605. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49606. /**
  49607. * Updates the background according to the new options
  49608. * @param options
  49609. */
  49610. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49611. /**
  49612. * Sets the primary color of all the available elements.
  49613. * @param color the main color to affect to the ground and the background
  49614. */
  49615. setMainColor(color: Color3): void;
  49616. /**
  49617. * Setup the image processing according to the specified options.
  49618. */
  49619. private _setupImageProcessing;
  49620. /**
  49621. * Setup the environment texture according to the specified options.
  49622. */
  49623. private _setupEnvironmentTexture;
  49624. /**
  49625. * Setup the background according to the specified options.
  49626. */
  49627. private _setupBackground;
  49628. /**
  49629. * Get the scene sizes according to the setup.
  49630. */
  49631. private _getSceneSize;
  49632. /**
  49633. * Setup the ground according to the specified options.
  49634. */
  49635. private _setupGround;
  49636. /**
  49637. * Setup the ground material according to the specified options.
  49638. */
  49639. private _setupGroundMaterial;
  49640. /**
  49641. * Setup the ground diffuse texture according to the specified options.
  49642. */
  49643. private _setupGroundDiffuseTexture;
  49644. /**
  49645. * Setup the ground mirror texture according to the specified options.
  49646. */
  49647. private _setupGroundMirrorTexture;
  49648. /**
  49649. * Setup the ground to receive the mirror texture.
  49650. */
  49651. private _setupMirrorInGroundMaterial;
  49652. /**
  49653. * Setup the skybox according to the specified options.
  49654. */
  49655. private _setupSkybox;
  49656. /**
  49657. * Setup the skybox material according to the specified options.
  49658. */
  49659. private _setupSkyboxMaterial;
  49660. /**
  49661. * Setup the skybox reflection texture according to the specified options.
  49662. */
  49663. private _setupSkyboxReflectionTexture;
  49664. private _errorHandler;
  49665. /**
  49666. * Dispose all the elements created by the Helper.
  49667. */
  49668. dispose(): void;
  49669. }
  49670. }
  49671. declare module "babylonjs/Helpers/photoDome" {
  49672. import { Observable } from "babylonjs/Misc/observable";
  49673. import { Nullable } from "babylonjs/types";
  49674. import { Scene } from "babylonjs/scene";
  49675. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49676. import { Mesh } from "babylonjs/Meshes/mesh";
  49677. import { Texture } from "babylonjs/Materials/Textures/texture";
  49678. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49679. import "babylonjs/Meshes/Builders/sphereBuilder";
  49680. /**
  49681. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49682. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49683. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49684. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49685. */
  49686. export class PhotoDome extends TransformNode {
  49687. /**
  49688. * Define the image as a Monoscopic panoramic 360 image.
  49689. */
  49690. static readonly MODE_MONOSCOPIC: number;
  49691. /**
  49692. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49693. */
  49694. static readonly MODE_TOPBOTTOM: number;
  49695. /**
  49696. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49697. */
  49698. static readonly MODE_SIDEBYSIDE: number;
  49699. private _useDirectMapping;
  49700. /**
  49701. * The texture being displayed on the sphere
  49702. */
  49703. protected _photoTexture: Texture;
  49704. /**
  49705. * Gets or sets the texture being displayed on the sphere
  49706. */
  49707. photoTexture: Texture;
  49708. /**
  49709. * Observable raised when an error occured while loading the 360 image
  49710. */
  49711. onLoadErrorObservable: Observable<string>;
  49712. /**
  49713. * The skybox material
  49714. */
  49715. protected _material: BackgroundMaterial;
  49716. /**
  49717. * The surface used for the skybox
  49718. */
  49719. protected _mesh: Mesh;
  49720. /**
  49721. * Gets the mesh used for the skybox.
  49722. */
  49723. readonly mesh: Mesh;
  49724. /**
  49725. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49726. * Also see the options.resolution property.
  49727. */
  49728. fovMultiplier: number;
  49729. private _imageMode;
  49730. /**
  49731. * Gets or set the current video mode for the video. It can be:
  49732. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49733. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49734. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49735. */
  49736. imageMode: number;
  49737. /**
  49738. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49739. * @param name Element's name, child elements will append suffixes for their own names.
  49740. * @param urlsOfPhoto defines the url of the photo to display
  49741. * @param options defines an object containing optional or exposed sub element properties
  49742. * @param onError defines a callback called when an error occured while loading the texture
  49743. */
  49744. constructor(name: string, urlOfPhoto: string, options: {
  49745. resolution?: number;
  49746. size?: number;
  49747. useDirectMapping?: boolean;
  49748. faceForward?: boolean;
  49749. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49750. private _onBeforeCameraRenderObserver;
  49751. private _changeImageMode;
  49752. /**
  49753. * Releases resources associated with this node.
  49754. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49755. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49756. */
  49757. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49758. }
  49759. }
  49760. declare module "babylonjs/Misc/rgbdTextureTools" {
  49761. import "babylonjs/Shaders/rgbdDecode.fragment";
  49762. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49763. import { Texture } from "babylonjs/Materials/Textures/texture";
  49764. /**
  49765. * Class used to host RGBD texture specific utilities
  49766. */
  49767. export class RGBDTextureTools {
  49768. /**
  49769. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49770. * @param texture the texture to expand.
  49771. */
  49772. static ExpandRGBDTexture(texture: Texture): void;
  49773. }
  49774. }
  49775. declare module "babylonjs/Misc/brdfTextureTools" {
  49776. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49777. import { Scene } from "babylonjs/scene";
  49778. /**
  49779. * Class used to host texture specific utilities
  49780. */
  49781. export class BRDFTextureTools {
  49782. /**
  49783. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49784. * @param scene defines the hosting scene
  49785. * @returns the environment BRDF texture
  49786. */
  49787. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49788. private static _environmentBRDFBase64Texture;
  49789. }
  49790. }
  49791. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  49792. import { Nullable } from "babylonjs/types";
  49793. import { Color3 } from "babylonjs/Maths/math.color";
  49794. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49795. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49796. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49797. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49798. import { Engine } from "babylonjs/Engines/engine";
  49799. import { Scene } from "babylonjs/scene";
  49800. /**
  49801. * @hidden
  49802. */
  49803. export interface IMaterialClearCoatDefines {
  49804. CLEARCOAT: boolean;
  49805. CLEARCOAT_DEFAULTIOR: boolean;
  49806. CLEARCOAT_TEXTURE: boolean;
  49807. CLEARCOAT_TEXTUREDIRECTUV: number;
  49808. CLEARCOAT_BUMP: boolean;
  49809. CLEARCOAT_BUMPDIRECTUV: number;
  49810. CLEARCOAT_TINT: boolean;
  49811. CLEARCOAT_TINT_TEXTURE: boolean;
  49812. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49813. /** @hidden */
  49814. _areTexturesDirty: boolean;
  49815. }
  49816. /**
  49817. * Define the code related to the clear coat parameters of the pbr material.
  49818. */
  49819. export class PBRClearCoatConfiguration {
  49820. /**
  49821. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49822. * The default fits with a polyurethane material.
  49823. */
  49824. private static readonly _DefaultIndexOfRefraction;
  49825. private _isEnabled;
  49826. /**
  49827. * Defines if the clear coat is enabled in the material.
  49828. */
  49829. isEnabled: boolean;
  49830. /**
  49831. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49832. */
  49833. intensity: number;
  49834. /**
  49835. * Defines the clear coat layer roughness.
  49836. */
  49837. roughness: number;
  49838. private _indexOfRefraction;
  49839. /**
  49840. * Defines the index of refraction of the clear coat.
  49841. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49842. * The default fits with a polyurethane material.
  49843. * Changing the default value is more performance intensive.
  49844. */
  49845. indexOfRefraction: number;
  49846. private _texture;
  49847. /**
  49848. * Stores the clear coat values in a texture.
  49849. */
  49850. texture: Nullable<BaseTexture>;
  49851. private _bumpTexture;
  49852. /**
  49853. * Define the clear coat specific bump texture.
  49854. */
  49855. bumpTexture: Nullable<BaseTexture>;
  49856. private _isTintEnabled;
  49857. /**
  49858. * Defines if the clear coat tint is enabled in the material.
  49859. */
  49860. isTintEnabled: boolean;
  49861. /**
  49862. * Defines the clear coat tint of the material.
  49863. * This is only use if tint is enabled
  49864. */
  49865. tintColor: Color3;
  49866. /**
  49867. * Defines the distance at which the tint color should be found in the
  49868. * clear coat media.
  49869. * This is only use if tint is enabled
  49870. */
  49871. tintColorAtDistance: number;
  49872. /**
  49873. * Defines the clear coat layer thickness.
  49874. * This is only use if tint is enabled
  49875. */
  49876. tintThickness: number;
  49877. private _tintTexture;
  49878. /**
  49879. * Stores the clear tint values in a texture.
  49880. * rgb is tint
  49881. * a is a thickness factor
  49882. */
  49883. tintTexture: Nullable<BaseTexture>;
  49884. /** @hidden */
  49885. private _internalMarkAllSubMeshesAsTexturesDirty;
  49886. /** @hidden */
  49887. _markAllSubMeshesAsTexturesDirty(): void;
  49888. /**
  49889. * Instantiate a new istance of clear coat configuration.
  49890. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49891. */
  49892. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49893. /**
  49894. * Gets wehter the submesh is ready to be used or not.
  49895. * @param defines the list of "defines" to update.
  49896. * @param scene defines the scene the material belongs to.
  49897. * @param engine defines the engine the material belongs to.
  49898. * @param disableBumpMap defines wether the material disables bump or not.
  49899. * @returns - boolean indicating that the submesh is ready or not.
  49900. */
  49901. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49902. /**
  49903. * Checks to see if a texture is used in the material.
  49904. * @param defines the list of "defines" to update.
  49905. * @param scene defines the scene to the material belongs to.
  49906. */
  49907. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49908. /**
  49909. * Binds the material data.
  49910. * @param uniformBuffer defines the Uniform buffer to fill in.
  49911. * @param scene defines the scene the material belongs to.
  49912. * @param engine defines the engine the material belongs to.
  49913. * @param disableBumpMap defines wether the material disables bump or not.
  49914. * @param isFrozen defines wether the material is frozen or not.
  49915. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49916. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49917. */
  49918. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49919. /**
  49920. * Checks to see if a texture is used in the material.
  49921. * @param texture - Base texture to use.
  49922. * @returns - Boolean specifying if a texture is used in the material.
  49923. */
  49924. hasTexture(texture: BaseTexture): boolean;
  49925. /**
  49926. * Returns an array of the actively used textures.
  49927. * @param activeTextures Array of BaseTextures
  49928. */
  49929. getActiveTextures(activeTextures: BaseTexture[]): void;
  49930. /**
  49931. * Returns the animatable textures.
  49932. * @param animatables Array of animatable textures.
  49933. */
  49934. getAnimatables(animatables: IAnimatable[]): void;
  49935. /**
  49936. * Disposes the resources of the material.
  49937. * @param forceDisposeTextures - Forces the disposal of all textures.
  49938. */
  49939. dispose(forceDisposeTextures?: boolean): void;
  49940. /**
  49941. * Get the current class name of the texture useful for serialization or dynamic coding.
  49942. * @returns "PBRClearCoatConfiguration"
  49943. */
  49944. getClassName(): string;
  49945. /**
  49946. * Add fallbacks to the effect fallbacks list.
  49947. * @param defines defines the Base texture to use.
  49948. * @param fallbacks defines the current fallback list.
  49949. * @param currentRank defines the current fallback rank.
  49950. * @returns the new fallback rank.
  49951. */
  49952. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49953. /**
  49954. * Add the required uniforms to the current list.
  49955. * @param uniforms defines the current uniform list.
  49956. */
  49957. static AddUniforms(uniforms: string[]): void;
  49958. /**
  49959. * Add the required samplers to the current list.
  49960. * @param samplers defines the current sampler list.
  49961. */
  49962. static AddSamplers(samplers: string[]): void;
  49963. /**
  49964. * Add the required uniforms to the current buffer.
  49965. * @param uniformBuffer defines the current uniform buffer.
  49966. */
  49967. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49968. /**
  49969. * Makes a duplicate of the current configuration into another one.
  49970. * @param clearCoatConfiguration define the config where to copy the info
  49971. */
  49972. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49973. /**
  49974. * Serializes this clear coat configuration.
  49975. * @returns - An object with the serialized config.
  49976. */
  49977. serialize(): any;
  49978. /**
  49979. * Parses a anisotropy Configuration from a serialized object.
  49980. * @param source - Serialized object.
  49981. * @param scene Defines the scene we are parsing for
  49982. * @param rootUrl Defines the rootUrl to load from
  49983. */
  49984. parse(source: any, scene: Scene, rootUrl: string): void;
  49985. }
  49986. }
  49987. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  49988. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49990. import { Vector2 } from "babylonjs/Maths/math.vector";
  49991. import { Scene } from "babylonjs/scene";
  49992. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49993. import { Nullable } from "babylonjs/types";
  49994. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49995. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49996. /**
  49997. * @hidden
  49998. */
  49999. export interface IMaterialAnisotropicDefines {
  50000. ANISOTROPIC: boolean;
  50001. ANISOTROPIC_TEXTURE: boolean;
  50002. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50003. MAINUV1: boolean;
  50004. _areTexturesDirty: boolean;
  50005. _needUVs: boolean;
  50006. }
  50007. /**
  50008. * Define the code related to the anisotropic parameters of the pbr material.
  50009. */
  50010. export class PBRAnisotropicConfiguration {
  50011. private _isEnabled;
  50012. /**
  50013. * Defines if the anisotropy is enabled in the material.
  50014. */
  50015. isEnabled: boolean;
  50016. /**
  50017. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50018. */
  50019. intensity: number;
  50020. /**
  50021. * Defines if the effect is along the tangents, bitangents or in between.
  50022. * By default, the effect is "strectching" the highlights along the tangents.
  50023. */
  50024. direction: Vector2;
  50025. private _texture;
  50026. /**
  50027. * Stores the anisotropy values in a texture.
  50028. * rg is direction (like normal from -1 to 1)
  50029. * b is a intensity
  50030. */
  50031. texture: Nullable<BaseTexture>;
  50032. /** @hidden */
  50033. private _internalMarkAllSubMeshesAsTexturesDirty;
  50034. /** @hidden */
  50035. _markAllSubMeshesAsTexturesDirty(): void;
  50036. /**
  50037. * Instantiate a new istance of anisotropy configuration.
  50038. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50039. */
  50040. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50041. /**
  50042. * Specifies that the submesh is ready to be used.
  50043. * @param defines the list of "defines" to update.
  50044. * @param scene defines the scene the material belongs to.
  50045. * @returns - boolean indicating that the submesh is ready or not.
  50046. */
  50047. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50048. /**
  50049. * Checks to see if a texture is used in the material.
  50050. * @param defines the list of "defines" to update.
  50051. * @param mesh the mesh we are preparing the defines for.
  50052. * @param scene defines the scene the material belongs to.
  50053. */
  50054. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50055. /**
  50056. * Binds the material data.
  50057. * @param uniformBuffer defines the Uniform buffer to fill in.
  50058. * @param scene defines the scene the material belongs to.
  50059. * @param isFrozen defines wether the material is frozen or not.
  50060. */
  50061. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50062. /**
  50063. * Checks to see if a texture is used in the material.
  50064. * @param texture - Base texture to use.
  50065. * @returns - Boolean specifying if a texture is used in the material.
  50066. */
  50067. hasTexture(texture: BaseTexture): boolean;
  50068. /**
  50069. * Returns an array of the actively used textures.
  50070. * @param activeTextures Array of BaseTextures
  50071. */
  50072. getActiveTextures(activeTextures: BaseTexture[]): void;
  50073. /**
  50074. * Returns the animatable textures.
  50075. * @param animatables Array of animatable textures.
  50076. */
  50077. getAnimatables(animatables: IAnimatable[]): void;
  50078. /**
  50079. * Disposes the resources of the material.
  50080. * @param forceDisposeTextures - Forces the disposal of all textures.
  50081. */
  50082. dispose(forceDisposeTextures?: boolean): void;
  50083. /**
  50084. * Get the current class name of the texture useful for serialization or dynamic coding.
  50085. * @returns "PBRAnisotropicConfiguration"
  50086. */
  50087. getClassName(): string;
  50088. /**
  50089. * Add fallbacks to the effect fallbacks list.
  50090. * @param defines defines the Base texture to use.
  50091. * @param fallbacks defines the current fallback list.
  50092. * @param currentRank defines the current fallback rank.
  50093. * @returns the new fallback rank.
  50094. */
  50095. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50096. /**
  50097. * Add the required uniforms to the current list.
  50098. * @param uniforms defines the current uniform list.
  50099. */
  50100. static AddUniforms(uniforms: string[]): void;
  50101. /**
  50102. * Add the required uniforms to the current buffer.
  50103. * @param uniformBuffer defines the current uniform buffer.
  50104. */
  50105. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50106. /**
  50107. * Add the required samplers to the current list.
  50108. * @param samplers defines the current sampler list.
  50109. */
  50110. static AddSamplers(samplers: string[]): void;
  50111. /**
  50112. * Makes a duplicate of the current configuration into another one.
  50113. * @param anisotropicConfiguration define the config where to copy the info
  50114. */
  50115. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50116. /**
  50117. * Serializes this anisotropy configuration.
  50118. * @returns - An object with the serialized config.
  50119. */
  50120. serialize(): any;
  50121. /**
  50122. * Parses a anisotropy Configuration from a serialized object.
  50123. * @param source - Serialized object.
  50124. * @param scene Defines the scene we are parsing for
  50125. * @param rootUrl Defines the rootUrl to load from
  50126. */
  50127. parse(source: any, scene: Scene, rootUrl: string): void;
  50128. }
  50129. }
  50130. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  50131. import { Scene } from "babylonjs/scene";
  50132. /**
  50133. * @hidden
  50134. */
  50135. export interface IMaterialBRDFDefines {
  50136. BRDF_V_HEIGHT_CORRELATED: boolean;
  50137. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50138. SPHERICAL_HARMONICS: boolean;
  50139. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50140. /** @hidden */
  50141. _areMiscDirty: boolean;
  50142. }
  50143. /**
  50144. * Define the code related to the BRDF parameters of the pbr material.
  50145. */
  50146. export class PBRBRDFConfiguration {
  50147. /**
  50148. * Default value used for the energy conservation.
  50149. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50150. */
  50151. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50152. /**
  50153. * Default value used for the Smith Visibility Height Correlated mode.
  50154. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50155. */
  50156. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50157. /**
  50158. * Default value used for the IBL diffuse part.
  50159. * This can help switching back to the polynomials mode globally which is a tiny bit
  50160. * less GPU intensive at the drawback of a lower quality.
  50161. */
  50162. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50163. /**
  50164. * Default value used for activating energy conservation for the specular workflow.
  50165. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50166. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50167. */
  50168. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50169. private _useEnergyConservation;
  50170. /**
  50171. * Defines if the material uses energy conservation.
  50172. */
  50173. useEnergyConservation: boolean;
  50174. private _useSmithVisibilityHeightCorrelated;
  50175. /**
  50176. * LEGACY Mode set to false
  50177. * Defines if the material uses height smith correlated visibility term.
  50178. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50179. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50180. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50181. * Not relying on height correlated will also disable energy conservation.
  50182. */
  50183. useSmithVisibilityHeightCorrelated: boolean;
  50184. private _useSphericalHarmonics;
  50185. /**
  50186. * LEGACY Mode set to false
  50187. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50188. * diffuse part of the IBL.
  50189. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50190. * to the ground truth.
  50191. */
  50192. useSphericalHarmonics: boolean;
  50193. private _useSpecularGlossinessInputEnergyConservation;
  50194. /**
  50195. * Defines if the material uses energy conservation, when the specular workflow is active.
  50196. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50197. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50198. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50199. */
  50200. useSpecularGlossinessInputEnergyConservation: boolean;
  50201. /** @hidden */
  50202. private _internalMarkAllSubMeshesAsMiscDirty;
  50203. /** @hidden */
  50204. _markAllSubMeshesAsMiscDirty(): void;
  50205. /**
  50206. * Instantiate a new istance of clear coat configuration.
  50207. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50208. */
  50209. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50210. /**
  50211. * Checks to see if a texture is used in the material.
  50212. * @param defines the list of "defines" to update.
  50213. */
  50214. prepareDefines(defines: IMaterialBRDFDefines): void;
  50215. /**
  50216. * Get the current class name of the texture useful for serialization or dynamic coding.
  50217. * @returns "PBRClearCoatConfiguration"
  50218. */
  50219. getClassName(): string;
  50220. /**
  50221. * Makes a duplicate of the current configuration into another one.
  50222. * @param brdfConfiguration define the config where to copy the info
  50223. */
  50224. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50225. /**
  50226. * Serializes this BRDF configuration.
  50227. * @returns - An object with the serialized config.
  50228. */
  50229. serialize(): any;
  50230. /**
  50231. * Parses a anisotropy Configuration from a serialized object.
  50232. * @param source - Serialized object.
  50233. * @param scene Defines the scene we are parsing for
  50234. * @param rootUrl Defines the rootUrl to load from
  50235. */
  50236. parse(source: any, scene: Scene, rootUrl: string): void;
  50237. }
  50238. }
  50239. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  50240. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50241. import { Color3 } from "babylonjs/Maths/math.color";
  50242. import { Scene } from "babylonjs/scene";
  50243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50244. import { Nullable } from "babylonjs/types";
  50245. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50246. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50247. /**
  50248. * @hidden
  50249. */
  50250. export interface IMaterialSheenDefines {
  50251. SHEEN: boolean;
  50252. SHEEN_TEXTURE: boolean;
  50253. SHEEN_TEXTUREDIRECTUV: number;
  50254. SHEEN_LINKWITHALBEDO: boolean;
  50255. /** @hidden */
  50256. _areTexturesDirty: boolean;
  50257. }
  50258. /**
  50259. * Define the code related to the Sheen parameters of the pbr material.
  50260. */
  50261. export class PBRSheenConfiguration {
  50262. private _isEnabled;
  50263. /**
  50264. * Defines if the material uses sheen.
  50265. */
  50266. isEnabled: boolean;
  50267. private _linkSheenWithAlbedo;
  50268. /**
  50269. * Defines if the sheen is linked to the sheen color.
  50270. */
  50271. linkSheenWithAlbedo: boolean;
  50272. /**
  50273. * Defines the sheen intensity.
  50274. */
  50275. intensity: number;
  50276. /**
  50277. * Defines the sheen color.
  50278. */
  50279. color: Color3;
  50280. private _texture;
  50281. /**
  50282. * Stores the sheen tint values in a texture.
  50283. * rgb is tint
  50284. * a is a intensity
  50285. */
  50286. texture: Nullable<BaseTexture>;
  50287. /** @hidden */
  50288. private _internalMarkAllSubMeshesAsTexturesDirty;
  50289. /** @hidden */
  50290. _markAllSubMeshesAsTexturesDirty(): void;
  50291. /**
  50292. * Instantiate a new istance of clear coat configuration.
  50293. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50294. */
  50295. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50296. /**
  50297. * Specifies that the submesh is ready to be used.
  50298. * @param defines the list of "defines" to update.
  50299. * @param scene defines the scene the material belongs to.
  50300. * @returns - boolean indicating that the submesh is ready or not.
  50301. */
  50302. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50303. /**
  50304. * Checks to see if a texture is used in the material.
  50305. * @param defines the list of "defines" to update.
  50306. * @param scene defines the scene the material belongs to.
  50307. */
  50308. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50309. /**
  50310. * Binds the material data.
  50311. * @param uniformBuffer defines the Uniform buffer to fill in.
  50312. * @param scene defines the scene the material belongs to.
  50313. * @param isFrozen defines wether the material is frozen or not.
  50314. */
  50315. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50316. /**
  50317. * Checks to see if a texture is used in the material.
  50318. * @param texture - Base texture to use.
  50319. * @returns - Boolean specifying if a texture is used in the material.
  50320. */
  50321. hasTexture(texture: BaseTexture): boolean;
  50322. /**
  50323. * Returns an array of the actively used textures.
  50324. * @param activeTextures Array of BaseTextures
  50325. */
  50326. getActiveTextures(activeTextures: BaseTexture[]): void;
  50327. /**
  50328. * Returns the animatable textures.
  50329. * @param animatables Array of animatable textures.
  50330. */
  50331. getAnimatables(animatables: IAnimatable[]): void;
  50332. /**
  50333. * Disposes the resources of the material.
  50334. * @param forceDisposeTextures - Forces the disposal of all textures.
  50335. */
  50336. dispose(forceDisposeTextures?: boolean): void;
  50337. /**
  50338. * Get the current class name of the texture useful for serialization or dynamic coding.
  50339. * @returns "PBRSheenConfiguration"
  50340. */
  50341. getClassName(): string;
  50342. /**
  50343. * Add fallbacks to the effect fallbacks list.
  50344. * @param defines defines the Base texture to use.
  50345. * @param fallbacks defines the current fallback list.
  50346. * @param currentRank defines the current fallback rank.
  50347. * @returns the new fallback rank.
  50348. */
  50349. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50350. /**
  50351. * Add the required uniforms to the current list.
  50352. * @param uniforms defines the current uniform list.
  50353. */
  50354. static AddUniforms(uniforms: string[]): void;
  50355. /**
  50356. * Add the required uniforms to the current buffer.
  50357. * @param uniformBuffer defines the current uniform buffer.
  50358. */
  50359. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50360. /**
  50361. * Add the required samplers to the current list.
  50362. * @param samplers defines the current sampler list.
  50363. */
  50364. static AddSamplers(samplers: string[]): void;
  50365. /**
  50366. * Makes a duplicate of the current configuration into another one.
  50367. * @param sheenConfiguration define the config where to copy the info
  50368. */
  50369. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50370. /**
  50371. * Serializes this BRDF configuration.
  50372. * @returns - An object with the serialized config.
  50373. */
  50374. serialize(): any;
  50375. /**
  50376. * Parses a anisotropy Configuration from a serialized object.
  50377. * @param source - Serialized object.
  50378. * @param scene Defines the scene we are parsing for
  50379. * @param rootUrl Defines the rootUrl to load from
  50380. */
  50381. parse(source: any, scene: Scene, rootUrl: string): void;
  50382. }
  50383. }
  50384. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  50385. import { Nullable } from "babylonjs/types";
  50386. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50387. import { Color3 } from "babylonjs/Maths/math.color";
  50388. import { SmartArray } from "babylonjs/Misc/smartArray";
  50389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50390. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50391. import { Effect } from "babylonjs/Materials/effect";
  50392. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50393. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50394. import { Engine } from "babylonjs/Engines/engine";
  50395. import { Scene } from "babylonjs/scene";
  50396. /**
  50397. * @hidden
  50398. */
  50399. export interface IMaterialSubSurfaceDefines {
  50400. SUBSURFACE: boolean;
  50401. SS_REFRACTION: boolean;
  50402. SS_TRANSLUCENCY: boolean;
  50403. SS_SCATERRING: boolean;
  50404. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50405. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50406. SS_REFRACTIONMAP_3D: boolean;
  50407. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50408. SS_LODINREFRACTIONALPHA: boolean;
  50409. SS_GAMMAREFRACTION: boolean;
  50410. SS_RGBDREFRACTION: boolean;
  50411. SS_LINEARSPECULARREFRACTION: boolean;
  50412. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50413. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50414. /** @hidden */
  50415. _areTexturesDirty: boolean;
  50416. }
  50417. /**
  50418. * Define the code related to the sub surface parameters of the pbr material.
  50419. */
  50420. export class PBRSubSurfaceConfiguration {
  50421. private _isRefractionEnabled;
  50422. /**
  50423. * Defines if the refraction is enabled in the material.
  50424. */
  50425. isRefractionEnabled: boolean;
  50426. private _isTranslucencyEnabled;
  50427. /**
  50428. * Defines if the translucency is enabled in the material.
  50429. */
  50430. isTranslucencyEnabled: boolean;
  50431. private _isScatteringEnabled;
  50432. /**
  50433. * Defines the refraction intensity of the material.
  50434. * The refraction when enabled replaces the Diffuse part of the material.
  50435. * The intensity helps transitionning between diffuse and refraction.
  50436. */
  50437. refractionIntensity: number;
  50438. /**
  50439. * Defines the translucency intensity of the material.
  50440. * When translucency has been enabled, this defines how much of the "translucency"
  50441. * is addded to the diffuse part of the material.
  50442. */
  50443. translucencyIntensity: number;
  50444. /**
  50445. * Defines the scattering intensity of the material.
  50446. * When scattering has been enabled, this defines how much of the "scattered light"
  50447. * is addded to the diffuse part of the material.
  50448. */
  50449. scatteringIntensity: number;
  50450. private _thicknessTexture;
  50451. /**
  50452. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50453. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50454. * 0 would mean minimumThickness
  50455. * 1 would mean maximumThickness
  50456. * The other channels might be use as a mask to vary the different effects intensity.
  50457. */
  50458. thicknessTexture: Nullable<BaseTexture>;
  50459. private _refractionTexture;
  50460. /**
  50461. * Defines the texture to use for refraction.
  50462. */
  50463. refractionTexture: Nullable<BaseTexture>;
  50464. private _indexOfRefraction;
  50465. /**
  50466. * Defines the index of refraction used in the material.
  50467. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50468. */
  50469. indexOfRefraction: number;
  50470. private _invertRefractionY;
  50471. /**
  50472. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50473. */
  50474. invertRefractionY: boolean;
  50475. private _linkRefractionWithTransparency;
  50476. /**
  50477. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50478. * Materials half opaque for instance using refraction could benefit from this control.
  50479. */
  50480. linkRefractionWithTransparency: boolean;
  50481. /**
  50482. * Defines the minimum thickness stored in the thickness map.
  50483. * If no thickness map is defined, this value will be used to simulate thickness.
  50484. */
  50485. minimumThickness: number;
  50486. /**
  50487. * Defines the maximum thickness stored in the thickness map.
  50488. */
  50489. maximumThickness: number;
  50490. /**
  50491. * Defines the volume tint of the material.
  50492. * This is used for both translucency and scattering.
  50493. */
  50494. tintColor: Color3;
  50495. /**
  50496. * Defines the distance at which the tint color should be found in the media.
  50497. * This is used for refraction only.
  50498. */
  50499. tintColorAtDistance: number;
  50500. /**
  50501. * Defines how far each channel transmit through the media.
  50502. * It is defined as a color to simplify it selection.
  50503. */
  50504. diffusionDistance: Color3;
  50505. private _useMaskFromThicknessTexture;
  50506. /**
  50507. * Stores the intensity of the different subsurface effects in the thickness texture.
  50508. * * the green channel is the translucency intensity.
  50509. * * the blue channel is the scattering intensity.
  50510. * * the alpha channel is the refraction intensity.
  50511. */
  50512. useMaskFromThicknessTexture: boolean;
  50513. /** @hidden */
  50514. private _internalMarkAllSubMeshesAsTexturesDirty;
  50515. /** @hidden */
  50516. _markAllSubMeshesAsTexturesDirty(): void;
  50517. /**
  50518. * Instantiate a new istance of sub surface configuration.
  50519. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50520. */
  50521. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50522. /**
  50523. * Gets wehter the submesh is ready to be used or not.
  50524. * @param defines the list of "defines" to update.
  50525. * @param scene defines the scene the material belongs to.
  50526. * @returns - boolean indicating that the submesh is ready or not.
  50527. */
  50528. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50529. /**
  50530. * Checks to see if a texture is used in the material.
  50531. * @param defines the list of "defines" to update.
  50532. * @param scene defines the scene to the material belongs to.
  50533. */
  50534. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50535. /**
  50536. * Binds the material data.
  50537. * @param uniformBuffer defines the Uniform buffer to fill in.
  50538. * @param scene defines the scene the material belongs to.
  50539. * @param engine defines the engine the material belongs to.
  50540. * @param isFrozen defines wether the material is frozen or not.
  50541. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50542. */
  50543. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50544. /**
  50545. * Unbinds the material from the mesh.
  50546. * @param activeEffect defines the effect that should be unbound from.
  50547. * @returns true if unbound, otherwise false
  50548. */
  50549. unbind(activeEffect: Effect): boolean;
  50550. /**
  50551. * Returns the texture used for refraction or null if none is used.
  50552. * @param scene defines the scene the material belongs to.
  50553. * @returns - Refraction texture if present. If no refraction texture and refraction
  50554. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50555. */
  50556. private _getRefractionTexture;
  50557. /**
  50558. * Returns true if alpha blending should be disabled.
  50559. */
  50560. readonly disableAlphaBlending: boolean;
  50561. /**
  50562. * Fills the list of render target textures.
  50563. * @param renderTargets the list of render targets to update
  50564. */
  50565. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50566. /**
  50567. * Checks to see if a texture is used in the material.
  50568. * @param texture - Base texture to use.
  50569. * @returns - Boolean specifying if a texture is used in the material.
  50570. */
  50571. hasTexture(texture: BaseTexture): boolean;
  50572. /**
  50573. * Gets a boolean indicating that current material needs to register RTT
  50574. * @returns true if this uses a render target otherwise false.
  50575. */
  50576. hasRenderTargetTextures(): boolean;
  50577. /**
  50578. * Returns an array of the actively used textures.
  50579. * @param activeTextures Array of BaseTextures
  50580. */
  50581. getActiveTextures(activeTextures: BaseTexture[]): void;
  50582. /**
  50583. * Returns the animatable textures.
  50584. * @param animatables Array of animatable textures.
  50585. */
  50586. getAnimatables(animatables: IAnimatable[]): void;
  50587. /**
  50588. * Disposes the resources of the material.
  50589. * @param forceDisposeTextures - Forces the disposal of all textures.
  50590. */
  50591. dispose(forceDisposeTextures?: boolean): void;
  50592. /**
  50593. * Get the current class name of the texture useful for serialization or dynamic coding.
  50594. * @returns "PBRSubSurfaceConfiguration"
  50595. */
  50596. getClassName(): string;
  50597. /**
  50598. * Add fallbacks to the effect fallbacks list.
  50599. * @param defines defines the Base texture to use.
  50600. * @param fallbacks defines the current fallback list.
  50601. * @param currentRank defines the current fallback rank.
  50602. * @returns the new fallback rank.
  50603. */
  50604. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50605. /**
  50606. * Add the required uniforms to the current list.
  50607. * @param uniforms defines the current uniform list.
  50608. */
  50609. static AddUniforms(uniforms: string[]): void;
  50610. /**
  50611. * Add the required samplers to the current list.
  50612. * @param samplers defines the current sampler list.
  50613. */
  50614. static AddSamplers(samplers: string[]): void;
  50615. /**
  50616. * Add the required uniforms to the current buffer.
  50617. * @param uniformBuffer defines the current uniform buffer.
  50618. */
  50619. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50620. /**
  50621. * Makes a duplicate of the current configuration into another one.
  50622. * @param configuration define the config where to copy the info
  50623. */
  50624. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50625. /**
  50626. * Serializes this Sub Surface configuration.
  50627. * @returns - An object with the serialized config.
  50628. */
  50629. serialize(): any;
  50630. /**
  50631. * Parses a anisotropy Configuration from a serialized object.
  50632. * @param source - Serialized object.
  50633. * @param scene Defines the scene we are parsing for
  50634. * @param rootUrl Defines the rootUrl to load from
  50635. */
  50636. parse(source: any, scene: Scene, rootUrl: string): void;
  50637. }
  50638. }
  50639. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  50640. /** @hidden */
  50641. export var pbrFragmentDeclaration: {
  50642. name: string;
  50643. shader: string;
  50644. };
  50645. }
  50646. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  50647. /** @hidden */
  50648. export var pbrUboDeclaration: {
  50649. name: string;
  50650. shader: string;
  50651. };
  50652. }
  50653. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  50654. /** @hidden */
  50655. export var pbrFragmentExtraDeclaration: {
  50656. name: string;
  50657. shader: string;
  50658. };
  50659. }
  50660. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  50661. /** @hidden */
  50662. export var pbrFragmentSamplersDeclaration: {
  50663. name: string;
  50664. shader: string;
  50665. };
  50666. }
  50667. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  50668. /** @hidden */
  50669. export var pbrHelperFunctions: {
  50670. name: string;
  50671. shader: string;
  50672. };
  50673. }
  50674. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  50675. /** @hidden */
  50676. export var harmonicsFunctions: {
  50677. name: string;
  50678. shader: string;
  50679. };
  50680. }
  50681. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  50682. /** @hidden */
  50683. export var pbrDirectLightingSetupFunctions: {
  50684. name: string;
  50685. shader: string;
  50686. };
  50687. }
  50688. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  50689. /** @hidden */
  50690. export var pbrDirectLightingFalloffFunctions: {
  50691. name: string;
  50692. shader: string;
  50693. };
  50694. }
  50695. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  50696. /** @hidden */
  50697. export var pbrBRDFFunctions: {
  50698. name: string;
  50699. shader: string;
  50700. };
  50701. }
  50702. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  50703. /** @hidden */
  50704. export var pbrDirectLightingFunctions: {
  50705. name: string;
  50706. shader: string;
  50707. };
  50708. }
  50709. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  50710. /** @hidden */
  50711. export var pbrIBLFunctions: {
  50712. name: string;
  50713. shader: string;
  50714. };
  50715. }
  50716. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  50717. /** @hidden */
  50718. export var pbrDebug: {
  50719. name: string;
  50720. shader: string;
  50721. };
  50722. }
  50723. declare module "babylonjs/Shaders/pbr.fragment" {
  50724. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  50725. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50726. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  50727. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50728. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50729. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  50730. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50731. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50732. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50733. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50734. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50735. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  50736. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50737. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50738. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50739. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  50740. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  50741. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  50742. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  50743. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  50744. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  50745. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50746. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50747. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  50748. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  50749. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50750. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  50751. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50752. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  50753. /** @hidden */
  50754. export var pbrPixelShader: {
  50755. name: string;
  50756. shader: string;
  50757. };
  50758. }
  50759. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  50760. /** @hidden */
  50761. export var pbrVertexDeclaration: {
  50762. name: string;
  50763. shader: string;
  50764. };
  50765. }
  50766. declare module "babylonjs/Shaders/pbr.vertex" {
  50767. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  50768. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50769. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50770. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50771. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50772. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50773. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  50774. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50775. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50776. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50777. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50778. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50779. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50780. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50781. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50782. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50783. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50784. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  50785. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50786. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50787. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50788. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  50789. /** @hidden */
  50790. export var pbrVertexShader: {
  50791. name: string;
  50792. shader: string;
  50793. };
  50794. }
  50795. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  50796. import { Nullable } from "babylonjs/types";
  50797. import { Scene } from "babylonjs/scene";
  50798. import { Matrix } from "babylonjs/Maths/math.vector";
  50799. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50801. import { Mesh } from "babylonjs/Meshes/mesh";
  50802. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  50803. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  50804. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  50805. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  50806. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  50807. import { Color3 } from "babylonjs/Maths/math.color";
  50808. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  50809. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  50810. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  50811. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50812. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50813. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50814. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  50815. import "babylonjs/Shaders/pbr.fragment";
  50816. import "babylonjs/Shaders/pbr.vertex";
  50817. /**
  50818. * Manages the defines for the PBR Material.
  50819. * @hidden
  50820. */
  50821. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50822. PBR: boolean;
  50823. MAINUV1: boolean;
  50824. MAINUV2: boolean;
  50825. UV1: boolean;
  50826. UV2: boolean;
  50827. ALBEDO: boolean;
  50828. ALBEDODIRECTUV: number;
  50829. VERTEXCOLOR: boolean;
  50830. AMBIENT: boolean;
  50831. AMBIENTDIRECTUV: number;
  50832. AMBIENTINGRAYSCALE: boolean;
  50833. OPACITY: boolean;
  50834. VERTEXALPHA: boolean;
  50835. OPACITYDIRECTUV: number;
  50836. OPACITYRGB: boolean;
  50837. ALPHATEST: boolean;
  50838. DEPTHPREPASS: boolean;
  50839. ALPHABLEND: boolean;
  50840. ALPHAFROMALBEDO: boolean;
  50841. ALPHATESTVALUE: string;
  50842. SPECULAROVERALPHA: boolean;
  50843. RADIANCEOVERALPHA: boolean;
  50844. ALPHAFRESNEL: boolean;
  50845. LINEARALPHAFRESNEL: boolean;
  50846. PREMULTIPLYALPHA: boolean;
  50847. EMISSIVE: boolean;
  50848. EMISSIVEDIRECTUV: number;
  50849. REFLECTIVITY: boolean;
  50850. REFLECTIVITYDIRECTUV: number;
  50851. SPECULARTERM: boolean;
  50852. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50853. MICROSURFACEAUTOMATIC: boolean;
  50854. LODBASEDMICROSFURACE: boolean;
  50855. MICROSURFACEMAP: boolean;
  50856. MICROSURFACEMAPDIRECTUV: number;
  50857. METALLICWORKFLOW: boolean;
  50858. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50859. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50860. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50861. AOSTOREINMETALMAPRED: boolean;
  50862. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50863. ENVIRONMENTBRDF: boolean;
  50864. ENVIRONMENTBRDF_RGBD: boolean;
  50865. NORMAL: boolean;
  50866. TANGENT: boolean;
  50867. BUMP: boolean;
  50868. BUMPDIRECTUV: number;
  50869. OBJECTSPACE_NORMALMAP: boolean;
  50870. PARALLAX: boolean;
  50871. PARALLAXOCCLUSION: boolean;
  50872. NORMALXYSCALE: boolean;
  50873. LIGHTMAP: boolean;
  50874. LIGHTMAPDIRECTUV: number;
  50875. USELIGHTMAPASSHADOWMAP: boolean;
  50876. GAMMALIGHTMAP: boolean;
  50877. RGBDLIGHTMAP: boolean;
  50878. REFLECTION: boolean;
  50879. REFLECTIONMAP_3D: boolean;
  50880. REFLECTIONMAP_SPHERICAL: boolean;
  50881. REFLECTIONMAP_PLANAR: boolean;
  50882. REFLECTIONMAP_CUBIC: boolean;
  50883. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50884. REFLECTIONMAP_PROJECTION: boolean;
  50885. REFLECTIONMAP_SKYBOX: boolean;
  50886. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50887. REFLECTIONMAP_EXPLICIT: boolean;
  50888. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50889. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50890. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50891. INVERTCUBICMAP: boolean;
  50892. USESPHERICALFROMREFLECTIONMAP: boolean;
  50893. USEIRRADIANCEMAP: boolean;
  50894. SPHERICAL_HARMONICS: boolean;
  50895. USESPHERICALINVERTEX: boolean;
  50896. REFLECTIONMAP_OPPOSITEZ: boolean;
  50897. LODINREFLECTIONALPHA: boolean;
  50898. GAMMAREFLECTION: boolean;
  50899. RGBDREFLECTION: boolean;
  50900. LINEARSPECULARREFLECTION: boolean;
  50901. RADIANCEOCCLUSION: boolean;
  50902. HORIZONOCCLUSION: boolean;
  50903. INSTANCES: boolean;
  50904. NUM_BONE_INFLUENCERS: number;
  50905. BonesPerMesh: number;
  50906. BONETEXTURE: boolean;
  50907. NONUNIFORMSCALING: boolean;
  50908. MORPHTARGETS: boolean;
  50909. MORPHTARGETS_NORMAL: boolean;
  50910. MORPHTARGETS_TANGENT: boolean;
  50911. MORPHTARGETS_UV: boolean;
  50912. NUM_MORPH_INFLUENCERS: number;
  50913. IMAGEPROCESSING: boolean;
  50914. VIGNETTE: boolean;
  50915. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50916. VIGNETTEBLENDMODEOPAQUE: boolean;
  50917. TONEMAPPING: boolean;
  50918. TONEMAPPING_ACES: boolean;
  50919. CONTRAST: boolean;
  50920. COLORCURVES: boolean;
  50921. COLORGRADING: boolean;
  50922. COLORGRADING3D: boolean;
  50923. SAMPLER3DGREENDEPTH: boolean;
  50924. SAMPLER3DBGRMAP: boolean;
  50925. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50926. EXPOSURE: boolean;
  50927. MULTIVIEW: boolean;
  50928. USEPHYSICALLIGHTFALLOFF: boolean;
  50929. USEGLTFLIGHTFALLOFF: boolean;
  50930. TWOSIDEDLIGHTING: boolean;
  50931. SHADOWFLOAT: boolean;
  50932. CLIPPLANE: boolean;
  50933. CLIPPLANE2: boolean;
  50934. CLIPPLANE3: boolean;
  50935. CLIPPLANE4: boolean;
  50936. POINTSIZE: boolean;
  50937. FOG: boolean;
  50938. LOGARITHMICDEPTH: boolean;
  50939. FORCENORMALFORWARD: boolean;
  50940. SPECULARAA: boolean;
  50941. CLEARCOAT: boolean;
  50942. CLEARCOAT_DEFAULTIOR: boolean;
  50943. CLEARCOAT_TEXTURE: boolean;
  50944. CLEARCOAT_TEXTUREDIRECTUV: number;
  50945. CLEARCOAT_BUMP: boolean;
  50946. CLEARCOAT_BUMPDIRECTUV: number;
  50947. CLEARCOAT_TINT: boolean;
  50948. CLEARCOAT_TINT_TEXTURE: boolean;
  50949. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50950. ANISOTROPIC: boolean;
  50951. ANISOTROPIC_TEXTURE: boolean;
  50952. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50953. BRDF_V_HEIGHT_CORRELATED: boolean;
  50954. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50955. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50956. SHEEN: boolean;
  50957. SHEEN_TEXTURE: boolean;
  50958. SHEEN_TEXTUREDIRECTUV: number;
  50959. SHEEN_LINKWITHALBEDO: boolean;
  50960. SUBSURFACE: boolean;
  50961. SS_REFRACTION: boolean;
  50962. SS_TRANSLUCENCY: boolean;
  50963. SS_SCATERRING: boolean;
  50964. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50965. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50966. SS_REFRACTIONMAP_3D: boolean;
  50967. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50968. SS_LODINREFRACTIONALPHA: boolean;
  50969. SS_GAMMAREFRACTION: boolean;
  50970. SS_RGBDREFRACTION: boolean;
  50971. SS_LINEARSPECULARREFRACTION: boolean;
  50972. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50973. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50974. UNLIT: boolean;
  50975. DEBUGMODE: number;
  50976. /**
  50977. * Initializes the PBR Material defines.
  50978. */
  50979. constructor();
  50980. /**
  50981. * Resets the PBR Material defines.
  50982. */
  50983. reset(): void;
  50984. }
  50985. /**
  50986. * The Physically based material base class of BJS.
  50987. *
  50988. * This offers the main features of a standard PBR material.
  50989. * For more information, please refer to the documentation :
  50990. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50991. */
  50992. export abstract class PBRBaseMaterial extends PushMaterial {
  50993. /**
  50994. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50995. */
  50996. static readonly PBRMATERIAL_OPAQUE: number;
  50997. /**
  50998. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50999. */
  51000. static readonly PBRMATERIAL_ALPHATEST: number;
  51001. /**
  51002. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51003. */
  51004. static readonly PBRMATERIAL_ALPHABLEND: number;
  51005. /**
  51006. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51007. * They are also discarded below the alpha cutoff threshold to improve performances.
  51008. */
  51009. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51010. /**
  51011. * Defines the default value of how much AO map is occluding the analytical lights
  51012. * (point spot...).
  51013. */
  51014. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51015. /**
  51016. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51017. */
  51018. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51019. /**
  51020. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51021. * to enhance interoperability with other engines.
  51022. */
  51023. static readonly LIGHTFALLOFF_GLTF: number;
  51024. /**
  51025. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51026. * to enhance interoperability with other materials.
  51027. */
  51028. static readonly LIGHTFALLOFF_STANDARD: number;
  51029. /**
  51030. * Intensity of the direct lights e.g. the four lights available in your scene.
  51031. * This impacts both the direct diffuse and specular highlights.
  51032. */
  51033. protected _directIntensity: number;
  51034. /**
  51035. * Intensity of the emissive part of the material.
  51036. * This helps controlling the emissive effect without modifying the emissive color.
  51037. */
  51038. protected _emissiveIntensity: number;
  51039. /**
  51040. * Intensity of the environment e.g. how much the environment will light the object
  51041. * either through harmonics for rough material or through the refelction for shiny ones.
  51042. */
  51043. protected _environmentIntensity: number;
  51044. /**
  51045. * This is a special control allowing the reduction of the specular highlights coming from the
  51046. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51047. */
  51048. protected _specularIntensity: number;
  51049. /**
  51050. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51051. */
  51052. private _lightingInfos;
  51053. /**
  51054. * Debug Control allowing disabling the bump map on this material.
  51055. */
  51056. protected _disableBumpMap: boolean;
  51057. /**
  51058. * AKA Diffuse Texture in standard nomenclature.
  51059. */
  51060. protected _albedoTexture: Nullable<BaseTexture>;
  51061. /**
  51062. * AKA Occlusion Texture in other nomenclature.
  51063. */
  51064. protected _ambientTexture: Nullable<BaseTexture>;
  51065. /**
  51066. * AKA Occlusion Texture Intensity in other nomenclature.
  51067. */
  51068. protected _ambientTextureStrength: number;
  51069. /**
  51070. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51071. * 1 means it completely occludes it
  51072. * 0 mean it has no impact
  51073. */
  51074. protected _ambientTextureImpactOnAnalyticalLights: number;
  51075. /**
  51076. * Stores the alpha values in a texture.
  51077. */
  51078. protected _opacityTexture: Nullable<BaseTexture>;
  51079. /**
  51080. * Stores the reflection values in a texture.
  51081. */
  51082. protected _reflectionTexture: Nullable<BaseTexture>;
  51083. /**
  51084. * Stores the emissive values in a texture.
  51085. */
  51086. protected _emissiveTexture: Nullable<BaseTexture>;
  51087. /**
  51088. * AKA Specular texture in other nomenclature.
  51089. */
  51090. protected _reflectivityTexture: Nullable<BaseTexture>;
  51091. /**
  51092. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51093. */
  51094. protected _metallicTexture: Nullable<BaseTexture>;
  51095. /**
  51096. * Specifies the metallic scalar of the metallic/roughness workflow.
  51097. * Can also be used to scale the metalness values of the metallic texture.
  51098. */
  51099. protected _metallic: Nullable<number>;
  51100. /**
  51101. * Specifies the roughness scalar of the metallic/roughness workflow.
  51102. * Can also be used to scale the roughness values of the metallic texture.
  51103. */
  51104. protected _roughness: Nullable<number>;
  51105. /**
  51106. * Specifies the an F0 factor to help configuring the material F0.
  51107. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51108. * to 0.5 the previously hard coded value stays the same.
  51109. * Can also be used to scale the F0 values of the metallic texture.
  51110. */
  51111. protected _metallicF0Factor: number;
  51112. /**
  51113. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51114. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51115. * your expectation as it multiplies with the texture data.
  51116. */
  51117. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51118. /**
  51119. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51120. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51121. */
  51122. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51123. /**
  51124. * Stores surface normal data used to displace a mesh in a texture.
  51125. */
  51126. protected _bumpTexture: Nullable<BaseTexture>;
  51127. /**
  51128. * Stores the pre-calculated light information of a mesh in a texture.
  51129. */
  51130. protected _lightmapTexture: Nullable<BaseTexture>;
  51131. /**
  51132. * The color of a material in ambient lighting.
  51133. */
  51134. protected _ambientColor: Color3;
  51135. /**
  51136. * AKA Diffuse Color in other nomenclature.
  51137. */
  51138. protected _albedoColor: Color3;
  51139. /**
  51140. * AKA Specular Color in other nomenclature.
  51141. */
  51142. protected _reflectivityColor: Color3;
  51143. /**
  51144. * The color applied when light is reflected from a material.
  51145. */
  51146. protected _reflectionColor: Color3;
  51147. /**
  51148. * The color applied when light is emitted from a material.
  51149. */
  51150. protected _emissiveColor: Color3;
  51151. /**
  51152. * AKA Glossiness in other nomenclature.
  51153. */
  51154. protected _microSurface: number;
  51155. /**
  51156. * Specifies that the material will use the light map as a show map.
  51157. */
  51158. protected _useLightmapAsShadowmap: boolean;
  51159. /**
  51160. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51161. * makes the reflect vector face the model (under horizon).
  51162. */
  51163. protected _useHorizonOcclusion: boolean;
  51164. /**
  51165. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51166. * too much the area relying on ambient texture to define their ambient occlusion.
  51167. */
  51168. protected _useRadianceOcclusion: boolean;
  51169. /**
  51170. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51171. */
  51172. protected _useAlphaFromAlbedoTexture: boolean;
  51173. /**
  51174. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51175. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51176. */
  51177. protected _useSpecularOverAlpha: boolean;
  51178. /**
  51179. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51180. */
  51181. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51182. /**
  51183. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51184. */
  51185. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51186. /**
  51187. * Specifies if the metallic texture contains the roughness information in its green channel.
  51188. */
  51189. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51190. /**
  51191. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51192. */
  51193. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51194. /**
  51195. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51196. */
  51197. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51198. /**
  51199. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51200. */
  51201. protected _useAmbientInGrayScale: boolean;
  51202. /**
  51203. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51204. * The material will try to infer what glossiness each pixel should be.
  51205. */
  51206. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51207. /**
  51208. * Defines the falloff type used in this material.
  51209. * It by default is Physical.
  51210. */
  51211. protected _lightFalloff: number;
  51212. /**
  51213. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51214. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51215. */
  51216. protected _useRadianceOverAlpha: boolean;
  51217. /**
  51218. * Allows using an object space normal map (instead of tangent space).
  51219. */
  51220. protected _useObjectSpaceNormalMap: boolean;
  51221. /**
  51222. * Allows using the bump map in parallax mode.
  51223. */
  51224. protected _useParallax: boolean;
  51225. /**
  51226. * Allows using the bump map in parallax occlusion mode.
  51227. */
  51228. protected _useParallaxOcclusion: boolean;
  51229. /**
  51230. * Controls the scale bias of the parallax mode.
  51231. */
  51232. protected _parallaxScaleBias: number;
  51233. /**
  51234. * If sets to true, disables all the lights affecting the material.
  51235. */
  51236. protected _disableLighting: boolean;
  51237. /**
  51238. * Number of Simultaneous lights allowed on the material.
  51239. */
  51240. protected _maxSimultaneousLights: number;
  51241. /**
  51242. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51243. */
  51244. protected _invertNormalMapX: boolean;
  51245. /**
  51246. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51247. */
  51248. protected _invertNormalMapY: boolean;
  51249. /**
  51250. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51251. */
  51252. protected _twoSidedLighting: boolean;
  51253. /**
  51254. * Defines the alpha limits in alpha test mode.
  51255. */
  51256. protected _alphaCutOff: number;
  51257. /**
  51258. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51259. */
  51260. protected _forceAlphaTest: boolean;
  51261. /**
  51262. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51263. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51264. */
  51265. protected _useAlphaFresnel: boolean;
  51266. /**
  51267. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51268. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51269. */
  51270. protected _useLinearAlphaFresnel: boolean;
  51271. /**
  51272. * The transparency mode of the material.
  51273. */
  51274. protected _transparencyMode: Nullable<number>;
  51275. /**
  51276. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51277. * from cos thetav and roughness:
  51278. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51279. */
  51280. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51281. /**
  51282. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51283. */
  51284. protected _forceIrradianceInFragment: boolean;
  51285. /**
  51286. * Force normal to face away from face.
  51287. */
  51288. protected _forceNormalForward: boolean;
  51289. /**
  51290. * Enables specular anti aliasing in the PBR shader.
  51291. * It will both interacts on the Geometry for analytical and IBL lighting.
  51292. * It also prefilter the roughness map based on the bump values.
  51293. */
  51294. protected _enableSpecularAntiAliasing: boolean;
  51295. /**
  51296. * Default configuration related to image processing available in the PBR Material.
  51297. */
  51298. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51299. /**
  51300. * Keep track of the image processing observer to allow dispose and replace.
  51301. */
  51302. private _imageProcessingObserver;
  51303. /**
  51304. * Attaches a new image processing configuration to the PBR Material.
  51305. * @param configuration
  51306. */
  51307. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51308. /**
  51309. * Stores the available render targets.
  51310. */
  51311. private _renderTargets;
  51312. /**
  51313. * Sets the global ambient color for the material used in lighting calculations.
  51314. */
  51315. private _globalAmbientColor;
  51316. /**
  51317. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51318. */
  51319. private _useLogarithmicDepth;
  51320. /**
  51321. * If set to true, no lighting calculations will be applied.
  51322. */
  51323. private _unlit;
  51324. private _debugMode;
  51325. /**
  51326. * @hidden
  51327. * This is reserved for the inspector.
  51328. * Defines the material debug mode.
  51329. * It helps seeing only some components of the material while troubleshooting.
  51330. */
  51331. debugMode: number;
  51332. /**
  51333. * @hidden
  51334. * This is reserved for the inspector.
  51335. * Specify from where on screen the debug mode should start.
  51336. * The value goes from -1 (full screen) to 1 (not visible)
  51337. * It helps with side by side comparison against the final render
  51338. * This defaults to -1
  51339. */
  51340. private debugLimit;
  51341. /**
  51342. * @hidden
  51343. * This is reserved for the inspector.
  51344. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51345. * You can use the factor to better multiply the final value.
  51346. */
  51347. private debugFactor;
  51348. /**
  51349. * Defines the clear coat layer parameters for the material.
  51350. */
  51351. readonly clearCoat: PBRClearCoatConfiguration;
  51352. /**
  51353. * Defines the anisotropic parameters for the material.
  51354. */
  51355. readonly anisotropy: PBRAnisotropicConfiguration;
  51356. /**
  51357. * Defines the BRDF parameters for the material.
  51358. */
  51359. readonly brdf: PBRBRDFConfiguration;
  51360. /**
  51361. * Defines the Sheen parameters for the material.
  51362. */
  51363. readonly sheen: PBRSheenConfiguration;
  51364. /**
  51365. * Defines the SubSurface parameters for the material.
  51366. */
  51367. readonly subSurface: PBRSubSurfaceConfiguration;
  51368. /**
  51369. * Custom callback helping to override the default shader used in the material.
  51370. */
  51371. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51372. protected _rebuildInParallel: boolean;
  51373. /**
  51374. * Instantiates a new PBRMaterial instance.
  51375. *
  51376. * @param name The material name
  51377. * @param scene The scene the material will be use in.
  51378. */
  51379. constructor(name: string, scene: Scene);
  51380. /**
  51381. * Gets a boolean indicating that current material needs to register RTT
  51382. */
  51383. readonly hasRenderTargetTextures: boolean;
  51384. /**
  51385. * Gets the name of the material class.
  51386. */
  51387. getClassName(): string;
  51388. /**
  51389. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51390. */
  51391. /**
  51392. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51393. */
  51394. useLogarithmicDepth: boolean;
  51395. /**
  51396. * Gets the current transparency mode.
  51397. */
  51398. /**
  51399. * Sets the transparency mode of the material.
  51400. *
  51401. * | Value | Type | Description |
  51402. * | ----- | ----------------------------------- | ----------- |
  51403. * | 0 | OPAQUE | |
  51404. * | 1 | ALPHATEST | |
  51405. * | 2 | ALPHABLEND | |
  51406. * | 3 | ALPHATESTANDBLEND | |
  51407. *
  51408. */
  51409. transparencyMode: Nullable<number>;
  51410. /**
  51411. * Returns true if alpha blending should be disabled.
  51412. */
  51413. private readonly _disableAlphaBlending;
  51414. /**
  51415. * Specifies whether or not this material should be rendered in alpha blend mode.
  51416. */
  51417. needAlphaBlending(): boolean;
  51418. /**
  51419. * Specifies if the mesh will require alpha blending.
  51420. * @param mesh - BJS mesh.
  51421. */
  51422. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51423. /**
  51424. * Specifies whether or not this material should be rendered in alpha test mode.
  51425. */
  51426. needAlphaTesting(): boolean;
  51427. /**
  51428. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51429. */
  51430. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51431. /**
  51432. * Gets the texture used for the alpha test.
  51433. */
  51434. getAlphaTestTexture(): Nullable<BaseTexture>;
  51435. /**
  51436. * Specifies that the submesh is ready to be used.
  51437. * @param mesh - BJS mesh.
  51438. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51439. * @param useInstances - Specifies that instances should be used.
  51440. * @returns - boolean indicating that the submesh is ready or not.
  51441. */
  51442. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51443. /**
  51444. * Specifies if the material uses metallic roughness workflow.
  51445. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51446. */
  51447. isMetallicWorkflow(): boolean;
  51448. private _prepareEffect;
  51449. private _prepareDefines;
  51450. /**
  51451. * Force shader compilation
  51452. */
  51453. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51454. /**
  51455. * Initializes the uniform buffer layout for the shader.
  51456. */
  51457. buildUniformLayout(): void;
  51458. /**
  51459. * Unbinds the material from the mesh
  51460. */
  51461. unbind(): void;
  51462. /**
  51463. * Binds the submesh data.
  51464. * @param world - The world matrix.
  51465. * @param mesh - The BJS mesh.
  51466. * @param subMesh - A submesh of the BJS mesh.
  51467. */
  51468. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51469. /**
  51470. * Returns the animatable textures.
  51471. * @returns - Array of animatable textures.
  51472. */
  51473. getAnimatables(): IAnimatable[];
  51474. /**
  51475. * Returns the texture used for reflections.
  51476. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51477. */
  51478. private _getReflectionTexture;
  51479. /**
  51480. * Returns an array of the actively used textures.
  51481. * @returns - Array of BaseTextures
  51482. */
  51483. getActiveTextures(): BaseTexture[];
  51484. /**
  51485. * Checks to see if a texture is used in the material.
  51486. * @param texture - Base texture to use.
  51487. * @returns - Boolean specifying if a texture is used in the material.
  51488. */
  51489. hasTexture(texture: BaseTexture): boolean;
  51490. /**
  51491. * Disposes the resources of the material.
  51492. * @param forceDisposeEffect - Forces the disposal of effects.
  51493. * @param forceDisposeTextures - Forces the disposal of all textures.
  51494. */
  51495. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51496. }
  51497. }
  51498. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  51499. import { Nullable } from "babylonjs/types";
  51500. import { Scene } from "babylonjs/scene";
  51501. import { Color3 } from "babylonjs/Maths/math.color";
  51502. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51503. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51504. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51505. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51506. /**
  51507. * The Physically based material of BJS.
  51508. *
  51509. * This offers the main features of a standard PBR material.
  51510. * For more information, please refer to the documentation :
  51511. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51512. */
  51513. export class PBRMaterial extends PBRBaseMaterial {
  51514. /**
  51515. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51516. */
  51517. static readonly PBRMATERIAL_OPAQUE: number;
  51518. /**
  51519. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51520. */
  51521. static readonly PBRMATERIAL_ALPHATEST: number;
  51522. /**
  51523. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51524. */
  51525. static readonly PBRMATERIAL_ALPHABLEND: number;
  51526. /**
  51527. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51528. * They are also discarded below the alpha cutoff threshold to improve performances.
  51529. */
  51530. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51531. /**
  51532. * Defines the default value of how much AO map is occluding the analytical lights
  51533. * (point spot...).
  51534. */
  51535. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51536. /**
  51537. * Intensity of the direct lights e.g. the four lights available in your scene.
  51538. * This impacts both the direct diffuse and specular highlights.
  51539. */
  51540. directIntensity: number;
  51541. /**
  51542. * Intensity of the emissive part of the material.
  51543. * This helps controlling the emissive effect without modifying the emissive color.
  51544. */
  51545. emissiveIntensity: number;
  51546. /**
  51547. * Intensity of the environment e.g. how much the environment will light the object
  51548. * either through harmonics for rough material or through the refelction for shiny ones.
  51549. */
  51550. environmentIntensity: number;
  51551. /**
  51552. * This is a special control allowing the reduction of the specular highlights coming from the
  51553. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51554. */
  51555. specularIntensity: number;
  51556. /**
  51557. * Debug Control allowing disabling the bump map on this material.
  51558. */
  51559. disableBumpMap: boolean;
  51560. /**
  51561. * AKA Diffuse Texture in standard nomenclature.
  51562. */
  51563. albedoTexture: BaseTexture;
  51564. /**
  51565. * AKA Occlusion Texture in other nomenclature.
  51566. */
  51567. ambientTexture: BaseTexture;
  51568. /**
  51569. * AKA Occlusion Texture Intensity in other nomenclature.
  51570. */
  51571. ambientTextureStrength: number;
  51572. /**
  51573. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51574. * 1 means it completely occludes it
  51575. * 0 mean it has no impact
  51576. */
  51577. ambientTextureImpactOnAnalyticalLights: number;
  51578. /**
  51579. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51580. */
  51581. opacityTexture: BaseTexture;
  51582. /**
  51583. * Stores the reflection values in a texture.
  51584. */
  51585. reflectionTexture: Nullable<BaseTexture>;
  51586. /**
  51587. * Stores the emissive values in a texture.
  51588. */
  51589. emissiveTexture: BaseTexture;
  51590. /**
  51591. * AKA Specular texture in other nomenclature.
  51592. */
  51593. reflectivityTexture: BaseTexture;
  51594. /**
  51595. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51596. */
  51597. metallicTexture: BaseTexture;
  51598. /**
  51599. * Specifies the metallic scalar of the metallic/roughness workflow.
  51600. * Can also be used to scale the metalness values of the metallic texture.
  51601. */
  51602. metallic: Nullable<number>;
  51603. /**
  51604. * Specifies the roughness scalar of the metallic/roughness workflow.
  51605. * Can also be used to scale the roughness values of the metallic texture.
  51606. */
  51607. roughness: Nullable<number>;
  51608. /**
  51609. * Specifies the an F0 factor to help configuring the material F0.
  51610. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51611. * to 0.5 the previously hard coded value stays the same.
  51612. * Can also be used to scale the F0 values of the metallic texture.
  51613. */
  51614. metallicF0Factor: number;
  51615. /**
  51616. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51617. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51618. * your expectation as it multiplies with the texture data.
  51619. */
  51620. useMetallicF0FactorFromMetallicTexture: boolean;
  51621. /**
  51622. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51623. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51624. */
  51625. microSurfaceTexture: BaseTexture;
  51626. /**
  51627. * Stores surface normal data used to displace a mesh in a texture.
  51628. */
  51629. bumpTexture: BaseTexture;
  51630. /**
  51631. * Stores the pre-calculated light information of a mesh in a texture.
  51632. */
  51633. lightmapTexture: BaseTexture;
  51634. /**
  51635. * Stores the refracted light information in a texture.
  51636. */
  51637. refractionTexture: Nullable<BaseTexture>;
  51638. /**
  51639. * The color of a material in ambient lighting.
  51640. */
  51641. ambientColor: Color3;
  51642. /**
  51643. * AKA Diffuse Color in other nomenclature.
  51644. */
  51645. albedoColor: Color3;
  51646. /**
  51647. * AKA Specular Color in other nomenclature.
  51648. */
  51649. reflectivityColor: Color3;
  51650. /**
  51651. * The color reflected from the material.
  51652. */
  51653. reflectionColor: Color3;
  51654. /**
  51655. * The color emitted from the material.
  51656. */
  51657. emissiveColor: Color3;
  51658. /**
  51659. * AKA Glossiness in other nomenclature.
  51660. */
  51661. microSurface: number;
  51662. /**
  51663. * source material index of refraction (IOR)' / 'destination material IOR.
  51664. */
  51665. indexOfRefraction: number;
  51666. /**
  51667. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51668. */
  51669. invertRefractionY: boolean;
  51670. /**
  51671. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51672. * Materials half opaque for instance using refraction could benefit from this control.
  51673. */
  51674. linkRefractionWithTransparency: boolean;
  51675. /**
  51676. * If true, the light map contains occlusion information instead of lighting info.
  51677. */
  51678. useLightmapAsShadowmap: boolean;
  51679. /**
  51680. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51681. */
  51682. useAlphaFromAlbedoTexture: boolean;
  51683. /**
  51684. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51685. */
  51686. forceAlphaTest: boolean;
  51687. /**
  51688. * Defines the alpha limits in alpha test mode.
  51689. */
  51690. alphaCutOff: number;
  51691. /**
  51692. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51693. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51694. */
  51695. useSpecularOverAlpha: boolean;
  51696. /**
  51697. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51698. */
  51699. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51700. /**
  51701. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51702. */
  51703. useRoughnessFromMetallicTextureAlpha: boolean;
  51704. /**
  51705. * Specifies if the metallic texture contains the roughness information in its green channel.
  51706. */
  51707. useRoughnessFromMetallicTextureGreen: boolean;
  51708. /**
  51709. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51710. */
  51711. useMetallnessFromMetallicTextureBlue: boolean;
  51712. /**
  51713. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51714. */
  51715. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51716. /**
  51717. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51718. */
  51719. useAmbientInGrayScale: boolean;
  51720. /**
  51721. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51722. * The material will try to infer what glossiness each pixel should be.
  51723. */
  51724. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51725. /**
  51726. * BJS is using an harcoded light falloff based on a manually sets up range.
  51727. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51728. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51729. */
  51730. /**
  51731. * BJS is using an harcoded light falloff based on a manually sets up range.
  51732. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51733. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51734. */
  51735. usePhysicalLightFalloff: boolean;
  51736. /**
  51737. * In order to support the falloff compatibility with gltf, a special mode has been added
  51738. * to reproduce the gltf light falloff.
  51739. */
  51740. /**
  51741. * In order to support the falloff compatibility with gltf, a special mode has been added
  51742. * to reproduce the gltf light falloff.
  51743. */
  51744. useGLTFLightFalloff: boolean;
  51745. /**
  51746. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51747. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51748. */
  51749. useRadianceOverAlpha: boolean;
  51750. /**
  51751. * Allows using an object space normal map (instead of tangent space).
  51752. */
  51753. useObjectSpaceNormalMap: boolean;
  51754. /**
  51755. * Allows using the bump map in parallax mode.
  51756. */
  51757. useParallax: boolean;
  51758. /**
  51759. * Allows using the bump map in parallax occlusion mode.
  51760. */
  51761. useParallaxOcclusion: boolean;
  51762. /**
  51763. * Controls the scale bias of the parallax mode.
  51764. */
  51765. parallaxScaleBias: number;
  51766. /**
  51767. * If sets to true, disables all the lights affecting the material.
  51768. */
  51769. disableLighting: boolean;
  51770. /**
  51771. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51772. */
  51773. forceIrradianceInFragment: boolean;
  51774. /**
  51775. * Number of Simultaneous lights allowed on the material.
  51776. */
  51777. maxSimultaneousLights: number;
  51778. /**
  51779. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51780. */
  51781. invertNormalMapX: boolean;
  51782. /**
  51783. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51784. */
  51785. invertNormalMapY: boolean;
  51786. /**
  51787. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51788. */
  51789. twoSidedLighting: boolean;
  51790. /**
  51791. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51792. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51793. */
  51794. useAlphaFresnel: boolean;
  51795. /**
  51796. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51797. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51798. */
  51799. useLinearAlphaFresnel: boolean;
  51800. /**
  51801. * Let user defines the brdf lookup texture used for IBL.
  51802. * A default 8bit version is embedded but you could point at :
  51803. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51804. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51805. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51806. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51807. */
  51808. environmentBRDFTexture: Nullable<BaseTexture>;
  51809. /**
  51810. * Force normal to face away from face.
  51811. */
  51812. forceNormalForward: boolean;
  51813. /**
  51814. * Enables specular anti aliasing in the PBR shader.
  51815. * It will both interacts on the Geometry for analytical and IBL lighting.
  51816. * It also prefilter the roughness map based on the bump values.
  51817. */
  51818. enableSpecularAntiAliasing: boolean;
  51819. /**
  51820. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51821. * makes the reflect vector face the model (under horizon).
  51822. */
  51823. useHorizonOcclusion: boolean;
  51824. /**
  51825. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51826. * too much the area relying on ambient texture to define their ambient occlusion.
  51827. */
  51828. useRadianceOcclusion: boolean;
  51829. /**
  51830. * If set to true, no lighting calculations will be applied.
  51831. */
  51832. unlit: boolean;
  51833. /**
  51834. * Gets the image processing configuration used either in this material.
  51835. */
  51836. /**
  51837. * Sets the Default image processing configuration used either in the this material.
  51838. *
  51839. * If sets to null, the scene one is in use.
  51840. */
  51841. imageProcessingConfiguration: ImageProcessingConfiguration;
  51842. /**
  51843. * Gets wether the color curves effect is enabled.
  51844. */
  51845. /**
  51846. * Sets wether the color curves effect is enabled.
  51847. */
  51848. cameraColorCurvesEnabled: boolean;
  51849. /**
  51850. * Gets wether the color grading effect is enabled.
  51851. */
  51852. /**
  51853. * Gets wether the color grading effect is enabled.
  51854. */
  51855. cameraColorGradingEnabled: boolean;
  51856. /**
  51857. * Gets wether tonemapping is enabled or not.
  51858. */
  51859. /**
  51860. * Sets wether tonemapping is enabled or not
  51861. */
  51862. cameraToneMappingEnabled: boolean;
  51863. /**
  51864. * The camera exposure used on this material.
  51865. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51866. * This corresponds to a photographic exposure.
  51867. */
  51868. /**
  51869. * The camera exposure used on this material.
  51870. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51871. * This corresponds to a photographic exposure.
  51872. */
  51873. cameraExposure: number;
  51874. /**
  51875. * Gets The camera contrast used on this material.
  51876. */
  51877. /**
  51878. * Sets The camera contrast used on this material.
  51879. */
  51880. cameraContrast: number;
  51881. /**
  51882. * Gets the Color Grading 2D Lookup Texture.
  51883. */
  51884. /**
  51885. * Sets the Color Grading 2D Lookup Texture.
  51886. */
  51887. cameraColorGradingTexture: Nullable<BaseTexture>;
  51888. /**
  51889. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51890. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51891. * 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;
  51892. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51893. */
  51894. /**
  51895. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51896. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51897. * 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;
  51898. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51899. */
  51900. cameraColorCurves: Nullable<ColorCurves>;
  51901. /**
  51902. * Instantiates a new PBRMaterial instance.
  51903. *
  51904. * @param name The material name
  51905. * @param scene The scene the material will be use in.
  51906. */
  51907. constructor(name: string, scene: Scene);
  51908. /**
  51909. * Returns the name of this material class.
  51910. */
  51911. getClassName(): string;
  51912. /**
  51913. * Makes a duplicate of the current material.
  51914. * @param name - name to use for the new material.
  51915. */
  51916. clone(name: string): PBRMaterial;
  51917. /**
  51918. * Serializes this PBR Material.
  51919. * @returns - An object with the serialized material.
  51920. */
  51921. serialize(): any;
  51922. /**
  51923. * Parses a PBR Material from a serialized object.
  51924. * @param source - Serialized object.
  51925. * @param scene - BJS scene instance.
  51926. * @param rootUrl - url for the scene object
  51927. * @returns - PBRMaterial
  51928. */
  51929. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51930. }
  51931. }
  51932. declare module "babylonjs/Misc/dds" {
  51933. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51934. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51935. import { Nullable } from "babylonjs/types";
  51936. import { Scene } from "babylonjs/scene";
  51937. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  51938. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51939. /**
  51940. * Direct draw surface info
  51941. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51942. */
  51943. export interface DDSInfo {
  51944. /**
  51945. * Width of the texture
  51946. */
  51947. width: number;
  51948. /**
  51949. * Width of the texture
  51950. */
  51951. height: number;
  51952. /**
  51953. * Number of Mipmaps for the texture
  51954. * @see https://en.wikipedia.org/wiki/Mipmap
  51955. */
  51956. mipmapCount: number;
  51957. /**
  51958. * If the textures format is a known fourCC format
  51959. * @see https://www.fourcc.org/
  51960. */
  51961. isFourCC: boolean;
  51962. /**
  51963. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51964. */
  51965. isRGB: boolean;
  51966. /**
  51967. * If the texture is a lumincance format
  51968. */
  51969. isLuminance: boolean;
  51970. /**
  51971. * If this is a cube texture
  51972. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51973. */
  51974. isCube: boolean;
  51975. /**
  51976. * If the texture is a compressed format eg. FOURCC_DXT1
  51977. */
  51978. isCompressed: boolean;
  51979. /**
  51980. * The dxgiFormat of the texture
  51981. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51982. */
  51983. dxgiFormat: number;
  51984. /**
  51985. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51986. */
  51987. textureType: number;
  51988. /**
  51989. * Sphericle polynomial created for the dds texture
  51990. */
  51991. sphericalPolynomial?: SphericalPolynomial;
  51992. }
  51993. /**
  51994. * Class used to provide DDS decompression tools
  51995. */
  51996. export class DDSTools {
  51997. /**
  51998. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51999. */
  52000. static StoreLODInAlphaChannel: boolean;
  52001. /**
  52002. * Gets DDS information from an array buffer
  52003. * @param arrayBuffer defines the array buffer to read data from
  52004. * @returns the DDS information
  52005. */
  52006. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  52007. private static _FloatView;
  52008. private static _Int32View;
  52009. private static _ToHalfFloat;
  52010. private static _FromHalfFloat;
  52011. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52012. private static _GetHalfFloatRGBAArrayBuffer;
  52013. private static _GetFloatRGBAArrayBuffer;
  52014. private static _GetFloatAsUIntRGBAArrayBuffer;
  52015. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52016. private static _GetRGBAArrayBuffer;
  52017. private static _ExtractLongWordOrder;
  52018. private static _GetRGBArrayBuffer;
  52019. private static _GetLuminanceArrayBuffer;
  52020. /**
  52021. * Uploads DDS Levels to a Babylon Texture
  52022. * @hidden
  52023. */
  52024. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52025. }
  52026. module "babylonjs/Engines/thinEngine" {
  52027. interface ThinEngine {
  52028. /**
  52029. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52030. * @param rootUrl defines the url where the file to load is located
  52031. * @param scene defines the current scene
  52032. * @param lodScale defines scale to apply to the mip map selection
  52033. * @param lodOffset defines offset to apply to the mip map selection
  52034. * @param onLoad defines an optional callback raised when the texture is loaded
  52035. * @param onError defines an optional callback raised if there is an issue to load the texture
  52036. * @param format defines the format of the data
  52037. * @param forcedExtension defines the extension to use to pick the right loader
  52038. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52039. * @returns the cube texture as an InternalTexture
  52040. */
  52041. 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;
  52042. }
  52043. }
  52044. }
  52045. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  52046. import { Nullable } from "babylonjs/types";
  52047. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52048. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52049. /**
  52050. * Implementation of the DDS Texture Loader.
  52051. * @hidden
  52052. */
  52053. export class _DDSTextureLoader implements IInternalTextureLoader {
  52054. /**
  52055. * Defines wether the loader supports cascade loading the different faces.
  52056. */
  52057. readonly supportCascades: boolean;
  52058. /**
  52059. * This returns if the loader support the current file information.
  52060. * @param extension defines the file extension of the file being loaded
  52061. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52062. * @param fallback defines the fallback internal texture if any
  52063. * @param isBase64 defines whether the texture is encoded as a base64
  52064. * @param isBuffer defines whether the texture data are stored as a buffer
  52065. * @returns true if the loader can load the specified file
  52066. */
  52067. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52068. /**
  52069. * Transform the url before loading if required.
  52070. * @param rootUrl the url of the texture
  52071. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52072. * @returns the transformed texture
  52073. */
  52074. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52075. /**
  52076. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52077. * @param rootUrl the url of the texture
  52078. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52079. * @returns the fallback texture
  52080. */
  52081. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52082. /**
  52083. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52084. * @param data contains the texture data
  52085. * @param texture defines the BabylonJS internal texture
  52086. * @param createPolynomials will be true if polynomials have been requested
  52087. * @param onLoad defines the callback to trigger once the texture is ready
  52088. * @param onError defines the callback to trigger in case of error
  52089. */
  52090. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52091. /**
  52092. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52093. * @param data contains the texture data
  52094. * @param texture defines the BabylonJS internal texture
  52095. * @param callback defines the method to call once ready to upload
  52096. */
  52097. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52098. }
  52099. }
  52100. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  52101. import { Nullable } from "babylonjs/types";
  52102. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52103. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52104. /**
  52105. * Implementation of the ENV Texture Loader.
  52106. * @hidden
  52107. */
  52108. export class _ENVTextureLoader implements IInternalTextureLoader {
  52109. /**
  52110. * Defines wether the loader supports cascade loading the different faces.
  52111. */
  52112. readonly supportCascades: boolean;
  52113. /**
  52114. * This returns if the loader support the current file information.
  52115. * @param extension defines the file extension of the file being loaded
  52116. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52117. * @param fallback defines the fallback internal texture if any
  52118. * @param isBase64 defines whether the texture is encoded as a base64
  52119. * @param isBuffer defines whether the texture data are stored as a buffer
  52120. * @returns true if the loader can load the specified file
  52121. */
  52122. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52123. /**
  52124. * Transform the url before loading if required.
  52125. * @param rootUrl the url of the texture
  52126. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52127. * @returns the transformed texture
  52128. */
  52129. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52130. /**
  52131. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52132. * @param rootUrl the url of the texture
  52133. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52134. * @returns the fallback texture
  52135. */
  52136. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52137. /**
  52138. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52139. * @param data contains the texture data
  52140. * @param texture defines the BabylonJS internal texture
  52141. * @param createPolynomials will be true if polynomials have been requested
  52142. * @param onLoad defines the callback to trigger once the texture is ready
  52143. * @param onError defines the callback to trigger in case of error
  52144. */
  52145. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52146. /**
  52147. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52148. * @param data contains the texture data
  52149. * @param texture defines the BabylonJS internal texture
  52150. * @param callback defines the method to call once ready to upload
  52151. */
  52152. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52153. }
  52154. }
  52155. declare module "babylonjs/Misc/khronosTextureContainer" {
  52156. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52157. /**
  52158. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52159. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52160. */
  52161. export class KhronosTextureContainer {
  52162. /** contents of the KTX container file */
  52163. arrayBuffer: any;
  52164. private static HEADER_LEN;
  52165. private static COMPRESSED_2D;
  52166. private static COMPRESSED_3D;
  52167. private static TEX_2D;
  52168. private static TEX_3D;
  52169. /**
  52170. * Gets the openGL type
  52171. */
  52172. glType: number;
  52173. /**
  52174. * Gets the openGL type size
  52175. */
  52176. glTypeSize: number;
  52177. /**
  52178. * Gets the openGL format
  52179. */
  52180. glFormat: number;
  52181. /**
  52182. * Gets the openGL internal format
  52183. */
  52184. glInternalFormat: number;
  52185. /**
  52186. * Gets the base internal format
  52187. */
  52188. glBaseInternalFormat: number;
  52189. /**
  52190. * Gets image width in pixel
  52191. */
  52192. pixelWidth: number;
  52193. /**
  52194. * Gets image height in pixel
  52195. */
  52196. pixelHeight: number;
  52197. /**
  52198. * Gets image depth in pixels
  52199. */
  52200. pixelDepth: number;
  52201. /**
  52202. * Gets the number of array elements
  52203. */
  52204. numberOfArrayElements: number;
  52205. /**
  52206. * Gets the number of faces
  52207. */
  52208. numberOfFaces: number;
  52209. /**
  52210. * Gets the number of mipmap levels
  52211. */
  52212. numberOfMipmapLevels: number;
  52213. /**
  52214. * Gets the bytes of key value data
  52215. */
  52216. bytesOfKeyValueData: number;
  52217. /**
  52218. * Gets the load type
  52219. */
  52220. loadType: number;
  52221. /**
  52222. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52223. */
  52224. isInvalid: boolean;
  52225. /**
  52226. * Creates a new KhronosTextureContainer
  52227. * @param arrayBuffer contents of the KTX container file
  52228. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52229. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52230. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52231. */
  52232. constructor(
  52233. /** contents of the KTX container file */
  52234. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52235. /**
  52236. * Uploads KTX content to a Babylon Texture.
  52237. * It is assumed that the texture has already been created & is currently bound
  52238. * @hidden
  52239. */
  52240. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52241. private _upload2DCompressedLevels;
  52242. }
  52243. }
  52244. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  52245. import { Nullable } from "babylonjs/types";
  52246. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52247. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52248. /**
  52249. * Implementation of the KTX Texture Loader.
  52250. * @hidden
  52251. */
  52252. export class _KTXTextureLoader implements IInternalTextureLoader {
  52253. /**
  52254. * Defines wether the loader supports cascade loading the different faces.
  52255. */
  52256. readonly supportCascades: boolean;
  52257. /**
  52258. * This returns if the loader support the current file information.
  52259. * @param extension defines the file extension of the file being loaded
  52260. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52261. * @param fallback defines the fallback internal texture if any
  52262. * @param isBase64 defines whether the texture is encoded as a base64
  52263. * @param isBuffer defines whether the texture data are stored as a buffer
  52264. * @returns true if the loader can load the specified file
  52265. */
  52266. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52267. /**
  52268. * Transform the url before loading if required.
  52269. * @param rootUrl the url of the texture
  52270. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52271. * @returns the transformed texture
  52272. */
  52273. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52274. /**
  52275. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52276. * @param rootUrl the url of the texture
  52277. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52278. * @returns the fallback texture
  52279. */
  52280. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52281. /**
  52282. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52283. * @param data contains the texture data
  52284. * @param texture defines the BabylonJS internal texture
  52285. * @param createPolynomials will be true if polynomials have been requested
  52286. * @param onLoad defines the callback to trigger once the texture is ready
  52287. * @param onError defines the callback to trigger in case of error
  52288. */
  52289. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52290. /**
  52291. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52292. * @param data contains the texture data
  52293. * @param texture defines the BabylonJS internal texture
  52294. * @param callback defines the method to call once ready to upload
  52295. */
  52296. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52297. }
  52298. }
  52299. declare module "babylonjs/Helpers/sceneHelpers" {
  52300. import { Nullable } from "babylonjs/types";
  52301. import { Mesh } from "babylonjs/Meshes/mesh";
  52302. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52303. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  52304. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  52305. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52306. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52307. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52308. import "babylonjs/Meshes/Builders/boxBuilder";
  52309. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  52310. /** @hidden */
  52311. export var _forceSceneHelpersToBundle: boolean;
  52312. module "babylonjs/scene" {
  52313. interface Scene {
  52314. /**
  52315. * Creates a default light for the scene.
  52316. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52317. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52318. */
  52319. createDefaultLight(replace?: boolean): void;
  52320. /**
  52321. * Creates a default camera for the scene.
  52322. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52323. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52324. * @param replace has default false, when true replaces the active camera in the scene
  52325. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52326. */
  52327. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52328. /**
  52329. * Creates a default camera and a default light.
  52330. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52331. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52332. * @param replace has the default false, when true replaces the active camera/light in the scene
  52333. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52334. */
  52335. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52336. /**
  52337. * Creates a new sky box
  52338. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52339. * @param environmentTexture defines the texture to use as environment texture
  52340. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52341. * @param scale defines the overall scale of the skybox
  52342. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52343. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52344. * @returns a new mesh holding the sky box
  52345. */
  52346. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52347. /**
  52348. * Creates a new environment
  52349. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52350. * @param options defines the options you can use to configure the environment
  52351. * @returns the new EnvironmentHelper
  52352. */
  52353. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52354. /**
  52355. * Creates a new VREXperienceHelper
  52356. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52357. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52358. * @returns a new VREXperienceHelper
  52359. */
  52360. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52361. /**
  52362. * Creates a new WebXRDefaultExperience
  52363. * @see http://doc.babylonjs.com/how_to/webxr
  52364. * @param options experience options
  52365. * @returns a promise for a new WebXRDefaultExperience
  52366. */
  52367. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52368. }
  52369. }
  52370. }
  52371. declare module "babylonjs/Helpers/videoDome" {
  52372. import { Scene } from "babylonjs/scene";
  52373. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52374. import { Mesh } from "babylonjs/Meshes/mesh";
  52375. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  52376. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52377. import "babylonjs/Meshes/Builders/sphereBuilder";
  52378. /**
  52379. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52380. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52381. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52382. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52383. */
  52384. export class VideoDome extends TransformNode {
  52385. /**
  52386. * Define the video source as a Monoscopic panoramic 360 video.
  52387. */
  52388. static readonly MODE_MONOSCOPIC: number;
  52389. /**
  52390. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52391. */
  52392. static readonly MODE_TOPBOTTOM: number;
  52393. /**
  52394. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52395. */
  52396. static readonly MODE_SIDEBYSIDE: number;
  52397. private _halfDome;
  52398. private _useDirectMapping;
  52399. /**
  52400. * The video texture being displayed on the sphere
  52401. */
  52402. protected _videoTexture: VideoTexture;
  52403. /**
  52404. * Gets the video texture being displayed on the sphere
  52405. */
  52406. readonly videoTexture: VideoTexture;
  52407. /**
  52408. * The skybox material
  52409. */
  52410. protected _material: BackgroundMaterial;
  52411. /**
  52412. * The surface used for the skybox
  52413. */
  52414. protected _mesh: Mesh;
  52415. /**
  52416. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52417. */
  52418. private _halfDomeMask;
  52419. /**
  52420. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52421. * Also see the options.resolution property.
  52422. */
  52423. fovMultiplier: number;
  52424. private _videoMode;
  52425. /**
  52426. * Gets or set the current video mode for the video. It can be:
  52427. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52428. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52429. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52430. */
  52431. videoMode: number;
  52432. /**
  52433. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52434. *
  52435. */
  52436. /**
  52437. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52438. */
  52439. halfDome: boolean;
  52440. /**
  52441. * Oberserver used in Stereoscopic VR Mode.
  52442. */
  52443. private _onBeforeCameraRenderObserver;
  52444. /**
  52445. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52446. * @param name Element's name, child elements will append suffixes for their own names.
  52447. * @param urlsOrVideo defines the url(s) or the video element to use
  52448. * @param options An object containing optional or exposed sub element properties
  52449. */
  52450. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52451. resolution?: number;
  52452. clickToPlay?: boolean;
  52453. autoPlay?: boolean;
  52454. loop?: boolean;
  52455. size?: number;
  52456. poster?: string;
  52457. faceForward?: boolean;
  52458. useDirectMapping?: boolean;
  52459. halfDomeMode?: boolean;
  52460. }, scene: Scene);
  52461. private _changeVideoMode;
  52462. /**
  52463. * Releases resources associated with this node.
  52464. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52465. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52466. */
  52467. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52468. }
  52469. }
  52470. declare module "babylonjs/Helpers/index" {
  52471. export * from "babylonjs/Helpers/environmentHelper";
  52472. export * from "babylonjs/Helpers/photoDome";
  52473. export * from "babylonjs/Helpers/sceneHelpers";
  52474. export * from "babylonjs/Helpers/videoDome";
  52475. }
  52476. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  52477. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  52478. import { IDisposable } from "babylonjs/scene";
  52479. import { Engine } from "babylonjs/Engines/engine";
  52480. /**
  52481. * This class can be used to get instrumentation data from a Babylon engine
  52482. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52483. */
  52484. export class EngineInstrumentation implements IDisposable {
  52485. /**
  52486. * Define the instrumented engine.
  52487. */
  52488. engine: Engine;
  52489. private _captureGPUFrameTime;
  52490. private _gpuFrameTimeToken;
  52491. private _gpuFrameTime;
  52492. private _captureShaderCompilationTime;
  52493. private _shaderCompilationTime;
  52494. private _onBeginFrameObserver;
  52495. private _onEndFrameObserver;
  52496. private _onBeforeShaderCompilationObserver;
  52497. private _onAfterShaderCompilationObserver;
  52498. /**
  52499. * Gets the perf counter used for GPU frame time
  52500. */
  52501. readonly gpuFrameTimeCounter: PerfCounter;
  52502. /**
  52503. * Gets the GPU frame time capture status
  52504. */
  52505. /**
  52506. * Enable or disable the GPU frame time capture
  52507. */
  52508. captureGPUFrameTime: boolean;
  52509. /**
  52510. * Gets the perf counter used for shader compilation time
  52511. */
  52512. readonly shaderCompilationTimeCounter: PerfCounter;
  52513. /**
  52514. * Gets the shader compilation time capture status
  52515. */
  52516. /**
  52517. * Enable or disable the shader compilation time capture
  52518. */
  52519. captureShaderCompilationTime: boolean;
  52520. /**
  52521. * Instantiates a new engine instrumentation.
  52522. * This class can be used to get instrumentation data from a Babylon engine
  52523. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52524. * @param engine Defines the engine to instrument
  52525. */
  52526. constructor(
  52527. /**
  52528. * Define the instrumented engine.
  52529. */
  52530. engine: Engine);
  52531. /**
  52532. * Dispose and release associated resources.
  52533. */
  52534. dispose(): void;
  52535. }
  52536. }
  52537. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  52538. import { Scene, IDisposable } from "babylonjs/scene";
  52539. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  52540. /**
  52541. * This class can be used to get instrumentation data from a Babylon engine
  52542. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52543. */
  52544. export class SceneInstrumentation implements IDisposable {
  52545. /**
  52546. * Defines the scene to instrument
  52547. */
  52548. scene: Scene;
  52549. private _captureActiveMeshesEvaluationTime;
  52550. private _activeMeshesEvaluationTime;
  52551. private _captureRenderTargetsRenderTime;
  52552. private _renderTargetsRenderTime;
  52553. private _captureFrameTime;
  52554. private _frameTime;
  52555. private _captureRenderTime;
  52556. private _renderTime;
  52557. private _captureInterFrameTime;
  52558. private _interFrameTime;
  52559. private _captureParticlesRenderTime;
  52560. private _particlesRenderTime;
  52561. private _captureSpritesRenderTime;
  52562. private _spritesRenderTime;
  52563. private _capturePhysicsTime;
  52564. private _physicsTime;
  52565. private _captureAnimationsTime;
  52566. private _animationsTime;
  52567. private _captureCameraRenderTime;
  52568. private _cameraRenderTime;
  52569. private _onBeforeActiveMeshesEvaluationObserver;
  52570. private _onAfterActiveMeshesEvaluationObserver;
  52571. private _onBeforeRenderTargetsRenderObserver;
  52572. private _onAfterRenderTargetsRenderObserver;
  52573. private _onAfterRenderObserver;
  52574. private _onBeforeDrawPhaseObserver;
  52575. private _onAfterDrawPhaseObserver;
  52576. private _onBeforeAnimationsObserver;
  52577. private _onBeforeParticlesRenderingObserver;
  52578. private _onAfterParticlesRenderingObserver;
  52579. private _onBeforeSpritesRenderingObserver;
  52580. private _onAfterSpritesRenderingObserver;
  52581. private _onBeforePhysicsObserver;
  52582. private _onAfterPhysicsObserver;
  52583. private _onAfterAnimationsObserver;
  52584. private _onBeforeCameraRenderObserver;
  52585. private _onAfterCameraRenderObserver;
  52586. /**
  52587. * Gets the perf counter used for active meshes evaluation time
  52588. */
  52589. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  52590. /**
  52591. * Gets the active meshes evaluation time capture status
  52592. */
  52593. /**
  52594. * Enable or disable the active meshes evaluation time capture
  52595. */
  52596. captureActiveMeshesEvaluationTime: boolean;
  52597. /**
  52598. * Gets the perf counter used for render targets render time
  52599. */
  52600. readonly renderTargetsRenderTimeCounter: PerfCounter;
  52601. /**
  52602. * Gets the render targets render time capture status
  52603. */
  52604. /**
  52605. * Enable or disable the render targets render time capture
  52606. */
  52607. captureRenderTargetsRenderTime: boolean;
  52608. /**
  52609. * Gets the perf counter used for particles render time
  52610. */
  52611. readonly particlesRenderTimeCounter: PerfCounter;
  52612. /**
  52613. * Gets the particles render time capture status
  52614. */
  52615. /**
  52616. * Enable or disable the particles render time capture
  52617. */
  52618. captureParticlesRenderTime: boolean;
  52619. /**
  52620. * Gets the perf counter used for sprites render time
  52621. */
  52622. readonly spritesRenderTimeCounter: PerfCounter;
  52623. /**
  52624. * Gets the sprites render time capture status
  52625. */
  52626. /**
  52627. * Enable or disable the sprites render time capture
  52628. */
  52629. captureSpritesRenderTime: boolean;
  52630. /**
  52631. * Gets the perf counter used for physics time
  52632. */
  52633. readonly physicsTimeCounter: PerfCounter;
  52634. /**
  52635. * Gets the physics time capture status
  52636. */
  52637. /**
  52638. * Enable or disable the physics time capture
  52639. */
  52640. capturePhysicsTime: boolean;
  52641. /**
  52642. * Gets the perf counter used for animations time
  52643. */
  52644. readonly animationsTimeCounter: PerfCounter;
  52645. /**
  52646. * Gets the animations time capture status
  52647. */
  52648. /**
  52649. * Enable or disable the animations time capture
  52650. */
  52651. captureAnimationsTime: boolean;
  52652. /**
  52653. * Gets the perf counter used for frame time capture
  52654. */
  52655. readonly frameTimeCounter: PerfCounter;
  52656. /**
  52657. * Gets the frame time capture status
  52658. */
  52659. /**
  52660. * Enable or disable the frame time capture
  52661. */
  52662. captureFrameTime: boolean;
  52663. /**
  52664. * Gets the perf counter used for inter-frames time capture
  52665. */
  52666. readonly interFrameTimeCounter: PerfCounter;
  52667. /**
  52668. * Gets the inter-frames time capture status
  52669. */
  52670. /**
  52671. * Enable or disable the inter-frames time capture
  52672. */
  52673. captureInterFrameTime: boolean;
  52674. /**
  52675. * Gets the perf counter used for render time capture
  52676. */
  52677. readonly renderTimeCounter: PerfCounter;
  52678. /**
  52679. * Gets the render time capture status
  52680. */
  52681. /**
  52682. * Enable or disable the render time capture
  52683. */
  52684. captureRenderTime: boolean;
  52685. /**
  52686. * Gets the perf counter used for camera render time capture
  52687. */
  52688. readonly cameraRenderTimeCounter: PerfCounter;
  52689. /**
  52690. * Gets the camera render time capture status
  52691. */
  52692. /**
  52693. * Enable or disable the camera render time capture
  52694. */
  52695. captureCameraRenderTime: boolean;
  52696. /**
  52697. * Gets the perf counter used for draw calls
  52698. */
  52699. readonly drawCallsCounter: PerfCounter;
  52700. /**
  52701. * Instantiates a new scene instrumentation.
  52702. * This class can be used to get instrumentation data from a Babylon engine
  52703. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52704. * @param scene Defines the scene to instrument
  52705. */
  52706. constructor(
  52707. /**
  52708. * Defines the scene to instrument
  52709. */
  52710. scene: Scene);
  52711. /**
  52712. * Dispose and release associated resources.
  52713. */
  52714. dispose(): void;
  52715. }
  52716. }
  52717. declare module "babylonjs/Instrumentation/index" {
  52718. export * from "babylonjs/Instrumentation/engineInstrumentation";
  52719. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  52720. export * from "babylonjs/Instrumentation/timeToken";
  52721. }
  52722. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  52723. /** @hidden */
  52724. export var glowMapGenerationPixelShader: {
  52725. name: string;
  52726. shader: string;
  52727. };
  52728. }
  52729. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  52730. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52731. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52732. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52733. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52734. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52735. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52736. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52737. /** @hidden */
  52738. export var glowMapGenerationVertexShader: {
  52739. name: string;
  52740. shader: string;
  52741. };
  52742. }
  52743. declare module "babylonjs/Layers/effectLayer" {
  52744. import { Observable } from "babylonjs/Misc/observable";
  52745. import { Nullable } from "babylonjs/types";
  52746. import { Camera } from "babylonjs/Cameras/camera";
  52747. import { Scene } from "babylonjs/scene";
  52748. import { ISize } from "babylonjs/Maths/math.size";
  52749. import { Color4 } from "babylonjs/Maths/math.color";
  52750. import { Engine } from "babylonjs/Engines/engine";
  52751. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52753. import { Mesh } from "babylonjs/Meshes/mesh";
  52754. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52755. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52756. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52757. import { Effect } from "babylonjs/Materials/effect";
  52758. import { Material } from "babylonjs/Materials/material";
  52759. import "babylonjs/Shaders/glowMapGeneration.fragment";
  52760. import "babylonjs/Shaders/glowMapGeneration.vertex";
  52761. /**
  52762. * Effect layer options. This helps customizing the behaviour
  52763. * of the effect layer.
  52764. */
  52765. export interface IEffectLayerOptions {
  52766. /**
  52767. * Multiplication factor apply to the canvas size to compute the render target size
  52768. * used to generated the objects (the smaller the faster).
  52769. */
  52770. mainTextureRatio: number;
  52771. /**
  52772. * Enforces a fixed size texture to ensure effect stability across devices.
  52773. */
  52774. mainTextureFixedSize?: number;
  52775. /**
  52776. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52777. */
  52778. alphaBlendingMode: number;
  52779. /**
  52780. * The camera attached to the layer.
  52781. */
  52782. camera: Nullable<Camera>;
  52783. /**
  52784. * The rendering group to draw the layer in.
  52785. */
  52786. renderingGroupId: number;
  52787. }
  52788. /**
  52789. * The effect layer Helps adding post process effect blended with the main pass.
  52790. *
  52791. * This can be for instance use to generate glow or higlight effects on the scene.
  52792. *
  52793. * The effect layer class can not be used directly and is intented to inherited from to be
  52794. * customized per effects.
  52795. */
  52796. export abstract class EffectLayer {
  52797. private _vertexBuffers;
  52798. private _indexBuffer;
  52799. private _cachedDefines;
  52800. private _effectLayerMapGenerationEffect;
  52801. private _effectLayerOptions;
  52802. private _mergeEffect;
  52803. protected _scene: Scene;
  52804. protected _engine: Engine;
  52805. protected _maxSize: number;
  52806. protected _mainTextureDesiredSize: ISize;
  52807. protected _mainTexture: RenderTargetTexture;
  52808. protected _shouldRender: boolean;
  52809. protected _postProcesses: PostProcess[];
  52810. protected _textures: BaseTexture[];
  52811. protected _emissiveTextureAndColor: {
  52812. texture: Nullable<BaseTexture>;
  52813. color: Color4;
  52814. };
  52815. /**
  52816. * The name of the layer
  52817. */
  52818. name: string;
  52819. /**
  52820. * The clear color of the texture used to generate the glow map.
  52821. */
  52822. neutralColor: Color4;
  52823. /**
  52824. * Specifies wether the highlight layer is enabled or not.
  52825. */
  52826. isEnabled: boolean;
  52827. /**
  52828. * Gets the camera attached to the layer.
  52829. */
  52830. readonly camera: Nullable<Camera>;
  52831. /**
  52832. * Gets the rendering group id the layer should render in.
  52833. */
  52834. renderingGroupId: number;
  52835. /**
  52836. * An event triggered when the effect layer has been disposed.
  52837. */
  52838. onDisposeObservable: Observable<EffectLayer>;
  52839. /**
  52840. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52841. */
  52842. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52843. /**
  52844. * An event triggered when the generated texture is being merged in the scene.
  52845. */
  52846. onBeforeComposeObservable: Observable<EffectLayer>;
  52847. /**
  52848. * An event triggered when the mesh is rendered into the effect render target.
  52849. */
  52850. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52851. /**
  52852. * An event triggered after the mesh has been rendered into the effect render target.
  52853. */
  52854. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52855. /**
  52856. * An event triggered when the generated texture has been merged in the scene.
  52857. */
  52858. onAfterComposeObservable: Observable<EffectLayer>;
  52859. /**
  52860. * An event triggered when the efffect layer changes its size.
  52861. */
  52862. onSizeChangedObservable: Observable<EffectLayer>;
  52863. /** @hidden */
  52864. static _SceneComponentInitialization: (scene: Scene) => void;
  52865. /**
  52866. * Instantiates a new effect Layer and references it in the scene.
  52867. * @param name The name of the layer
  52868. * @param scene The scene to use the layer in
  52869. */
  52870. constructor(
  52871. /** The Friendly of the effect in the scene */
  52872. name: string, scene: Scene);
  52873. /**
  52874. * Get the effect name of the layer.
  52875. * @return The effect name
  52876. */
  52877. abstract getEffectName(): string;
  52878. /**
  52879. * Checks for the readiness of the element composing the layer.
  52880. * @param subMesh the mesh to check for
  52881. * @param useInstances specify wether or not to use instances to render the mesh
  52882. * @return true if ready otherwise, false
  52883. */
  52884. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52885. /**
  52886. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52887. * @returns true if the effect requires stencil during the main canvas render pass.
  52888. */
  52889. abstract needStencil(): boolean;
  52890. /**
  52891. * Create the merge effect. This is the shader use to blit the information back
  52892. * to the main canvas at the end of the scene rendering.
  52893. * @returns The effect containing the shader used to merge the effect on the main canvas
  52894. */
  52895. protected abstract _createMergeEffect(): Effect;
  52896. /**
  52897. * Creates the render target textures and post processes used in the effect layer.
  52898. */
  52899. protected abstract _createTextureAndPostProcesses(): void;
  52900. /**
  52901. * Implementation specific of rendering the generating effect on the main canvas.
  52902. * @param effect The effect used to render through
  52903. */
  52904. protected abstract _internalRender(effect: Effect): void;
  52905. /**
  52906. * Sets the required values for both the emissive texture and and the main color.
  52907. */
  52908. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52909. /**
  52910. * Free any resources and references associated to a mesh.
  52911. * Internal use
  52912. * @param mesh The mesh to free.
  52913. */
  52914. abstract _disposeMesh(mesh: Mesh): void;
  52915. /**
  52916. * Serializes this layer (Glow or Highlight for example)
  52917. * @returns a serialized layer object
  52918. */
  52919. abstract serialize?(): any;
  52920. /**
  52921. * Initializes the effect layer with the required options.
  52922. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52923. */
  52924. protected _init(options: Partial<IEffectLayerOptions>): void;
  52925. /**
  52926. * Generates the index buffer of the full screen quad blending to the main canvas.
  52927. */
  52928. private _generateIndexBuffer;
  52929. /**
  52930. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52931. */
  52932. private _generateVertexBuffer;
  52933. /**
  52934. * Sets the main texture desired size which is the closest power of two
  52935. * of the engine canvas size.
  52936. */
  52937. private _setMainTextureSize;
  52938. /**
  52939. * Creates the main texture for the effect layer.
  52940. */
  52941. protected _createMainTexture(): void;
  52942. /**
  52943. * Adds specific effects defines.
  52944. * @param defines The defines to add specifics to.
  52945. */
  52946. protected _addCustomEffectDefines(defines: string[]): void;
  52947. /**
  52948. * Checks for the readiness of the element composing the layer.
  52949. * @param subMesh the mesh to check for
  52950. * @param useInstances specify wether or not to use instances to render the mesh
  52951. * @param emissiveTexture the associated emissive texture used to generate the glow
  52952. * @return true if ready otherwise, false
  52953. */
  52954. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52955. /**
  52956. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52957. */
  52958. render(): void;
  52959. /**
  52960. * Determine if a given mesh will be used in the current effect.
  52961. * @param mesh mesh to test
  52962. * @returns true if the mesh will be used
  52963. */
  52964. hasMesh(mesh: AbstractMesh): boolean;
  52965. /**
  52966. * Returns true if the layer contains information to display, otherwise false.
  52967. * @returns true if the glow layer should be rendered
  52968. */
  52969. shouldRender(): boolean;
  52970. /**
  52971. * Returns true if the mesh should render, otherwise false.
  52972. * @param mesh The mesh to render
  52973. * @returns true if it should render otherwise false
  52974. */
  52975. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52976. /**
  52977. * Returns true if the mesh can be rendered, otherwise false.
  52978. * @param mesh The mesh to render
  52979. * @param material The material used on the mesh
  52980. * @returns true if it can be rendered otherwise false
  52981. */
  52982. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52983. /**
  52984. * Returns true if the mesh should render, otherwise false.
  52985. * @param mesh The mesh to render
  52986. * @returns true if it should render otherwise false
  52987. */
  52988. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52989. /**
  52990. * Renders the submesh passed in parameter to the generation map.
  52991. */
  52992. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52993. /**
  52994. * Defines wether the current material of the mesh should be use to render the effect.
  52995. * @param mesh defines the current mesh to render
  52996. */
  52997. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52998. /**
  52999. * Rebuild the required buffers.
  53000. * @hidden Internal use only.
  53001. */
  53002. _rebuild(): void;
  53003. /**
  53004. * Dispose only the render target textures and post process.
  53005. */
  53006. private _disposeTextureAndPostProcesses;
  53007. /**
  53008. * Dispose the highlight layer and free resources.
  53009. */
  53010. dispose(): void;
  53011. /**
  53012. * Gets the class name of the effect layer
  53013. * @returns the string with the class name of the effect layer
  53014. */
  53015. getClassName(): string;
  53016. /**
  53017. * Creates an effect layer from parsed effect layer data
  53018. * @param parsedEffectLayer defines effect layer data
  53019. * @param scene defines the current scene
  53020. * @param rootUrl defines the root URL containing the effect layer information
  53021. * @returns a parsed effect Layer
  53022. */
  53023. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53024. }
  53025. }
  53026. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  53027. import { Scene } from "babylonjs/scene";
  53028. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53029. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  53030. import { AbstractScene } from "babylonjs/abstractScene";
  53031. module "babylonjs/abstractScene" {
  53032. interface AbstractScene {
  53033. /**
  53034. * The list of effect layers (highlights/glow) added to the scene
  53035. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53036. * @see http://doc.babylonjs.com/how_to/glow_layer
  53037. */
  53038. effectLayers: Array<EffectLayer>;
  53039. /**
  53040. * Removes the given effect layer from this scene.
  53041. * @param toRemove defines the effect layer to remove
  53042. * @returns the index of the removed effect layer
  53043. */
  53044. removeEffectLayer(toRemove: EffectLayer): number;
  53045. /**
  53046. * Adds the given effect layer to this scene
  53047. * @param newEffectLayer defines the effect layer to add
  53048. */
  53049. addEffectLayer(newEffectLayer: EffectLayer): void;
  53050. }
  53051. }
  53052. /**
  53053. * Defines the layer scene component responsible to manage any effect layers
  53054. * in a given scene.
  53055. */
  53056. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53057. /**
  53058. * The component name helpfull to identify the component in the list of scene components.
  53059. */
  53060. readonly name: string;
  53061. /**
  53062. * The scene the component belongs to.
  53063. */
  53064. scene: Scene;
  53065. private _engine;
  53066. private _renderEffects;
  53067. private _needStencil;
  53068. private _previousStencilState;
  53069. /**
  53070. * Creates a new instance of the component for the given scene
  53071. * @param scene Defines the scene to register the component in
  53072. */
  53073. constructor(scene: Scene);
  53074. /**
  53075. * Registers the component in a given scene
  53076. */
  53077. register(): void;
  53078. /**
  53079. * Rebuilds the elements related to this component in case of
  53080. * context lost for instance.
  53081. */
  53082. rebuild(): void;
  53083. /**
  53084. * Serializes the component data to the specified json object
  53085. * @param serializationObject The object to serialize to
  53086. */
  53087. serialize(serializationObject: any): void;
  53088. /**
  53089. * Adds all the elements from the container to the scene
  53090. * @param container the container holding the elements
  53091. */
  53092. addFromContainer(container: AbstractScene): void;
  53093. /**
  53094. * Removes all the elements in the container from the scene
  53095. * @param container contains the elements to remove
  53096. * @param dispose if the removed element should be disposed (default: false)
  53097. */
  53098. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53099. /**
  53100. * Disposes the component and the associated ressources.
  53101. */
  53102. dispose(): void;
  53103. private _isReadyForMesh;
  53104. private _renderMainTexture;
  53105. private _setStencil;
  53106. private _setStencilBack;
  53107. private _draw;
  53108. private _drawCamera;
  53109. private _drawRenderingGroup;
  53110. }
  53111. }
  53112. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  53113. /** @hidden */
  53114. export var glowMapMergePixelShader: {
  53115. name: string;
  53116. shader: string;
  53117. };
  53118. }
  53119. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  53120. /** @hidden */
  53121. export var glowMapMergeVertexShader: {
  53122. name: string;
  53123. shader: string;
  53124. };
  53125. }
  53126. declare module "babylonjs/Layers/glowLayer" {
  53127. import { Nullable } from "babylonjs/types";
  53128. import { Camera } from "babylonjs/Cameras/camera";
  53129. import { Scene } from "babylonjs/scene";
  53130. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53132. import { Mesh } from "babylonjs/Meshes/mesh";
  53133. import { Texture } from "babylonjs/Materials/Textures/texture";
  53134. import { Effect } from "babylonjs/Materials/effect";
  53135. import { Material } from "babylonjs/Materials/material";
  53136. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  53137. import { Color4 } from "babylonjs/Maths/math.color";
  53138. import "babylonjs/Shaders/glowMapMerge.fragment";
  53139. import "babylonjs/Shaders/glowMapMerge.vertex";
  53140. import "babylonjs/Layers/effectLayerSceneComponent";
  53141. module "babylonjs/abstractScene" {
  53142. interface AbstractScene {
  53143. /**
  53144. * Return a the first highlight layer of the scene with a given name.
  53145. * @param name The name of the highlight layer to look for.
  53146. * @return The highlight layer if found otherwise null.
  53147. */
  53148. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53149. }
  53150. }
  53151. /**
  53152. * Glow layer options. This helps customizing the behaviour
  53153. * of the glow layer.
  53154. */
  53155. export interface IGlowLayerOptions {
  53156. /**
  53157. * Multiplication factor apply to the canvas size to compute the render target size
  53158. * used to generated the glowing objects (the smaller the faster).
  53159. */
  53160. mainTextureRatio: number;
  53161. /**
  53162. * Enforces a fixed size texture to ensure resize independant blur.
  53163. */
  53164. mainTextureFixedSize?: number;
  53165. /**
  53166. * How big is the kernel of the blur texture.
  53167. */
  53168. blurKernelSize: number;
  53169. /**
  53170. * The camera attached to the layer.
  53171. */
  53172. camera: Nullable<Camera>;
  53173. /**
  53174. * Enable MSAA by chosing the number of samples.
  53175. */
  53176. mainTextureSamples?: number;
  53177. /**
  53178. * The rendering group to draw the layer in.
  53179. */
  53180. renderingGroupId: number;
  53181. }
  53182. /**
  53183. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53184. *
  53185. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53186. *
  53187. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53188. */
  53189. export class GlowLayer extends EffectLayer {
  53190. /**
  53191. * Effect Name of the layer.
  53192. */
  53193. static readonly EffectName: string;
  53194. /**
  53195. * The default blur kernel size used for the glow.
  53196. */
  53197. static DefaultBlurKernelSize: number;
  53198. /**
  53199. * The default texture size ratio used for the glow.
  53200. */
  53201. static DefaultTextureRatio: number;
  53202. /**
  53203. * Sets the kernel size of the blur.
  53204. */
  53205. /**
  53206. * Gets the kernel size of the blur.
  53207. */
  53208. blurKernelSize: number;
  53209. /**
  53210. * Sets the glow intensity.
  53211. */
  53212. /**
  53213. * Gets the glow intensity.
  53214. */
  53215. intensity: number;
  53216. private _options;
  53217. private _intensity;
  53218. private _horizontalBlurPostprocess1;
  53219. private _verticalBlurPostprocess1;
  53220. private _horizontalBlurPostprocess2;
  53221. private _verticalBlurPostprocess2;
  53222. private _blurTexture1;
  53223. private _blurTexture2;
  53224. private _postProcesses1;
  53225. private _postProcesses2;
  53226. private _includedOnlyMeshes;
  53227. private _excludedMeshes;
  53228. private _meshesUsingTheirOwnMaterials;
  53229. /**
  53230. * Callback used to let the user override the color selection on a per mesh basis
  53231. */
  53232. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53233. /**
  53234. * Callback used to let the user override the texture selection on a per mesh basis
  53235. */
  53236. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53237. /**
  53238. * Instantiates a new glow Layer and references it to the scene.
  53239. * @param name The name of the layer
  53240. * @param scene The scene to use the layer in
  53241. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53242. */
  53243. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53244. /**
  53245. * Get the effect name of the layer.
  53246. * @return The effect name
  53247. */
  53248. getEffectName(): string;
  53249. /**
  53250. * Create the merge effect. This is the shader use to blit the information back
  53251. * to the main canvas at the end of the scene rendering.
  53252. */
  53253. protected _createMergeEffect(): Effect;
  53254. /**
  53255. * Creates the render target textures and post processes used in the glow layer.
  53256. */
  53257. protected _createTextureAndPostProcesses(): void;
  53258. /**
  53259. * Checks for the readiness of the element composing the layer.
  53260. * @param subMesh the mesh to check for
  53261. * @param useInstances specify wether or not to use instances to render the mesh
  53262. * @param emissiveTexture the associated emissive texture used to generate the glow
  53263. * @return true if ready otherwise, false
  53264. */
  53265. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53266. /**
  53267. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53268. */
  53269. needStencil(): boolean;
  53270. /**
  53271. * Returns true if the mesh can be rendered, otherwise false.
  53272. * @param mesh The mesh to render
  53273. * @param material The material used on the mesh
  53274. * @returns true if it can be rendered otherwise false
  53275. */
  53276. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53277. /**
  53278. * Implementation specific of rendering the generating effect on the main canvas.
  53279. * @param effect The effect used to render through
  53280. */
  53281. protected _internalRender(effect: Effect): void;
  53282. /**
  53283. * Sets the required values for both the emissive texture and and the main color.
  53284. */
  53285. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53286. /**
  53287. * Returns true if the mesh should render, otherwise false.
  53288. * @param mesh The mesh to render
  53289. * @returns true if it should render otherwise false
  53290. */
  53291. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53292. /**
  53293. * Adds specific effects defines.
  53294. * @param defines The defines to add specifics to.
  53295. */
  53296. protected _addCustomEffectDefines(defines: string[]): void;
  53297. /**
  53298. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53299. * @param mesh The mesh to exclude from the glow layer
  53300. */
  53301. addExcludedMesh(mesh: Mesh): void;
  53302. /**
  53303. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53304. * @param mesh The mesh to remove
  53305. */
  53306. removeExcludedMesh(mesh: Mesh): void;
  53307. /**
  53308. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53309. * @param mesh The mesh to include in the glow layer
  53310. */
  53311. addIncludedOnlyMesh(mesh: Mesh): void;
  53312. /**
  53313. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53314. * @param mesh The mesh to remove
  53315. */
  53316. removeIncludedOnlyMesh(mesh: Mesh): void;
  53317. /**
  53318. * Determine if a given mesh will be used in the glow layer
  53319. * @param mesh The mesh to test
  53320. * @returns true if the mesh will be highlighted by the current glow layer
  53321. */
  53322. hasMesh(mesh: AbstractMesh): boolean;
  53323. /**
  53324. * Defines wether the current material of the mesh should be use to render the effect.
  53325. * @param mesh defines the current mesh to render
  53326. */
  53327. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53328. /**
  53329. * Add a mesh to be rendered through its own material and not with emissive only.
  53330. * @param mesh The mesh for which we need to use its material
  53331. */
  53332. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53333. /**
  53334. * Remove a mesh from being rendered through its own material and not with emissive only.
  53335. * @param mesh The mesh for which we need to not use its material
  53336. */
  53337. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53338. /**
  53339. * Free any resources and references associated to a mesh.
  53340. * Internal use
  53341. * @param mesh The mesh to free.
  53342. * @hidden
  53343. */
  53344. _disposeMesh(mesh: Mesh): void;
  53345. /**
  53346. * Gets the class name of the effect layer
  53347. * @returns the string with the class name of the effect layer
  53348. */
  53349. getClassName(): string;
  53350. /**
  53351. * Serializes this glow layer
  53352. * @returns a serialized glow layer object
  53353. */
  53354. serialize(): any;
  53355. /**
  53356. * Creates a Glow Layer from parsed glow layer data
  53357. * @param parsedGlowLayer defines glow layer data
  53358. * @param scene defines the current scene
  53359. * @param rootUrl defines the root URL containing the glow layer information
  53360. * @returns a parsed Glow Layer
  53361. */
  53362. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53363. }
  53364. }
  53365. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  53366. /** @hidden */
  53367. export var glowBlurPostProcessPixelShader: {
  53368. name: string;
  53369. shader: string;
  53370. };
  53371. }
  53372. declare module "babylonjs/Layers/highlightLayer" {
  53373. import { Observable } from "babylonjs/Misc/observable";
  53374. import { Nullable } from "babylonjs/types";
  53375. import { Camera } from "babylonjs/Cameras/camera";
  53376. import { Scene } from "babylonjs/scene";
  53377. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53379. import { Mesh } from "babylonjs/Meshes/mesh";
  53380. import { Effect } from "babylonjs/Materials/effect";
  53381. import { Material } from "babylonjs/Materials/material";
  53382. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  53383. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  53384. import "babylonjs/Shaders/glowMapMerge.fragment";
  53385. import "babylonjs/Shaders/glowMapMerge.vertex";
  53386. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  53387. module "babylonjs/abstractScene" {
  53388. interface AbstractScene {
  53389. /**
  53390. * Return a the first highlight layer of the scene with a given name.
  53391. * @param name The name of the highlight layer to look for.
  53392. * @return The highlight layer if found otherwise null.
  53393. */
  53394. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53395. }
  53396. }
  53397. /**
  53398. * Highlight layer options. This helps customizing the behaviour
  53399. * of the highlight layer.
  53400. */
  53401. export interface IHighlightLayerOptions {
  53402. /**
  53403. * Multiplication factor apply to the canvas size to compute the render target size
  53404. * used to generated the glowing objects (the smaller the faster).
  53405. */
  53406. mainTextureRatio: number;
  53407. /**
  53408. * Enforces a fixed size texture to ensure resize independant blur.
  53409. */
  53410. mainTextureFixedSize?: number;
  53411. /**
  53412. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53413. * of the picture to blur (the smaller the faster).
  53414. */
  53415. blurTextureSizeRatio: number;
  53416. /**
  53417. * How big in texel of the blur texture is the vertical blur.
  53418. */
  53419. blurVerticalSize: number;
  53420. /**
  53421. * How big in texel of the blur texture is the horizontal blur.
  53422. */
  53423. blurHorizontalSize: number;
  53424. /**
  53425. * Alpha blending mode used to apply the blur. Default is combine.
  53426. */
  53427. alphaBlendingMode: number;
  53428. /**
  53429. * The camera attached to the layer.
  53430. */
  53431. camera: Nullable<Camera>;
  53432. /**
  53433. * Should we display highlight as a solid stroke?
  53434. */
  53435. isStroke?: boolean;
  53436. /**
  53437. * The rendering group to draw the layer in.
  53438. */
  53439. renderingGroupId: number;
  53440. }
  53441. /**
  53442. * The highlight layer Helps adding a glow effect around a mesh.
  53443. *
  53444. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53445. * glowy meshes to your scene.
  53446. *
  53447. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53448. */
  53449. export class HighlightLayer extends EffectLayer {
  53450. name: string;
  53451. /**
  53452. * Effect Name of the highlight layer.
  53453. */
  53454. static readonly EffectName: string;
  53455. /**
  53456. * The neutral color used during the preparation of the glow effect.
  53457. * This is black by default as the blend operation is a blend operation.
  53458. */
  53459. static NeutralColor: Color4;
  53460. /**
  53461. * Stencil value used for glowing meshes.
  53462. */
  53463. static GlowingMeshStencilReference: number;
  53464. /**
  53465. * Stencil value used for the other meshes in the scene.
  53466. */
  53467. static NormalMeshStencilReference: number;
  53468. /**
  53469. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53470. */
  53471. innerGlow: boolean;
  53472. /**
  53473. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53474. */
  53475. outerGlow: boolean;
  53476. /**
  53477. * Specifies the horizontal size of the blur.
  53478. */
  53479. /**
  53480. * Gets the horizontal size of the blur.
  53481. */
  53482. blurHorizontalSize: number;
  53483. /**
  53484. * Specifies the vertical size of the blur.
  53485. */
  53486. /**
  53487. * Gets the vertical size of the blur.
  53488. */
  53489. blurVerticalSize: number;
  53490. /**
  53491. * An event triggered when the highlight layer is being blurred.
  53492. */
  53493. onBeforeBlurObservable: Observable<HighlightLayer>;
  53494. /**
  53495. * An event triggered when the highlight layer has been blurred.
  53496. */
  53497. onAfterBlurObservable: Observable<HighlightLayer>;
  53498. private _instanceGlowingMeshStencilReference;
  53499. private _options;
  53500. private _downSamplePostprocess;
  53501. private _horizontalBlurPostprocess;
  53502. private _verticalBlurPostprocess;
  53503. private _blurTexture;
  53504. private _meshes;
  53505. private _excludedMeshes;
  53506. /**
  53507. * Instantiates a new highlight Layer and references it to the scene..
  53508. * @param name The name of the layer
  53509. * @param scene The scene to use the layer in
  53510. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53511. */
  53512. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53513. /**
  53514. * Get the effect name of the layer.
  53515. * @return The effect name
  53516. */
  53517. getEffectName(): string;
  53518. /**
  53519. * Create the merge effect. This is the shader use to blit the information back
  53520. * to the main canvas at the end of the scene rendering.
  53521. */
  53522. protected _createMergeEffect(): Effect;
  53523. /**
  53524. * Creates the render target textures and post processes used in the highlight layer.
  53525. */
  53526. protected _createTextureAndPostProcesses(): void;
  53527. /**
  53528. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53529. */
  53530. needStencil(): boolean;
  53531. /**
  53532. * Checks for the readiness of the element composing the layer.
  53533. * @param subMesh the mesh to check for
  53534. * @param useInstances specify wether or not to use instances to render the mesh
  53535. * @param emissiveTexture the associated emissive texture used to generate the glow
  53536. * @return true if ready otherwise, false
  53537. */
  53538. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53539. /**
  53540. * Implementation specific of rendering the generating effect on the main canvas.
  53541. * @param effect The effect used to render through
  53542. */
  53543. protected _internalRender(effect: Effect): void;
  53544. /**
  53545. * Returns true if the layer contains information to display, otherwise false.
  53546. */
  53547. shouldRender(): boolean;
  53548. /**
  53549. * Returns true if the mesh should render, otherwise false.
  53550. * @param mesh The mesh to render
  53551. * @returns true if it should render otherwise false
  53552. */
  53553. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53554. /**
  53555. * Sets the required values for both the emissive texture and and the main color.
  53556. */
  53557. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53558. /**
  53559. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53560. * @param mesh The mesh to exclude from the highlight layer
  53561. */
  53562. addExcludedMesh(mesh: Mesh): void;
  53563. /**
  53564. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53565. * @param mesh The mesh to highlight
  53566. */
  53567. removeExcludedMesh(mesh: Mesh): void;
  53568. /**
  53569. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53570. * @param mesh mesh to test
  53571. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53572. */
  53573. hasMesh(mesh: AbstractMesh): boolean;
  53574. /**
  53575. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53576. * @param mesh The mesh to highlight
  53577. * @param color The color of the highlight
  53578. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53579. */
  53580. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53581. /**
  53582. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53583. * @param mesh The mesh to highlight
  53584. */
  53585. removeMesh(mesh: Mesh): void;
  53586. /**
  53587. * Force the stencil to the normal expected value for none glowing parts
  53588. */
  53589. private _defaultStencilReference;
  53590. /**
  53591. * Free any resources and references associated to a mesh.
  53592. * Internal use
  53593. * @param mesh The mesh to free.
  53594. * @hidden
  53595. */
  53596. _disposeMesh(mesh: Mesh): void;
  53597. /**
  53598. * Dispose the highlight layer and free resources.
  53599. */
  53600. dispose(): void;
  53601. /**
  53602. * Gets the class name of the effect layer
  53603. * @returns the string with the class name of the effect layer
  53604. */
  53605. getClassName(): string;
  53606. /**
  53607. * Serializes this Highlight layer
  53608. * @returns a serialized Highlight layer object
  53609. */
  53610. serialize(): any;
  53611. /**
  53612. * Creates a Highlight layer from parsed Highlight layer data
  53613. * @param parsedHightlightLayer defines the Highlight layer data
  53614. * @param scene defines the current scene
  53615. * @param rootUrl defines the root URL containing the Highlight layer information
  53616. * @returns a parsed Highlight layer
  53617. */
  53618. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53619. }
  53620. }
  53621. declare module "babylonjs/Layers/layerSceneComponent" {
  53622. import { Scene } from "babylonjs/scene";
  53623. import { ISceneComponent } from "babylonjs/sceneComponent";
  53624. import { Layer } from "babylonjs/Layers/layer";
  53625. import { AbstractScene } from "babylonjs/abstractScene";
  53626. module "babylonjs/abstractScene" {
  53627. interface AbstractScene {
  53628. /**
  53629. * The list of layers (background and foreground) of the scene
  53630. */
  53631. layers: Array<Layer>;
  53632. }
  53633. }
  53634. /**
  53635. * Defines the layer scene component responsible to manage any layers
  53636. * in a given scene.
  53637. */
  53638. export class LayerSceneComponent implements ISceneComponent {
  53639. /**
  53640. * The component name helpfull to identify the component in the list of scene components.
  53641. */
  53642. readonly name: string;
  53643. /**
  53644. * The scene the component belongs to.
  53645. */
  53646. scene: Scene;
  53647. private _engine;
  53648. /**
  53649. * Creates a new instance of the component for the given scene
  53650. * @param scene Defines the scene to register the component in
  53651. */
  53652. constructor(scene: Scene);
  53653. /**
  53654. * Registers the component in a given scene
  53655. */
  53656. register(): void;
  53657. /**
  53658. * Rebuilds the elements related to this component in case of
  53659. * context lost for instance.
  53660. */
  53661. rebuild(): void;
  53662. /**
  53663. * Disposes the component and the associated ressources.
  53664. */
  53665. dispose(): void;
  53666. private _draw;
  53667. private _drawCameraPredicate;
  53668. private _drawCameraBackground;
  53669. private _drawCameraForeground;
  53670. private _drawRenderTargetPredicate;
  53671. private _drawRenderTargetBackground;
  53672. private _drawRenderTargetForeground;
  53673. /**
  53674. * Adds all the elements from the container to the scene
  53675. * @param container the container holding the elements
  53676. */
  53677. addFromContainer(container: AbstractScene): void;
  53678. /**
  53679. * Removes all the elements in the container from the scene
  53680. * @param container contains the elements to remove
  53681. * @param dispose if the removed element should be disposed (default: false)
  53682. */
  53683. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53684. }
  53685. }
  53686. declare module "babylonjs/Shaders/layer.fragment" {
  53687. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53688. /** @hidden */
  53689. export var layerPixelShader: {
  53690. name: string;
  53691. shader: string;
  53692. };
  53693. }
  53694. declare module "babylonjs/Shaders/layer.vertex" {
  53695. /** @hidden */
  53696. export var layerVertexShader: {
  53697. name: string;
  53698. shader: string;
  53699. };
  53700. }
  53701. declare module "babylonjs/Layers/layer" {
  53702. import { Observable } from "babylonjs/Misc/observable";
  53703. import { Nullable } from "babylonjs/types";
  53704. import { Scene } from "babylonjs/scene";
  53705. import { Vector2 } from "babylonjs/Maths/math.vector";
  53706. import { Color4 } from "babylonjs/Maths/math.color";
  53707. import { Texture } from "babylonjs/Materials/Textures/texture";
  53708. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53709. import "babylonjs/Shaders/layer.fragment";
  53710. import "babylonjs/Shaders/layer.vertex";
  53711. /**
  53712. * This represents a full screen 2d layer.
  53713. * This can be useful to display a picture in the background of your scene for instance.
  53714. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53715. */
  53716. export class Layer {
  53717. /**
  53718. * Define the name of the layer.
  53719. */
  53720. name: string;
  53721. /**
  53722. * Define the texture the layer should display.
  53723. */
  53724. texture: Nullable<Texture>;
  53725. /**
  53726. * Is the layer in background or foreground.
  53727. */
  53728. isBackground: boolean;
  53729. /**
  53730. * Define the color of the layer (instead of texture).
  53731. */
  53732. color: Color4;
  53733. /**
  53734. * Define the scale of the layer in order to zoom in out of the texture.
  53735. */
  53736. scale: Vector2;
  53737. /**
  53738. * Define an offset for the layer in order to shift the texture.
  53739. */
  53740. offset: Vector2;
  53741. /**
  53742. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53743. */
  53744. alphaBlendingMode: number;
  53745. /**
  53746. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53747. * Alpha test will not mix with the background color in case of transparency.
  53748. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53749. */
  53750. alphaTest: boolean;
  53751. /**
  53752. * Define a mask to restrict the layer to only some of the scene cameras.
  53753. */
  53754. layerMask: number;
  53755. /**
  53756. * Define the list of render target the layer is visible into.
  53757. */
  53758. renderTargetTextures: RenderTargetTexture[];
  53759. /**
  53760. * Define if the layer is only used in renderTarget or if it also
  53761. * renders in the main frame buffer of the canvas.
  53762. */
  53763. renderOnlyInRenderTargetTextures: boolean;
  53764. private _scene;
  53765. private _vertexBuffers;
  53766. private _indexBuffer;
  53767. private _effect;
  53768. private _previousDefines;
  53769. /**
  53770. * An event triggered when the layer is disposed.
  53771. */
  53772. onDisposeObservable: Observable<Layer>;
  53773. private _onDisposeObserver;
  53774. /**
  53775. * Back compatibility with callback before the onDisposeObservable existed.
  53776. * The set callback will be triggered when the layer has been disposed.
  53777. */
  53778. onDispose: () => void;
  53779. /**
  53780. * An event triggered before rendering the scene
  53781. */
  53782. onBeforeRenderObservable: Observable<Layer>;
  53783. private _onBeforeRenderObserver;
  53784. /**
  53785. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53786. * The set callback will be triggered just before rendering the layer.
  53787. */
  53788. onBeforeRender: () => void;
  53789. /**
  53790. * An event triggered after rendering the scene
  53791. */
  53792. onAfterRenderObservable: Observable<Layer>;
  53793. private _onAfterRenderObserver;
  53794. /**
  53795. * Back compatibility with callback before the onAfterRenderObservable existed.
  53796. * The set callback will be triggered just after rendering the layer.
  53797. */
  53798. onAfterRender: () => void;
  53799. /**
  53800. * Instantiates a new layer.
  53801. * This represents a full screen 2d layer.
  53802. * This can be useful to display a picture in the background of your scene for instance.
  53803. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53804. * @param name Define the name of the layer in the scene
  53805. * @param imgUrl Define the url of the texture to display in the layer
  53806. * @param scene Define the scene the layer belongs to
  53807. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53808. * @param color Defines a color for the layer
  53809. */
  53810. constructor(
  53811. /**
  53812. * Define the name of the layer.
  53813. */
  53814. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53815. private _createIndexBuffer;
  53816. /** @hidden */
  53817. _rebuild(): void;
  53818. /**
  53819. * Renders the layer in the scene.
  53820. */
  53821. render(): void;
  53822. /**
  53823. * Disposes and releases the associated ressources.
  53824. */
  53825. dispose(): void;
  53826. }
  53827. }
  53828. declare module "babylonjs/Layers/index" {
  53829. export * from "babylonjs/Layers/effectLayer";
  53830. export * from "babylonjs/Layers/effectLayerSceneComponent";
  53831. export * from "babylonjs/Layers/glowLayer";
  53832. export * from "babylonjs/Layers/highlightLayer";
  53833. export * from "babylonjs/Layers/layer";
  53834. export * from "babylonjs/Layers/layerSceneComponent";
  53835. }
  53836. declare module "babylonjs/Shaders/lensFlare.fragment" {
  53837. /** @hidden */
  53838. export var lensFlarePixelShader: {
  53839. name: string;
  53840. shader: string;
  53841. };
  53842. }
  53843. declare module "babylonjs/Shaders/lensFlare.vertex" {
  53844. /** @hidden */
  53845. export var lensFlareVertexShader: {
  53846. name: string;
  53847. shader: string;
  53848. };
  53849. }
  53850. declare module "babylonjs/LensFlares/lensFlareSystem" {
  53851. import { Scene } from "babylonjs/scene";
  53852. import { Vector3 } from "babylonjs/Maths/math.vector";
  53853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53854. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  53855. import "babylonjs/Shaders/lensFlare.fragment";
  53856. import "babylonjs/Shaders/lensFlare.vertex";
  53857. import { Viewport } from "babylonjs/Maths/math.viewport";
  53858. /**
  53859. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53860. * It is usually composed of several `lensFlare`.
  53861. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53862. */
  53863. export class LensFlareSystem {
  53864. /**
  53865. * Define the name of the lens flare system
  53866. */
  53867. name: string;
  53868. /**
  53869. * List of lens flares used in this system.
  53870. */
  53871. lensFlares: LensFlare[];
  53872. /**
  53873. * Define a limit from the border the lens flare can be visible.
  53874. */
  53875. borderLimit: number;
  53876. /**
  53877. * Define a viewport border we do not want to see the lens flare in.
  53878. */
  53879. viewportBorder: number;
  53880. /**
  53881. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53882. */
  53883. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53884. /**
  53885. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53886. */
  53887. layerMask: number;
  53888. /**
  53889. * Define the id of the lens flare system in the scene.
  53890. * (equal to name by default)
  53891. */
  53892. id: string;
  53893. private _scene;
  53894. private _emitter;
  53895. private _vertexBuffers;
  53896. private _indexBuffer;
  53897. private _effect;
  53898. private _positionX;
  53899. private _positionY;
  53900. private _isEnabled;
  53901. /** @hidden */
  53902. static _SceneComponentInitialization: (scene: Scene) => void;
  53903. /**
  53904. * Instantiates a lens flare system.
  53905. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53906. * It is usually composed of several `lensFlare`.
  53907. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53908. * @param name Define the name of the lens flare system in the scene
  53909. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53910. * @param scene Define the scene the lens flare system belongs to
  53911. */
  53912. constructor(
  53913. /**
  53914. * Define the name of the lens flare system
  53915. */
  53916. name: string, emitter: any, scene: Scene);
  53917. /**
  53918. * Define if the lens flare system is enabled.
  53919. */
  53920. isEnabled: boolean;
  53921. /**
  53922. * Get the scene the effects belongs to.
  53923. * @returns the scene holding the lens flare system
  53924. */
  53925. getScene(): Scene;
  53926. /**
  53927. * Get the emitter of the lens flare system.
  53928. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53929. * @returns the emitter of the lens flare system
  53930. */
  53931. getEmitter(): any;
  53932. /**
  53933. * Set the emitter of the lens flare system.
  53934. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53935. * @param newEmitter Define the new emitter of the system
  53936. */
  53937. setEmitter(newEmitter: any): void;
  53938. /**
  53939. * Get the lens flare system emitter position.
  53940. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53941. * @returns the position
  53942. */
  53943. getEmitterPosition(): Vector3;
  53944. /**
  53945. * @hidden
  53946. */
  53947. computeEffectivePosition(globalViewport: Viewport): boolean;
  53948. /** @hidden */
  53949. _isVisible(): boolean;
  53950. /**
  53951. * @hidden
  53952. */
  53953. render(): boolean;
  53954. /**
  53955. * Dispose and release the lens flare with its associated resources.
  53956. */
  53957. dispose(): void;
  53958. /**
  53959. * Parse a lens flare system from a JSON repressentation
  53960. * @param parsedLensFlareSystem Define the JSON to parse
  53961. * @param scene Define the scene the parsed system should be instantiated in
  53962. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53963. * @returns the parsed system
  53964. */
  53965. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53966. /**
  53967. * Serialize the current Lens Flare System into a JSON representation.
  53968. * @returns the serialized JSON
  53969. */
  53970. serialize(): any;
  53971. }
  53972. }
  53973. declare module "babylonjs/LensFlares/lensFlare" {
  53974. import { Nullable } from "babylonjs/types";
  53975. import { Color3 } from "babylonjs/Maths/math.color";
  53976. import { Texture } from "babylonjs/Materials/Textures/texture";
  53977. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53978. /**
  53979. * This represents one of the lens effect in a `lensFlareSystem`.
  53980. * It controls one of the indiviual texture used in the effect.
  53981. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53982. */
  53983. export class LensFlare {
  53984. /**
  53985. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53986. */
  53987. size: number;
  53988. /**
  53989. * 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.
  53990. */
  53991. position: number;
  53992. /**
  53993. * Define the lens color.
  53994. */
  53995. color: Color3;
  53996. /**
  53997. * Define the lens texture.
  53998. */
  53999. texture: Nullable<Texture>;
  54000. /**
  54001. * Define the alpha mode to render this particular lens.
  54002. */
  54003. alphaMode: number;
  54004. private _system;
  54005. /**
  54006. * Creates a new Lens Flare.
  54007. * This represents one of the lens effect in a `lensFlareSystem`.
  54008. * It controls one of the indiviual texture used in the effect.
  54009. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54010. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54011. * @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.
  54012. * @param color Define the lens color
  54013. * @param imgUrl Define the lens texture url
  54014. * @param system Define the `lensFlareSystem` this flare is part of
  54015. * @returns The newly created Lens Flare
  54016. */
  54017. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54018. /**
  54019. * Instantiates a new Lens Flare.
  54020. * This represents one of the lens effect in a `lensFlareSystem`.
  54021. * It controls one of the indiviual texture used in the effect.
  54022. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54023. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54024. * @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.
  54025. * @param color Define the lens color
  54026. * @param imgUrl Define the lens texture url
  54027. * @param system Define the `lensFlareSystem` this flare is part of
  54028. */
  54029. constructor(
  54030. /**
  54031. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54032. */
  54033. size: number,
  54034. /**
  54035. * 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.
  54036. */
  54037. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54038. /**
  54039. * Dispose and release the lens flare with its associated resources.
  54040. */
  54041. dispose(): void;
  54042. }
  54043. }
  54044. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  54045. import { Nullable } from "babylonjs/types";
  54046. import { Scene } from "babylonjs/scene";
  54047. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  54048. import { AbstractScene } from "babylonjs/abstractScene";
  54049. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  54050. module "babylonjs/abstractScene" {
  54051. interface AbstractScene {
  54052. /**
  54053. * The list of lens flare system added to the scene
  54054. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54055. */
  54056. lensFlareSystems: Array<LensFlareSystem>;
  54057. /**
  54058. * Removes the given lens flare system from this scene.
  54059. * @param toRemove The lens flare system to remove
  54060. * @returns The index of the removed lens flare system
  54061. */
  54062. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54063. /**
  54064. * Adds the given lens flare system to this scene
  54065. * @param newLensFlareSystem The lens flare system to add
  54066. */
  54067. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54068. /**
  54069. * Gets a lens flare system using its name
  54070. * @param name defines the name to look for
  54071. * @returns the lens flare system or null if not found
  54072. */
  54073. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54074. /**
  54075. * Gets a lens flare system using its id
  54076. * @param id defines the id to look for
  54077. * @returns the lens flare system or null if not found
  54078. */
  54079. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54080. }
  54081. }
  54082. /**
  54083. * Defines the lens flare scene component responsible to manage any lens flares
  54084. * in a given scene.
  54085. */
  54086. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54087. /**
  54088. * The component name helpfull to identify the component in the list of scene components.
  54089. */
  54090. readonly name: string;
  54091. /**
  54092. * The scene the component belongs to.
  54093. */
  54094. scene: Scene;
  54095. /**
  54096. * Creates a new instance of the component for the given scene
  54097. * @param scene Defines the scene to register the component in
  54098. */
  54099. constructor(scene: Scene);
  54100. /**
  54101. * Registers the component in a given scene
  54102. */
  54103. register(): void;
  54104. /**
  54105. * Rebuilds the elements related to this component in case of
  54106. * context lost for instance.
  54107. */
  54108. rebuild(): void;
  54109. /**
  54110. * Adds all the elements from the container to the scene
  54111. * @param container the container holding the elements
  54112. */
  54113. addFromContainer(container: AbstractScene): void;
  54114. /**
  54115. * Removes all the elements in the container from the scene
  54116. * @param container contains the elements to remove
  54117. * @param dispose if the removed element should be disposed (default: false)
  54118. */
  54119. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54120. /**
  54121. * Serializes the component data to the specified json object
  54122. * @param serializationObject The object to serialize to
  54123. */
  54124. serialize(serializationObject: any): void;
  54125. /**
  54126. * Disposes the component and the associated ressources.
  54127. */
  54128. dispose(): void;
  54129. private _draw;
  54130. }
  54131. }
  54132. declare module "babylonjs/LensFlares/index" {
  54133. export * from "babylonjs/LensFlares/lensFlare";
  54134. export * from "babylonjs/LensFlares/lensFlareSystem";
  54135. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  54136. }
  54137. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  54138. import { Scene } from "babylonjs/scene";
  54139. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  54140. import { AbstractScene } from "babylonjs/abstractScene";
  54141. /**
  54142. * Defines the shadow generator component responsible to manage any shadow generators
  54143. * in a given scene.
  54144. */
  54145. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54146. /**
  54147. * The component name helpfull to identify the component in the list of scene components.
  54148. */
  54149. readonly name: string;
  54150. /**
  54151. * The scene the component belongs to.
  54152. */
  54153. scene: Scene;
  54154. /**
  54155. * Creates a new instance of the component for the given scene
  54156. * @param scene Defines the scene to register the component in
  54157. */
  54158. constructor(scene: Scene);
  54159. /**
  54160. * Registers the component in a given scene
  54161. */
  54162. register(): void;
  54163. /**
  54164. * Rebuilds the elements related to this component in case of
  54165. * context lost for instance.
  54166. */
  54167. rebuild(): void;
  54168. /**
  54169. * Serializes the component data to the specified json object
  54170. * @param serializationObject The object to serialize to
  54171. */
  54172. serialize(serializationObject: any): void;
  54173. /**
  54174. * Adds all the elements from the container to the scene
  54175. * @param container the container holding the elements
  54176. */
  54177. addFromContainer(container: AbstractScene): void;
  54178. /**
  54179. * Removes all the elements in the container from the scene
  54180. * @param container contains the elements to remove
  54181. * @param dispose if the removed element should be disposed (default: false)
  54182. */
  54183. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54184. /**
  54185. * Rebuilds the elements related to this component in case of
  54186. * context lost for instance.
  54187. */
  54188. dispose(): void;
  54189. private _gatherRenderTargets;
  54190. }
  54191. }
  54192. declare module "babylonjs/Lights/Shadows/index" {
  54193. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  54194. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  54195. }
  54196. declare module "babylonjs/Lights/pointLight" {
  54197. import { Scene } from "babylonjs/scene";
  54198. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54200. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54201. import { Effect } from "babylonjs/Materials/effect";
  54202. /**
  54203. * A point light is a light defined by an unique point in world space.
  54204. * The light is emitted in every direction from this point.
  54205. * A good example of a point light is a standard light bulb.
  54206. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54207. */
  54208. export class PointLight extends ShadowLight {
  54209. private _shadowAngle;
  54210. /**
  54211. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54212. * This specifies what angle the shadow will use to be created.
  54213. *
  54214. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54215. */
  54216. /**
  54217. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54218. * This specifies what angle the shadow will use to be created.
  54219. *
  54220. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54221. */
  54222. shadowAngle: number;
  54223. /**
  54224. * Gets the direction if it has been set.
  54225. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54226. */
  54227. /**
  54228. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54229. */
  54230. direction: Vector3;
  54231. /**
  54232. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54233. * A PointLight emits the light in every direction.
  54234. * It can cast shadows.
  54235. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54236. * ```javascript
  54237. * var pointLight = new PointLight("pl", camera.position, scene);
  54238. * ```
  54239. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54240. * @param name The light friendly name
  54241. * @param position The position of the point light in the scene
  54242. * @param scene The scene the lights belongs to
  54243. */
  54244. constructor(name: string, position: Vector3, scene: Scene);
  54245. /**
  54246. * Returns the string "PointLight"
  54247. * @returns the class name
  54248. */
  54249. getClassName(): string;
  54250. /**
  54251. * Returns the integer 0.
  54252. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54253. */
  54254. getTypeID(): number;
  54255. /**
  54256. * Specifies wether or not the shadowmap should be a cube texture.
  54257. * @returns true if the shadowmap needs to be a cube texture.
  54258. */
  54259. needCube(): boolean;
  54260. /**
  54261. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54262. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54263. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54264. */
  54265. getShadowDirection(faceIndex?: number): Vector3;
  54266. /**
  54267. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54268. * - fov = PI / 2
  54269. * - aspect ratio : 1.0
  54270. * - z-near and far equal to the active camera minZ and maxZ.
  54271. * Returns the PointLight.
  54272. */
  54273. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54274. protected _buildUniformLayout(): void;
  54275. /**
  54276. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54277. * @param effect The effect to update
  54278. * @param lightIndex The index of the light in the effect to update
  54279. * @returns The point light
  54280. */
  54281. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54282. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54283. /**
  54284. * Prepares the list of defines specific to the light type.
  54285. * @param defines the list of defines
  54286. * @param lightIndex defines the index of the light for the effect
  54287. */
  54288. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54289. }
  54290. }
  54291. declare module "babylonjs/Lights/index" {
  54292. export * from "babylonjs/Lights/light";
  54293. export * from "babylonjs/Lights/shadowLight";
  54294. export * from "babylonjs/Lights/Shadows/index";
  54295. export * from "babylonjs/Lights/directionalLight";
  54296. export * from "babylonjs/Lights/hemisphericLight";
  54297. export * from "babylonjs/Lights/pointLight";
  54298. export * from "babylonjs/Lights/spotLight";
  54299. }
  54300. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  54301. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54302. /**
  54303. * Header information of HDR texture files.
  54304. */
  54305. export interface HDRInfo {
  54306. /**
  54307. * The height of the texture in pixels.
  54308. */
  54309. height: number;
  54310. /**
  54311. * The width of the texture in pixels.
  54312. */
  54313. width: number;
  54314. /**
  54315. * The index of the beginning of the data in the binary file.
  54316. */
  54317. dataPosition: number;
  54318. }
  54319. /**
  54320. * This groups tools to convert HDR texture to native colors array.
  54321. */
  54322. export class HDRTools {
  54323. private static Ldexp;
  54324. private static Rgbe2float;
  54325. private static readStringLine;
  54326. /**
  54327. * Reads header information from an RGBE texture stored in a native array.
  54328. * More information on this format are available here:
  54329. * https://en.wikipedia.org/wiki/RGBE_image_format
  54330. *
  54331. * @param uint8array The binary file stored in native array.
  54332. * @return The header information.
  54333. */
  54334. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54335. /**
  54336. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54337. * This RGBE texture needs to store the information as a panorama.
  54338. *
  54339. * More information on this format are available here:
  54340. * https://en.wikipedia.org/wiki/RGBE_image_format
  54341. *
  54342. * @param buffer The binary file stored in an array buffer.
  54343. * @param size The expected size of the extracted cubemap.
  54344. * @return The Cube Map information.
  54345. */
  54346. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54347. /**
  54348. * Returns the pixels data extracted from an RGBE texture.
  54349. * This pixels will be stored left to right up to down in the R G B order in one array.
  54350. *
  54351. * More information on this format are available here:
  54352. * https://en.wikipedia.org/wiki/RGBE_image_format
  54353. *
  54354. * @param uint8array The binary file stored in an array buffer.
  54355. * @param hdrInfo The header information of the file.
  54356. * @return The pixels data in RGB right to left up to down order.
  54357. */
  54358. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54359. private static RGBE_ReadPixels_RLE;
  54360. }
  54361. }
  54362. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  54363. import { Nullable } from "babylonjs/types";
  54364. import { Scene } from "babylonjs/scene";
  54365. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54366. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54367. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54368. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54369. /**
  54370. * This represents a texture coming from an HDR input.
  54371. *
  54372. * The only supported format is currently panorama picture stored in RGBE format.
  54373. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54374. */
  54375. export class HDRCubeTexture extends BaseTexture {
  54376. private static _facesMapping;
  54377. private _generateHarmonics;
  54378. private _noMipmap;
  54379. private _textureMatrix;
  54380. private _size;
  54381. private _onLoad;
  54382. private _onError;
  54383. /**
  54384. * The texture URL.
  54385. */
  54386. url: string;
  54387. /**
  54388. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54389. */
  54390. coordinatesMode: number;
  54391. protected _isBlocking: boolean;
  54392. /**
  54393. * Sets wether or not the texture is blocking during loading.
  54394. */
  54395. /**
  54396. * Gets wether or not the texture is blocking during loading.
  54397. */
  54398. isBlocking: boolean;
  54399. protected _rotationY: number;
  54400. /**
  54401. * Sets texture matrix rotation angle around Y axis in radians.
  54402. */
  54403. /**
  54404. * Gets texture matrix rotation angle around Y axis radians.
  54405. */
  54406. rotationY: number;
  54407. /**
  54408. * Gets or sets the center of the bounding box associated with the cube texture
  54409. * It must define where the camera used to render the texture was set
  54410. */
  54411. boundingBoxPosition: Vector3;
  54412. private _boundingBoxSize;
  54413. /**
  54414. * Gets or sets the size of the bounding box associated with the cube texture
  54415. * When defined, the cubemap will switch to local mode
  54416. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54417. * @example https://www.babylonjs-playground.com/#RNASML
  54418. */
  54419. boundingBoxSize: Vector3;
  54420. /**
  54421. * Instantiates an HDRTexture from the following parameters.
  54422. *
  54423. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54424. * @param scene The scene the texture will be used in
  54425. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54426. * @param noMipmap Forces to not generate the mipmap if true
  54427. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54428. * @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)
  54429. * @param reserved Reserved flag for internal use.
  54430. */
  54431. 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>);
  54432. /**
  54433. * Get the current class name of the texture useful for serialization or dynamic coding.
  54434. * @returns "HDRCubeTexture"
  54435. */
  54436. getClassName(): string;
  54437. /**
  54438. * Occurs when the file is raw .hdr file.
  54439. */
  54440. private loadTexture;
  54441. clone(): HDRCubeTexture;
  54442. delayLoad(): void;
  54443. /**
  54444. * Get the texture reflection matrix used to rotate/transform the reflection.
  54445. * @returns the reflection matrix
  54446. */
  54447. getReflectionTextureMatrix(): Matrix;
  54448. /**
  54449. * Set the texture reflection matrix used to rotate/transform the reflection.
  54450. * @param value Define the reflection matrix to set
  54451. */
  54452. setReflectionTextureMatrix(value: Matrix): void;
  54453. /**
  54454. * Parses a JSON representation of an HDR Texture in order to create the texture
  54455. * @param parsedTexture Define the JSON representation
  54456. * @param scene Define the scene the texture should be created in
  54457. * @param rootUrl Define the root url in case we need to load relative dependencies
  54458. * @returns the newly created texture after parsing
  54459. */
  54460. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54461. serialize(): any;
  54462. }
  54463. }
  54464. declare module "babylonjs/Physics/physicsEngine" {
  54465. import { Nullable } from "babylonjs/types";
  54466. import { Vector3 } from "babylonjs/Maths/math.vector";
  54467. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  54468. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  54469. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  54470. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54471. /**
  54472. * Class used to control physics engine
  54473. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54474. */
  54475. export class PhysicsEngine implements IPhysicsEngine {
  54476. private _physicsPlugin;
  54477. /**
  54478. * Global value used to control the smallest number supported by the simulation
  54479. */
  54480. static Epsilon: number;
  54481. private _impostors;
  54482. private _joints;
  54483. private _subTimeStep;
  54484. /**
  54485. * Gets the gravity vector used by the simulation
  54486. */
  54487. gravity: Vector3;
  54488. /**
  54489. * Factory used to create the default physics plugin.
  54490. * @returns The default physics plugin
  54491. */
  54492. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54493. /**
  54494. * Creates a new Physics Engine
  54495. * @param gravity defines the gravity vector used by the simulation
  54496. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54497. */
  54498. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54499. /**
  54500. * Sets the gravity vector used by the simulation
  54501. * @param gravity defines the gravity vector to use
  54502. */
  54503. setGravity(gravity: Vector3): void;
  54504. /**
  54505. * Set the time step of the physics engine.
  54506. * Default is 1/60.
  54507. * To slow it down, enter 1/600 for example.
  54508. * To speed it up, 1/30
  54509. * @param newTimeStep defines the new timestep to apply to this world.
  54510. */
  54511. setTimeStep(newTimeStep?: number): void;
  54512. /**
  54513. * Get the time step of the physics engine.
  54514. * @returns the current time step
  54515. */
  54516. getTimeStep(): number;
  54517. /**
  54518. * Set the sub time step of the physics engine.
  54519. * Default is 0 meaning there is no sub steps
  54520. * To increase physics resolution precision, set a small value (like 1 ms)
  54521. * @param subTimeStep defines the new sub timestep used for physics resolution.
  54522. */
  54523. setSubTimeStep(subTimeStep?: number): void;
  54524. /**
  54525. * Get the sub time step of the physics engine.
  54526. * @returns the current sub time step
  54527. */
  54528. getSubTimeStep(): number;
  54529. /**
  54530. * Release all resources
  54531. */
  54532. dispose(): void;
  54533. /**
  54534. * Gets the name of the current physics plugin
  54535. * @returns the name of the plugin
  54536. */
  54537. getPhysicsPluginName(): string;
  54538. /**
  54539. * Adding a new impostor for the impostor tracking.
  54540. * This will be done by the impostor itself.
  54541. * @param impostor the impostor to add
  54542. */
  54543. addImpostor(impostor: PhysicsImpostor): void;
  54544. /**
  54545. * Remove an impostor from the engine.
  54546. * This impostor and its mesh will not longer be updated by the physics engine.
  54547. * @param impostor the impostor to remove
  54548. */
  54549. removeImpostor(impostor: PhysicsImpostor): void;
  54550. /**
  54551. * Add a joint to the physics engine
  54552. * @param mainImpostor defines the main impostor to which the joint is added.
  54553. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54554. * @param joint defines the joint that will connect both impostors.
  54555. */
  54556. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54557. /**
  54558. * Removes a joint from the simulation
  54559. * @param mainImpostor defines the impostor used with the joint
  54560. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54561. * @param joint defines the joint to remove
  54562. */
  54563. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54564. /**
  54565. * Called by the scene. No need to call it.
  54566. * @param delta defines the timespam between frames
  54567. */
  54568. _step(delta: number): void;
  54569. /**
  54570. * Gets the current plugin used to run the simulation
  54571. * @returns current plugin
  54572. */
  54573. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54574. /**
  54575. * Gets the list of physic impostors
  54576. * @returns an array of PhysicsImpostor
  54577. */
  54578. getImpostors(): Array<PhysicsImpostor>;
  54579. /**
  54580. * Gets the impostor for a physics enabled object
  54581. * @param object defines the object impersonated by the impostor
  54582. * @returns the PhysicsImpostor or null if not found
  54583. */
  54584. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54585. /**
  54586. * Gets the impostor for a physics body object
  54587. * @param body defines physics body used by the impostor
  54588. * @returns the PhysicsImpostor or null if not found
  54589. */
  54590. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54591. /**
  54592. * Does a raycast in the physics world
  54593. * @param from when should the ray start?
  54594. * @param to when should the ray end?
  54595. * @returns PhysicsRaycastResult
  54596. */
  54597. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54598. }
  54599. }
  54600. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  54601. import { Nullable } from "babylonjs/types";
  54602. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54604. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54605. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54606. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54607. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54608. /** @hidden */
  54609. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54610. private _useDeltaForWorldStep;
  54611. world: any;
  54612. name: string;
  54613. private _physicsMaterials;
  54614. private _fixedTimeStep;
  54615. private _cannonRaycastResult;
  54616. private _raycastResult;
  54617. private _physicsBodysToRemoveAfterStep;
  54618. BJSCANNON: any;
  54619. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54620. setGravity(gravity: Vector3): void;
  54621. setTimeStep(timeStep: number): void;
  54622. getTimeStep(): number;
  54623. executeStep(delta: number): void;
  54624. private _removeMarkedPhysicsBodiesFromWorld;
  54625. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54626. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54627. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54628. private _processChildMeshes;
  54629. removePhysicsBody(impostor: PhysicsImpostor): void;
  54630. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54631. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54632. private _addMaterial;
  54633. private _checkWithEpsilon;
  54634. private _createShape;
  54635. private _createHeightmap;
  54636. private _minus90X;
  54637. private _plus90X;
  54638. private _tmpPosition;
  54639. private _tmpDeltaPosition;
  54640. private _tmpUnityRotation;
  54641. private _updatePhysicsBodyTransformation;
  54642. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54643. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54644. isSupported(): boolean;
  54645. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54646. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54647. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54648. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54649. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54650. getBodyMass(impostor: PhysicsImpostor): number;
  54651. getBodyFriction(impostor: PhysicsImpostor): number;
  54652. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54653. getBodyRestitution(impostor: PhysicsImpostor): number;
  54654. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54655. sleepBody(impostor: PhysicsImpostor): void;
  54656. wakeUpBody(impostor: PhysicsImpostor): void;
  54657. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54658. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54659. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54660. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54661. getRadius(impostor: PhysicsImpostor): number;
  54662. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54663. dispose(): void;
  54664. private _extendNamespace;
  54665. /**
  54666. * Does a raycast in the physics world
  54667. * @param from when should the ray start?
  54668. * @param to when should the ray end?
  54669. * @returns PhysicsRaycastResult
  54670. */
  54671. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54672. }
  54673. }
  54674. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  54675. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54676. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54677. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54679. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54680. import { Nullable } from "babylonjs/types";
  54681. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54682. /** @hidden */
  54683. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54684. world: any;
  54685. name: string;
  54686. BJSOIMO: any;
  54687. private _raycastResult;
  54688. constructor(iterations?: number, oimoInjection?: any);
  54689. setGravity(gravity: Vector3): void;
  54690. setTimeStep(timeStep: number): void;
  54691. getTimeStep(): number;
  54692. private _tmpImpostorsArray;
  54693. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54694. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54695. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54696. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54697. private _tmpPositionVector;
  54698. removePhysicsBody(impostor: PhysicsImpostor): void;
  54699. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54700. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54701. isSupported(): boolean;
  54702. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54703. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54704. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54705. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54706. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54707. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54708. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54709. getBodyMass(impostor: PhysicsImpostor): number;
  54710. getBodyFriction(impostor: PhysicsImpostor): number;
  54711. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54712. getBodyRestitution(impostor: PhysicsImpostor): number;
  54713. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54714. sleepBody(impostor: PhysicsImpostor): void;
  54715. wakeUpBody(impostor: PhysicsImpostor): void;
  54716. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54717. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54718. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54719. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54720. getRadius(impostor: PhysicsImpostor): number;
  54721. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54722. dispose(): void;
  54723. /**
  54724. * Does a raycast in the physics world
  54725. * @param from when should the ray start?
  54726. * @param to when should the ray end?
  54727. * @returns PhysicsRaycastResult
  54728. */
  54729. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54730. }
  54731. }
  54732. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  54733. import { Nullable } from "babylonjs/types";
  54734. import { Scene } from "babylonjs/scene";
  54735. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  54736. import { Color4 } from "babylonjs/Maths/math.color";
  54737. import { Mesh } from "babylonjs/Meshes/mesh";
  54738. /**
  54739. * Class containing static functions to help procedurally build meshes
  54740. */
  54741. export class RibbonBuilder {
  54742. /**
  54743. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54744. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54745. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54746. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54747. * * 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
  54748. * * 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
  54749. * * 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
  54750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54752. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54753. * * 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
  54754. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54755. * * 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
  54756. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54758. * @param name defines the name of the mesh
  54759. * @param options defines the options used to create the mesh
  54760. * @param scene defines the hosting scene
  54761. * @returns the ribbon mesh
  54762. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54763. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54764. */
  54765. static CreateRibbon(name: string, options: {
  54766. pathArray: Vector3[][];
  54767. closeArray?: boolean;
  54768. closePath?: boolean;
  54769. offset?: number;
  54770. updatable?: boolean;
  54771. sideOrientation?: number;
  54772. frontUVs?: Vector4;
  54773. backUVs?: Vector4;
  54774. instance?: Mesh;
  54775. invertUV?: boolean;
  54776. uvs?: Vector2[];
  54777. colors?: Color4[];
  54778. }, scene?: Nullable<Scene>): Mesh;
  54779. }
  54780. }
  54781. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  54782. import { Nullable } from "babylonjs/types";
  54783. import { Scene } from "babylonjs/scene";
  54784. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  54785. import { Mesh } from "babylonjs/Meshes/mesh";
  54786. /**
  54787. * Class containing static functions to help procedurally build meshes
  54788. */
  54789. export class ShapeBuilder {
  54790. /**
  54791. * 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.
  54792. * * 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.
  54793. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54794. * * 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.
  54795. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54796. * * 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
  54797. * * 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
  54798. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54799. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54800. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54801. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54802. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54803. * @param name defines the name of the mesh
  54804. * @param options defines the options used to create the mesh
  54805. * @param scene defines the hosting scene
  54806. * @returns the extruded shape mesh
  54807. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54808. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54809. */
  54810. static ExtrudeShape(name: string, options: {
  54811. shape: Vector3[];
  54812. path: Vector3[];
  54813. scale?: number;
  54814. rotation?: number;
  54815. cap?: number;
  54816. updatable?: boolean;
  54817. sideOrientation?: number;
  54818. frontUVs?: Vector4;
  54819. backUVs?: Vector4;
  54820. instance?: Mesh;
  54821. invertUV?: boolean;
  54822. }, scene?: Nullable<Scene>): Mesh;
  54823. /**
  54824. * Creates an custom extruded shape mesh.
  54825. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54826. * * 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.
  54827. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54828. * * 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
  54829. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54830. * * 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
  54831. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54832. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54833. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54834. * * 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
  54835. * * 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
  54836. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54839. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54841. * @param name defines the name of the mesh
  54842. * @param options defines the options used to create the mesh
  54843. * @param scene defines the hosting scene
  54844. * @returns the custom extruded shape mesh
  54845. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54846. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54847. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54848. */
  54849. static ExtrudeShapeCustom(name: string, options: {
  54850. shape: Vector3[];
  54851. path: Vector3[];
  54852. scaleFunction?: any;
  54853. rotationFunction?: any;
  54854. ribbonCloseArray?: boolean;
  54855. ribbonClosePath?: boolean;
  54856. cap?: number;
  54857. updatable?: boolean;
  54858. sideOrientation?: number;
  54859. frontUVs?: Vector4;
  54860. backUVs?: Vector4;
  54861. instance?: Mesh;
  54862. invertUV?: boolean;
  54863. }, scene?: Nullable<Scene>): Mesh;
  54864. private static _ExtrudeShapeGeneric;
  54865. }
  54866. }
  54867. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  54868. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  54869. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54870. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54871. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54872. import { Nullable } from "babylonjs/types";
  54873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54874. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54875. /**
  54876. * AmmoJS Physics plugin
  54877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  54878. * @see https://github.com/kripken/ammo.js/
  54879. */
  54880. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  54881. private _useDeltaForWorldStep;
  54882. /**
  54883. * Reference to the Ammo library
  54884. */
  54885. bjsAMMO: any;
  54886. /**
  54887. * Created ammoJS world which physics bodies are added to
  54888. */
  54889. world: any;
  54890. /**
  54891. * Name of the plugin
  54892. */
  54893. name: string;
  54894. private _timeStep;
  54895. private _fixedTimeStep;
  54896. private _maxSteps;
  54897. private _tmpQuaternion;
  54898. private _tmpAmmoTransform;
  54899. private _tmpAmmoQuaternion;
  54900. private _tmpAmmoConcreteContactResultCallback;
  54901. private _collisionConfiguration;
  54902. private _dispatcher;
  54903. private _overlappingPairCache;
  54904. private _solver;
  54905. private _softBodySolver;
  54906. private _tmpAmmoVectorA;
  54907. private _tmpAmmoVectorB;
  54908. private _tmpAmmoVectorC;
  54909. private _tmpAmmoVectorD;
  54910. private _tmpContactCallbackResult;
  54911. private _tmpAmmoVectorRCA;
  54912. private _tmpAmmoVectorRCB;
  54913. private _raycastResult;
  54914. private static readonly DISABLE_COLLISION_FLAG;
  54915. private static readonly KINEMATIC_FLAG;
  54916. private static readonly DISABLE_DEACTIVATION_FLAG;
  54917. /**
  54918. * Initializes the ammoJS plugin
  54919. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  54920. * @param ammoInjection can be used to inject your own ammo reference
  54921. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  54922. */
  54923. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  54924. /**
  54925. * Sets the gravity of the physics world (m/(s^2))
  54926. * @param gravity Gravity to set
  54927. */
  54928. setGravity(gravity: Vector3): void;
  54929. /**
  54930. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  54931. * @param timeStep timestep to use in seconds
  54932. */
  54933. setTimeStep(timeStep: number): void;
  54934. /**
  54935. * 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)
  54936. * @param fixedTimeStep fixedTimeStep to use in seconds
  54937. */
  54938. setFixedTimeStep(fixedTimeStep: number): void;
  54939. /**
  54940. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  54941. * @param maxSteps the maximum number of steps by the physics engine per frame
  54942. */
  54943. setMaxSteps(maxSteps: number): void;
  54944. /**
  54945. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  54946. * @returns the current timestep in seconds
  54947. */
  54948. getTimeStep(): number;
  54949. /**
  54950. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  54951. */
  54952. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  54953. private _isImpostorInContact;
  54954. private _isImpostorPairInContact;
  54955. private _stepSimulation;
  54956. /**
  54957. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  54958. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  54959. * After the step the babylon meshes are set to the position of the physics imposters
  54960. * @param delta amount of time to step forward
  54961. * @param impostors array of imposters to update before/after the step
  54962. */
  54963. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54964. /**
  54965. * Update babylon mesh to match physics world object
  54966. * @param impostor imposter to match
  54967. */
  54968. private _afterSoftStep;
  54969. /**
  54970. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54971. * @param impostor imposter to match
  54972. */
  54973. private _ropeStep;
  54974. /**
  54975. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54976. * @param impostor imposter to match
  54977. */
  54978. private _softbodyOrClothStep;
  54979. private _tmpVector;
  54980. private _tmpMatrix;
  54981. /**
  54982. * Applies an impulse on the imposter
  54983. * @param impostor imposter to apply impulse to
  54984. * @param force amount of force to be applied to the imposter
  54985. * @param contactPoint the location to apply the impulse on the imposter
  54986. */
  54987. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54988. /**
  54989. * Applies a force on the imposter
  54990. * @param impostor imposter to apply force
  54991. * @param force amount of force to be applied to the imposter
  54992. * @param contactPoint the location to apply the force on the imposter
  54993. */
  54994. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54995. /**
  54996. * Creates a physics body using the plugin
  54997. * @param impostor the imposter to create the physics body on
  54998. */
  54999. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55000. /**
  55001. * Removes the physics body from the imposter and disposes of the body's memory
  55002. * @param impostor imposter to remove the physics body from
  55003. */
  55004. removePhysicsBody(impostor: PhysicsImpostor): void;
  55005. /**
  55006. * Generates a joint
  55007. * @param impostorJoint the imposter joint to create the joint with
  55008. */
  55009. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55010. /**
  55011. * Removes a joint
  55012. * @param impostorJoint the imposter joint to remove the joint from
  55013. */
  55014. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55015. private _addMeshVerts;
  55016. /**
  55017. * Initialise the soft body vertices to match its object's (mesh) vertices
  55018. * Softbody vertices (nodes) are in world space and to match this
  55019. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55020. * @param impostor to create the softbody for
  55021. */
  55022. private _softVertexData;
  55023. /**
  55024. * Create an impostor's soft body
  55025. * @param impostor to create the softbody for
  55026. */
  55027. private _createSoftbody;
  55028. /**
  55029. * Create cloth for an impostor
  55030. * @param impostor to create the softbody for
  55031. */
  55032. private _createCloth;
  55033. /**
  55034. * Create rope for an impostor
  55035. * @param impostor to create the softbody for
  55036. */
  55037. private _createRope;
  55038. /**
  55039. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55040. * @param impostor to create the custom physics shape for
  55041. */
  55042. private _createCustom;
  55043. private _addHullVerts;
  55044. private _createShape;
  55045. /**
  55046. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55047. * @param impostor imposter containing the physics body and babylon object
  55048. */
  55049. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55050. /**
  55051. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55052. * @param impostor imposter containing the physics body and babylon object
  55053. * @param newPosition new position
  55054. * @param newRotation new rotation
  55055. */
  55056. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55057. /**
  55058. * If this plugin is supported
  55059. * @returns true if its supported
  55060. */
  55061. isSupported(): boolean;
  55062. /**
  55063. * Sets the linear velocity of the physics body
  55064. * @param impostor imposter to set the velocity on
  55065. * @param velocity velocity to set
  55066. */
  55067. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55068. /**
  55069. * Sets the angular velocity of the physics body
  55070. * @param impostor imposter to set the velocity on
  55071. * @param velocity velocity to set
  55072. */
  55073. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55074. /**
  55075. * gets the linear velocity
  55076. * @param impostor imposter to get linear velocity from
  55077. * @returns linear velocity
  55078. */
  55079. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55080. /**
  55081. * gets the angular velocity
  55082. * @param impostor imposter to get angular velocity from
  55083. * @returns angular velocity
  55084. */
  55085. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55086. /**
  55087. * Sets the mass of physics body
  55088. * @param impostor imposter to set the mass on
  55089. * @param mass mass to set
  55090. */
  55091. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55092. /**
  55093. * Gets the mass of the physics body
  55094. * @param impostor imposter to get the mass from
  55095. * @returns mass
  55096. */
  55097. getBodyMass(impostor: PhysicsImpostor): number;
  55098. /**
  55099. * Gets friction of the impostor
  55100. * @param impostor impostor to get friction from
  55101. * @returns friction value
  55102. */
  55103. getBodyFriction(impostor: PhysicsImpostor): number;
  55104. /**
  55105. * Sets friction of the impostor
  55106. * @param impostor impostor to set friction on
  55107. * @param friction friction value
  55108. */
  55109. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55110. /**
  55111. * Gets restitution of the impostor
  55112. * @param impostor impostor to get restitution from
  55113. * @returns restitution value
  55114. */
  55115. getBodyRestitution(impostor: PhysicsImpostor): number;
  55116. /**
  55117. * Sets resitution of the impostor
  55118. * @param impostor impostor to set resitution on
  55119. * @param restitution resitution value
  55120. */
  55121. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55122. /**
  55123. * Gets pressure inside the impostor
  55124. * @param impostor impostor to get pressure from
  55125. * @returns pressure value
  55126. */
  55127. getBodyPressure(impostor: PhysicsImpostor): number;
  55128. /**
  55129. * Sets pressure inside a soft body impostor
  55130. * Cloth and rope must remain 0 pressure
  55131. * @param impostor impostor to set pressure on
  55132. * @param pressure pressure value
  55133. */
  55134. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55135. /**
  55136. * Gets stiffness of the impostor
  55137. * @param impostor impostor to get stiffness from
  55138. * @returns pressure value
  55139. */
  55140. getBodyStiffness(impostor: PhysicsImpostor): number;
  55141. /**
  55142. * Sets stiffness of the impostor
  55143. * @param impostor impostor to set stiffness on
  55144. * @param stiffness stiffness value from 0 to 1
  55145. */
  55146. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55147. /**
  55148. * Gets velocityIterations of the impostor
  55149. * @param impostor impostor to get velocity iterations from
  55150. * @returns velocityIterations value
  55151. */
  55152. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55153. /**
  55154. * Sets velocityIterations of the impostor
  55155. * @param impostor impostor to set velocity iterations on
  55156. * @param velocityIterations velocityIterations value
  55157. */
  55158. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55159. /**
  55160. * Gets positionIterations of the impostor
  55161. * @param impostor impostor to get position iterations from
  55162. * @returns positionIterations value
  55163. */
  55164. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55165. /**
  55166. * Sets positionIterations of the impostor
  55167. * @param impostor impostor to set position on
  55168. * @param positionIterations positionIterations value
  55169. */
  55170. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55171. /**
  55172. * Append an anchor to a cloth object
  55173. * @param impostor is the cloth impostor to add anchor to
  55174. * @param otherImpostor is the rigid impostor to anchor to
  55175. * @param width ratio across width from 0 to 1
  55176. * @param height ratio up height from 0 to 1
  55177. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55178. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55179. */
  55180. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55181. /**
  55182. * Append an hook to a rope object
  55183. * @param impostor is the rope impostor to add hook to
  55184. * @param otherImpostor is the rigid impostor to hook to
  55185. * @param length ratio along the rope from 0 to 1
  55186. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55187. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55188. */
  55189. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55190. /**
  55191. * Sleeps the physics body and stops it from being active
  55192. * @param impostor impostor to sleep
  55193. */
  55194. sleepBody(impostor: PhysicsImpostor): void;
  55195. /**
  55196. * Activates the physics body
  55197. * @param impostor impostor to activate
  55198. */
  55199. wakeUpBody(impostor: PhysicsImpostor): void;
  55200. /**
  55201. * Updates the distance parameters of the joint
  55202. * @param joint joint to update
  55203. * @param maxDistance maximum distance of the joint
  55204. * @param minDistance minimum distance of the joint
  55205. */
  55206. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55207. /**
  55208. * Sets a motor on the joint
  55209. * @param joint joint to set motor on
  55210. * @param speed speed of the motor
  55211. * @param maxForce maximum force of the motor
  55212. * @param motorIndex index of the motor
  55213. */
  55214. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55215. /**
  55216. * Sets the motors limit
  55217. * @param joint joint to set limit on
  55218. * @param upperLimit upper limit
  55219. * @param lowerLimit lower limit
  55220. */
  55221. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55222. /**
  55223. * Syncs the position and rotation of a mesh with the impostor
  55224. * @param mesh mesh to sync
  55225. * @param impostor impostor to update the mesh with
  55226. */
  55227. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55228. /**
  55229. * Gets the radius of the impostor
  55230. * @param impostor impostor to get radius from
  55231. * @returns the radius
  55232. */
  55233. getRadius(impostor: PhysicsImpostor): number;
  55234. /**
  55235. * Gets the box size of the impostor
  55236. * @param impostor impostor to get box size from
  55237. * @param result the resulting box size
  55238. */
  55239. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55240. /**
  55241. * Disposes of the impostor
  55242. */
  55243. dispose(): void;
  55244. /**
  55245. * Does a raycast in the physics world
  55246. * @param from when should the ray start?
  55247. * @param to when should the ray end?
  55248. * @returns PhysicsRaycastResult
  55249. */
  55250. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55251. }
  55252. }
  55253. declare module "babylonjs/Probes/reflectionProbe" {
  55254. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55255. import { Vector3 } from "babylonjs/Maths/math.vector";
  55256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55257. import { Nullable } from "babylonjs/types";
  55258. import { Scene } from "babylonjs/scene";
  55259. module "babylonjs/abstractScene" {
  55260. interface AbstractScene {
  55261. /**
  55262. * The list of reflection probes added to the scene
  55263. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55264. */
  55265. reflectionProbes: Array<ReflectionProbe>;
  55266. /**
  55267. * Removes the given reflection probe from this scene.
  55268. * @param toRemove The reflection probe to remove
  55269. * @returns The index of the removed reflection probe
  55270. */
  55271. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55272. /**
  55273. * Adds the given reflection probe to this scene.
  55274. * @param newReflectionProbe The reflection probe to add
  55275. */
  55276. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55277. }
  55278. }
  55279. /**
  55280. * Class used to generate realtime reflection / refraction cube textures
  55281. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55282. */
  55283. export class ReflectionProbe {
  55284. /** defines the name of the probe */
  55285. name: string;
  55286. private _scene;
  55287. private _renderTargetTexture;
  55288. private _projectionMatrix;
  55289. private _viewMatrix;
  55290. private _target;
  55291. private _add;
  55292. private _attachedMesh;
  55293. private _invertYAxis;
  55294. /** Gets or sets probe position (center of the cube map) */
  55295. position: Vector3;
  55296. /**
  55297. * Creates a new reflection probe
  55298. * @param name defines the name of the probe
  55299. * @param size defines the texture resolution (for each face)
  55300. * @param scene defines the hosting scene
  55301. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55302. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55303. */
  55304. constructor(
  55305. /** defines the name of the probe */
  55306. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55307. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55308. samples: number;
  55309. /** Gets or sets the refresh rate to use (on every frame by default) */
  55310. refreshRate: number;
  55311. /**
  55312. * Gets the hosting scene
  55313. * @returns a Scene
  55314. */
  55315. getScene(): Scene;
  55316. /** Gets the internal CubeTexture used to render to */
  55317. readonly cubeTexture: RenderTargetTexture;
  55318. /** Gets the list of meshes to render */
  55319. readonly renderList: Nullable<AbstractMesh[]>;
  55320. /**
  55321. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55322. * @param mesh defines the mesh to attach to
  55323. */
  55324. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55325. /**
  55326. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55327. * @param renderingGroupId The rendering group id corresponding to its index
  55328. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55329. */
  55330. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55331. /**
  55332. * Clean all associated resources
  55333. */
  55334. dispose(): void;
  55335. /**
  55336. * Converts the reflection probe information to a readable string for debug purpose.
  55337. * @param fullDetails Supports for multiple levels of logging within scene loading
  55338. * @returns the human readable reflection probe info
  55339. */
  55340. toString(fullDetails?: boolean): string;
  55341. /**
  55342. * Get the class name of the relfection probe.
  55343. * @returns "ReflectionProbe"
  55344. */
  55345. getClassName(): string;
  55346. /**
  55347. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55348. * @returns The JSON representation of the texture
  55349. */
  55350. serialize(): any;
  55351. /**
  55352. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55353. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55354. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55355. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55356. * @returns The parsed reflection probe if successful
  55357. */
  55358. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55359. }
  55360. }
  55361. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  55362. /** @hidden */
  55363. export var _BabylonLoaderRegistered: boolean;
  55364. /**
  55365. * Helps setting up some configuration for the babylon file loader.
  55366. */
  55367. export class BabylonFileLoaderConfiguration {
  55368. /**
  55369. * The loader does not allow injecting custom physix engine into the plugins.
  55370. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55371. * So you could set this variable to your engine import to make it work.
  55372. */
  55373. static LoaderInjectedPhysicsEngine: any;
  55374. }
  55375. }
  55376. declare module "babylonjs/Loading/Plugins/index" {
  55377. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  55378. }
  55379. declare module "babylonjs/Loading/index" {
  55380. export * from "babylonjs/Loading/loadingScreen";
  55381. export * from "babylonjs/Loading/Plugins/index";
  55382. export * from "babylonjs/Loading/sceneLoader";
  55383. export * from "babylonjs/Loading/sceneLoaderFlags";
  55384. }
  55385. declare module "babylonjs/Materials/Background/index" {
  55386. export * from "babylonjs/Materials/Background/backgroundMaterial";
  55387. }
  55388. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  55389. import { Scene } from "babylonjs/scene";
  55390. import { Color3 } from "babylonjs/Maths/math.color";
  55391. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  55392. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55393. /**
  55394. * The Physically based simple base material of BJS.
  55395. *
  55396. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55397. * It is used as the base class for both the specGloss and metalRough conventions.
  55398. */
  55399. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55400. /**
  55401. * Number of Simultaneous lights allowed on the material.
  55402. */
  55403. maxSimultaneousLights: number;
  55404. /**
  55405. * If sets to true, disables all the lights affecting the material.
  55406. */
  55407. disableLighting: boolean;
  55408. /**
  55409. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55410. */
  55411. environmentTexture: BaseTexture;
  55412. /**
  55413. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55414. */
  55415. invertNormalMapX: boolean;
  55416. /**
  55417. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55418. */
  55419. invertNormalMapY: boolean;
  55420. /**
  55421. * Normal map used in the model.
  55422. */
  55423. normalTexture: BaseTexture;
  55424. /**
  55425. * Emissivie color used to self-illuminate the model.
  55426. */
  55427. emissiveColor: Color3;
  55428. /**
  55429. * Emissivie texture used to self-illuminate the model.
  55430. */
  55431. emissiveTexture: BaseTexture;
  55432. /**
  55433. * Occlusion Channel Strenght.
  55434. */
  55435. occlusionStrength: number;
  55436. /**
  55437. * Occlusion Texture of the material (adding extra occlusion effects).
  55438. */
  55439. occlusionTexture: BaseTexture;
  55440. /**
  55441. * Defines the alpha limits in alpha test mode.
  55442. */
  55443. alphaCutOff: number;
  55444. /**
  55445. * Gets the current double sided mode.
  55446. */
  55447. /**
  55448. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55449. */
  55450. doubleSided: boolean;
  55451. /**
  55452. * Stores the pre-calculated light information of a mesh in a texture.
  55453. */
  55454. lightmapTexture: BaseTexture;
  55455. /**
  55456. * If true, the light map contains occlusion information instead of lighting info.
  55457. */
  55458. useLightmapAsShadowmap: boolean;
  55459. /**
  55460. * Instantiates a new PBRMaterial instance.
  55461. *
  55462. * @param name The material name
  55463. * @param scene The scene the material will be use in.
  55464. */
  55465. constructor(name: string, scene: Scene);
  55466. getClassName(): string;
  55467. }
  55468. }
  55469. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  55470. import { Scene } from "babylonjs/scene";
  55471. import { Color3 } from "babylonjs/Maths/math.color";
  55472. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55473. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55474. /**
  55475. * The PBR material of BJS following the metal roughness convention.
  55476. *
  55477. * This fits to the PBR convention in the GLTF definition:
  55478. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55479. */
  55480. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55481. /**
  55482. * The base color has two different interpretations depending on the value of metalness.
  55483. * When the material is a metal, the base color is the specific measured reflectance value
  55484. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55485. * of the material.
  55486. */
  55487. baseColor: Color3;
  55488. /**
  55489. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55490. * well as opacity information in the alpha channel.
  55491. */
  55492. baseTexture: BaseTexture;
  55493. /**
  55494. * Specifies the metallic scalar value of the material.
  55495. * Can also be used to scale the metalness values of the metallic texture.
  55496. */
  55497. metallic: number;
  55498. /**
  55499. * Specifies the roughness scalar value of the material.
  55500. * Can also be used to scale the roughness values of the metallic texture.
  55501. */
  55502. roughness: number;
  55503. /**
  55504. * Texture containing both the metallic value in the B channel and the
  55505. * roughness value in the G channel to keep better precision.
  55506. */
  55507. metallicRoughnessTexture: BaseTexture;
  55508. /**
  55509. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55510. *
  55511. * @param name The material name
  55512. * @param scene The scene the material will be use in.
  55513. */
  55514. constructor(name: string, scene: Scene);
  55515. /**
  55516. * Return the currrent class name of the material.
  55517. */
  55518. getClassName(): string;
  55519. /**
  55520. * Makes a duplicate of the current material.
  55521. * @param name - name to use for the new material.
  55522. */
  55523. clone(name: string): PBRMetallicRoughnessMaterial;
  55524. /**
  55525. * Serialize the material to a parsable JSON object.
  55526. */
  55527. serialize(): any;
  55528. /**
  55529. * Parses a JSON object correponding to the serialize function.
  55530. */
  55531. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55532. }
  55533. }
  55534. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  55535. import { Scene } from "babylonjs/scene";
  55536. import { Color3 } from "babylonjs/Maths/math.color";
  55537. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55538. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55539. /**
  55540. * The PBR material of BJS following the specular glossiness convention.
  55541. *
  55542. * This fits to the PBR convention in the GLTF definition:
  55543. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55544. */
  55545. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55546. /**
  55547. * Specifies the diffuse color of the material.
  55548. */
  55549. diffuseColor: Color3;
  55550. /**
  55551. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55552. * channel.
  55553. */
  55554. diffuseTexture: BaseTexture;
  55555. /**
  55556. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55557. */
  55558. specularColor: Color3;
  55559. /**
  55560. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55561. */
  55562. glossiness: number;
  55563. /**
  55564. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55565. */
  55566. specularGlossinessTexture: BaseTexture;
  55567. /**
  55568. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55569. *
  55570. * @param name The material name
  55571. * @param scene The scene the material will be use in.
  55572. */
  55573. constructor(name: string, scene: Scene);
  55574. /**
  55575. * Return the currrent class name of the material.
  55576. */
  55577. getClassName(): string;
  55578. /**
  55579. * Makes a duplicate of the current material.
  55580. * @param name - name to use for the new material.
  55581. */
  55582. clone(name: string): PBRSpecularGlossinessMaterial;
  55583. /**
  55584. * Serialize the material to a parsable JSON object.
  55585. */
  55586. serialize(): any;
  55587. /**
  55588. * Parses a JSON object correponding to the serialize function.
  55589. */
  55590. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55591. }
  55592. }
  55593. declare module "babylonjs/Materials/PBR/index" {
  55594. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  55595. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55596. export * from "babylonjs/Materials/PBR/pbrMaterial";
  55597. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  55598. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  55599. }
  55600. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  55601. import { Nullable } from "babylonjs/types";
  55602. import { Scene } from "babylonjs/scene";
  55603. import { Matrix } from "babylonjs/Maths/math.vector";
  55604. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55605. /**
  55606. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55607. * It can help converting any input color in a desired output one. This can then be used to create effects
  55608. * from sepia, black and white to sixties or futuristic rendering...
  55609. *
  55610. * The only supported format is currently 3dl.
  55611. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55612. */
  55613. export class ColorGradingTexture extends BaseTexture {
  55614. /**
  55615. * The current texture matrix. (will always be identity in color grading texture)
  55616. */
  55617. private _textureMatrix;
  55618. /**
  55619. * The texture URL.
  55620. */
  55621. url: string;
  55622. /**
  55623. * Empty line regex stored for GC.
  55624. */
  55625. private static _noneEmptyLineRegex;
  55626. private _engine;
  55627. /**
  55628. * Instantiates a ColorGradingTexture from the following parameters.
  55629. *
  55630. * @param url The location of the color gradind data (currently only supporting 3dl)
  55631. * @param scene The scene the texture will be used in
  55632. */
  55633. constructor(url: string, scene: Scene);
  55634. /**
  55635. * Returns the texture matrix used in most of the material.
  55636. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55637. */
  55638. getTextureMatrix(): Matrix;
  55639. /**
  55640. * Occurs when the file being loaded is a .3dl LUT file.
  55641. */
  55642. private load3dlTexture;
  55643. /**
  55644. * Starts the loading process of the texture.
  55645. */
  55646. private loadTexture;
  55647. /**
  55648. * Clones the color gradind texture.
  55649. */
  55650. clone(): ColorGradingTexture;
  55651. /**
  55652. * Called during delayed load for textures.
  55653. */
  55654. delayLoad(): void;
  55655. /**
  55656. * Parses a color grading texture serialized by Babylon.
  55657. * @param parsedTexture The texture information being parsedTexture
  55658. * @param scene The scene to load the texture in
  55659. * @param rootUrl The root url of the data assets to load
  55660. * @return A color gradind texture
  55661. */
  55662. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55663. /**
  55664. * Serializes the LUT texture to json format.
  55665. */
  55666. serialize(): any;
  55667. }
  55668. }
  55669. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  55670. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55671. import { Scene } from "babylonjs/scene";
  55672. import { Nullable } from "babylonjs/types";
  55673. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55674. /**
  55675. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55676. */
  55677. export class EquiRectangularCubeTexture extends BaseTexture {
  55678. /** The six faces of the cube. */
  55679. private static _FacesMapping;
  55680. private _noMipmap;
  55681. private _onLoad;
  55682. private _onError;
  55683. /** The size of the cubemap. */
  55684. private _size;
  55685. /** The buffer of the image. */
  55686. private _buffer;
  55687. /** The width of the input image. */
  55688. private _width;
  55689. /** The height of the input image. */
  55690. private _height;
  55691. /** The URL to the image. */
  55692. url: string;
  55693. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55694. coordinatesMode: number;
  55695. /**
  55696. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55697. * @param url The location of the image
  55698. * @param scene The scene the texture will be used in
  55699. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55700. * @param noMipmap Forces to not generate the mipmap if true
  55701. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55702. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55703. * @param onLoad — defines a callback called when texture is loaded
  55704. * @param onError — defines a callback called if there is an error
  55705. */
  55706. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55707. /**
  55708. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55709. */
  55710. private loadImage;
  55711. /**
  55712. * Convert the image buffer into a cubemap and create a CubeTexture.
  55713. */
  55714. private loadTexture;
  55715. /**
  55716. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55717. * @param buffer The ArrayBuffer that should be converted.
  55718. * @returns The buffer as Float32Array.
  55719. */
  55720. private getFloat32ArrayFromArrayBuffer;
  55721. /**
  55722. * Get the current class name of the texture useful for serialization or dynamic coding.
  55723. * @returns "EquiRectangularCubeTexture"
  55724. */
  55725. getClassName(): string;
  55726. /**
  55727. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55728. * @returns A clone of the current EquiRectangularCubeTexture.
  55729. */
  55730. clone(): EquiRectangularCubeTexture;
  55731. }
  55732. }
  55733. declare module "babylonjs/Misc/tga" {
  55734. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55735. /**
  55736. * Based on jsTGALoader - Javascript loader for TGA file
  55737. * By Vincent Thibault
  55738. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55739. */
  55740. export class TGATools {
  55741. private static _TYPE_INDEXED;
  55742. private static _TYPE_RGB;
  55743. private static _TYPE_GREY;
  55744. private static _TYPE_RLE_INDEXED;
  55745. private static _TYPE_RLE_RGB;
  55746. private static _TYPE_RLE_GREY;
  55747. private static _ORIGIN_MASK;
  55748. private static _ORIGIN_SHIFT;
  55749. private static _ORIGIN_BL;
  55750. private static _ORIGIN_BR;
  55751. private static _ORIGIN_UL;
  55752. private static _ORIGIN_UR;
  55753. /**
  55754. * Gets the header of a TGA file
  55755. * @param data defines the TGA data
  55756. * @returns the header
  55757. */
  55758. static GetTGAHeader(data: Uint8Array): any;
  55759. /**
  55760. * Uploads TGA content to a Babylon Texture
  55761. * @hidden
  55762. */
  55763. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55764. /** @hidden */
  55765. 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;
  55766. /** @hidden */
  55767. 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;
  55768. /** @hidden */
  55769. 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;
  55770. /** @hidden */
  55771. 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;
  55772. /** @hidden */
  55773. 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;
  55774. /** @hidden */
  55775. 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;
  55776. }
  55777. }
  55778. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  55779. import { Nullable } from "babylonjs/types";
  55780. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55781. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55782. /**
  55783. * Implementation of the TGA Texture Loader.
  55784. * @hidden
  55785. */
  55786. export class _TGATextureLoader implements IInternalTextureLoader {
  55787. /**
  55788. * Defines wether the loader supports cascade loading the different faces.
  55789. */
  55790. readonly supportCascades: boolean;
  55791. /**
  55792. * This returns if the loader support the current file information.
  55793. * @param extension defines the file extension of the file being loaded
  55794. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55795. * @param fallback defines the fallback internal texture if any
  55796. * @param isBase64 defines whether the texture is encoded as a base64
  55797. * @param isBuffer defines whether the texture data are stored as a buffer
  55798. * @returns true if the loader can load the specified file
  55799. */
  55800. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55801. /**
  55802. * Transform the url before loading if required.
  55803. * @param rootUrl the url of the texture
  55804. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55805. * @returns the transformed texture
  55806. */
  55807. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55808. /**
  55809. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55810. * @param rootUrl the url of the texture
  55811. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55812. * @returns the fallback texture
  55813. */
  55814. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55815. /**
  55816. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55817. * @param data contains the texture data
  55818. * @param texture defines the BabylonJS internal texture
  55819. * @param createPolynomials will be true if polynomials have been requested
  55820. * @param onLoad defines the callback to trigger once the texture is ready
  55821. * @param onError defines the callback to trigger in case of error
  55822. */
  55823. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55824. /**
  55825. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55826. * @param data contains the texture data
  55827. * @param texture defines the BabylonJS internal texture
  55828. * @param callback defines the method to call once ready to upload
  55829. */
  55830. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55831. }
  55832. }
  55833. declare module "babylonjs/Misc/basis" {
  55834. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55835. /**
  55836. * Info about the .basis files
  55837. */
  55838. class BasisFileInfo {
  55839. /**
  55840. * If the file has alpha
  55841. */
  55842. hasAlpha: boolean;
  55843. /**
  55844. * Info about each image of the basis file
  55845. */
  55846. images: Array<{
  55847. levels: Array<{
  55848. width: number;
  55849. height: number;
  55850. transcodedPixels: ArrayBufferView;
  55851. }>;
  55852. }>;
  55853. }
  55854. /**
  55855. * Result of transcoding a basis file
  55856. */
  55857. class TranscodeResult {
  55858. /**
  55859. * Info about the .basis file
  55860. */
  55861. fileInfo: BasisFileInfo;
  55862. /**
  55863. * Format to use when loading the file
  55864. */
  55865. format: number;
  55866. }
  55867. /**
  55868. * Configuration options for the Basis transcoder
  55869. */
  55870. export class BasisTranscodeConfiguration {
  55871. /**
  55872. * Supported compression formats used to determine the supported output format of the transcoder
  55873. */
  55874. supportedCompressionFormats?: {
  55875. /**
  55876. * etc1 compression format
  55877. */
  55878. etc1?: boolean;
  55879. /**
  55880. * s3tc compression format
  55881. */
  55882. s3tc?: boolean;
  55883. /**
  55884. * pvrtc compression format
  55885. */
  55886. pvrtc?: boolean;
  55887. /**
  55888. * etc2 compression format
  55889. */
  55890. etc2?: boolean;
  55891. };
  55892. /**
  55893. * If mipmap levels should be loaded for transcoded images (Default: true)
  55894. */
  55895. loadMipmapLevels?: boolean;
  55896. /**
  55897. * Index of a single image to load (Default: all images)
  55898. */
  55899. loadSingleImage?: number;
  55900. }
  55901. /**
  55902. * Used to load .Basis files
  55903. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  55904. */
  55905. export class BasisTools {
  55906. private static _IgnoreSupportedFormats;
  55907. /**
  55908. * URL to use when loading the basis transcoder
  55909. */
  55910. static JSModuleURL: string;
  55911. /**
  55912. * URL to use when loading the wasm module for the transcoder
  55913. */
  55914. static WasmModuleURL: string;
  55915. /**
  55916. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  55917. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  55918. * @returns internal format corresponding to the Basis format
  55919. */
  55920. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  55921. private static _WorkerPromise;
  55922. private static _Worker;
  55923. private static _actionId;
  55924. private static _CreateWorkerAsync;
  55925. /**
  55926. * Transcodes a loaded image file to compressed pixel data
  55927. * @param imageData image data to transcode
  55928. * @param config configuration options for the transcoding
  55929. * @returns a promise resulting in the transcoded image
  55930. */
  55931. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  55932. /**
  55933. * Loads a texture from the transcode result
  55934. * @param texture texture load to
  55935. * @param transcodeResult the result of transcoding the basis file to load from
  55936. */
  55937. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  55938. }
  55939. }
  55940. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  55941. import { Nullable } from "babylonjs/types";
  55942. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55943. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55944. /**
  55945. * Loader for .basis file format
  55946. */
  55947. export class _BasisTextureLoader implements IInternalTextureLoader {
  55948. /**
  55949. * Defines whether the loader supports cascade loading the different faces.
  55950. */
  55951. readonly supportCascades: boolean;
  55952. /**
  55953. * This returns if the loader support the current file information.
  55954. * @param extension defines the file extension of the file being loaded
  55955. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55956. * @param fallback defines the fallback internal texture if any
  55957. * @param isBase64 defines whether the texture is encoded as a base64
  55958. * @param isBuffer defines whether the texture data are stored as a buffer
  55959. * @returns true if the loader can load the specified file
  55960. */
  55961. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55962. /**
  55963. * Transform the url before loading if required.
  55964. * @param rootUrl the url of the texture
  55965. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55966. * @returns the transformed texture
  55967. */
  55968. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55969. /**
  55970. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55971. * @param rootUrl the url of the texture
  55972. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55973. * @returns the fallback texture
  55974. */
  55975. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55976. /**
  55977. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  55978. * @param data contains the texture data
  55979. * @param texture defines the BabylonJS internal texture
  55980. * @param createPolynomials will be true if polynomials have been requested
  55981. * @param onLoad defines the callback to trigger once the texture is ready
  55982. * @param onError defines the callback to trigger in case of error
  55983. */
  55984. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55985. /**
  55986. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55987. * @param data contains the texture data
  55988. * @param texture defines the BabylonJS internal texture
  55989. * @param callback defines the method to call once ready to upload
  55990. */
  55991. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55992. }
  55993. }
  55994. declare module "babylonjs/Materials/Textures/Loaders/index" {
  55995. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55996. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55997. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55998. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  55999. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  56000. }
  56001. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  56002. import { Scene } from "babylonjs/scene";
  56003. import { Texture } from "babylonjs/Materials/Textures/texture";
  56004. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  56005. /**
  56006. * 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.
  56007. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56008. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56009. */
  56010. export class CustomProceduralTexture extends ProceduralTexture {
  56011. private _animate;
  56012. private _time;
  56013. private _config;
  56014. private _texturePath;
  56015. /**
  56016. * Instantiates a new Custom Procedural Texture.
  56017. * 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.
  56018. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56019. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56020. * @param name Define the name of the texture
  56021. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56022. * @param size Define the size of the texture to create
  56023. * @param scene Define the scene the texture belongs to
  56024. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56025. * @param generateMipMaps Define if the texture should creates mip maps or not
  56026. */
  56027. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56028. private _loadJson;
  56029. /**
  56030. * Is the texture ready to be used ? (rendered at least once)
  56031. * @returns true if ready, otherwise, false.
  56032. */
  56033. isReady(): boolean;
  56034. /**
  56035. * Render the texture to its associated render target.
  56036. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56037. */
  56038. render(useCameraPostProcess?: boolean): void;
  56039. /**
  56040. * Update the list of dependant textures samplers in the shader.
  56041. */
  56042. updateTextures(): void;
  56043. /**
  56044. * Update the uniform values of the procedural texture in the shader.
  56045. */
  56046. updateShaderUniforms(): void;
  56047. /**
  56048. * Define if the texture animates or not.
  56049. */
  56050. animate: boolean;
  56051. }
  56052. }
  56053. declare module "babylonjs/Shaders/noise.fragment" {
  56054. /** @hidden */
  56055. export var noisePixelShader: {
  56056. name: string;
  56057. shader: string;
  56058. };
  56059. }
  56060. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  56061. import { Nullable } from "babylonjs/types";
  56062. import { Scene } from "babylonjs/scene";
  56063. import { Texture } from "babylonjs/Materials/Textures/texture";
  56064. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  56065. import "babylonjs/Shaders/noise.fragment";
  56066. /**
  56067. * Class used to generate noise procedural textures
  56068. */
  56069. export class NoiseProceduralTexture extends ProceduralTexture {
  56070. private _time;
  56071. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56072. brightness: number;
  56073. /** Defines the number of octaves to process */
  56074. octaves: number;
  56075. /** Defines the level of persistence (0.8 by default) */
  56076. persistence: number;
  56077. /** Gets or sets animation speed factor (default is 1) */
  56078. animationSpeedFactor: number;
  56079. /**
  56080. * Creates a new NoiseProceduralTexture
  56081. * @param name defines the name fo the texture
  56082. * @param size defines the size of the texture (default is 256)
  56083. * @param scene defines the hosting scene
  56084. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56085. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56086. */
  56087. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56088. private _updateShaderUniforms;
  56089. protected _getDefines(): string;
  56090. /** Generate the current state of the procedural texture */
  56091. render(useCameraPostProcess?: boolean): void;
  56092. /**
  56093. * Serializes this noise procedural texture
  56094. * @returns a serialized noise procedural texture object
  56095. */
  56096. serialize(): any;
  56097. /**
  56098. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56099. * @param parsedTexture defines parsed texture data
  56100. * @param scene defines the current scene
  56101. * @param rootUrl defines the root URL containing noise procedural texture information
  56102. * @returns a parsed NoiseProceduralTexture
  56103. */
  56104. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56105. }
  56106. }
  56107. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  56108. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  56109. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  56110. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  56111. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  56112. }
  56113. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  56114. import { Nullable } from "babylonjs/types";
  56115. import { Scene } from "babylonjs/scene";
  56116. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  56117. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56118. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  56119. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56120. /**
  56121. * Raw cube texture where the raw buffers are passed in
  56122. */
  56123. export class RawCubeTexture extends CubeTexture {
  56124. /**
  56125. * Creates a cube texture where the raw buffers are passed in.
  56126. * @param scene defines the scene the texture is attached to
  56127. * @param data defines the array of data to use to create each face
  56128. * @param size defines the size of the textures
  56129. * @param format defines the format of the data
  56130. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56131. * @param generateMipMaps defines if the engine should generate the mip levels
  56132. * @param invertY defines if data must be stored with Y axis inverted
  56133. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56134. * @param compression defines the compression used (null by default)
  56135. */
  56136. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56137. /**
  56138. * Updates the raw cube texture.
  56139. * @param data defines the data to store
  56140. * @param format defines the data format
  56141. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56142. * @param invertY defines if data must be stored with Y axis inverted
  56143. * @param compression defines the compression used (null by default)
  56144. * @param level defines which level of the texture to update
  56145. */
  56146. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56147. /**
  56148. * Updates a raw cube texture with RGBD encoded data.
  56149. * @param data defines the array of data [mipmap][face] to use to create each face
  56150. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56151. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56152. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56153. * @returns a promsie that resolves when the operation is complete
  56154. */
  56155. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56156. /**
  56157. * Clones the raw cube texture.
  56158. * @return a new cube texture
  56159. */
  56160. clone(): CubeTexture;
  56161. /** @hidden */
  56162. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56163. }
  56164. }
  56165. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  56166. import { Scene } from "babylonjs/scene";
  56167. import { Texture } from "babylonjs/Materials/Textures/texture";
  56168. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56169. /**
  56170. * Class used to store 3D textures containing user data
  56171. */
  56172. export class RawTexture3D extends Texture {
  56173. /** Gets or sets the texture format to use */
  56174. format: number;
  56175. private _engine;
  56176. /**
  56177. * Create a new RawTexture3D
  56178. * @param data defines the data of the texture
  56179. * @param width defines the width of the texture
  56180. * @param height defines the height of the texture
  56181. * @param depth defines the depth of the texture
  56182. * @param format defines the texture format to use
  56183. * @param scene defines the hosting scene
  56184. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56185. * @param invertY defines if texture must be stored with Y axis inverted
  56186. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56187. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56188. */
  56189. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56190. /** Gets or sets the texture format to use */
  56191. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56192. /**
  56193. * Update the texture with new data
  56194. * @param data defines the data to store in the texture
  56195. */
  56196. update(data: ArrayBufferView): void;
  56197. }
  56198. }
  56199. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  56200. import { Scene } from "babylonjs/scene";
  56201. import { Texture } from "babylonjs/Materials/Textures/texture";
  56202. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56203. /**
  56204. * Class used to store 2D array textures containing user data
  56205. */
  56206. export class RawTexture2DArray extends Texture {
  56207. /** Gets or sets the texture format to use */
  56208. format: number;
  56209. private _engine;
  56210. /**
  56211. * Create a new RawTexture2DArray
  56212. * @param data defines the data of the texture
  56213. * @param width defines the width of the texture
  56214. * @param height defines the height of the texture
  56215. * @param depth defines the number of layers of the texture
  56216. * @param format defines the texture format to use
  56217. * @param scene defines the hosting scene
  56218. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56219. * @param invertY defines if texture must be stored with Y axis inverted
  56220. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56221. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56222. */
  56223. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56224. /** Gets or sets the texture format to use */
  56225. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56226. /**
  56227. * Update the texture with new data
  56228. * @param data defines the data to store in the texture
  56229. */
  56230. update(data: ArrayBufferView): void;
  56231. }
  56232. }
  56233. declare module "babylonjs/Materials/Textures/refractionTexture" {
  56234. import { Scene } from "babylonjs/scene";
  56235. import { Plane } from "babylonjs/Maths/math.plane";
  56236. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56237. /**
  56238. * Creates a refraction texture used by refraction channel of the standard material.
  56239. * It is like a mirror but to see through a material.
  56240. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56241. */
  56242. export class RefractionTexture extends RenderTargetTexture {
  56243. /**
  56244. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56245. * 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.
  56246. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56247. */
  56248. refractionPlane: Plane;
  56249. /**
  56250. * Define how deep under the surface we should see.
  56251. */
  56252. depth: number;
  56253. /**
  56254. * Creates a refraction texture used by refraction channel of the standard material.
  56255. * It is like a mirror but to see through a material.
  56256. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56257. * @param name Define the texture name
  56258. * @param size Define the size of the underlying texture
  56259. * @param scene Define the scene the refraction belongs to
  56260. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56261. */
  56262. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56263. /**
  56264. * Clone the refraction texture.
  56265. * @returns the cloned texture
  56266. */
  56267. clone(): RefractionTexture;
  56268. /**
  56269. * Serialize the texture to a JSON representation you could use in Parse later on
  56270. * @returns the serialized JSON representation
  56271. */
  56272. serialize(): any;
  56273. }
  56274. }
  56275. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  56276. import { Nullable } from "babylonjs/types";
  56277. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56278. import { Matrix } from "babylonjs/Maths/math.vector";
  56279. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  56280. import "babylonjs/Engines/Extensions/engine.videoTexture";
  56281. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  56282. import { Scene } from "babylonjs/scene";
  56283. /**
  56284. * Defines the options related to the creation of an HtmlElementTexture
  56285. */
  56286. export interface IHtmlElementTextureOptions {
  56287. /**
  56288. * Defines wether mip maps should be created or not.
  56289. */
  56290. generateMipMaps?: boolean;
  56291. /**
  56292. * Defines the sampling mode of the texture.
  56293. */
  56294. samplingMode?: number;
  56295. /**
  56296. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56297. */
  56298. engine: Nullable<ThinEngine>;
  56299. /**
  56300. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56301. */
  56302. scene: Nullable<Scene>;
  56303. }
  56304. /**
  56305. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56306. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56307. * is automatically managed.
  56308. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56309. * in your application.
  56310. *
  56311. * As the update is not automatic, you need to call them manually.
  56312. */
  56313. export class HtmlElementTexture extends BaseTexture {
  56314. /**
  56315. * The texture URL.
  56316. */
  56317. element: HTMLVideoElement | HTMLCanvasElement;
  56318. private static readonly DefaultOptions;
  56319. private _textureMatrix;
  56320. private _engine;
  56321. private _isVideo;
  56322. private _generateMipMaps;
  56323. private _samplingMode;
  56324. /**
  56325. * Instantiates a HtmlElementTexture from the following parameters.
  56326. *
  56327. * @param name Defines the name of the texture
  56328. * @param element Defines the video or canvas the texture is filled with
  56329. * @param options Defines the other none mandatory texture creation options
  56330. */
  56331. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56332. private _createInternalTexture;
  56333. /**
  56334. * Returns the texture matrix used in most of the material.
  56335. */
  56336. getTextureMatrix(): Matrix;
  56337. /**
  56338. * Updates the content of the texture.
  56339. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56340. */
  56341. update(invertY?: Nullable<boolean>): void;
  56342. }
  56343. }
  56344. declare module "babylonjs/Materials/Textures/index" {
  56345. export * from "babylonjs/Materials/Textures/baseTexture";
  56346. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  56347. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  56348. export * from "babylonjs/Materials/Textures/cubeTexture";
  56349. export * from "babylonjs/Materials/Textures/dynamicTexture";
  56350. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  56351. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  56352. export * from "babylonjs/Materials/Textures/internalTexture";
  56353. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  56354. export * from "babylonjs/Materials/Textures/Loaders/index";
  56355. export * from "babylonjs/Materials/Textures/mirrorTexture";
  56356. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  56357. export * from "babylonjs/Materials/Textures/Procedurals/index";
  56358. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  56359. export * from "babylonjs/Materials/Textures/rawTexture";
  56360. export * from "babylonjs/Materials/Textures/rawTexture3D";
  56361. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  56362. export * from "babylonjs/Materials/Textures/refractionTexture";
  56363. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  56364. export * from "babylonjs/Materials/Textures/texture";
  56365. export * from "babylonjs/Materials/Textures/videoTexture";
  56366. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  56367. }
  56368. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  56369. /**
  56370. * Enum used to define the target of a block
  56371. */
  56372. export enum NodeMaterialBlockTargets {
  56373. /** Vertex shader */
  56374. Vertex = 1,
  56375. /** Fragment shader */
  56376. Fragment = 2,
  56377. /** Neutral */
  56378. Neutral = 4,
  56379. /** Vertex and Fragment */
  56380. VertexAndFragment = 3
  56381. }
  56382. }
  56383. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  56384. /**
  56385. * Defines the kind of connection point for node based material
  56386. */
  56387. export enum NodeMaterialBlockConnectionPointTypes {
  56388. /** Float */
  56389. Float = 1,
  56390. /** Int */
  56391. Int = 2,
  56392. /** Vector2 */
  56393. Vector2 = 4,
  56394. /** Vector3 */
  56395. Vector3 = 8,
  56396. /** Vector4 */
  56397. Vector4 = 16,
  56398. /** Color3 */
  56399. Color3 = 32,
  56400. /** Color4 */
  56401. Color4 = 64,
  56402. /** Matrix */
  56403. Matrix = 128,
  56404. /** Detect type based on connection */
  56405. AutoDetect = 1024,
  56406. /** Output type that will be defined by input type */
  56407. BasedOnInput = 2048
  56408. }
  56409. }
  56410. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  56411. /**
  56412. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56413. */
  56414. export enum NodeMaterialBlockConnectionPointMode {
  56415. /** Value is an uniform */
  56416. Uniform = 0,
  56417. /** Value is a mesh attribute */
  56418. Attribute = 1,
  56419. /** Value is a varying between vertex and fragment shaders */
  56420. Varying = 2,
  56421. /** Mode is undefined */
  56422. Undefined = 3
  56423. }
  56424. }
  56425. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  56426. /**
  56427. * Enum used to define system values e.g. values automatically provided by the system
  56428. */
  56429. export enum NodeMaterialSystemValues {
  56430. /** World */
  56431. World = 1,
  56432. /** View */
  56433. View = 2,
  56434. /** Projection */
  56435. Projection = 3,
  56436. /** ViewProjection */
  56437. ViewProjection = 4,
  56438. /** WorldView */
  56439. WorldView = 5,
  56440. /** WorldViewProjection */
  56441. WorldViewProjection = 6,
  56442. /** CameraPosition */
  56443. CameraPosition = 7,
  56444. /** Fog Color */
  56445. FogColor = 8,
  56446. /** Delta time */
  56447. DeltaTime = 9
  56448. }
  56449. }
  56450. declare module "babylonjs/Materials/Node/Enums/index" {
  56451. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56452. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56453. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  56454. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56455. }
  56456. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  56457. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56458. /**
  56459. * Root class for all node material optimizers
  56460. */
  56461. export class NodeMaterialOptimizer {
  56462. /**
  56463. * Function used to optimize a NodeMaterial graph
  56464. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56465. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56466. */
  56467. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56468. }
  56469. }
  56470. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  56471. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56472. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56473. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56474. import { Scene } from "babylonjs/scene";
  56475. /**
  56476. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56477. */
  56478. export class TransformBlock extends NodeMaterialBlock {
  56479. /**
  56480. * Defines the value to use to complement W value to transform it to a Vector4
  56481. */
  56482. complementW: number;
  56483. /**
  56484. * Defines the value to use to complement z value to transform it to a Vector4
  56485. */
  56486. complementZ: number;
  56487. /**
  56488. * Creates a new TransformBlock
  56489. * @param name defines the block name
  56490. */
  56491. constructor(name: string);
  56492. /**
  56493. * Gets the current class name
  56494. * @returns the class name
  56495. */
  56496. getClassName(): string;
  56497. /**
  56498. * Gets the vector input
  56499. */
  56500. readonly vector: NodeMaterialConnectionPoint;
  56501. /**
  56502. * Gets the output component
  56503. */
  56504. readonly output: NodeMaterialConnectionPoint;
  56505. /**
  56506. * Gets the matrix transform input
  56507. */
  56508. readonly transform: NodeMaterialConnectionPoint;
  56509. protected _buildBlock(state: NodeMaterialBuildState): this;
  56510. serialize(): any;
  56511. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56512. protected _dumpPropertiesCode(): string;
  56513. }
  56514. }
  56515. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  56516. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56517. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56518. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56519. /**
  56520. * Block used to output the vertex position
  56521. */
  56522. export class VertexOutputBlock extends NodeMaterialBlock {
  56523. /**
  56524. * Creates a new VertexOutputBlock
  56525. * @param name defines the block name
  56526. */
  56527. constructor(name: string);
  56528. /**
  56529. * Gets the current class name
  56530. * @returns the class name
  56531. */
  56532. getClassName(): string;
  56533. /**
  56534. * Gets the vector input component
  56535. */
  56536. readonly vector: NodeMaterialConnectionPoint;
  56537. protected _buildBlock(state: NodeMaterialBuildState): this;
  56538. }
  56539. }
  56540. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  56541. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56542. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56543. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56544. /**
  56545. * Block used to output the final color
  56546. */
  56547. export class FragmentOutputBlock extends NodeMaterialBlock {
  56548. /**
  56549. * Create a new FragmentOutputBlock
  56550. * @param name defines the block name
  56551. */
  56552. constructor(name: string);
  56553. /**
  56554. * Gets the current class name
  56555. * @returns the class name
  56556. */
  56557. getClassName(): string;
  56558. /**
  56559. * Gets the rgba input component
  56560. */
  56561. readonly rgba: NodeMaterialConnectionPoint;
  56562. /**
  56563. * Gets the rgb input component
  56564. */
  56565. readonly rgb: NodeMaterialConnectionPoint;
  56566. /**
  56567. * Gets the a input component
  56568. */
  56569. readonly a: NodeMaterialConnectionPoint;
  56570. protected _buildBlock(state: NodeMaterialBuildState): this;
  56571. }
  56572. }
  56573. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  56574. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56575. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56576. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56577. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56579. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56580. import { Effect } from "babylonjs/Materials/effect";
  56581. import { Mesh } from "babylonjs/Meshes/mesh";
  56582. import { Nullable } from "babylonjs/types";
  56583. import { Scene } from "babylonjs/scene";
  56584. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56585. /**
  56586. * Block used to read a reflection texture from a sampler
  56587. */
  56588. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56589. private _define3DName;
  56590. private _defineCubicName;
  56591. private _defineExplicitName;
  56592. private _defineProjectionName;
  56593. private _defineLocalCubicName;
  56594. private _defineSphericalName;
  56595. private _definePlanarName;
  56596. private _defineEquirectangularName;
  56597. private _defineMirroredEquirectangularFixedName;
  56598. private _defineEquirectangularFixedName;
  56599. private _defineSkyboxName;
  56600. private _cubeSamplerName;
  56601. private _2DSamplerName;
  56602. private _positionUVWName;
  56603. private _directionWName;
  56604. private _reflectionCoordsName;
  56605. private _reflection2DCoordsName;
  56606. private _reflectionColorName;
  56607. private _reflectionMatrixName;
  56608. /**
  56609. * Gets or sets the texture associated with the node
  56610. */
  56611. texture: Nullable<BaseTexture>;
  56612. /**
  56613. * Create a new TextureBlock
  56614. * @param name defines the block name
  56615. */
  56616. constructor(name: string);
  56617. /**
  56618. * Gets the current class name
  56619. * @returns the class name
  56620. */
  56621. getClassName(): string;
  56622. /**
  56623. * Gets the world position input component
  56624. */
  56625. readonly position: NodeMaterialConnectionPoint;
  56626. /**
  56627. * Gets the world position input component
  56628. */
  56629. readonly worldPosition: NodeMaterialConnectionPoint;
  56630. /**
  56631. * Gets the world normal input component
  56632. */
  56633. readonly worldNormal: NodeMaterialConnectionPoint;
  56634. /**
  56635. * Gets the world input component
  56636. */
  56637. readonly world: NodeMaterialConnectionPoint;
  56638. /**
  56639. * Gets the camera (or eye) position component
  56640. */
  56641. readonly cameraPosition: NodeMaterialConnectionPoint;
  56642. /**
  56643. * Gets the view input component
  56644. */
  56645. readonly view: NodeMaterialConnectionPoint;
  56646. /**
  56647. * Gets the rgb output component
  56648. */
  56649. readonly rgb: NodeMaterialConnectionPoint;
  56650. /**
  56651. * Gets the r output component
  56652. */
  56653. readonly r: NodeMaterialConnectionPoint;
  56654. /**
  56655. * Gets the g output component
  56656. */
  56657. readonly g: NodeMaterialConnectionPoint;
  56658. /**
  56659. * Gets the b output component
  56660. */
  56661. readonly b: NodeMaterialConnectionPoint;
  56662. autoConfigure(material: NodeMaterial): void;
  56663. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56664. isReady(): boolean;
  56665. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56666. private _injectVertexCode;
  56667. private _writeOutput;
  56668. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56669. protected _dumpPropertiesCode(): string;
  56670. serialize(): any;
  56671. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56672. }
  56673. }
  56674. declare module "babylonjs/Materials/Node/nodeMaterial" {
  56675. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56676. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56677. import { Scene } from "babylonjs/scene";
  56678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56679. import { Matrix } from "babylonjs/Maths/math.vector";
  56680. import { Mesh } from "babylonjs/Meshes/mesh";
  56681. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56682. import { Observable } from "babylonjs/Misc/observable";
  56683. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56684. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  56685. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  56686. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  56687. import { Nullable } from "babylonjs/types";
  56688. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56689. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56690. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56691. /**
  56692. * Interface used to configure the node material editor
  56693. */
  56694. export interface INodeMaterialEditorOptions {
  56695. /** Define the URl to load node editor script */
  56696. editorURL?: string;
  56697. }
  56698. /** @hidden */
  56699. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56700. /** BONES */
  56701. NUM_BONE_INFLUENCERS: number;
  56702. BonesPerMesh: number;
  56703. BONETEXTURE: boolean;
  56704. /** MORPH TARGETS */
  56705. MORPHTARGETS: boolean;
  56706. MORPHTARGETS_NORMAL: boolean;
  56707. MORPHTARGETS_TANGENT: boolean;
  56708. MORPHTARGETS_UV: boolean;
  56709. NUM_MORPH_INFLUENCERS: number;
  56710. /** IMAGE PROCESSING */
  56711. IMAGEPROCESSING: boolean;
  56712. VIGNETTE: boolean;
  56713. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56714. VIGNETTEBLENDMODEOPAQUE: boolean;
  56715. TONEMAPPING: boolean;
  56716. TONEMAPPING_ACES: boolean;
  56717. CONTRAST: boolean;
  56718. EXPOSURE: boolean;
  56719. COLORCURVES: boolean;
  56720. COLORGRADING: boolean;
  56721. COLORGRADING3D: boolean;
  56722. SAMPLER3DGREENDEPTH: boolean;
  56723. SAMPLER3DBGRMAP: boolean;
  56724. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56725. /** MISC. */
  56726. BUMPDIRECTUV: number;
  56727. constructor();
  56728. setValue(name: string, value: boolean): void;
  56729. }
  56730. /**
  56731. * Class used to configure NodeMaterial
  56732. */
  56733. export interface INodeMaterialOptions {
  56734. /**
  56735. * Defines if blocks should emit comments
  56736. */
  56737. emitComments: boolean;
  56738. }
  56739. /**
  56740. * Class used to create a node based material built by assembling shader blocks
  56741. */
  56742. export class NodeMaterial extends PushMaterial {
  56743. private static _BuildIdGenerator;
  56744. private _options;
  56745. private _vertexCompilationState;
  56746. private _fragmentCompilationState;
  56747. private _sharedData;
  56748. private _buildId;
  56749. private _buildWasSuccessful;
  56750. private _cachedWorldViewMatrix;
  56751. private _cachedWorldViewProjectionMatrix;
  56752. private _optimizers;
  56753. private _animationFrame;
  56754. /** Define the URl to load node editor script */
  56755. static EditorURL: string;
  56756. private BJSNODEMATERIALEDITOR;
  56757. /** Get the inspector from bundle or global */
  56758. private _getGlobalNodeMaterialEditor;
  56759. /**
  56760. * Gets or sets data used by visual editor
  56761. * @see https://nme.babylonjs.com
  56762. */
  56763. editorData: any;
  56764. /**
  56765. * 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)
  56766. */
  56767. ignoreAlpha: boolean;
  56768. /**
  56769. * Defines the maximum number of lights that can be used in the material
  56770. */
  56771. maxSimultaneousLights: number;
  56772. /**
  56773. * Observable raised when the material is built
  56774. */
  56775. onBuildObservable: Observable<NodeMaterial>;
  56776. /**
  56777. * Gets or sets the root nodes of the material vertex shader
  56778. */
  56779. _vertexOutputNodes: NodeMaterialBlock[];
  56780. /**
  56781. * Gets or sets the root nodes of the material fragment (pixel) shader
  56782. */
  56783. _fragmentOutputNodes: NodeMaterialBlock[];
  56784. /** Gets or sets options to control the node material overall behavior */
  56785. options: INodeMaterialOptions;
  56786. /**
  56787. * Default configuration related to image processing available in the standard Material.
  56788. */
  56789. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56790. /**
  56791. * Gets the image processing configuration used either in this material.
  56792. */
  56793. /**
  56794. * Sets the Default image processing configuration used either in the this material.
  56795. *
  56796. * If sets to null, the scene one is in use.
  56797. */
  56798. imageProcessingConfiguration: ImageProcessingConfiguration;
  56799. /**
  56800. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  56801. */
  56802. attachedBlocks: NodeMaterialBlock[];
  56803. /**
  56804. * Create a new node based material
  56805. * @param name defines the material name
  56806. * @param scene defines the hosting scene
  56807. * @param options defines creation option
  56808. */
  56809. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  56810. /**
  56811. * Gets the current class name of the material e.g. "NodeMaterial"
  56812. * @returns the class name
  56813. */
  56814. getClassName(): string;
  56815. /**
  56816. * Keep track of the image processing observer to allow dispose and replace.
  56817. */
  56818. private _imageProcessingObserver;
  56819. /**
  56820. * Attaches a new image processing configuration to the Standard Material.
  56821. * @param configuration
  56822. */
  56823. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56824. /**
  56825. * Get a block by its name
  56826. * @param name defines the name of the block to retrieve
  56827. * @returns the required block or null if not found
  56828. */
  56829. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  56830. /**
  56831. * Get a block by its name
  56832. * @param predicate defines the predicate used to find the good candidate
  56833. * @returns the required block or null if not found
  56834. */
  56835. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  56836. /**
  56837. * Get an input block by its name
  56838. * @param predicate defines the predicate used to find the good candidate
  56839. * @returns the required input block or null if not found
  56840. */
  56841. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  56842. /**
  56843. * Gets the list of input blocks attached to this material
  56844. * @returns an array of InputBlocks
  56845. */
  56846. getInputBlocks(): InputBlock[];
  56847. /**
  56848. * Adds a new optimizer to the list of optimizers
  56849. * @param optimizer defines the optimizers to add
  56850. * @returns the current material
  56851. */
  56852. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56853. /**
  56854. * Remove an optimizer from the list of optimizers
  56855. * @param optimizer defines the optimizers to remove
  56856. * @returns the current material
  56857. */
  56858. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56859. /**
  56860. * Add a new block to the list of output nodes
  56861. * @param node defines the node to add
  56862. * @returns the current material
  56863. */
  56864. addOutputNode(node: NodeMaterialBlock): this;
  56865. /**
  56866. * Remove a block from the list of root nodes
  56867. * @param node defines the node to remove
  56868. * @returns the current material
  56869. */
  56870. removeOutputNode(node: NodeMaterialBlock): this;
  56871. private _addVertexOutputNode;
  56872. private _removeVertexOutputNode;
  56873. private _addFragmentOutputNode;
  56874. private _removeFragmentOutputNode;
  56875. /**
  56876. * Specifies if the material will require alpha blending
  56877. * @returns a boolean specifying if alpha blending is needed
  56878. */
  56879. needAlphaBlending(): boolean;
  56880. /**
  56881. * Specifies if this material should be rendered in alpha test mode
  56882. * @returns a boolean specifying if an alpha test is needed.
  56883. */
  56884. needAlphaTesting(): boolean;
  56885. private _initializeBlock;
  56886. private _resetDualBlocks;
  56887. /**
  56888. * Remove a block from the current node material
  56889. * @param block defines the block to remove
  56890. */
  56891. removeBlock(block: NodeMaterialBlock): void;
  56892. /**
  56893. * Build the material and generates the inner effect
  56894. * @param verbose defines if the build should log activity
  56895. */
  56896. build(verbose?: boolean): void;
  56897. /**
  56898. * Runs an otpimization phase to try to improve the shader code
  56899. */
  56900. optimize(): void;
  56901. private _prepareDefinesForAttributes;
  56902. /**
  56903. * Get if the submesh is ready to be used and all its information available.
  56904. * Child classes can use it to update shaders
  56905. * @param mesh defines the mesh to check
  56906. * @param subMesh defines which submesh to check
  56907. * @param useInstances specifies that instances should be used
  56908. * @returns a boolean indicating that the submesh is ready or not
  56909. */
  56910. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56911. /**
  56912. * Get a string representing the shaders built by the current node graph
  56913. */
  56914. readonly compiledShaders: string;
  56915. /**
  56916. * Binds the world matrix to the material
  56917. * @param world defines the world transformation matrix
  56918. */
  56919. bindOnlyWorldMatrix(world: Matrix): void;
  56920. /**
  56921. * Binds the submesh to this material by preparing the effect and shader to draw
  56922. * @param world defines the world transformation matrix
  56923. * @param mesh defines the mesh containing the submesh
  56924. * @param subMesh defines the submesh to bind the material to
  56925. */
  56926. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56927. /**
  56928. * Gets the active textures from the material
  56929. * @returns an array of textures
  56930. */
  56931. getActiveTextures(): BaseTexture[];
  56932. /**
  56933. * Gets the list of texture blocks
  56934. * @returns an array of texture blocks
  56935. */
  56936. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  56937. /**
  56938. * Specifies if the material uses a texture
  56939. * @param texture defines the texture to check against the material
  56940. * @returns a boolean specifying if the material uses the texture
  56941. */
  56942. hasTexture(texture: BaseTexture): boolean;
  56943. /**
  56944. * Disposes the material
  56945. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  56946. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  56947. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  56948. */
  56949. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  56950. /** Creates the node editor window. */
  56951. private _createNodeEditor;
  56952. /**
  56953. * Launch the node material editor
  56954. * @param config Define the configuration of the editor
  56955. * @return a promise fulfilled when the node editor is visible
  56956. */
  56957. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  56958. /**
  56959. * Clear the current material
  56960. */
  56961. clear(): void;
  56962. /**
  56963. * Clear the current material and set it to a default state
  56964. */
  56965. setToDefault(): void;
  56966. /**
  56967. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  56968. * @param url defines the url to load from
  56969. * @returns a promise that will fullfil when the material is fully loaded
  56970. */
  56971. loadAsync(url: string): Promise<void>;
  56972. private _gatherBlocks;
  56973. /**
  56974. * Generate a string containing the code declaration required to create an equivalent of this material
  56975. * @returns a string
  56976. */
  56977. generateCode(): string;
  56978. /**
  56979. * Serializes this material in a JSON representation
  56980. * @returns the serialized material object
  56981. */
  56982. serialize(): any;
  56983. private _restoreConnections;
  56984. /**
  56985. * Clear the current graph and load a new one from a serialization object
  56986. * @param source defines the JSON representation of the material
  56987. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56988. */
  56989. loadFromSerialization(source: any, rootUrl?: string): void;
  56990. /**
  56991. * Creates a node material from parsed material data
  56992. * @param source defines the JSON representation of the material
  56993. * @param scene defines the hosting scene
  56994. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56995. * @returns a new node material
  56996. */
  56997. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  56998. /**
  56999. * Creates a new node material set to default basic configuration
  57000. * @param name defines the name of the material
  57001. * @param scene defines the hosting scene
  57002. * @returns a new NodeMaterial
  57003. */
  57004. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57005. }
  57006. }
  57007. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  57008. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57009. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57010. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57011. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57013. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57014. import { Effect } from "babylonjs/Materials/effect";
  57015. import { Mesh } from "babylonjs/Meshes/mesh";
  57016. import { Nullable } from "babylonjs/types";
  57017. import { Texture } from "babylonjs/Materials/Textures/texture";
  57018. import { Scene } from "babylonjs/scene";
  57019. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57020. /**
  57021. * Block used to read a texture from a sampler
  57022. */
  57023. export class TextureBlock extends NodeMaterialBlock {
  57024. private _defineName;
  57025. private _linearDefineName;
  57026. private _tempTextureRead;
  57027. private _samplerName;
  57028. private _transformedUVName;
  57029. private _textureTransformName;
  57030. private _textureInfoName;
  57031. private _mainUVName;
  57032. private _mainUVDefineName;
  57033. /**
  57034. * Gets or sets the texture associated with the node
  57035. */
  57036. texture: Nullable<Texture>;
  57037. /**
  57038. * Create a new TextureBlock
  57039. * @param name defines the block name
  57040. */
  57041. constructor(name: string);
  57042. /**
  57043. * Gets the current class name
  57044. * @returns the class name
  57045. */
  57046. getClassName(): string;
  57047. /**
  57048. * Gets the uv input component
  57049. */
  57050. readonly uv: NodeMaterialConnectionPoint;
  57051. /**
  57052. * Gets the rgba output component
  57053. */
  57054. readonly rgba: NodeMaterialConnectionPoint;
  57055. /**
  57056. * Gets the rgb output component
  57057. */
  57058. readonly rgb: NodeMaterialConnectionPoint;
  57059. /**
  57060. * Gets the r output component
  57061. */
  57062. readonly r: NodeMaterialConnectionPoint;
  57063. /**
  57064. * Gets the g output component
  57065. */
  57066. readonly g: NodeMaterialConnectionPoint;
  57067. /**
  57068. * Gets the b output component
  57069. */
  57070. readonly b: NodeMaterialConnectionPoint;
  57071. /**
  57072. * Gets the a output component
  57073. */
  57074. readonly a: NodeMaterialConnectionPoint;
  57075. readonly target: NodeMaterialBlockTargets;
  57076. autoConfigure(material: NodeMaterial): void;
  57077. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57078. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57079. private _getTextureBase;
  57080. isReady(): boolean;
  57081. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57082. private readonly _isMixed;
  57083. private _injectVertexCode;
  57084. private _writeTextureRead;
  57085. private _writeOutput;
  57086. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57087. protected _dumpPropertiesCode(): string;
  57088. serialize(): any;
  57089. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57090. }
  57091. }
  57092. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  57093. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57094. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57095. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57096. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57097. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57098. import { Scene } from "babylonjs/scene";
  57099. /**
  57100. * Class used to store shared data between 2 NodeMaterialBuildState
  57101. */
  57102. export class NodeMaterialBuildStateSharedData {
  57103. /**
  57104. * Gets the list of emitted varyings
  57105. */
  57106. temps: string[];
  57107. /**
  57108. * Gets the list of emitted varyings
  57109. */
  57110. varyings: string[];
  57111. /**
  57112. * Gets the varying declaration string
  57113. */
  57114. varyingDeclaration: string;
  57115. /**
  57116. * Input blocks
  57117. */
  57118. inputBlocks: InputBlock[];
  57119. /**
  57120. * Input blocks
  57121. */
  57122. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57123. /**
  57124. * Bindable blocks (Blocks that need to set data to the effect)
  57125. */
  57126. bindableBlocks: NodeMaterialBlock[];
  57127. /**
  57128. * List of blocks that can provide a compilation fallback
  57129. */
  57130. blocksWithFallbacks: NodeMaterialBlock[];
  57131. /**
  57132. * List of blocks that can provide a define update
  57133. */
  57134. blocksWithDefines: NodeMaterialBlock[];
  57135. /**
  57136. * List of blocks that can provide a repeatable content
  57137. */
  57138. repeatableContentBlocks: NodeMaterialBlock[];
  57139. /**
  57140. * List of blocks that can provide a dynamic list of uniforms
  57141. */
  57142. dynamicUniformBlocks: NodeMaterialBlock[];
  57143. /**
  57144. * List of blocks that can block the isReady function for the material
  57145. */
  57146. blockingBlocks: NodeMaterialBlock[];
  57147. /**
  57148. * Gets the list of animated inputs
  57149. */
  57150. animatedInputs: InputBlock[];
  57151. /**
  57152. * Build Id used to avoid multiple recompilations
  57153. */
  57154. buildId: number;
  57155. /** List of emitted variables */
  57156. variableNames: {
  57157. [key: string]: number;
  57158. };
  57159. /** List of emitted defines */
  57160. defineNames: {
  57161. [key: string]: number;
  57162. };
  57163. /** Should emit comments? */
  57164. emitComments: boolean;
  57165. /** Emit build activity */
  57166. verbose: boolean;
  57167. /** Gets or sets the hosting scene */
  57168. scene: Scene;
  57169. /**
  57170. * Gets the compilation hints emitted at compilation time
  57171. */
  57172. hints: {
  57173. needWorldViewMatrix: boolean;
  57174. needWorldViewProjectionMatrix: boolean;
  57175. needAlphaBlending: boolean;
  57176. needAlphaTesting: boolean;
  57177. };
  57178. /**
  57179. * List of compilation checks
  57180. */
  57181. checks: {
  57182. emitVertex: boolean;
  57183. emitFragment: boolean;
  57184. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57185. };
  57186. /** Creates a new shared data */
  57187. constructor();
  57188. /**
  57189. * Emits console errors and exceptions if there is a failing check
  57190. */
  57191. emitErrors(): void;
  57192. }
  57193. }
  57194. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  57195. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57196. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57197. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  57198. /**
  57199. * Class used to store node based material build state
  57200. */
  57201. export class NodeMaterialBuildState {
  57202. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57203. supportUniformBuffers: boolean;
  57204. /**
  57205. * Gets the list of emitted attributes
  57206. */
  57207. attributes: string[];
  57208. /**
  57209. * Gets the list of emitted uniforms
  57210. */
  57211. uniforms: string[];
  57212. /**
  57213. * Gets the list of emitted constants
  57214. */
  57215. constants: string[];
  57216. /**
  57217. * Gets the list of emitted samplers
  57218. */
  57219. samplers: string[];
  57220. /**
  57221. * Gets the list of emitted functions
  57222. */
  57223. functions: {
  57224. [key: string]: string;
  57225. };
  57226. /**
  57227. * Gets the list of emitted extensions
  57228. */
  57229. extensions: {
  57230. [key: string]: string;
  57231. };
  57232. /**
  57233. * Gets the target of the compilation state
  57234. */
  57235. target: NodeMaterialBlockTargets;
  57236. /**
  57237. * Gets the list of emitted counters
  57238. */
  57239. counters: {
  57240. [key: string]: number;
  57241. };
  57242. /**
  57243. * Shared data between multiple NodeMaterialBuildState instances
  57244. */
  57245. sharedData: NodeMaterialBuildStateSharedData;
  57246. /** @hidden */
  57247. _vertexState: NodeMaterialBuildState;
  57248. /** @hidden */
  57249. _attributeDeclaration: string;
  57250. /** @hidden */
  57251. _uniformDeclaration: string;
  57252. /** @hidden */
  57253. _constantDeclaration: string;
  57254. /** @hidden */
  57255. _samplerDeclaration: string;
  57256. /** @hidden */
  57257. _varyingTransfer: string;
  57258. private _repeatableContentAnchorIndex;
  57259. /** @hidden */
  57260. _builtCompilationString: string;
  57261. /**
  57262. * Gets the emitted compilation strings
  57263. */
  57264. compilationString: string;
  57265. /**
  57266. * Finalize the compilation strings
  57267. * @param state defines the current compilation state
  57268. */
  57269. finalize(state: NodeMaterialBuildState): void;
  57270. /** @hidden */
  57271. readonly _repeatableContentAnchor: string;
  57272. /** @hidden */
  57273. _getFreeVariableName(prefix: string): string;
  57274. /** @hidden */
  57275. _getFreeDefineName(prefix: string): string;
  57276. /** @hidden */
  57277. _excludeVariableName(name: string): void;
  57278. /** @hidden */
  57279. _emit2DSampler(name: string): void;
  57280. /** @hidden */
  57281. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57282. /** @hidden */
  57283. _emitExtension(name: string, extension: string): void;
  57284. /** @hidden */
  57285. _emitFunction(name: string, code: string, comments: string): void;
  57286. /** @hidden */
  57287. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57288. replaceStrings?: {
  57289. search: RegExp;
  57290. replace: string;
  57291. }[];
  57292. repeatKey?: string;
  57293. }): string;
  57294. /** @hidden */
  57295. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57296. repeatKey?: string;
  57297. removeAttributes?: boolean;
  57298. removeUniforms?: boolean;
  57299. removeVaryings?: boolean;
  57300. removeIfDef?: boolean;
  57301. replaceStrings?: {
  57302. search: RegExp;
  57303. replace: string;
  57304. }[];
  57305. }, storeKey?: string): void;
  57306. /** @hidden */
  57307. _registerTempVariable(name: string): boolean;
  57308. /** @hidden */
  57309. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57310. /** @hidden */
  57311. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57312. /** @hidden */
  57313. _emitFloat(value: number): string;
  57314. }
  57315. }
  57316. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  57317. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57318. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57319. import { Nullable } from "babylonjs/types";
  57320. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57321. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57322. import { Effect } from "babylonjs/Materials/effect";
  57323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57324. import { Mesh } from "babylonjs/Meshes/mesh";
  57325. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57326. import { Scene } from "babylonjs/scene";
  57327. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57328. /**
  57329. * Defines a block that can be used inside a node based material
  57330. */
  57331. export class NodeMaterialBlock {
  57332. private _buildId;
  57333. private _buildTarget;
  57334. private _target;
  57335. private _isFinalMerger;
  57336. private _isInput;
  57337. protected _isUnique: boolean;
  57338. /** @hidden */
  57339. _codeVariableName: string;
  57340. /** @hidden */
  57341. _inputs: NodeMaterialConnectionPoint[];
  57342. /** @hidden */
  57343. _outputs: NodeMaterialConnectionPoint[];
  57344. /** @hidden */
  57345. _preparationId: number;
  57346. /**
  57347. * Gets or sets the name of the block
  57348. */
  57349. name: string;
  57350. /**
  57351. * Gets or sets the unique id of the node
  57352. */
  57353. uniqueId: number;
  57354. /**
  57355. * Gets or sets the comments associated with this block
  57356. */
  57357. comments: string;
  57358. /**
  57359. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57360. */
  57361. readonly isUnique: boolean;
  57362. /**
  57363. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57364. */
  57365. readonly isFinalMerger: boolean;
  57366. /**
  57367. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57368. */
  57369. readonly isInput: boolean;
  57370. /**
  57371. * Gets or sets the build Id
  57372. */
  57373. buildId: number;
  57374. /**
  57375. * Gets or sets the target of the block
  57376. */
  57377. target: NodeMaterialBlockTargets;
  57378. /**
  57379. * Gets the list of input points
  57380. */
  57381. readonly inputs: NodeMaterialConnectionPoint[];
  57382. /** Gets the list of output points */
  57383. readonly outputs: NodeMaterialConnectionPoint[];
  57384. /**
  57385. * Find an input by its name
  57386. * @param name defines the name of the input to look for
  57387. * @returns the input or null if not found
  57388. */
  57389. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57390. /**
  57391. * Find an output by its name
  57392. * @param name defines the name of the outputto look for
  57393. * @returns the output or null if not found
  57394. */
  57395. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57396. /**
  57397. * Creates a new NodeMaterialBlock
  57398. * @param name defines the block name
  57399. * @param target defines the target of that block (Vertex by default)
  57400. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57401. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57402. */
  57403. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57404. /**
  57405. * Initialize the block and prepare the context for build
  57406. * @param state defines the state that will be used for the build
  57407. */
  57408. initialize(state: NodeMaterialBuildState): void;
  57409. /**
  57410. * Bind data to effect. Will only be called for blocks with isBindable === true
  57411. * @param effect defines the effect to bind data to
  57412. * @param nodeMaterial defines the hosting NodeMaterial
  57413. * @param mesh defines the mesh that will be rendered
  57414. */
  57415. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57416. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57417. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57418. protected _writeFloat(value: number): string;
  57419. /**
  57420. * Gets the current class name e.g. "NodeMaterialBlock"
  57421. * @returns the class name
  57422. */
  57423. getClassName(): string;
  57424. /**
  57425. * Register a new input. Must be called inside a block constructor
  57426. * @param name defines the connection point name
  57427. * @param type defines the connection point type
  57428. * @param isOptional defines a boolean indicating that this input can be omitted
  57429. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57430. * @returns the current block
  57431. */
  57432. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57433. /**
  57434. * Register a new output. Must be called inside a block constructor
  57435. * @param name defines the connection point name
  57436. * @param type defines the connection point type
  57437. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57438. * @returns the current block
  57439. */
  57440. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57441. /**
  57442. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57443. * @param forOutput defines an optional connection point to check compatibility with
  57444. * @returns the first available input or null
  57445. */
  57446. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57447. /**
  57448. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57449. * @param forBlock defines an optional block to check compatibility with
  57450. * @returns the first available input or null
  57451. */
  57452. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57453. /**
  57454. * Gets the sibling of the given output
  57455. * @param current defines the current output
  57456. * @returns the next output in the list or null
  57457. */
  57458. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57459. /**
  57460. * Connect current block with another block
  57461. * @param other defines the block to connect with
  57462. * @param options define the various options to help pick the right connections
  57463. * @returns the current block
  57464. */
  57465. connectTo(other: NodeMaterialBlock, options?: {
  57466. input?: string;
  57467. output?: string;
  57468. outputSwizzle?: string;
  57469. }): this | undefined;
  57470. protected _buildBlock(state: NodeMaterialBuildState): void;
  57471. /**
  57472. * Add uniforms, samplers and uniform buffers at compilation time
  57473. * @param state defines the state to update
  57474. * @param nodeMaterial defines the node material requesting the update
  57475. * @param defines defines the material defines to update
  57476. * @param uniformBuffers defines the list of uniform buffer names
  57477. */
  57478. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57479. /**
  57480. * Add potential fallbacks if shader compilation fails
  57481. * @param mesh defines the mesh to be rendered
  57482. * @param fallbacks defines the current prioritized list of fallbacks
  57483. */
  57484. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57485. /**
  57486. * Initialize defines for shader compilation
  57487. * @param mesh defines the mesh to be rendered
  57488. * @param nodeMaterial defines the node material requesting the update
  57489. * @param defines defines the material defines to update
  57490. * @param useInstances specifies that instances should be used
  57491. */
  57492. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57493. /**
  57494. * Update defines for shader compilation
  57495. * @param mesh defines the mesh to be rendered
  57496. * @param nodeMaterial defines the node material requesting the update
  57497. * @param defines defines the material defines to update
  57498. * @param useInstances specifies that instances should be used
  57499. */
  57500. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57501. /**
  57502. * Lets the block try to connect some inputs automatically
  57503. * @param material defines the hosting NodeMaterial
  57504. */
  57505. autoConfigure(material: NodeMaterial): void;
  57506. /**
  57507. * Function called when a block is declared as repeatable content generator
  57508. * @param vertexShaderState defines the current compilation state for the vertex shader
  57509. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57510. * @param mesh defines the mesh to be rendered
  57511. * @param defines defines the material defines to update
  57512. */
  57513. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57514. /**
  57515. * Checks if the block is ready
  57516. * @param mesh defines the mesh to be rendered
  57517. * @param nodeMaterial defines the node material requesting the update
  57518. * @param defines defines the material defines to update
  57519. * @param useInstances specifies that instances should be used
  57520. * @returns true if the block is ready
  57521. */
  57522. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57523. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57524. private _processBuild;
  57525. /**
  57526. * Compile the current node and generate the shader code
  57527. * @param state defines the current compilation state (uniforms, samplers, current string)
  57528. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57529. * @returns true if already built
  57530. */
  57531. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57532. protected _inputRename(name: string): string;
  57533. protected _outputRename(name: string): string;
  57534. protected _dumpPropertiesCode(): string;
  57535. /** @hidden */
  57536. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57537. /** @hidden */
  57538. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57539. /**
  57540. * Clone the current block to a new identical block
  57541. * @param scene defines the hosting scene
  57542. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57543. * @returns a copy of the current block
  57544. */
  57545. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57546. /**
  57547. * Serializes this block in a JSON representation
  57548. * @returns the serialized block object
  57549. */
  57550. serialize(): any;
  57551. /** @hidden */
  57552. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57553. /**
  57554. * Release resources
  57555. */
  57556. dispose(): void;
  57557. }
  57558. }
  57559. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  57560. /**
  57561. * Enum defining the type of animations supported by InputBlock
  57562. */
  57563. export enum AnimatedInputBlockTypes {
  57564. /** No animation */
  57565. None = 0,
  57566. /** Time based animation. Will only work for floats */
  57567. Time = 1
  57568. }
  57569. }
  57570. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  57571. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57572. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57573. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  57574. import { Nullable } from "babylonjs/types";
  57575. import { Effect } from "babylonjs/Materials/effect";
  57576. import { Matrix } from "babylonjs/Maths/math.vector";
  57577. import { Scene } from "babylonjs/scene";
  57578. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57579. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57580. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57581. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57582. /**
  57583. * Block used to expose an input value
  57584. */
  57585. export class InputBlock extends NodeMaterialBlock {
  57586. private _mode;
  57587. private _associatedVariableName;
  57588. private _storedValue;
  57589. private _valueCallback;
  57590. private _type;
  57591. private _animationType;
  57592. /** Gets or set a value used to limit the range of float values */
  57593. min: number;
  57594. /** Gets or set a value used to limit the range of float values */
  57595. max: number;
  57596. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57597. matrixMode: number;
  57598. /** @hidden */
  57599. _systemValue: Nullable<NodeMaterialSystemValues>;
  57600. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57601. visibleInInspector: boolean;
  57602. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57603. isConstant: boolean;
  57604. /** Gets or sets the group to use to display this block in the Inspector */
  57605. groupInInspector: string;
  57606. /**
  57607. * Gets or sets the connection point type (default is float)
  57608. */
  57609. readonly type: NodeMaterialBlockConnectionPointTypes;
  57610. /**
  57611. * Creates a new InputBlock
  57612. * @param name defines the block name
  57613. * @param target defines the target of that block (Vertex by default)
  57614. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57615. */
  57616. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57617. /**
  57618. * Gets the output component
  57619. */
  57620. readonly output: NodeMaterialConnectionPoint;
  57621. /**
  57622. * Set the source of this connection point to a vertex attribute
  57623. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57624. * @returns the current connection point
  57625. */
  57626. setAsAttribute(attributeName?: string): InputBlock;
  57627. /**
  57628. * Set the source of this connection point to a system value
  57629. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57630. * @returns the current connection point
  57631. */
  57632. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57633. /**
  57634. * Gets or sets the value of that point.
  57635. * Please note that this value will be ignored if valueCallback is defined
  57636. */
  57637. value: any;
  57638. /**
  57639. * Gets or sets a callback used to get the value of that point.
  57640. * Please note that setting this value will force the connection point to ignore the value property
  57641. */
  57642. valueCallback: () => any;
  57643. /**
  57644. * Gets or sets the associated variable name in the shader
  57645. */
  57646. associatedVariableName: string;
  57647. /** Gets or sets the type of animation applied to the input */
  57648. animationType: AnimatedInputBlockTypes;
  57649. /**
  57650. * Gets a boolean indicating that this connection point not defined yet
  57651. */
  57652. readonly isUndefined: boolean;
  57653. /**
  57654. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57655. * In this case the connection point name must be the name of the uniform to use.
  57656. * Can only be set on inputs
  57657. */
  57658. isUniform: boolean;
  57659. /**
  57660. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57661. * In this case the connection point name must be the name of the attribute to use
  57662. * Can only be set on inputs
  57663. */
  57664. isAttribute: boolean;
  57665. /**
  57666. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57667. * Can only be set on exit points
  57668. */
  57669. isVarying: boolean;
  57670. /**
  57671. * Gets a boolean indicating that the current connection point is a system value
  57672. */
  57673. readonly isSystemValue: boolean;
  57674. /**
  57675. * Gets or sets the current well known value or null if not defined as a system value
  57676. */
  57677. systemValue: Nullable<NodeMaterialSystemValues>;
  57678. /**
  57679. * Gets the current class name
  57680. * @returns the class name
  57681. */
  57682. getClassName(): string;
  57683. /**
  57684. * Animate the input if animationType !== None
  57685. * @param scene defines the rendering scene
  57686. */
  57687. animate(scene: Scene): void;
  57688. private _emitDefine;
  57689. initialize(state: NodeMaterialBuildState): void;
  57690. /**
  57691. * Set the input block to its default value (based on its type)
  57692. */
  57693. setDefaultValue(): void;
  57694. private _emitConstant;
  57695. private _emit;
  57696. /** @hidden */
  57697. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57698. /** @hidden */
  57699. _transmit(effect: Effect, scene: Scene): void;
  57700. protected _buildBlock(state: NodeMaterialBuildState): void;
  57701. protected _dumpPropertiesCode(): string;
  57702. serialize(): any;
  57703. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57704. }
  57705. }
  57706. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  57707. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57708. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57709. import { Nullable } from "babylonjs/types";
  57710. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57711. import { Observable } from "babylonjs/Misc/observable";
  57712. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57713. /**
  57714. * Enum used to define the compatibility state between two connection points
  57715. */
  57716. export enum NodeMaterialConnectionPointCompatibilityStates {
  57717. /** Points are compatibles */
  57718. Compatible = 0,
  57719. /** Points are incompatible because of their types */
  57720. TypeIncompatible = 1,
  57721. /** Points are incompatible because of their targets (vertex vs fragment) */
  57722. TargetIncompatible = 2
  57723. }
  57724. /**
  57725. * Defines the direction of a connection point
  57726. */
  57727. export enum NodeMaterialConnectionPointDirection {
  57728. /** Input */
  57729. Input = 0,
  57730. /** Output */
  57731. Output = 1
  57732. }
  57733. /**
  57734. * Defines a connection point for a block
  57735. */
  57736. export class NodeMaterialConnectionPoint {
  57737. /** @hidden */
  57738. _ownerBlock: NodeMaterialBlock;
  57739. /** @hidden */
  57740. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57741. private _endpoints;
  57742. private _associatedVariableName;
  57743. private _direction;
  57744. /** @hidden */
  57745. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57746. /** @hidden */
  57747. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57748. private _type;
  57749. /** @hidden */
  57750. _enforceAssociatedVariableName: boolean;
  57751. /** Gets the direction of the point */
  57752. readonly direction: NodeMaterialConnectionPointDirection;
  57753. /**
  57754. * Gets or sets the additional types supported by this connection point
  57755. */
  57756. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57757. /**
  57758. * Gets or sets the additional types excluded by this connection point
  57759. */
  57760. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57761. /**
  57762. * Observable triggered when this point is connected
  57763. */
  57764. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  57765. /**
  57766. * Gets or sets the associated variable name in the shader
  57767. */
  57768. associatedVariableName: string;
  57769. /**
  57770. * Gets or sets the connection point type (default is float)
  57771. */
  57772. type: NodeMaterialBlockConnectionPointTypes;
  57773. /**
  57774. * Gets or sets the connection point name
  57775. */
  57776. name: string;
  57777. /**
  57778. * Gets or sets a boolean indicating that this connection point can be omitted
  57779. */
  57780. isOptional: boolean;
  57781. /**
  57782. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  57783. */
  57784. define: string;
  57785. /** @hidden */
  57786. _prioritizeVertex: boolean;
  57787. private _target;
  57788. /** Gets or sets the target of that connection point */
  57789. target: NodeMaterialBlockTargets;
  57790. /**
  57791. * Gets a boolean indicating that the current point is connected
  57792. */
  57793. readonly isConnected: boolean;
  57794. /**
  57795. * Gets a boolean indicating that the current point is connected to an input block
  57796. */
  57797. readonly isConnectedToInputBlock: boolean;
  57798. /**
  57799. * Gets a the connected input block (if any)
  57800. */
  57801. readonly connectInputBlock: Nullable<InputBlock>;
  57802. /** Get the other side of the connection (if any) */
  57803. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57804. /** Get the block that owns this connection point */
  57805. readonly ownerBlock: NodeMaterialBlock;
  57806. /** Get the block connected on the other side of this connection (if any) */
  57807. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  57808. /** Get the block connected on the endpoints of this connection (if any) */
  57809. readonly connectedBlocks: Array<NodeMaterialBlock>;
  57810. /** Gets the list of connected endpoints */
  57811. readonly endpoints: NodeMaterialConnectionPoint[];
  57812. /** Gets a boolean indicating if that output point is connected to at least one input */
  57813. readonly hasEndpoints: boolean;
  57814. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  57815. readonly isConnectedInVertexShader: boolean;
  57816. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  57817. readonly isConnectedInFragmentShader: boolean;
  57818. /**
  57819. * Creates a new connection point
  57820. * @param name defines the connection point name
  57821. * @param ownerBlock defines the block hosting this connection point
  57822. * @param direction defines the direction of the connection point
  57823. */
  57824. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  57825. /**
  57826. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  57827. * @returns the class name
  57828. */
  57829. getClassName(): string;
  57830. /**
  57831. * Gets a boolean indicating if the current point can be connected to another point
  57832. * @param connectionPoint defines the other connection point
  57833. * @returns a boolean
  57834. */
  57835. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  57836. /**
  57837. * Gets a number indicating if the current point can be connected to another point
  57838. * @param connectionPoint defines the other connection point
  57839. * @returns a number defining the compatibility state
  57840. */
  57841. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57842. /**
  57843. * Connect this point to another connection point
  57844. * @param connectionPoint defines the other connection point
  57845. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  57846. * @returns the current connection point
  57847. */
  57848. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  57849. /**
  57850. * Disconnect this point from one of his endpoint
  57851. * @param endpoint defines the other connection point
  57852. * @returns the current connection point
  57853. */
  57854. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  57855. /**
  57856. * Serializes this point in a JSON representation
  57857. * @returns the serialized point object
  57858. */
  57859. serialize(): any;
  57860. /**
  57861. * Release resources
  57862. */
  57863. dispose(): void;
  57864. }
  57865. }
  57866. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  57867. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57868. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57870. import { Mesh } from "babylonjs/Meshes/mesh";
  57871. import { Effect } from "babylonjs/Materials/effect";
  57872. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57873. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57874. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57875. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57876. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57877. /**
  57878. * Block used to add support for vertex skinning (bones)
  57879. */
  57880. export class BonesBlock extends NodeMaterialBlock {
  57881. /**
  57882. * Creates a new BonesBlock
  57883. * @param name defines the block name
  57884. */
  57885. constructor(name: string);
  57886. /**
  57887. * Initialize the block and prepare the context for build
  57888. * @param state defines the state that will be used for the build
  57889. */
  57890. initialize(state: NodeMaterialBuildState): void;
  57891. /**
  57892. * Gets the current class name
  57893. * @returns the class name
  57894. */
  57895. getClassName(): string;
  57896. /**
  57897. * Gets the matrix indices input component
  57898. */
  57899. readonly matricesIndices: NodeMaterialConnectionPoint;
  57900. /**
  57901. * Gets the matrix weights input component
  57902. */
  57903. readonly matricesWeights: NodeMaterialConnectionPoint;
  57904. /**
  57905. * Gets the extra matrix indices input component
  57906. */
  57907. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  57908. /**
  57909. * Gets the extra matrix weights input component
  57910. */
  57911. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  57912. /**
  57913. * Gets the world input component
  57914. */
  57915. readonly world: NodeMaterialConnectionPoint;
  57916. /**
  57917. * Gets the output component
  57918. */
  57919. readonly output: NodeMaterialConnectionPoint;
  57920. autoConfigure(material: NodeMaterial): void;
  57921. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57922. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57923. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57924. protected _buildBlock(state: NodeMaterialBuildState): this;
  57925. }
  57926. }
  57927. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  57928. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57929. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57930. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57932. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57933. /**
  57934. * Block used to add support for instances
  57935. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  57936. */
  57937. export class InstancesBlock extends NodeMaterialBlock {
  57938. /**
  57939. * Creates a new InstancesBlock
  57940. * @param name defines the block name
  57941. */
  57942. constructor(name: string);
  57943. /**
  57944. * Gets the current class name
  57945. * @returns the class name
  57946. */
  57947. getClassName(): string;
  57948. /**
  57949. * Gets the first world row input component
  57950. */
  57951. readonly world0: NodeMaterialConnectionPoint;
  57952. /**
  57953. * Gets the second world row input component
  57954. */
  57955. readonly world1: NodeMaterialConnectionPoint;
  57956. /**
  57957. * Gets the third world row input component
  57958. */
  57959. readonly world2: NodeMaterialConnectionPoint;
  57960. /**
  57961. * Gets the forth world row input component
  57962. */
  57963. readonly world3: NodeMaterialConnectionPoint;
  57964. /**
  57965. * Gets the world input component
  57966. */
  57967. readonly world: NodeMaterialConnectionPoint;
  57968. /**
  57969. * Gets the output component
  57970. */
  57971. readonly output: NodeMaterialConnectionPoint;
  57972. autoConfigure(material: NodeMaterial): void;
  57973. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57974. protected _buildBlock(state: NodeMaterialBuildState): this;
  57975. }
  57976. }
  57977. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  57978. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57979. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57980. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57982. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57983. import { Effect } from "babylonjs/Materials/effect";
  57984. import { Mesh } from "babylonjs/Meshes/mesh";
  57985. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57986. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57987. /**
  57988. * Block used to add morph targets support to vertex shader
  57989. */
  57990. export class MorphTargetsBlock extends NodeMaterialBlock {
  57991. private _repeatableContentAnchor;
  57992. private _repeatebleContentGenerated;
  57993. /**
  57994. * Create a new MorphTargetsBlock
  57995. * @param name defines the block name
  57996. */
  57997. constructor(name: string);
  57998. /**
  57999. * Gets the current class name
  58000. * @returns the class name
  58001. */
  58002. getClassName(): string;
  58003. /**
  58004. * Gets the position input component
  58005. */
  58006. readonly position: NodeMaterialConnectionPoint;
  58007. /**
  58008. * Gets the normal input component
  58009. */
  58010. readonly normal: NodeMaterialConnectionPoint;
  58011. /**
  58012. * Gets the tangent input component
  58013. */
  58014. readonly tangent: NodeMaterialConnectionPoint;
  58015. /**
  58016. * Gets the tangent input component
  58017. */
  58018. readonly uv: NodeMaterialConnectionPoint;
  58019. /**
  58020. * Gets the position output component
  58021. */
  58022. readonly positionOutput: NodeMaterialConnectionPoint;
  58023. /**
  58024. * Gets the normal output component
  58025. */
  58026. readonly normalOutput: NodeMaterialConnectionPoint;
  58027. /**
  58028. * Gets the tangent output component
  58029. */
  58030. readonly tangentOutput: NodeMaterialConnectionPoint;
  58031. /**
  58032. * Gets the tangent output component
  58033. */
  58034. readonly uvOutput: NodeMaterialConnectionPoint;
  58035. initialize(state: NodeMaterialBuildState): void;
  58036. autoConfigure(material: NodeMaterial): void;
  58037. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58038. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58039. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58040. protected _buildBlock(state: NodeMaterialBuildState): this;
  58041. }
  58042. }
  58043. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  58044. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58045. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58046. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58047. import { Nullable } from "babylonjs/types";
  58048. import { Scene } from "babylonjs/scene";
  58049. import { Effect } from "babylonjs/Materials/effect";
  58050. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58051. import { Mesh } from "babylonjs/Meshes/mesh";
  58052. import { Light } from "babylonjs/Lights/light";
  58053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58054. /**
  58055. * Block used to get data information from a light
  58056. */
  58057. export class LightInformationBlock extends NodeMaterialBlock {
  58058. private _lightDataUniformName;
  58059. private _lightColorUniformName;
  58060. private _lightTypeDefineName;
  58061. /**
  58062. * Gets or sets the light associated with this block
  58063. */
  58064. light: Nullable<Light>;
  58065. /**
  58066. * Creates a new LightInformationBlock
  58067. * @param name defines the block name
  58068. */
  58069. constructor(name: string);
  58070. /**
  58071. * Gets the current class name
  58072. * @returns the class name
  58073. */
  58074. getClassName(): string;
  58075. /**
  58076. * Gets the world position input component
  58077. */
  58078. readonly worldPosition: NodeMaterialConnectionPoint;
  58079. /**
  58080. * Gets the direction output component
  58081. */
  58082. readonly direction: NodeMaterialConnectionPoint;
  58083. /**
  58084. * Gets the direction output component
  58085. */
  58086. readonly color: NodeMaterialConnectionPoint;
  58087. /**
  58088. * Gets the direction output component
  58089. */
  58090. readonly intensity: NodeMaterialConnectionPoint;
  58091. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58092. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58093. protected _buildBlock(state: NodeMaterialBuildState): this;
  58094. serialize(): any;
  58095. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58096. }
  58097. }
  58098. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  58099. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  58100. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  58101. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  58102. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  58103. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  58104. }
  58105. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  58106. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58107. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58108. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58110. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58111. import { Effect } from "babylonjs/Materials/effect";
  58112. import { Mesh } from "babylonjs/Meshes/mesh";
  58113. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58114. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58115. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58116. /**
  58117. * Block used to add image processing support to fragment shader
  58118. */
  58119. export class ImageProcessingBlock extends NodeMaterialBlock {
  58120. /**
  58121. * Create a new ImageProcessingBlock
  58122. * @param name defines the block name
  58123. */
  58124. constructor(name: string);
  58125. /**
  58126. * Gets the current class name
  58127. * @returns the class name
  58128. */
  58129. getClassName(): string;
  58130. /**
  58131. * Gets the color input component
  58132. */
  58133. readonly color: NodeMaterialConnectionPoint;
  58134. /**
  58135. * Gets the output component
  58136. */
  58137. readonly output: NodeMaterialConnectionPoint;
  58138. /**
  58139. * Initialize the block and prepare the context for build
  58140. * @param state defines the state that will be used for the build
  58141. */
  58142. initialize(state: NodeMaterialBuildState): void;
  58143. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58144. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58145. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58146. protected _buildBlock(state: NodeMaterialBuildState): this;
  58147. }
  58148. }
  58149. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  58150. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58151. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58152. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58153. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58155. import { Effect } from "babylonjs/Materials/effect";
  58156. import { Mesh } from "babylonjs/Meshes/mesh";
  58157. import { Scene } from "babylonjs/scene";
  58158. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58159. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58160. /**
  58161. * Block used to pertub normals based on a normal map
  58162. */
  58163. export class PerturbNormalBlock extends NodeMaterialBlock {
  58164. private _tangentSpaceParameterName;
  58165. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58166. invertX: boolean;
  58167. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58168. invertY: boolean;
  58169. /**
  58170. * Create a new PerturbNormalBlock
  58171. * @param name defines the block name
  58172. */
  58173. constructor(name: string);
  58174. /**
  58175. * Gets the current class name
  58176. * @returns the class name
  58177. */
  58178. getClassName(): string;
  58179. /**
  58180. * Gets the world position input component
  58181. */
  58182. readonly worldPosition: NodeMaterialConnectionPoint;
  58183. /**
  58184. * Gets the world normal input component
  58185. */
  58186. readonly worldNormal: NodeMaterialConnectionPoint;
  58187. /**
  58188. * Gets the uv input component
  58189. */
  58190. readonly uv: NodeMaterialConnectionPoint;
  58191. /**
  58192. * Gets the normal map color input component
  58193. */
  58194. readonly normalMapColor: NodeMaterialConnectionPoint;
  58195. /**
  58196. * Gets the strength input component
  58197. */
  58198. readonly strength: NodeMaterialConnectionPoint;
  58199. /**
  58200. * Gets the output component
  58201. */
  58202. readonly output: NodeMaterialConnectionPoint;
  58203. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58204. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58205. autoConfigure(material: NodeMaterial): void;
  58206. protected _buildBlock(state: NodeMaterialBuildState): this;
  58207. protected _dumpPropertiesCode(): string;
  58208. serialize(): any;
  58209. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58210. }
  58211. }
  58212. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  58213. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58214. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58215. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58216. /**
  58217. * Block used to discard a pixel if a value is smaller than a cutoff
  58218. */
  58219. export class DiscardBlock extends NodeMaterialBlock {
  58220. /**
  58221. * Create a new DiscardBlock
  58222. * @param name defines the block name
  58223. */
  58224. constructor(name: string);
  58225. /**
  58226. * Gets the current class name
  58227. * @returns the class name
  58228. */
  58229. getClassName(): string;
  58230. /**
  58231. * Gets the color input component
  58232. */
  58233. readonly value: NodeMaterialConnectionPoint;
  58234. /**
  58235. * Gets the cutoff input component
  58236. */
  58237. readonly cutoff: NodeMaterialConnectionPoint;
  58238. protected _buildBlock(state: NodeMaterialBuildState): this;
  58239. }
  58240. }
  58241. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  58242. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58243. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58244. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58245. /**
  58246. * Block used to test if the fragment shader is front facing
  58247. */
  58248. export class FrontFacingBlock extends NodeMaterialBlock {
  58249. /**
  58250. * Creates a new FrontFacingBlock
  58251. * @param name defines the block name
  58252. */
  58253. constructor(name: string);
  58254. /**
  58255. * Gets the current class name
  58256. * @returns the class name
  58257. */
  58258. getClassName(): string;
  58259. /**
  58260. * Gets the output component
  58261. */
  58262. readonly output: NodeMaterialConnectionPoint;
  58263. protected _buildBlock(state: NodeMaterialBuildState): this;
  58264. }
  58265. }
  58266. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  58267. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58268. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58269. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58270. /**
  58271. * Block used to get the derivative value on x and y of a given input
  58272. */
  58273. export class DerivativeBlock extends NodeMaterialBlock {
  58274. /**
  58275. * Create a new DerivativeBlock
  58276. * @param name defines the block name
  58277. */
  58278. constructor(name: string);
  58279. /**
  58280. * Gets the current class name
  58281. * @returns the class name
  58282. */
  58283. getClassName(): string;
  58284. /**
  58285. * Gets the input component
  58286. */
  58287. readonly input: NodeMaterialConnectionPoint;
  58288. /**
  58289. * Gets the derivative output on x
  58290. */
  58291. readonly dx: NodeMaterialConnectionPoint;
  58292. /**
  58293. * Gets the derivative output on y
  58294. */
  58295. readonly dy: NodeMaterialConnectionPoint;
  58296. protected _buildBlock(state: NodeMaterialBuildState): this;
  58297. }
  58298. }
  58299. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  58300. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  58301. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  58302. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  58303. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  58304. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  58305. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  58306. }
  58307. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  58308. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58309. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58310. import { Mesh } from "babylonjs/Meshes/mesh";
  58311. import { Effect } from "babylonjs/Materials/effect";
  58312. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58314. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58315. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58316. /**
  58317. * Block used to add support for scene fog
  58318. */
  58319. export class FogBlock extends NodeMaterialBlock {
  58320. private _fogDistanceName;
  58321. private _fogParameters;
  58322. /**
  58323. * Create a new FogBlock
  58324. * @param name defines the block name
  58325. */
  58326. constructor(name: string);
  58327. /**
  58328. * Gets the current class name
  58329. * @returns the class name
  58330. */
  58331. getClassName(): string;
  58332. /**
  58333. * Gets the world position input component
  58334. */
  58335. readonly worldPosition: NodeMaterialConnectionPoint;
  58336. /**
  58337. * Gets the view input component
  58338. */
  58339. readonly view: NodeMaterialConnectionPoint;
  58340. /**
  58341. * Gets the color input component
  58342. */
  58343. readonly input: NodeMaterialConnectionPoint;
  58344. /**
  58345. * Gets the fog color input component
  58346. */
  58347. readonly fogColor: NodeMaterialConnectionPoint;
  58348. /**
  58349. * Gets the output component
  58350. */
  58351. readonly output: NodeMaterialConnectionPoint;
  58352. autoConfigure(material: NodeMaterial): void;
  58353. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58354. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58355. protected _buildBlock(state: NodeMaterialBuildState): this;
  58356. }
  58357. }
  58358. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  58359. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58360. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58361. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58363. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58364. import { Effect } from "babylonjs/Materials/effect";
  58365. import { Mesh } from "babylonjs/Meshes/mesh";
  58366. import { Light } from "babylonjs/Lights/light";
  58367. import { Nullable } from "babylonjs/types";
  58368. import { Scene } from "babylonjs/scene";
  58369. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58370. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58371. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58372. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58373. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  58374. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58375. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58376. /**
  58377. * Block used to add light in the fragment shader
  58378. */
  58379. export class LightBlock extends NodeMaterialBlock {
  58380. private _lightId;
  58381. /**
  58382. * Gets or sets the light associated with this block
  58383. */
  58384. light: Nullable<Light>;
  58385. /**
  58386. * Create a new LightBlock
  58387. * @param name defines the block name
  58388. */
  58389. constructor(name: string);
  58390. /**
  58391. * Gets the current class name
  58392. * @returns the class name
  58393. */
  58394. getClassName(): string;
  58395. /**
  58396. * Gets the world position input component
  58397. */
  58398. readonly worldPosition: NodeMaterialConnectionPoint;
  58399. /**
  58400. * Gets the world normal input component
  58401. */
  58402. readonly worldNormal: NodeMaterialConnectionPoint;
  58403. /**
  58404. * Gets the camera (or eye) position component
  58405. */
  58406. readonly cameraPosition: NodeMaterialConnectionPoint;
  58407. /**
  58408. * Gets the glossiness component
  58409. */
  58410. readonly glossiness: NodeMaterialConnectionPoint;
  58411. /**
  58412. * Gets the glossinness power component
  58413. */
  58414. readonly glossPower: NodeMaterialConnectionPoint;
  58415. /**
  58416. * Gets the diffuse color component
  58417. */
  58418. readonly diffuseColor: NodeMaterialConnectionPoint;
  58419. /**
  58420. * Gets the specular color component
  58421. */
  58422. readonly specularColor: NodeMaterialConnectionPoint;
  58423. /**
  58424. * Gets the diffuse output component
  58425. */
  58426. readonly diffuseOutput: NodeMaterialConnectionPoint;
  58427. /**
  58428. * Gets the specular output component
  58429. */
  58430. readonly specularOutput: NodeMaterialConnectionPoint;
  58431. autoConfigure(material: NodeMaterial): void;
  58432. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58433. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58434. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58435. private _injectVertexCode;
  58436. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58437. serialize(): any;
  58438. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58439. }
  58440. }
  58441. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  58442. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  58443. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  58444. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  58445. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  58446. }
  58447. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  58448. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58449. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  58450. }
  58451. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  58452. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58453. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58454. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58455. /**
  58456. * Block used to multiply 2 values
  58457. */
  58458. export class MultiplyBlock extends NodeMaterialBlock {
  58459. /**
  58460. * Creates a new MultiplyBlock
  58461. * @param name defines the block name
  58462. */
  58463. constructor(name: string);
  58464. /**
  58465. * Gets the current class name
  58466. * @returns the class name
  58467. */
  58468. getClassName(): string;
  58469. /**
  58470. * Gets the left operand input component
  58471. */
  58472. readonly left: NodeMaterialConnectionPoint;
  58473. /**
  58474. * Gets the right operand input component
  58475. */
  58476. readonly right: NodeMaterialConnectionPoint;
  58477. /**
  58478. * Gets the output component
  58479. */
  58480. readonly output: NodeMaterialConnectionPoint;
  58481. protected _buildBlock(state: NodeMaterialBuildState): this;
  58482. }
  58483. }
  58484. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  58485. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58486. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58487. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58488. /**
  58489. * Block used to add 2 vectors
  58490. */
  58491. export class AddBlock extends NodeMaterialBlock {
  58492. /**
  58493. * Creates a new AddBlock
  58494. * @param name defines the block name
  58495. */
  58496. constructor(name: string);
  58497. /**
  58498. * Gets the current class name
  58499. * @returns the class name
  58500. */
  58501. getClassName(): string;
  58502. /**
  58503. * Gets the left operand input component
  58504. */
  58505. readonly left: NodeMaterialConnectionPoint;
  58506. /**
  58507. * Gets the right operand input component
  58508. */
  58509. readonly right: NodeMaterialConnectionPoint;
  58510. /**
  58511. * Gets the output component
  58512. */
  58513. readonly output: NodeMaterialConnectionPoint;
  58514. protected _buildBlock(state: NodeMaterialBuildState): this;
  58515. }
  58516. }
  58517. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  58518. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58519. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58520. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58521. /**
  58522. * Block used to scale a vector by a float
  58523. */
  58524. export class ScaleBlock extends NodeMaterialBlock {
  58525. /**
  58526. * Creates a new ScaleBlock
  58527. * @param name defines the block name
  58528. */
  58529. constructor(name: string);
  58530. /**
  58531. * Gets the current class name
  58532. * @returns the class name
  58533. */
  58534. getClassName(): string;
  58535. /**
  58536. * Gets the input component
  58537. */
  58538. readonly input: NodeMaterialConnectionPoint;
  58539. /**
  58540. * Gets the factor input component
  58541. */
  58542. readonly factor: NodeMaterialConnectionPoint;
  58543. /**
  58544. * Gets the output component
  58545. */
  58546. readonly output: NodeMaterialConnectionPoint;
  58547. protected _buildBlock(state: NodeMaterialBuildState): this;
  58548. }
  58549. }
  58550. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  58551. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58552. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58553. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58554. import { Scene } from "babylonjs/scene";
  58555. /**
  58556. * Block used to clamp a float
  58557. */
  58558. export class ClampBlock extends NodeMaterialBlock {
  58559. /** Gets or sets the minimum range */
  58560. minimum: number;
  58561. /** Gets or sets the maximum range */
  58562. maximum: number;
  58563. /**
  58564. * Creates a new ClampBlock
  58565. * @param name defines the block name
  58566. */
  58567. constructor(name: string);
  58568. /**
  58569. * Gets the current class name
  58570. * @returns the class name
  58571. */
  58572. getClassName(): string;
  58573. /**
  58574. * Gets the value input component
  58575. */
  58576. readonly value: NodeMaterialConnectionPoint;
  58577. /**
  58578. * Gets the output component
  58579. */
  58580. readonly output: NodeMaterialConnectionPoint;
  58581. protected _buildBlock(state: NodeMaterialBuildState): this;
  58582. protected _dumpPropertiesCode(): string;
  58583. serialize(): any;
  58584. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58585. }
  58586. }
  58587. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  58588. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58589. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58590. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58591. /**
  58592. * Block used to apply a cross product between 2 vectors
  58593. */
  58594. export class CrossBlock extends NodeMaterialBlock {
  58595. /**
  58596. * Creates a new CrossBlock
  58597. * @param name defines the block name
  58598. */
  58599. constructor(name: string);
  58600. /**
  58601. * Gets the current class name
  58602. * @returns the class name
  58603. */
  58604. getClassName(): string;
  58605. /**
  58606. * Gets the left operand input component
  58607. */
  58608. readonly left: NodeMaterialConnectionPoint;
  58609. /**
  58610. * Gets the right operand input component
  58611. */
  58612. readonly right: NodeMaterialConnectionPoint;
  58613. /**
  58614. * Gets the output component
  58615. */
  58616. readonly output: NodeMaterialConnectionPoint;
  58617. protected _buildBlock(state: NodeMaterialBuildState): this;
  58618. }
  58619. }
  58620. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  58621. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58622. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58623. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58624. /**
  58625. * Block used to apply a dot product between 2 vectors
  58626. */
  58627. export class DotBlock extends NodeMaterialBlock {
  58628. /**
  58629. * Creates a new DotBlock
  58630. * @param name defines the block name
  58631. */
  58632. constructor(name: string);
  58633. /**
  58634. * Gets the current class name
  58635. * @returns the class name
  58636. */
  58637. getClassName(): string;
  58638. /**
  58639. * Gets the left operand input component
  58640. */
  58641. readonly left: NodeMaterialConnectionPoint;
  58642. /**
  58643. * Gets the right operand input component
  58644. */
  58645. readonly right: NodeMaterialConnectionPoint;
  58646. /**
  58647. * Gets the output component
  58648. */
  58649. readonly output: NodeMaterialConnectionPoint;
  58650. protected _buildBlock(state: NodeMaterialBuildState): this;
  58651. }
  58652. }
  58653. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  58654. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58655. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58656. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58657. import { Vector2 } from "babylonjs/Maths/math.vector";
  58658. import { Scene } from "babylonjs/scene";
  58659. /**
  58660. * Block used to remap a float from a range to a new one
  58661. */
  58662. export class RemapBlock extends NodeMaterialBlock {
  58663. /**
  58664. * Gets or sets the source range
  58665. */
  58666. sourceRange: Vector2;
  58667. /**
  58668. * Gets or sets the target range
  58669. */
  58670. targetRange: Vector2;
  58671. /**
  58672. * Creates a new RemapBlock
  58673. * @param name defines the block name
  58674. */
  58675. constructor(name: string);
  58676. /**
  58677. * Gets the current class name
  58678. * @returns the class name
  58679. */
  58680. getClassName(): string;
  58681. /**
  58682. * Gets the input component
  58683. */
  58684. readonly input: NodeMaterialConnectionPoint;
  58685. /**
  58686. * Gets the source min input component
  58687. */
  58688. readonly sourceMin: NodeMaterialConnectionPoint;
  58689. /**
  58690. * Gets the source max input component
  58691. */
  58692. readonly sourceMax: NodeMaterialConnectionPoint;
  58693. /**
  58694. * Gets the target min input component
  58695. */
  58696. readonly targetMin: NodeMaterialConnectionPoint;
  58697. /**
  58698. * Gets the target max input component
  58699. */
  58700. readonly targetMax: NodeMaterialConnectionPoint;
  58701. /**
  58702. * Gets the output component
  58703. */
  58704. readonly output: NodeMaterialConnectionPoint;
  58705. protected _buildBlock(state: NodeMaterialBuildState): this;
  58706. protected _dumpPropertiesCode(): string;
  58707. serialize(): any;
  58708. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58709. }
  58710. }
  58711. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  58712. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58713. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58714. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58715. /**
  58716. * Block used to normalize a vector
  58717. */
  58718. export class NormalizeBlock extends NodeMaterialBlock {
  58719. /**
  58720. * Creates a new NormalizeBlock
  58721. * @param name defines the block name
  58722. */
  58723. constructor(name: string);
  58724. /**
  58725. * Gets the current class name
  58726. * @returns the class name
  58727. */
  58728. getClassName(): string;
  58729. /**
  58730. * Gets the input component
  58731. */
  58732. readonly input: NodeMaterialConnectionPoint;
  58733. /**
  58734. * Gets the output component
  58735. */
  58736. readonly output: NodeMaterialConnectionPoint;
  58737. protected _buildBlock(state: NodeMaterialBuildState): this;
  58738. }
  58739. }
  58740. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  58741. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58742. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58743. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58744. import { Scene } from "babylonjs/scene";
  58745. /**
  58746. * Operations supported by the Trigonometry block
  58747. */
  58748. export enum TrigonometryBlockOperations {
  58749. /** Cos */
  58750. Cos = 0,
  58751. /** Sin */
  58752. Sin = 1,
  58753. /** Abs */
  58754. Abs = 2,
  58755. /** Exp */
  58756. Exp = 3,
  58757. /** Exp2 */
  58758. Exp2 = 4,
  58759. /** Round */
  58760. Round = 5,
  58761. /** Floor */
  58762. Floor = 6,
  58763. /** Ceiling */
  58764. Ceiling = 7,
  58765. /** Square root */
  58766. Sqrt = 8,
  58767. /** Log */
  58768. Log = 9,
  58769. /** Tangent */
  58770. Tan = 10,
  58771. /** Arc tangent */
  58772. ArcTan = 11,
  58773. /** Arc cosinus */
  58774. ArcCos = 12,
  58775. /** Arc sinus */
  58776. ArcSin = 13,
  58777. /** Fraction */
  58778. Fract = 14,
  58779. /** Sign */
  58780. Sign = 15,
  58781. /** To radians (from degrees) */
  58782. Radians = 16,
  58783. /** To degrees (from radians) */
  58784. Degrees = 17
  58785. }
  58786. /**
  58787. * Block used to apply trigonometry operation to floats
  58788. */
  58789. export class TrigonometryBlock extends NodeMaterialBlock {
  58790. /**
  58791. * Gets or sets the operation applied by the block
  58792. */
  58793. operation: TrigonometryBlockOperations;
  58794. /**
  58795. * Creates a new TrigonometryBlock
  58796. * @param name defines the block name
  58797. */
  58798. constructor(name: string);
  58799. /**
  58800. * Gets the current class name
  58801. * @returns the class name
  58802. */
  58803. getClassName(): string;
  58804. /**
  58805. * Gets the input component
  58806. */
  58807. readonly input: NodeMaterialConnectionPoint;
  58808. /**
  58809. * Gets the output component
  58810. */
  58811. readonly output: NodeMaterialConnectionPoint;
  58812. protected _buildBlock(state: NodeMaterialBuildState): this;
  58813. serialize(): any;
  58814. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58815. protected _dumpPropertiesCode(): string;
  58816. }
  58817. }
  58818. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  58819. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58820. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58821. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58822. /**
  58823. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58824. */
  58825. export class ColorMergerBlock extends NodeMaterialBlock {
  58826. /**
  58827. * Create a new ColorMergerBlock
  58828. * @param name defines the block name
  58829. */
  58830. constructor(name: string);
  58831. /**
  58832. * Gets the current class name
  58833. * @returns the class name
  58834. */
  58835. getClassName(): string;
  58836. /**
  58837. * Gets the rgb component (input)
  58838. */
  58839. readonly rgbIn: NodeMaterialConnectionPoint;
  58840. /**
  58841. * Gets the r component (input)
  58842. */
  58843. readonly r: NodeMaterialConnectionPoint;
  58844. /**
  58845. * Gets the g component (input)
  58846. */
  58847. readonly g: NodeMaterialConnectionPoint;
  58848. /**
  58849. * Gets the b component (input)
  58850. */
  58851. readonly b: NodeMaterialConnectionPoint;
  58852. /**
  58853. * Gets the a component (input)
  58854. */
  58855. readonly a: NodeMaterialConnectionPoint;
  58856. /**
  58857. * Gets the rgba component (output)
  58858. */
  58859. readonly rgba: NodeMaterialConnectionPoint;
  58860. /**
  58861. * Gets the rgb component (output)
  58862. */
  58863. readonly rgbOut: NodeMaterialConnectionPoint;
  58864. /**
  58865. * Gets the rgb component (output)
  58866. * @deprecated Please use rgbOut instead.
  58867. */
  58868. readonly rgb: NodeMaterialConnectionPoint;
  58869. protected _buildBlock(state: NodeMaterialBuildState): this;
  58870. }
  58871. }
  58872. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  58873. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58874. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58875. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58876. /**
  58877. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58878. */
  58879. export class VectorMergerBlock extends NodeMaterialBlock {
  58880. /**
  58881. * Create a new VectorMergerBlock
  58882. * @param name defines the block name
  58883. */
  58884. constructor(name: string);
  58885. /**
  58886. * Gets the current class name
  58887. * @returns the class name
  58888. */
  58889. getClassName(): string;
  58890. /**
  58891. * Gets the xyz component (input)
  58892. */
  58893. readonly xyzIn: NodeMaterialConnectionPoint;
  58894. /**
  58895. * Gets the xy component (input)
  58896. */
  58897. readonly xyIn: NodeMaterialConnectionPoint;
  58898. /**
  58899. * Gets the x component (input)
  58900. */
  58901. readonly x: NodeMaterialConnectionPoint;
  58902. /**
  58903. * Gets the y component (input)
  58904. */
  58905. readonly y: NodeMaterialConnectionPoint;
  58906. /**
  58907. * Gets the z component (input)
  58908. */
  58909. readonly z: NodeMaterialConnectionPoint;
  58910. /**
  58911. * Gets the w component (input)
  58912. */
  58913. readonly w: NodeMaterialConnectionPoint;
  58914. /**
  58915. * Gets the xyzw component (output)
  58916. */
  58917. readonly xyzw: NodeMaterialConnectionPoint;
  58918. /**
  58919. * Gets the xyz component (output)
  58920. */
  58921. readonly xyzOut: NodeMaterialConnectionPoint;
  58922. /**
  58923. * Gets the xy component (output)
  58924. */
  58925. readonly xyOut: NodeMaterialConnectionPoint;
  58926. /**
  58927. * Gets the xy component (output)
  58928. * @deprecated Please use xyOut instead.
  58929. */
  58930. readonly xy: NodeMaterialConnectionPoint;
  58931. /**
  58932. * Gets the xyz component (output)
  58933. * @deprecated Please use xyzOut instead.
  58934. */
  58935. readonly xyz: NodeMaterialConnectionPoint;
  58936. protected _buildBlock(state: NodeMaterialBuildState): this;
  58937. }
  58938. }
  58939. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  58940. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58941. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58942. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58943. /**
  58944. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  58945. */
  58946. export class ColorSplitterBlock extends NodeMaterialBlock {
  58947. /**
  58948. * Create a new ColorSplitterBlock
  58949. * @param name defines the block name
  58950. */
  58951. constructor(name: string);
  58952. /**
  58953. * Gets the current class name
  58954. * @returns the class name
  58955. */
  58956. getClassName(): string;
  58957. /**
  58958. * Gets the rgba component (input)
  58959. */
  58960. readonly rgba: NodeMaterialConnectionPoint;
  58961. /**
  58962. * Gets the rgb component (input)
  58963. */
  58964. readonly rgbIn: NodeMaterialConnectionPoint;
  58965. /**
  58966. * Gets the rgb component (output)
  58967. */
  58968. readonly rgbOut: NodeMaterialConnectionPoint;
  58969. /**
  58970. * Gets the r component (output)
  58971. */
  58972. readonly r: NodeMaterialConnectionPoint;
  58973. /**
  58974. * Gets the g component (output)
  58975. */
  58976. readonly g: NodeMaterialConnectionPoint;
  58977. /**
  58978. * Gets the b component (output)
  58979. */
  58980. readonly b: NodeMaterialConnectionPoint;
  58981. /**
  58982. * Gets the a component (output)
  58983. */
  58984. readonly a: NodeMaterialConnectionPoint;
  58985. protected _inputRename(name: string): string;
  58986. protected _outputRename(name: string): string;
  58987. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58988. }
  58989. }
  58990. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  58991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58992. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58993. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58994. /**
  58995. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  58996. */
  58997. export class VectorSplitterBlock extends NodeMaterialBlock {
  58998. /**
  58999. * Create a new VectorSplitterBlock
  59000. * @param name defines the block name
  59001. */
  59002. constructor(name: string);
  59003. /**
  59004. * Gets the current class name
  59005. * @returns the class name
  59006. */
  59007. getClassName(): string;
  59008. /**
  59009. * Gets the xyzw component (input)
  59010. */
  59011. readonly xyzw: NodeMaterialConnectionPoint;
  59012. /**
  59013. * Gets the xyz component (input)
  59014. */
  59015. readonly xyzIn: NodeMaterialConnectionPoint;
  59016. /**
  59017. * Gets the xy component (input)
  59018. */
  59019. readonly xyIn: NodeMaterialConnectionPoint;
  59020. /**
  59021. * Gets the xyz component (output)
  59022. */
  59023. readonly xyzOut: NodeMaterialConnectionPoint;
  59024. /**
  59025. * Gets the xy component (output)
  59026. */
  59027. readonly xyOut: NodeMaterialConnectionPoint;
  59028. /**
  59029. * Gets the x component (output)
  59030. */
  59031. readonly x: NodeMaterialConnectionPoint;
  59032. /**
  59033. * Gets the y component (output)
  59034. */
  59035. readonly y: NodeMaterialConnectionPoint;
  59036. /**
  59037. * Gets the z component (output)
  59038. */
  59039. readonly z: NodeMaterialConnectionPoint;
  59040. /**
  59041. * Gets the w component (output)
  59042. */
  59043. readonly w: NodeMaterialConnectionPoint;
  59044. protected _inputRename(name: string): string;
  59045. protected _outputRename(name: string): string;
  59046. protected _buildBlock(state: NodeMaterialBuildState): this;
  59047. }
  59048. }
  59049. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  59050. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59051. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59052. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59053. /**
  59054. * Block used to lerp between 2 values
  59055. */
  59056. export class LerpBlock extends NodeMaterialBlock {
  59057. /**
  59058. * Creates a new LerpBlock
  59059. * @param name defines the block name
  59060. */
  59061. constructor(name: string);
  59062. /**
  59063. * Gets the current class name
  59064. * @returns the class name
  59065. */
  59066. getClassName(): string;
  59067. /**
  59068. * Gets the left operand input component
  59069. */
  59070. readonly left: NodeMaterialConnectionPoint;
  59071. /**
  59072. * Gets the right operand input component
  59073. */
  59074. readonly right: NodeMaterialConnectionPoint;
  59075. /**
  59076. * Gets the gradient operand input component
  59077. */
  59078. readonly gradient: NodeMaterialConnectionPoint;
  59079. /**
  59080. * Gets the output component
  59081. */
  59082. readonly output: NodeMaterialConnectionPoint;
  59083. protected _buildBlock(state: NodeMaterialBuildState): this;
  59084. }
  59085. }
  59086. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  59087. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59088. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59089. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59090. /**
  59091. * Block used to divide 2 vectors
  59092. */
  59093. export class DivideBlock extends NodeMaterialBlock {
  59094. /**
  59095. * Creates a new DivideBlock
  59096. * @param name defines the block name
  59097. */
  59098. constructor(name: string);
  59099. /**
  59100. * Gets the current class name
  59101. * @returns the class name
  59102. */
  59103. getClassName(): string;
  59104. /**
  59105. * Gets the left operand input component
  59106. */
  59107. readonly left: NodeMaterialConnectionPoint;
  59108. /**
  59109. * Gets the right operand input component
  59110. */
  59111. readonly right: NodeMaterialConnectionPoint;
  59112. /**
  59113. * Gets the output component
  59114. */
  59115. readonly output: NodeMaterialConnectionPoint;
  59116. protected _buildBlock(state: NodeMaterialBuildState): this;
  59117. }
  59118. }
  59119. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  59120. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59121. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59122. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59123. /**
  59124. * Block used to subtract 2 vectors
  59125. */
  59126. export class SubtractBlock extends NodeMaterialBlock {
  59127. /**
  59128. * Creates a new SubtractBlock
  59129. * @param name defines the block name
  59130. */
  59131. constructor(name: string);
  59132. /**
  59133. * Gets the current class name
  59134. * @returns the class name
  59135. */
  59136. getClassName(): string;
  59137. /**
  59138. * Gets the left operand input component
  59139. */
  59140. readonly left: NodeMaterialConnectionPoint;
  59141. /**
  59142. * Gets the right operand input component
  59143. */
  59144. readonly right: NodeMaterialConnectionPoint;
  59145. /**
  59146. * Gets the output component
  59147. */
  59148. readonly output: NodeMaterialConnectionPoint;
  59149. protected _buildBlock(state: NodeMaterialBuildState): this;
  59150. }
  59151. }
  59152. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  59153. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59154. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59155. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59156. /**
  59157. * Block used to step a value
  59158. */
  59159. export class StepBlock extends NodeMaterialBlock {
  59160. /**
  59161. * Creates a new StepBlock
  59162. * @param name defines the block name
  59163. */
  59164. constructor(name: string);
  59165. /**
  59166. * Gets the current class name
  59167. * @returns the class name
  59168. */
  59169. getClassName(): string;
  59170. /**
  59171. * Gets the value operand input component
  59172. */
  59173. readonly value: NodeMaterialConnectionPoint;
  59174. /**
  59175. * Gets the edge operand input component
  59176. */
  59177. readonly edge: NodeMaterialConnectionPoint;
  59178. /**
  59179. * Gets the output component
  59180. */
  59181. readonly output: NodeMaterialConnectionPoint;
  59182. protected _buildBlock(state: NodeMaterialBuildState): this;
  59183. }
  59184. }
  59185. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  59186. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59187. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59188. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59189. /**
  59190. * Block used to get the opposite (1 - x) of a value
  59191. */
  59192. export class OneMinusBlock extends NodeMaterialBlock {
  59193. /**
  59194. * Creates a new OneMinusBlock
  59195. * @param name defines the block name
  59196. */
  59197. constructor(name: string);
  59198. /**
  59199. * Gets the current class name
  59200. * @returns the class name
  59201. */
  59202. getClassName(): string;
  59203. /**
  59204. * Gets the input component
  59205. */
  59206. readonly input: NodeMaterialConnectionPoint;
  59207. /**
  59208. * Gets the output component
  59209. */
  59210. readonly output: NodeMaterialConnectionPoint;
  59211. protected _buildBlock(state: NodeMaterialBuildState): this;
  59212. }
  59213. }
  59214. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  59215. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59216. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59217. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59218. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59219. /**
  59220. * Block used to get the view direction
  59221. */
  59222. export class ViewDirectionBlock extends NodeMaterialBlock {
  59223. /**
  59224. * Creates a new ViewDirectionBlock
  59225. * @param name defines the block name
  59226. */
  59227. constructor(name: string);
  59228. /**
  59229. * Gets the current class name
  59230. * @returns the class name
  59231. */
  59232. getClassName(): string;
  59233. /**
  59234. * Gets the world position component
  59235. */
  59236. readonly worldPosition: NodeMaterialConnectionPoint;
  59237. /**
  59238. * Gets the camera position component
  59239. */
  59240. readonly cameraPosition: NodeMaterialConnectionPoint;
  59241. /**
  59242. * Gets the output component
  59243. */
  59244. readonly output: NodeMaterialConnectionPoint;
  59245. autoConfigure(material: NodeMaterial): void;
  59246. protected _buildBlock(state: NodeMaterialBuildState): this;
  59247. }
  59248. }
  59249. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  59250. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59251. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59252. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59253. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59254. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  59255. /**
  59256. * Block used to compute fresnel value
  59257. */
  59258. export class FresnelBlock extends NodeMaterialBlock {
  59259. /**
  59260. * Create a new FresnelBlock
  59261. * @param name defines the block name
  59262. */
  59263. constructor(name: string);
  59264. /**
  59265. * Gets the current class name
  59266. * @returns the class name
  59267. */
  59268. getClassName(): string;
  59269. /**
  59270. * Gets the world normal input component
  59271. */
  59272. readonly worldNormal: NodeMaterialConnectionPoint;
  59273. /**
  59274. * Gets the view direction input component
  59275. */
  59276. readonly viewDirection: NodeMaterialConnectionPoint;
  59277. /**
  59278. * Gets the bias input component
  59279. */
  59280. readonly bias: NodeMaterialConnectionPoint;
  59281. /**
  59282. * Gets the camera (or eye) position component
  59283. */
  59284. readonly power: NodeMaterialConnectionPoint;
  59285. /**
  59286. * Gets the fresnel output component
  59287. */
  59288. readonly fresnel: NodeMaterialConnectionPoint;
  59289. autoConfigure(material: NodeMaterial): void;
  59290. protected _buildBlock(state: NodeMaterialBuildState): this;
  59291. }
  59292. }
  59293. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  59294. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59295. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59296. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59297. /**
  59298. * Block used to get the max of 2 values
  59299. */
  59300. export class MaxBlock extends NodeMaterialBlock {
  59301. /**
  59302. * Creates a new MaxBlock
  59303. * @param name defines the block name
  59304. */
  59305. constructor(name: string);
  59306. /**
  59307. * Gets the current class name
  59308. * @returns the class name
  59309. */
  59310. getClassName(): string;
  59311. /**
  59312. * Gets the left operand input component
  59313. */
  59314. readonly left: NodeMaterialConnectionPoint;
  59315. /**
  59316. * Gets the right operand input component
  59317. */
  59318. readonly right: NodeMaterialConnectionPoint;
  59319. /**
  59320. * Gets the output component
  59321. */
  59322. readonly output: NodeMaterialConnectionPoint;
  59323. protected _buildBlock(state: NodeMaterialBuildState): this;
  59324. }
  59325. }
  59326. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  59327. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59328. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59329. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59330. /**
  59331. * Block used to get the min of 2 values
  59332. */
  59333. export class MinBlock extends NodeMaterialBlock {
  59334. /**
  59335. * Creates a new MinBlock
  59336. * @param name defines the block name
  59337. */
  59338. constructor(name: string);
  59339. /**
  59340. * Gets the current class name
  59341. * @returns the class name
  59342. */
  59343. getClassName(): string;
  59344. /**
  59345. * Gets the left operand input component
  59346. */
  59347. readonly left: NodeMaterialConnectionPoint;
  59348. /**
  59349. * Gets the right operand input component
  59350. */
  59351. readonly right: NodeMaterialConnectionPoint;
  59352. /**
  59353. * Gets the output component
  59354. */
  59355. readonly output: NodeMaterialConnectionPoint;
  59356. protected _buildBlock(state: NodeMaterialBuildState): this;
  59357. }
  59358. }
  59359. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  59360. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59361. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59362. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59363. /**
  59364. * Block used to get the distance between 2 values
  59365. */
  59366. export class DistanceBlock extends NodeMaterialBlock {
  59367. /**
  59368. * Creates a new DistanceBlock
  59369. * @param name defines the block name
  59370. */
  59371. constructor(name: string);
  59372. /**
  59373. * Gets the current class name
  59374. * @returns the class name
  59375. */
  59376. getClassName(): string;
  59377. /**
  59378. * Gets the left operand input component
  59379. */
  59380. readonly left: NodeMaterialConnectionPoint;
  59381. /**
  59382. * Gets the right operand input component
  59383. */
  59384. readonly right: NodeMaterialConnectionPoint;
  59385. /**
  59386. * Gets the output component
  59387. */
  59388. readonly output: NodeMaterialConnectionPoint;
  59389. protected _buildBlock(state: NodeMaterialBuildState): this;
  59390. }
  59391. }
  59392. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  59393. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59394. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59395. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59396. /**
  59397. * Block used to get the length of a vector
  59398. */
  59399. export class LengthBlock extends NodeMaterialBlock {
  59400. /**
  59401. * Creates a new LengthBlock
  59402. * @param name defines the block name
  59403. */
  59404. constructor(name: string);
  59405. /**
  59406. * Gets the current class name
  59407. * @returns the class name
  59408. */
  59409. getClassName(): string;
  59410. /**
  59411. * Gets the value input component
  59412. */
  59413. readonly value: NodeMaterialConnectionPoint;
  59414. /**
  59415. * Gets the output component
  59416. */
  59417. readonly output: NodeMaterialConnectionPoint;
  59418. protected _buildBlock(state: NodeMaterialBuildState): this;
  59419. }
  59420. }
  59421. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  59422. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59423. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59424. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59425. /**
  59426. * Block used to get negative version of a value (i.e. x * -1)
  59427. */
  59428. export class NegateBlock extends NodeMaterialBlock {
  59429. /**
  59430. * Creates a new NegateBlock
  59431. * @param name defines the block name
  59432. */
  59433. constructor(name: string);
  59434. /**
  59435. * Gets the current class name
  59436. * @returns the class name
  59437. */
  59438. getClassName(): string;
  59439. /**
  59440. * Gets the value input component
  59441. */
  59442. readonly value: NodeMaterialConnectionPoint;
  59443. /**
  59444. * Gets the output component
  59445. */
  59446. readonly output: NodeMaterialConnectionPoint;
  59447. protected _buildBlock(state: NodeMaterialBuildState): this;
  59448. }
  59449. }
  59450. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  59451. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59452. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59453. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59454. /**
  59455. * Block used to get the value of the first parameter raised to the power of the second
  59456. */
  59457. export class PowBlock extends NodeMaterialBlock {
  59458. /**
  59459. * Creates a new PowBlock
  59460. * @param name defines the block name
  59461. */
  59462. constructor(name: string);
  59463. /**
  59464. * Gets the current class name
  59465. * @returns the class name
  59466. */
  59467. getClassName(): string;
  59468. /**
  59469. * Gets the value operand input component
  59470. */
  59471. readonly value: NodeMaterialConnectionPoint;
  59472. /**
  59473. * Gets the power operand input component
  59474. */
  59475. readonly power: NodeMaterialConnectionPoint;
  59476. /**
  59477. * Gets the output component
  59478. */
  59479. readonly output: NodeMaterialConnectionPoint;
  59480. protected _buildBlock(state: NodeMaterialBuildState): this;
  59481. }
  59482. }
  59483. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  59484. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59485. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59486. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59487. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59488. /**
  59489. * Block used to get a random number
  59490. */
  59491. export class RandomNumberBlock extends NodeMaterialBlock {
  59492. /**
  59493. * Creates a new RandomNumberBlock
  59494. * @param name defines the block name
  59495. */
  59496. constructor(name: string);
  59497. /**
  59498. * Gets the current class name
  59499. * @returns the class name
  59500. */
  59501. getClassName(): string;
  59502. /**
  59503. * Gets the seed input component
  59504. */
  59505. readonly seed: NodeMaterialConnectionPoint;
  59506. /**
  59507. * Gets the output component
  59508. */
  59509. readonly output: NodeMaterialConnectionPoint;
  59510. protected _buildBlock(state: NodeMaterialBuildState): this;
  59511. }
  59512. }
  59513. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  59514. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59515. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59516. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59517. /**
  59518. * Block used to compute arc tangent of 2 values
  59519. */
  59520. export class ArcTan2Block extends NodeMaterialBlock {
  59521. /**
  59522. * Creates a new ArcTan2Block
  59523. * @param name defines the block name
  59524. */
  59525. constructor(name: string);
  59526. /**
  59527. * Gets the current class name
  59528. * @returns the class name
  59529. */
  59530. getClassName(): string;
  59531. /**
  59532. * Gets the x operand input component
  59533. */
  59534. readonly x: NodeMaterialConnectionPoint;
  59535. /**
  59536. * Gets the y operand input component
  59537. */
  59538. readonly y: NodeMaterialConnectionPoint;
  59539. /**
  59540. * Gets the output component
  59541. */
  59542. readonly output: NodeMaterialConnectionPoint;
  59543. protected _buildBlock(state: NodeMaterialBuildState): this;
  59544. }
  59545. }
  59546. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  59547. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59548. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59549. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59550. /**
  59551. * Block used to smooth step a value
  59552. */
  59553. export class SmoothStepBlock extends NodeMaterialBlock {
  59554. /**
  59555. * Creates a new SmoothStepBlock
  59556. * @param name defines the block name
  59557. */
  59558. constructor(name: string);
  59559. /**
  59560. * Gets the current class name
  59561. * @returns the class name
  59562. */
  59563. getClassName(): string;
  59564. /**
  59565. * Gets the value operand input component
  59566. */
  59567. readonly value: NodeMaterialConnectionPoint;
  59568. /**
  59569. * Gets the first edge operand input component
  59570. */
  59571. readonly edge0: NodeMaterialConnectionPoint;
  59572. /**
  59573. * Gets the second edge operand input component
  59574. */
  59575. readonly edge1: NodeMaterialConnectionPoint;
  59576. /**
  59577. * Gets the output component
  59578. */
  59579. readonly output: NodeMaterialConnectionPoint;
  59580. protected _buildBlock(state: NodeMaterialBuildState): this;
  59581. }
  59582. }
  59583. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  59584. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59585. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59586. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59587. /**
  59588. * Block used to get the reciprocal (1 / x) of a value
  59589. */
  59590. export class ReciprocalBlock extends NodeMaterialBlock {
  59591. /**
  59592. * Creates a new ReciprocalBlock
  59593. * @param name defines the block name
  59594. */
  59595. constructor(name: string);
  59596. /**
  59597. * Gets the current class name
  59598. * @returns the class name
  59599. */
  59600. getClassName(): string;
  59601. /**
  59602. * Gets the input component
  59603. */
  59604. readonly input: NodeMaterialConnectionPoint;
  59605. /**
  59606. * Gets the output component
  59607. */
  59608. readonly output: NodeMaterialConnectionPoint;
  59609. protected _buildBlock(state: NodeMaterialBuildState): this;
  59610. }
  59611. }
  59612. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  59613. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59614. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59615. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59616. /**
  59617. * Block used to replace a color by another one
  59618. */
  59619. export class ReplaceColorBlock extends NodeMaterialBlock {
  59620. /**
  59621. * Creates a new ReplaceColorBlock
  59622. * @param name defines the block name
  59623. */
  59624. constructor(name: string);
  59625. /**
  59626. * Gets the current class name
  59627. * @returns the class name
  59628. */
  59629. getClassName(): string;
  59630. /**
  59631. * Gets the value input component
  59632. */
  59633. readonly value: NodeMaterialConnectionPoint;
  59634. /**
  59635. * Gets the reference input component
  59636. */
  59637. readonly reference: NodeMaterialConnectionPoint;
  59638. /**
  59639. * Gets the distance input component
  59640. */
  59641. readonly distance: NodeMaterialConnectionPoint;
  59642. /**
  59643. * Gets the replacement input component
  59644. */
  59645. readonly replacement: NodeMaterialConnectionPoint;
  59646. /**
  59647. * Gets the output component
  59648. */
  59649. readonly output: NodeMaterialConnectionPoint;
  59650. protected _buildBlock(state: NodeMaterialBuildState): this;
  59651. }
  59652. }
  59653. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  59654. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59655. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59656. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59657. /**
  59658. * Block used to posterize a value
  59659. * @see https://en.wikipedia.org/wiki/Posterization
  59660. */
  59661. export class PosterizeBlock extends NodeMaterialBlock {
  59662. /**
  59663. * Creates a new PosterizeBlock
  59664. * @param name defines the block name
  59665. */
  59666. constructor(name: string);
  59667. /**
  59668. * Gets the current class name
  59669. * @returns the class name
  59670. */
  59671. getClassName(): string;
  59672. /**
  59673. * Gets the value input component
  59674. */
  59675. readonly value: NodeMaterialConnectionPoint;
  59676. /**
  59677. * Gets the steps input component
  59678. */
  59679. readonly steps: NodeMaterialConnectionPoint;
  59680. /**
  59681. * Gets the output component
  59682. */
  59683. readonly output: NodeMaterialConnectionPoint;
  59684. protected _buildBlock(state: NodeMaterialBuildState): this;
  59685. }
  59686. }
  59687. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  59688. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59689. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59690. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59691. import { Scene } from "babylonjs/scene";
  59692. /**
  59693. * Operations supported by the Wave block
  59694. */
  59695. export enum WaveBlockKind {
  59696. /** SawTooth */
  59697. SawTooth = 0,
  59698. /** Square */
  59699. Square = 1,
  59700. /** Triangle */
  59701. Triangle = 2
  59702. }
  59703. /**
  59704. * Block used to apply wave operation to floats
  59705. */
  59706. export class WaveBlock extends NodeMaterialBlock {
  59707. /**
  59708. * Gets or sets the kibnd of wave to be applied by the block
  59709. */
  59710. kind: WaveBlockKind;
  59711. /**
  59712. * Creates a new WaveBlock
  59713. * @param name defines the block name
  59714. */
  59715. constructor(name: string);
  59716. /**
  59717. * Gets the current class name
  59718. * @returns the class name
  59719. */
  59720. getClassName(): string;
  59721. /**
  59722. * Gets the input component
  59723. */
  59724. readonly input: NodeMaterialConnectionPoint;
  59725. /**
  59726. * Gets the output component
  59727. */
  59728. readonly output: NodeMaterialConnectionPoint;
  59729. protected _buildBlock(state: NodeMaterialBuildState): this;
  59730. serialize(): any;
  59731. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59732. }
  59733. }
  59734. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  59735. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59736. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59737. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59738. import { Color3 } from "babylonjs/Maths/math.color";
  59739. import { Scene } from "babylonjs/scene";
  59740. /**
  59741. * Class used to store a color step for the GradientBlock
  59742. */
  59743. export class GradientBlockColorStep {
  59744. /**
  59745. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59746. */
  59747. step: number;
  59748. /**
  59749. * Gets or sets the color associated with this step
  59750. */
  59751. color: Color3;
  59752. /**
  59753. * Creates a new GradientBlockColorStep
  59754. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59755. * @param color defines the color associated with this step
  59756. */
  59757. constructor(
  59758. /**
  59759. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59760. */
  59761. step: number,
  59762. /**
  59763. * Gets or sets the color associated with this step
  59764. */
  59765. color: Color3);
  59766. }
  59767. /**
  59768. * Block used to return a color from a gradient based on an input value between 0 and 1
  59769. */
  59770. export class GradientBlock extends NodeMaterialBlock {
  59771. /**
  59772. * Gets or sets the list of color steps
  59773. */
  59774. colorSteps: GradientBlockColorStep[];
  59775. /**
  59776. * Creates a new GradientBlock
  59777. * @param name defines the block name
  59778. */
  59779. constructor(name: string);
  59780. /**
  59781. * Gets the current class name
  59782. * @returns the class name
  59783. */
  59784. getClassName(): string;
  59785. /**
  59786. * Gets the gradient input component
  59787. */
  59788. readonly gradient: NodeMaterialConnectionPoint;
  59789. /**
  59790. * Gets the output component
  59791. */
  59792. readonly output: NodeMaterialConnectionPoint;
  59793. private _writeColorConstant;
  59794. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59795. serialize(): any;
  59796. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59797. protected _dumpPropertiesCode(): string;
  59798. }
  59799. }
  59800. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  59801. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59802. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59803. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59804. /**
  59805. * Block used to normalize lerp between 2 values
  59806. */
  59807. export class NLerpBlock extends NodeMaterialBlock {
  59808. /**
  59809. * Creates a new NLerpBlock
  59810. * @param name defines the block name
  59811. */
  59812. constructor(name: string);
  59813. /**
  59814. * Gets the current class name
  59815. * @returns the class name
  59816. */
  59817. getClassName(): string;
  59818. /**
  59819. * Gets the left operand input component
  59820. */
  59821. readonly left: NodeMaterialConnectionPoint;
  59822. /**
  59823. * Gets the right operand input component
  59824. */
  59825. readonly right: NodeMaterialConnectionPoint;
  59826. /**
  59827. * Gets the gradient operand input component
  59828. */
  59829. readonly gradient: NodeMaterialConnectionPoint;
  59830. /**
  59831. * Gets the output component
  59832. */
  59833. readonly output: NodeMaterialConnectionPoint;
  59834. protected _buildBlock(state: NodeMaterialBuildState): this;
  59835. }
  59836. }
  59837. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  59838. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59839. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59840. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59841. import { Scene } from "babylonjs/scene";
  59842. /**
  59843. * block used to Generate a Worley Noise 3D Noise Pattern
  59844. */
  59845. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59846. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59847. manhattanDistance: boolean;
  59848. /**
  59849. * Creates a new WorleyNoise3DBlock
  59850. * @param name defines the block name
  59851. */
  59852. constructor(name: string);
  59853. /**
  59854. * Gets the current class name
  59855. * @returns the class name
  59856. */
  59857. getClassName(): string;
  59858. /**
  59859. * Gets the seed input component
  59860. */
  59861. readonly seed: NodeMaterialConnectionPoint;
  59862. /**
  59863. * Gets the jitter input component
  59864. */
  59865. readonly jitter: NodeMaterialConnectionPoint;
  59866. /**
  59867. * Gets the output component
  59868. */
  59869. readonly output: NodeMaterialConnectionPoint;
  59870. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59871. /**
  59872. * Exposes the properties to the UI?
  59873. */
  59874. protected _dumpPropertiesCode(): string;
  59875. /**
  59876. * Exposes the properties to the Seralize?
  59877. */
  59878. serialize(): any;
  59879. /**
  59880. * Exposes the properties to the deseralize?
  59881. */
  59882. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59883. }
  59884. }
  59885. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  59886. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59887. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59888. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59889. /**
  59890. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59891. */
  59892. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59893. /**
  59894. * Creates a new SimplexPerlin3DBlock
  59895. * @param name defines the block name
  59896. */
  59897. constructor(name: string);
  59898. /**
  59899. * Gets the current class name
  59900. * @returns the class name
  59901. */
  59902. getClassName(): string;
  59903. /**
  59904. * Gets the seed operand input component
  59905. */
  59906. readonly seed: NodeMaterialConnectionPoint;
  59907. /**
  59908. * Gets the output component
  59909. */
  59910. readonly output: NodeMaterialConnectionPoint;
  59911. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59912. }
  59913. }
  59914. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  59915. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59916. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59917. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59918. /**
  59919. * Block used to blend normals
  59920. */
  59921. export class NormalBlendBlock extends NodeMaterialBlock {
  59922. /**
  59923. * Creates a new NormalBlendBlock
  59924. * @param name defines the block name
  59925. */
  59926. constructor(name: string);
  59927. /**
  59928. * Gets the current class name
  59929. * @returns the class name
  59930. */
  59931. getClassName(): string;
  59932. /**
  59933. * Gets the first input component
  59934. */
  59935. readonly normalMap0: NodeMaterialConnectionPoint;
  59936. /**
  59937. * Gets the second input component
  59938. */
  59939. readonly normalMap1: NodeMaterialConnectionPoint;
  59940. /**
  59941. * Gets the output component
  59942. */
  59943. readonly output: NodeMaterialConnectionPoint;
  59944. protected _buildBlock(state: NodeMaterialBuildState): this;
  59945. }
  59946. }
  59947. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  59948. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59949. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59950. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59951. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59952. /**
  59953. * Block used to rotate a 2d vector by a given angle
  59954. */
  59955. export class Rotate2dBlock extends NodeMaterialBlock {
  59956. /**
  59957. * Creates a new Rotate2dBlock
  59958. * @param name defines the block name
  59959. */
  59960. constructor(name: string);
  59961. /**
  59962. * Gets the current class name
  59963. * @returns the class name
  59964. */
  59965. getClassName(): string;
  59966. /**
  59967. * Gets the input vector
  59968. */
  59969. readonly input: NodeMaterialConnectionPoint;
  59970. /**
  59971. * Gets the input angle
  59972. */
  59973. readonly angle: NodeMaterialConnectionPoint;
  59974. /**
  59975. * Gets the output component
  59976. */
  59977. readonly output: NodeMaterialConnectionPoint;
  59978. autoConfigure(material: NodeMaterial): void;
  59979. protected _buildBlock(state: NodeMaterialBuildState): this;
  59980. }
  59981. }
  59982. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  59983. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59984. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59985. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59986. /**
  59987. * Block used to get the reflected vector from a direction and a normal
  59988. */
  59989. export class ReflectBlock extends NodeMaterialBlock {
  59990. /**
  59991. * Creates a new ReflectBlock
  59992. * @param name defines the block name
  59993. */
  59994. constructor(name: string);
  59995. /**
  59996. * Gets the current class name
  59997. * @returns the class name
  59998. */
  59999. getClassName(): string;
  60000. /**
  60001. * Gets the incident component
  60002. */
  60003. readonly incident: NodeMaterialConnectionPoint;
  60004. /**
  60005. * Gets the normal component
  60006. */
  60007. readonly normal: NodeMaterialConnectionPoint;
  60008. /**
  60009. * Gets the output component
  60010. */
  60011. readonly output: NodeMaterialConnectionPoint;
  60012. protected _buildBlock(state: NodeMaterialBuildState): this;
  60013. }
  60014. }
  60015. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  60016. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60017. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60018. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60019. /**
  60020. * Block used to get the refracted vector from a direction and a normal
  60021. */
  60022. export class RefractBlock extends NodeMaterialBlock {
  60023. /**
  60024. * Creates a new RefractBlock
  60025. * @param name defines the block name
  60026. */
  60027. constructor(name: string);
  60028. /**
  60029. * Gets the current class name
  60030. * @returns the class name
  60031. */
  60032. getClassName(): string;
  60033. /**
  60034. * Gets the incident component
  60035. */
  60036. readonly incident: NodeMaterialConnectionPoint;
  60037. /**
  60038. * Gets the normal component
  60039. */
  60040. readonly normal: NodeMaterialConnectionPoint;
  60041. /**
  60042. * Gets the index of refraction component
  60043. */
  60044. readonly ior: NodeMaterialConnectionPoint;
  60045. /**
  60046. * Gets the output component
  60047. */
  60048. readonly output: NodeMaterialConnectionPoint;
  60049. protected _buildBlock(state: NodeMaterialBuildState): this;
  60050. }
  60051. }
  60052. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  60053. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60054. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60055. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60056. /**
  60057. * Block used to desaturate a color
  60058. */
  60059. export class DesaturateBlock extends NodeMaterialBlock {
  60060. /**
  60061. * Creates a new DesaturateBlock
  60062. * @param name defines the block name
  60063. */
  60064. constructor(name: string);
  60065. /**
  60066. * Gets the current class name
  60067. * @returns the class name
  60068. */
  60069. getClassName(): string;
  60070. /**
  60071. * Gets the color operand input component
  60072. */
  60073. readonly color: NodeMaterialConnectionPoint;
  60074. /**
  60075. * Gets the level operand input component
  60076. */
  60077. readonly level: NodeMaterialConnectionPoint;
  60078. /**
  60079. * Gets the output component
  60080. */
  60081. readonly output: NodeMaterialConnectionPoint;
  60082. protected _buildBlock(state: NodeMaterialBuildState): this;
  60083. }
  60084. }
  60085. declare module "babylonjs/Materials/Node/Blocks/index" {
  60086. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  60087. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  60088. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  60089. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  60090. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  60091. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  60092. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  60093. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  60094. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  60095. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  60096. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  60097. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  60098. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  60099. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  60100. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  60101. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  60102. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  60103. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  60104. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  60105. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  60106. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  60107. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  60108. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  60109. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  60110. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  60111. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  60112. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  60113. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  60114. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  60115. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  60116. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  60117. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  60118. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  60119. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  60120. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  60121. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  60122. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  60123. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  60124. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  60125. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  60126. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  60127. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  60128. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  60129. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  60130. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  60131. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  60132. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  60133. }
  60134. declare module "babylonjs/Materials/Node/Optimizers/index" {
  60135. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  60136. }
  60137. declare module "babylonjs/Materials/Node/index" {
  60138. export * from "babylonjs/Materials/Node/Enums/index";
  60139. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60140. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  60141. export * from "babylonjs/Materials/Node/nodeMaterial";
  60142. export * from "babylonjs/Materials/Node/Blocks/index";
  60143. export * from "babylonjs/Materials/Node/Optimizers/index";
  60144. }
  60145. declare module "babylonjs/Materials/effectRenderer" {
  60146. import { Nullable } from "babylonjs/types";
  60147. import { Texture } from "babylonjs/Materials/Textures/texture";
  60148. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60149. import { Viewport } from "babylonjs/Maths/math.viewport";
  60150. import { Observable } from "babylonjs/Misc/observable";
  60151. import { Effect } from "babylonjs/Materials/effect";
  60152. import "babylonjs/Engines/Extensions/engine.renderTarget";
  60153. import "babylonjs/Shaders/postprocess.vertex";
  60154. /**
  60155. * Effect Render Options
  60156. */
  60157. export interface IEffectRendererOptions {
  60158. /**
  60159. * Defines the vertices positions.
  60160. */
  60161. positions?: number[];
  60162. /**
  60163. * Defines the indices.
  60164. */
  60165. indices?: number[];
  60166. }
  60167. /**
  60168. * Helper class to render one or more effects
  60169. */
  60170. export class EffectRenderer {
  60171. private engine;
  60172. private static _DefaultOptions;
  60173. private _vertexBuffers;
  60174. private _indexBuffer;
  60175. private _ringBufferIndex;
  60176. private _ringScreenBuffer;
  60177. private _fullscreenViewport;
  60178. private _getNextFrameBuffer;
  60179. /**
  60180. * Creates an effect renderer
  60181. * @param engine the engine to use for rendering
  60182. * @param options defines the options of the effect renderer
  60183. */
  60184. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60185. /**
  60186. * Sets the current viewport in normalized coordinates 0-1
  60187. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60188. */
  60189. setViewport(viewport?: Viewport): void;
  60190. /**
  60191. * Binds the embedded attributes buffer to the effect.
  60192. * @param effect Defines the effect to bind the attributes for
  60193. */
  60194. bindBuffers(effect: Effect): void;
  60195. /**
  60196. * Sets the current effect wrapper to use during draw.
  60197. * The effect needs to be ready before calling this api.
  60198. * This also sets the default full screen position attribute.
  60199. * @param effectWrapper Defines the effect to draw with
  60200. */
  60201. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60202. /**
  60203. * Draws a full screen quad.
  60204. */
  60205. draw(): void;
  60206. /**
  60207. * renders one or more effects to a specified texture
  60208. * @param effectWrappers list of effects to renderer
  60209. * @param outputTexture texture to draw to, if null it will render to the screen
  60210. */
  60211. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60212. /**
  60213. * Disposes of the effect renderer
  60214. */
  60215. dispose(): void;
  60216. }
  60217. /**
  60218. * Options to create an EffectWrapper
  60219. */
  60220. interface EffectWrapperCreationOptions {
  60221. /**
  60222. * Engine to use to create the effect
  60223. */
  60224. engine: ThinEngine;
  60225. /**
  60226. * Fragment shader for the effect
  60227. */
  60228. fragmentShader: string;
  60229. /**
  60230. * Vertex shader for the effect
  60231. */
  60232. vertexShader?: string;
  60233. /**
  60234. * Attributes to use in the shader
  60235. */
  60236. attributeNames?: Array<string>;
  60237. /**
  60238. * Uniforms to use in the shader
  60239. */
  60240. uniformNames?: Array<string>;
  60241. /**
  60242. * Texture sampler names to use in the shader
  60243. */
  60244. samplerNames?: Array<string>;
  60245. /**
  60246. * The friendly name of the effect displayed in Spector.
  60247. */
  60248. name?: string;
  60249. }
  60250. /**
  60251. * Wraps an effect to be used for rendering
  60252. */
  60253. export class EffectWrapper {
  60254. /**
  60255. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60256. */
  60257. onApplyObservable: Observable<{}>;
  60258. /**
  60259. * The underlying effect
  60260. */
  60261. effect: Effect;
  60262. /**
  60263. * Creates an effect to be renderer
  60264. * @param creationOptions options to create the effect
  60265. */
  60266. constructor(creationOptions: EffectWrapperCreationOptions);
  60267. /**
  60268. * Disposes of the effect wrapper
  60269. */
  60270. dispose(): void;
  60271. }
  60272. }
  60273. declare module "babylonjs/Materials/index" {
  60274. export * from "babylonjs/Materials/Background/index";
  60275. export * from "babylonjs/Materials/colorCurves";
  60276. export * from "babylonjs/Materials/iEffectFallbacks";
  60277. export * from "babylonjs/Materials/effectFallbacks";
  60278. export * from "babylonjs/Materials/effect";
  60279. export * from "babylonjs/Materials/fresnelParameters";
  60280. export * from "babylonjs/Materials/imageProcessingConfiguration";
  60281. export * from "babylonjs/Materials/material";
  60282. export * from "babylonjs/Materials/materialDefines";
  60283. export * from "babylonjs/Materials/materialHelper";
  60284. export * from "babylonjs/Materials/multiMaterial";
  60285. export * from "babylonjs/Materials/PBR/index";
  60286. export * from "babylonjs/Materials/pushMaterial";
  60287. export * from "babylonjs/Materials/shaderMaterial";
  60288. export * from "babylonjs/Materials/standardMaterial";
  60289. export * from "babylonjs/Materials/Textures/index";
  60290. export * from "babylonjs/Materials/uniformBuffer";
  60291. export * from "babylonjs/Materials/materialFlags";
  60292. export * from "babylonjs/Materials/Node/index";
  60293. export * from "babylonjs/Materials/effectRenderer";
  60294. }
  60295. declare module "babylonjs/Maths/index" {
  60296. export * from "babylonjs/Maths/math.scalar";
  60297. export * from "babylonjs/Maths/math";
  60298. export * from "babylonjs/Maths/sphericalPolynomial";
  60299. }
  60300. declare module "babylonjs/Misc/workerPool" {
  60301. import { IDisposable } from "babylonjs/scene";
  60302. /**
  60303. * Helper class to push actions to a pool of workers.
  60304. */
  60305. export class WorkerPool implements IDisposable {
  60306. private _workerInfos;
  60307. private _pendingActions;
  60308. /**
  60309. * Constructor
  60310. * @param workers Array of workers to use for actions
  60311. */
  60312. constructor(workers: Array<Worker>);
  60313. /**
  60314. * Terminates all workers and clears any pending actions.
  60315. */
  60316. dispose(): void;
  60317. /**
  60318. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60319. * pended until a worker has completed its action.
  60320. * @param action The action to perform. Call onComplete when the action is complete.
  60321. */
  60322. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60323. private _execute;
  60324. }
  60325. }
  60326. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  60327. import { IDisposable } from "babylonjs/scene";
  60328. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  60329. /**
  60330. * Configuration for Draco compression
  60331. */
  60332. export interface IDracoCompressionConfiguration {
  60333. /**
  60334. * Configuration for the decoder.
  60335. */
  60336. decoder: {
  60337. /**
  60338. * The url to the WebAssembly module.
  60339. */
  60340. wasmUrl?: string;
  60341. /**
  60342. * The url to the WebAssembly binary.
  60343. */
  60344. wasmBinaryUrl?: string;
  60345. /**
  60346. * The url to the fallback JavaScript module.
  60347. */
  60348. fallbackUrl?: string;
  60349. };
  60350. }
  60351. /**
  60352. * Draco compression (https://google.github.io/draco/)
  60353. *
  60354. * This class wraps the Draco module.
  60355. *
  60356. * **Encoder**
  60357. *
  60358. * The encoder is not currently implemented.
  60359. *
  60360. * **Decoder**
  60361. *
  60362. * 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.
  60363. *
  60364. * To update the configuration, use the following code:
  60365. * ```javascript
  60366. * DracoCompression.Configuration = {
  60367. * decoder: {
  60368. * wasmUrl: "<url to the WebAssembly library>",
  60369. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60370. * fallbackUrl: "<url to the fallback JavaScript library>",
  60371. * }
  60372. * };
  60373. * ```
  60374. *
  60375. * 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.
  60376. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60377. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60378. *
  60379. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60380. * ```javascript
  60381. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60382. * ```
  60383. *
  60384. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60385. */
  60386. export class DracoCompression implements IDisposable {
  60387. private _workerPoolPromise?;
  60388. private _decoderModulePromise?;
  60389. /**
  60390. * The configuration. Defaults to the following urls:
  60391. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60392. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60393. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60394. */
  60395. static Configuration: IDracoCompressionConfiguration;
  60396. /**
  60397. * Returns true if the decoder configuration is available.
  60398. */
  60399. static readonly DecoderAvailable: boolean;
  60400. /**
  60401. * Default number of workers to create when creating the draco compression object.
  60402. */
  60403. static DefaultNumWorkers: number;
  60404. private static GetDefaultNumWorkers;
  60405. private static _Default;
  60406. /**
  60407. * Default instance for the draco compression object.
  60408. */
  60409. static readonly Default: DracoCompression;
  60410. /**
  60411. * Constructor
  60412. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60413. */
  60414. constructor(numWorkers?: number);
  60415. /**
  60416. * Stop all async operations and release resources.
  60417. */
  60418. dispose(): void;
  60419. /**
  60420. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60421. * @returns a promise that resolves when ready
  60422. */
  60423. whenReadyAsync(): Promise<void>;
  60424. /**
  60425. * Decode Draco compressed mesh data to vertex data.
  60426. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60427. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60428. * @returns A promise that resolves with the decoded vertex data
  60429. */
  60430. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60431. [kind: string]: number;
  60432. }): Promise<VertexData>;
  60433. }
  60434. }
  60435. declare module "babylonjs/Meshes/Compression/index" {
  60436. export * from "babylonjs/Meshes/Compression/dracoCompression";
  60437. }
  60438. declare module "babylonjs/Meshes/csg" {
  60439. import { Nullable } from "babylonjs/types";
  60440. import { Scene } from "babylonjs/scene";
  60441. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60442. import { Mesh } from "babylonjs/Meshes/mesh";
  60443. import { Material } from "babylonjs/Materials/material";
  60444. /**
  60445. * Class for building Constructive Solid Geometry
  60446. */
  60447. export class CSG {
  60448. private polygons;
  60449. /**
  60450. * The world matrix
  60451. */
  60452. matrix: Matrix;
  60453. /**
  60454. * Stores the position
  60455. */
  60456. position: Vector3;
  60457. /**
  60458. * Stores the rotation
  60459. */
  60460. rotation: Vector3;
  60461. /**
  60462. * Stores the rotation quaternion
  60463. */
  60464. rotationQuaternion: Nullable<Quaternion>;
  60465. /**
  60466. * Stores the scaling vector
  60467. */
  60468. scaling: Vector3;
  60469. /**
  60470. * Convert the Mesh to CSG
  60471. * @param mesh The Mesh to convert to CSG
  60472. * @returns A new CSG from the Mesh
  60473. */
  60474. static FromMesh(mesh: Mesh): CSG;
  60475. /**
  60476. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60477. * @param polygons Polygons used to construct a CSG solid
  60478. */
  60479. private static FromPolygons;
  60480. /**
  60481. * Clones, or makes a deep copy, of the CSG
  60482. * @returns A new CSG
  60483. */
  60484. clone(): CSG;
  60485. /**
  60486. * Unions this CSG with another CSG
  60487. * @param csg The CSG to union against this CSG
  60488. * @returns The unioned CSG
  60489. */
  60490. union(csg: CSG): CSG;
  60491. /**
  60492. * Unions this CSG with another CSG in place
  60493. * @param csg The CSG to union against this CSG
  60494. */
  60495. unionInPlace(csg: CSG): void;
  60496. /**
  60497. * Subtracts this CSG with another CSG
  60498. * @param csg The CSG to subtract against this CSG
  60499. * @returns A new CSG
  60500. */
  60501. subtract(csg: CSG): CSG;
  60502. /**
  60503. * Subtracts this CSG with another CSG in place
  60504. * @param csg The CSG to subtact against this CSG
  60505. */
  60506. subtractInPlace(csg: CSG): void;
  60507. /**
  60508. * Intersect this CSG with another CSG
  60509. * @param csg The CSG to intersect against this CSG
  60510. * @returns A new CSG
  60511. */
  60512. intersect(csg: CSG): CSG;
  60513. /**
  60514. * Intersects this CSG with another CSG in place
  60515. * @param csg The CSG to intersect against this CSG
  60516. */
  60517. intersectInPlace(csg: CSG): void;
  60518. /**
  60519. * Return a new CSG solid with solid and empty space switched. This solid is
  60520. * not modified.
  60521. * @returns A new CSG solid with solid and empty space switched
  60522. */
  60523. inverse(): CSG;
  60524. /**
  60525. * Inverses the CSG in place
  60526. */
  60527. inverseInPlace(): void;
  60528. /**
  60529. * This is used to keep meshes transformations so they can be restored
  60530. * when we build back a Babylon Mesh
  60531. * NB : All CSG operations are performed in world coordinates
  60532. * @param csg The CSG to copy the transform attributes from
  60533. * @returns This CSG
  60534. */
  60535. copyTransformAttributes(csg: CSG): CSG;
  60536. /**
  60537. * Build Raw mesh from CSG
  60538. * Coordinates here are in world space
  60539. * @param name The name of the mesh geometry
  60540. * @param scene The Scene
  60541. * @param keepSubMeshes Specifies if the submeshes should be kept
  60542. * @returns A new Mesh
  60543. */
  60544. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60545. /**
  60546. * Build Mesh from CSG taking material and transforms into account
  60547. * @param name The name of the Mesh
  60548. * @param material The material of the Mesh
  60549. * @param scene The Scene
  60550. * @param keepSubMeshes Specifies if submeshes should be kept
  60551. * @returns The new Mesh
  60552. */
  60553. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60554. }
  60555. }
  60556. declare module "babylonjs/Meshes/trailMesh" {
  60557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60558. import { Mesh } from "babylonjs/Meshes/mesh";
  60559. import { Scene } from "babylonjs/scene";
  60560. /**
  60561. * Class used to create a trail following a mesh
  60562. */
  60563. export class TrailMesh extends Mesh {
  60564. private _generator;
  60565. private _autoStart;
  60566. private _running;
  60567. private _diameter;
  60568. private _length;
  60569. private _sectionPolygonPointsCount;
  60570. private _sectionVectors;
  60571. private _sectionNormalVectors;
  60572. private _beforeRenderObserver;
  60573. /**
  60574. * @constructor
  60575. * @param name The value used by scene.getMeshByName() to do a lookup.
  60576. * @param generator The mesh to generate a trail.
  60577. * @param scene The scene to add this mesh to.
  60578. * @param diameter Diameter of trailing mesh. Default is 1.
  60579. * @param length Length of trailing mesh. Default is 60.
  60580. * @param autoStart Automatically start trailing mesh. Default true.
  60581. */
  60582. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60583. /**
  60584. * "TrailMesh"
  60585. * @returns "TrailMesh"
  60586. */
  60587. getClassName(): string;
  60588. private _createMesh;
  60589. /**
  60590. * Start trailing mesh.
  60591. */
  60592. start(): void;
  60593. /**
  60594. * Stop trailing mesh.
  60595. */
  60596. stop(): void;
  60597. /**
  60598. * Update trailing mesh geometry.
  60599. */
  60600. update(): void;
  60601. /**
  60602. * Returns a new TrailMesh object.
  60603. * @param name is a string, the name given to the new mesh
  60604. * @param newGenerator use new generator object for cloned trail mesh
  60605. * @returns a new mesh
  60606. */
  60607. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  60608. /**
  60609. * Serializes this trail mesh
  60610. * @param serializationObject object to write serialization to
  60611. */
  60612. serialize(serializationObject: any): void;
  60613. /**
  60614. * Parses a serialized trail mesh
  60615. * @param parsedMesh the serialized mesh
  60616. * @param scene the scene to create the trail mesh in
  60617. * @returns the created trail mesh
  60618. */
  60619. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60620. }
  60621. }
  60622. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  60623. import { Nullable } from "babylonjs/types";
  60624. import { Scene } from "babylonjs/scene";
  60625. import { Vector4 } from "babylonjs/Maths/math.vector";
  60626. import { Color4 } from "babylonjs/Maths/math.color";
  60627. import { Mesh } from "babylonjs/Meshes/mesh";
  60628. /**
  60629. * Class containing static functions to help procedurally build meshes
  60630. */
  60631. export class TiledBoxBuilder {
  60632. /**
  60633. * Creates a box mesh
  60634. * 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)
  60635. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60636. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60637. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60639. * @param name defines the name of the mesh
  60640. * @param options defines the options used to create the mesh
  60641. * @param scene defines the hosting scene
  60642. * @returns the box mesh
  60643. */
  60644. static CreateTiledBox(name: string, options: {
  60645. pattern?: number;
  60646. width?: number;
  60647. height?: number;
  60648. depth?: number;
  60649. tileSize?: number;
  60650. tileWidth?: number;
  60651. tileHeight?: number;
  60652. alignHorizontal?: number;
  60653. alignVertical?: number;
  60654. faceUV?: Vector4[];
  60655. faceColors?: Color4[];
  60656. sideOrientation?: number;
  60657. updatable?: boolean;
  60658. }, scene?: Nullable<Scene>): Mesh;
  60659. }
  60660. }
  60661. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  60662. import { Vector4 } from "babylonjs/Maths/math.vector";
  60663. import { Mesh } from "babylonjs/Meshes/mesh";
  60664. /**
  60665. * Class containing static functions to help procedurally build meshes
  60666. */
  60667. export class TorusKnotBuilder {
  60668. /**
  60669. * Creates a torus knot mesh
  60670. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60671. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60672. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60673. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60675. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60677. * @param name defines the name of the mesh
  60678. * @param options defines the options used to create the mesh
  60679. * @param scene defines the hosting scene
  60680. * @returns the torus knot mesh
  60681. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60682. */
  60683. static CreateTorusKnot(name: string, options: {
  60684. radius?: number;
  60685. tube?: number;
  60686. radialSegments?: number;
  60687. tubularSegments?: number;
  60688. p?: number;
  60689. q?: number;
  60690. updatable?: boolean;
  60691. sideOrientation?: number;
  60692. frontUVs?: Vector4;
  60693. backUVs?: Vector4;
  60694. }, scene: any): Mesh;
  60695. }
  60696. }
  60697. declare module "babylonjs/Meshes/polygonMesh" {
  60698. import { Scene } from "babylonjs/scene";
  60699. import { Vector2 } from "babylonjs/Maths/math.vector";
  60700. import { Mesh } from "babylonjs/Meshes/mesh";
  60701. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  60702. import { Path2 } from "babylonjs/Maths/math.path";
  60703. /**
  60704. * Polygon
  60705. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60706. */
  60707. export class Polygon {
  60708. /**
  60709. * Creates a rectangle
  60710. * @param xmin bottom X coord
  60711. * @param ymin bottom Y coord
  60712. * @param xmax top X coord
  60713. * @param ymax top Y coord
  60714. * @returns points that make the resulting rectation
  60715. */
  60716. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60717. /**
  60718. * Creates a circle
  60719. * @param radius radius of circle
  60720. * @param cx scale in x
  60721. * @param cy scale in y
  60722. * @param numberOfSides number of sides that make up the circle
  60723. * @returns points that make the resulting circle
  60724. */
  60725. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60726. /**
  60727. * Creates a polygon from input string
  60728. * @param input Input polygon data
  60729. * @returns the parsed points
  60730. */
  60731. static Parse(input: string): Vector2[];
  60732. /**
  60733. * Starts building a polygon from x and y coordinates
  60734. * @param x x coordinate
  60735. * @param y y coordinate
  60736. * @returns the started path2
  60737. */
  60738. static StartingAt(x: number, y: number): Path2;
  60739. }
  60740. /**
  60741. * Builds a polygon
  60742. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60743. */
  60744. export class PolygonMeshBuilder {
  60745. private _points;
  60746. private _outlinepoints;
  60747. private _holes;
  60748. private _name;
  60749. private _scene;
  60750. private _epoints;
  60751. private _eholes;
  60752. private _addToepoint;
  60753. /**
  60754. * Babylon reference to the earcut plugin.
  60755. */
  60756. bjsEarcut: any;
  60757. /**
  60758. * Creates a PolygonMeshBuilder
  60759. * @param name name of the builder
  60760. * @param contours Path of the polygon
  60761. * @param scene scene to add to when creating the mesh
  60762. * @param earcutInjection can be used to inject your own earcut reference
  60763. */
  60764. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60765. /**
  60766. * Adds a whole within the polygon
  60767. * @param hole Array of points defining the hole
  60768. * @returns this
  60769. */
  60770. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60771. /**
  60772. * Creates the polygon
  60773. * @param updatable If the mesh should be updatable
  60774. * @param depth The depth of the mesh created
  60775. * @returns the created mesh
  60776. */
  60777. build(updatable?: boolean, depth?: number): Mesh;
  60778. /**
  60779. * Creates the polygon
  60780. * @param depth The depth of the mesh created
  60781. * @returns the created VertexData
  60782. */
  60783. buildVertexData(depth?: number): VertexData;
  60784. /**
  60785. * Adds a side to the polygon
  60786. * @param positions points that make the polygon
  60787. * @param normals normals of the polygon
  60788. * @param uvs uvs of the polygon
  60789. * @param indices indices of the polygon
  60790. * @param bounds bounds of the polygon
  60791. * @param points points of the polygon
  60792. * @param depth depth of the polygon
  60793. * @param flip flip of the polygon
  60794. */
  60795. private addSide;
  60796. }
  60797. }
  60798. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  60799. import { Scene } from "babylonjs/scene";
  60800. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60801. import { Color4 } from "babylonjs/Maths/math.color";
  60802. import { Mesh } from "babylonjs/Meshes/mesh";
  60803. import { Nullable } from "babylonjs/types";
  60804. /**
  60805. * Class containing static functions to help procedurally build meshes
  60806. */
  60807. export class PolygonBuilder {
  60808. /**
  60809. * Creates a polygon mesh
  60810. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60811. * * 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
  60812. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60814. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60815. * * Remember you can only change the shape positions, not their number when updating a polygon
  60816. * @param name defines the name of the mesh
  60817. * @param options defines the options used to create the mesh
  60818. * @param scene defines the hosting scene
  60819. * @param earcutInjection can be used to inject your own earcut reference
  60820. * @returns the polygon mesh
  60821. */
  60822. static CreatePolygon(name: string, options: {
  60823. shape: Vector3[];
  60824. holes?: Vector3[][];
  60825. depth?: number;
  60826. faceUV?: Vector4[];
  60827. faceColors?: Color4[];
  60828. updatable?: boolean;
  60829. sideOrientation?: number;
  60830. frontUVs?: Vector4;
  60831. backUVs?: Vector4;
  60832. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60833. /**
  60834. * Creates an extruded polygon mesh, with depth in the Y direction.
  60835. * * 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)
  60836. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60837. * @param name defines the name of the mesh
  60838. * @param options defines the options used to create the mesh
  60839. * @param scene defines the hosting scene
  60840. * @param earcutInjection can be used to inject your own earcut reference
  60841. * @returns the polygon mesh
  60842. */
  60843. static ExtrudePolygon(name: string, options: {
  60844. shape: Vector3[];
  60845. holes?: Vector3[][];
  60846. depth?: number;
  60847. faceUV?: Vector4[];
  60848. faceColors?: Color4[];
  60849. updatable?: boolean;
  60850. sideOrientation?: number;
  60851. frontUVs?: Vector4;
  60852. backUVs?: Vector4;
  60853. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60854. }
  60855. }
  60856. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  60857. import { Scene } from "babylonjs/scene";
  60858. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60859. import { Mesh } from "babylonjs/Meshes/mesh";
  60860. import { Nullable } from "babylonjs/types";
  60861. /**
  60862. * Class containing static functions to help procedurally build meshes
  60863. */
  60864. export class LatheBuilder {
  60865. /**
  60866. * Creates lathe mesh.
  60867. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60868. * * 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
  60869. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60870. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60871. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60872. * * 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
  60873. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60874. * * 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
  60875. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60876. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60877. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60879. * @param name defines the name of the mesh
  60880. * @param options defines the options used to create the mesh
  60881. * @param scene defines the hosting scene
  60882. * @returns the lathe mesh
  60883. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60884. */
  60885. static CreateLathe(name: string, options: {
  60886. shape: Vector3[];
  60887. radius?: number;
  60888. tessellation?: number;
  60889. clip?: number;
  60890. arc?: number;
  60891. closed?: boolean;
  60892. updatable?: boolean;
  60893. sideOrientation?: number;
  60894. frontUVs?: Vector4;
  60895. backUVs?: Vector4;
  60896. cap?: number;
  60897. invertUV?: boolean;
  60898. }, scene?: Nullable<Scene>): Mesh;
  60899. }
  60900. }
  60901. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  60902. import { Nullable } from "babylonjs/types";
  60903. import { Scene } from "babylonjs/scene";
  60904. import { Vector4 } from "babylonjs/Maths/math.vector";
  60905. import { Mesh } from "babylonjs/Meshes/mesh";
  60906. /**
  60907. * Class containing static functions to help procedurally build meshes
  60908. */
  60909. export class TiledPlaneBuilder {
  60910. /**
  60911. * Creates a tiled plane mesh
  60912. * * The parameter `pattern` will, depending on value, do nothing or
  60913. * * * flip (reflect about central vertical) alternate tiles across and up
  60914. * * * flip every tile on alternate rows
  60915. * * * rotate (180 degs) alternate tiles across and up
  60916. * * * rotate every tile on alternate rows
  60917. * * * flip and rotate alternate tiles across and up
  60918. * * * flip and rotate every tile on alternate rows
  60919. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60920. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60921. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60922. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60923. * * 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)
  60924. * * 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)
  60925. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60926. * @param name defines the name of the mesh
  60927. * @param options defines the options used to create the mesh
  60928. * @param scene defines the hosting scene
  60929. * @returns the box mesh
  60930. */
  60931. static CreateTiledPlane(name: string, options: {
  60932. pattern?: number;
  60933. tileSize?: number;
  60934. tileWidth?: number;
  60935. tileHeight?: number;
  60936. size?: number;
  60937. width?: number;
  60938. height?: number;
  60939. alignHorizontal?: number;
  60940. alignVertical?: number;
  60941. sideOrientation?: number;
  60942. frontUVs?: Vector4;
  60943. backUVs?: Vector4;
  60944. updatable?: boolean;
  60945. }, scene?: Nullable<Scene>): Mesh;
  60946. }
  60947. }
  60948. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  60949. import { Nullable } from "babylonjs/types";
  60950. import { Scene } from "babylonjs/scene";
  60951. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60952. import { Mesh } from "babylonjs/Meshes/mesh";
  60953. /**
  60954. * Class containing static functions to help procedurally build meshes
  60955. */
  60956. export class TubeBuilder {
  60957. /**
  60958. * Creates a tube mesh.
  60959. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60960. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60961. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60962. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60963. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60964. * * 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)
  60965. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60966. * * 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
  60967. * * 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
  60968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60969. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60970. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60972. * @param name defines the name of the mesh
  60973. * @param options defines the options used to create the mesh
  60974. * @param scene defines the hosting scene
  60975. * @returns the tube mesh
  60976. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60977. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60978. */
  60979. static CreateTube(name: string, options: {
  60980. path: Vector3[];
  60981. radius?: number;
  60982. tessellation?: number;
  60983. radiusFunction?: {
  60984. (i: number, distance: number): number;
  60985. };
  60986. cap?: number;
  60987. arc?: number;
  60988. updatable?: boolean;
  60989. sideOrientation?: number;
  60990. frontUVs?: Vector4;
  60991. backUVs?: Vector4;
  60992. instance?: Mesh;
  60993. invertUV?: boolean;
  60994. }, scene?: Nullable<Scene>): Mesh;
  60995. }
  60996. }
  60997. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  60998. import { Scene } from "babylonjs/scene";
  60999. import { Vector4 } from "babylonjs/Maths/math.vector";
  61000. import { Mesh } from "babylonjs/Meshes/mesh";
  61001. import { Nullable } from "babylonjs/types";
  61002. /**
  61003. * Class containing static functions to help procedurally build meshes
  61004. */
  61005. export class IcoSphereBuilder {
  61006. /**
  61007. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61008. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61009. * * 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`)
  61010. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61011. * * 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
  61012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61013. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61015. * @param name defines the name of the mesh
  61016. * @param options defines the options used to create the mesh
  61017. * @param scene defines the hosting scene
  61018. * @returns the icosahedron mesh
  61019. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61020. */
  61021. static CreateIcoSphere(name: string, options: {
  61022. radius?: number;
  61023. radiusX?: number;
  61024. radiusY?: number;
  61025. radiusZ?: number;
  61026. flat?: boolean;
  61027. subdivisions?: number;
  61028. sideOrientation?: number;
  61029. frontUVs?: Vector4;
  61030. backUVs?: Vector4;
  61031. updatable?: boolean;
  61032. }, scene?: Nullable<Scene>): Mesh;
  61033. }
  61034. }
  61035. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  61036. import { Vector3 } from "babylonjs/Maths/math.vector";
  61037. import { Mesh } from "babylonjs/Meshes/mesh";
  61038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61039. /**
  61040. * Class containing static functions to help procedurally build meshes
  61041. */
  61042. export class DecalBuilder {
  61043. /**
  61044. * Creates a decal mesh.
  61045. * 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
  61046. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61047. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61048. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61049. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61050. * @param name defines the name of the mesh
  61051. * @param sourceMesh defines the mesh where the decal must be applied
  61052. * @param options defines the options used to create the mesh
  61053. * @param scene defines the hosting scene
  61054. * @returns the decal mesh
  61055. * @see https://doc.babylonjs.com/how_to/decals
  61056. */
  61057. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61058. position?: Vector3;
  61059. normal?: Vector3;
  61060. size?: Vector3;
  61061. angle?: number;
  61062. }): Mesh;
  61063. }
  61064. }
  61065. declare module "babylonjs/Meshes/meshBuilder" {
  61066. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  61067. import { Nullable } from "babylonjs/types";
  61068. import { Scene } from "babylonjs/scene";
  61069. import { Mesh } from "babylonjs/Meshes/mesh";
  61070. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  61071. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  61072. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61073. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61074. import { Plane } from "babylonjs/Maths/math.plane";
  61075. /**
  61076. * Class containing static functions to help procedurally build meshes
  61077. */
  61078. export class MeshBuilder {
  61079. /**
  61080. * Creates a box mesh
  61081. * * The parameter `size` sets the size (float) of each box side (default 1)
  61082. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61083. * * 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)
  61084. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61085. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61086. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61088. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61089. * @param name defines the name of the mesh
  61090. * @param options defines the options used to create the mesh
  61091. * @param scene defines the hosting scene
  61092. * @returns the box mesh
  61093. */
  61094. static CreateBox(name: string, options: {
  61095. size?: number;
  61096. width?: number;
  61097. height?: number;
  61098. depth?: number;
  61099. faceUV?: Vector4[];
  61100. faceColors?: Color4[];
  61101. sideOrientation?: number;
  61102. frontUVs?: Vector4;
  61103. backUVs?: Vector4;
  61104. updatable?: boolean;
  61105. }, scene?: Nullable<Scene>): Mesh;
  61106. /**
  61107. * Creates a tiled box mesh
  61108. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61110. * @param name defines the name of the mesh
  61111. * @param options defines the options used to create the mesh
  61112. * @param scene defines the hosting scene
  61113. * @returns the tiled box mesh
  61114. */
  61115. static CreateTiledBox(name: string, options: {
  61116. pattern?: number;
  61117. size?: number;
  61118. width?: number;
  61119. height?: number;
  61120. depth: number;
  61121. tileSize?: number;
  61122. tileWidth?: number;
  61123. tileHeight?: number;
  61124. faceUV?: Vector4[];
  61125. faceColors?: Color4[];
  61126. alignHorizontal?: number;
  61127. alignVertical?: number;
  61128. sideOrientation?: number;
  61129. updatable?: boolean;
  61130. }, scene?: Nullable<Scene>): Mesh;
  61131. /**
  61132. * Creates a sphere mesh
  61133. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61134. * * 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`)
  61135. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61136. * * 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
  61137. * * 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)
  61138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61139. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61141. * @param name defines the name of the mesh
  61142. * @param options defines the options used to create the mesh
  61143. * @param scene defines the hosting scene
  61144. * @returns the sphere mesh
  61145. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61146. */
  61147. static CreateSphere(name: string, options: {
  61148. segments?: number;
  61149. diameter?: number;
  61150. diameterX?: number;
  61151. diameterY?: number;
  61152. diameterZ?: number;
  61153. arc?: number;
  61154. slice?: number;
  61155. sideOrientation?: number;
  61156. frontUVs?: Vector4;
  61157. backUVs?: Vector4;
  61158. updatable?: boolean;
  61159. }, scene?: Nullable<Scene>): Mesh;
  61160. /**
  61161. * Creates a plane polygonal mesh. By default, this is a disc
  61162. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61163. * * 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
  61164. * * 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
  61165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61166. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61168. * @param name defines the name of the mesh
  61169. * @param options defines the options used to create the mesh
  61170. * @param scene defines the hosting scene
  61171. * @returns the plane polygonal mesh
  61172. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61173. */
  61174. static CreateDisc(name: string, options: {
  61175. radius?: number;
  61176. tessellation?: number;
  61177. arc?: number;
  61178. updatable?: boolean;
  61179. sideOrientation?: number;
  61180. frontUVs?: Vector4;
  61181. backUVs?: Vector4;
  61182. }, scene?: Nullable<Scene>): Mesh;
  61183. /**
  61184. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61185. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61186. * * 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`)
  61187. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61188. * * 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
  61189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61192. * @param name defines the name of the mesh
  61193. * @param options defines the options used to create the mesh
  61194. * @param scene defines the hosting scene
  61195. * @returns the icosahedron mesh
  61196. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61197. */
  61198. static CreateIcoSphere(name: string, options: {
  61199. radius?: number;
  61200. radiusX?: number;
  61201. radiusY?: number;
  61202. radiusZ?: number;
  61203. flat?: boolean;
  61204. subdivisions?: number;
  61205. sideOrientation?: number;
  61206. frontUVs?: Vector4;
  61207. backUVs?: Vector4;
  61208. updatable?: boolean;
  61209. }, scene?: Nullable<Scene>): Mesh;
  61210. /**
  61211. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61212. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61213. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61214. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61215. * * 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
  61216. * * 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
  61217. * * 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
  61218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61219. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61220. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61221. * * 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
  61222. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61223. * * 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
  61224. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61226. * @param name defines the name of the mesh
  61227. * @param options defines the options used to create the mesh
  61228. * @param scene defines the hosting scene
  61229. * @returns the ribbon mesh
  61230. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61231. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61232. */
  61233. static CreateRibbon(name: string, options: {
  61234. pathArray: Vector3[][];
  61235. closeArray?: boolean;
  61236. closePath?: boolean;
  61237. offset?: number;
  61238. updatable?: boolean;
  61239. sideOrientation?: number;
  61240. frontUVs?: Vector4;
  61241. backUVs?: Vector4;
  61242. instance?: Mesh;
  61243. invertUV?: boolean;
  61244. uvs?: Vector2[];
  61245. colors?: Color4[];
  61246. }, scene?: Nullable<Scene>): Mesh;
  61247. /**
  61248. * Creates a cylinder or a cone mesh
  61249. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61250. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61251. * * 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.
  61252. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61253. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61254. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61255. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61256. * * 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).
  61257. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61258. * * 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).
  61259. * * 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
  61260. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61261. * * 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
  61262. * * 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.
  61263. * * If `enclose` is false, a ring surface is one element.
  61264. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61265. * * 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
  61266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61267. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61269. * @param name defines the name of the mesh
  61270. * @param options defines the options used to create the mesh
  61271. * @param scene defines the hosting scene
  61272. * @returns the cylinder mesh
  61273. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61274. */
  61275. static CreateCylinder(name: string, options: {
  61276. height?: number;
  61277. diameterTop?: number;
  61278. diameterBottom?: number;
  61279. diameter?: number;
  61280. tessellation?: number;
  61281. subdivisions?: number;
  61282. arc?: number;
  61283. faceColors?: Color4[];
  61284. faceUV?: Vector4[];
  61285. updatable?: boolean;
  61286. hasRings?: boolean;
  61287. enclose?: boolean;
  61288. cap?: number;
  61289. sideOrientation?: number;
  61290. frontUVs?: Vector4;
  61291. backUVs?: Vector4;
  61292. }, scene?: Nullable<Scene>): Mesh;
  61293. /**
  61294. * Creates a torus mesh
  61295. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61296. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61297. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61299. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61301. * @param name defines the name of the mesh
  61302. * @param options defines the options used to create the mesh
  61303. * @param scene defines the hosting scene
  61304. * @returns the torus mesh
  61305. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61306. */
  61307. static CreateTorus(name: string, options: {
  61308. diameter?: number;
  61309. thickness?: number;
  61310. tessellation?: number;
  61311. updatable?: boolean;
  61312. sideOrientation?: number;
  61313. frontUVs?: Vector4;
  61314. backUVs?: Vector4;
  61315. }, scene?: Nullable<Scene>): Mesh;
  61316. /**
  61317. * Creates a torus knot mesh
  61318. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61319. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61320. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61321. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61322. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61323. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61325. * @param name defines the name of the mesh
  61326. * @param options defines the options used to create the mesh
  61327. * @param scene defines the hosting scene
  61328. * @returns the torus knot mesh
  61329. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61330. */
  61331. static CreateTorusKnot(name: string, options: {
  61332. radius?: number;
  61333. tube?: number;
  61334. radialSegments?: number;
  61335. tubularSegments?: number;
  61336. p?: number;
  61337. q?: number;
  61338. updatable?: boolean;
  61339. sideOrientation?: number;
  61340. frontUVs?: Vector4;
  61341. backUVs?: Vector4;
  61342. }, scene?: Nullable<Scene>): Mesh;
  61343. /**
  61344. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61345. * * 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
  61346. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61347. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61348. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61349. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61350. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61351. * * 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
  61352. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61354. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61355. * @param name defines the name of the new line system
  61356. * @param options defines the options used to create the line system
  61357. * @param scene defines the hosting scene
  61358. * @returns a new line system mesh
  61359. */
  61360. static CreateLineSystem(name: string, options: {
  61361. lines: Vector3[][];
  61362. updatable?: boolean;
  61363. instance?: Nullable<LinesMesh>;
  61364. colors?: Nullable<Color4[][]>;
  61365. useVertexAlpha?: boolean;
  61366. }, scene: Nullable<Scene>): LinesMesh;
  61367. /**
  61368. * Creates a line mesh
  61369. * 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
  61370. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61371. * * The parameter `points` is an array successive Vector3
  61372. * * 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
  61373. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61374. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61375. * * When updating an instance, remember that only point positions can change, not the number of points
  61376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61377. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61378. * @param name defines the name of the new line system
  61379. * @param options defines the options used to create the line system
  61380. * @param scene defines the hosting scene
  61381. * @returns a new line mesh
  61382. */
  61383. static CreateLines(name: string, options: {
  61384. points: Vector3[];
  61385. updatable?: boolean;
  61386. instance?: Nullable<LinesMesh>;
  61387. colors?: Color4[];
  61388. useVertexAlpha?: boolean;
  61389. }, scene?: Nullable<Scene>): LinesMesh;
  61390. /**
  61391. * Creates a dashed line mesh
  61392. * * 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
  61393. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61394. * * The parameter `points` is an array successive Vector3
  61395. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61396. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61397. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61398. * * 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
  61399. * * When updating an instance, remember that only point positions can change, not the number of points
  61400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61401. * @param name defines the name of the mesh
  61402. * @param options defines the options used to create the mesh
  61403. * @param scene defines the hosting scene
  61404. * @returns the dashed line mesh
  61405. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61406. */
  61407. static CreateDashedLines(name: string, options: {
  61408. points: Vector3[];
  61409. dashSize?: number;
  61410. gapSize?: number;
  61411. dashNb?: number;
  61412. updatable?: boolean;
  61413. instance?: LinesMesh;
  61414. }, scene?: Nullable<Scene>): LinesMesh;
  61415. /**
  61416. * 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.
  61417. * * 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.
  61418. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61419. * * 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.
  61420. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61421. * * 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
  61422. * * 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
  61423. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61425. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61426. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61428. * @param name defines the name of the mesh
  61429. * @param options defines the options used to create the mesh
  61430. * @param scene defines the hosting scene
  61431. * @returns the extruded shape mesh
  61432. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61433. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61434. */
  61435. static ExtrudeShape(name: string, options: {
  61436. shape: Vector3[];
  61437. path: Vector3[];
  61438. scale?: number;
  61439. rotation?: number;
  61440. cap?: number;
  61441. updatable?: boolean;
  61442. sideOrientation?: number;
  61443. frontUVs?: Vector4;
  61444. backUVs?: Vector4;
  61445. instance?: Mesh;
  61446. invertUV?: boolean;
  61447. }, scene?: Nullable<Scene>): Mesh;
  61448. /**
  61449. * Creates an custom extruded shape mesh.
  61450. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61451. * * 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.
  61452. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61453. * * 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
  61454. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61455. * * 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
  61456. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61457. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61458. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61459. * * 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
  61460. * * 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
  61461. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61463. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61464. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61466. * @param name defines the name of the mesh
  61467. * @param options defines the options used to create the mesh
  61468. * @param scene defines the hosting scene
  61469. * @returns the custom extruded shape mesh
  61470. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61471. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61472. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61473. */
  61474. static ExtrudeShapeCustom(name: string, options: {
  61475. shape: Vector3[];
  61476. path: Vector3[];
  61477. scaleFunction?: any;
  61478. rotationFunction?: any;
  61479. ribbonCloseArray?: boolean;
  61480. ribbonClosePath?: boolean;
  61481. cap?: number;
  61482. updatable?: boolean;
  61483. sideOrientation?: number;
  61484. frontUVs?: Vector4;
  61485. backUVs?: Vector4;
  61486. instance?: Mesh;
  61487. invertUV?: boolean;
  61488. }, scene?: Nullable<Scene>): Mesh;
  61489. /**
  61490. * Creates lathe mesh.
  61491. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61492. * * 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
  61493. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61494. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61495. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61496. * * 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
  61497. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61498. * * 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
  61499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61500. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61501. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61503. * @param name defines the name of the mesh
  61504. * @param options defines the options used to create the mesh
  61505. * @param scene defines the hosting scene
  61506. * @returns the lathe mesh
  61507. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61508. */
  61509. static CreateLathe(name: string, options: {
  61510. shape: Vector3[];
  61511. radius?: number;
  61512. tessellation?: number;
  61513. clip?: number;
  61514. arc?: number;
  61515. closed?: boolean;
  61516. updatable?: boolean;
  61517. sideOrientation?: number;
  61518. frontUVs?: Vector4;
  61519. backUVs?: Vector4;
  61520. cap?: number;
  61521. invertUV?: boolean;
  61522. }, scene?: Nullable<Scene>): Mesh;
  61523. /**
  61524. * Creates a tiled plane mesh
  61525. * * You can set a limited pattern arrangement with the tiles
  61526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61527. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61529. * @param name defines the name of the mesh
  61530. * @param options defines the options used to create the mesh
  61531. * @param scene defines the hosting scene
  61532. * @returns the plane mesh
  61533. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61534. */
  61535. static CreateTiledPlane(name: string, options: {
  61536. pattern?: number;
  61537. tileSize?: number;
  61538. tileWidth?: number;
  61539. tileHeight?: number;
  61540. size?: number;
  61541. width?: number;
  61542. height?: number;
  61543. alignHorizontal?: number;
  61544. alignVertical?: number;
  61545. sideOrientation?: number;
  61546. frontUVs?: Vector4;
  61547. backUVs?: Vector4;
  61548. updatable?: boolean;
  61549. }, scene?: Nullable<Scene>): Mesh;
  61550. /**
  61551. * Creates a plane mesh
  61552. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61553. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61554. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61556. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61558. * @param name defines the name of the mesh
  61559. * @param options defines the options used to create the mesh
  61560. * @param scene defines the hosting scene
  61561. * @returns the plane mesh
  61562. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61563. */
  61564. static CreatePlane(name: string, options: {
  61565. size?: number;
  61566. width?: number;
  61567. height?: number;
  61568. sideOrientation?: number;
  61569. frontUVs?: Vector4;
  61570. backUVs?: Vector4;
  61571. updatable?: boolean;
  61572. sourcePlane?: Plane;
  61573. }, scene?: Nullable<Scene>): Mesh;
  61574. /**
  61575. * Creates a ground mesh
  61576. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61577. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61579. * @param name defines the name of the mesh
  61580. * @param options defines the options used to create the mesh
  61581. * @param scene defines the hosting scene
  61582. * @returns the ground mesh
  61583. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61584. */
  61585. static CreateGround(name: string, options: {
  61586. width?: number;
  61587. height?: number;
  61588. subdivisions?: number;
  61589. subdivisionsX?: number;
  61590. subdivisionsY?: number;
  61591. updatable?: boolean;
  61592. }, scene?: Nullable<Scene>): Mesh;
  61593. /**
  61594. * Creates a tiled ground mesh
  61595. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61596. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61597. * * 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
  61598. * * 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
  61599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61600. * @param name defines the name of the mesh
  61601. * @param options defines the options used to create the mesh
  61602. * @param scene defines the hosting scene
  61603. * @returns the tiled ground mesh
  61604. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61605. */
  61606. static CreateTiledGround(name: string, options: {
  61607. xmin: number;
  61608. zmin: number;
  61609. xmax: number;
  61610. zmax: number;
  61611. subdivisions?: {
  61612. w: number;
  61613. h: number;
  61614. };
  61615. precision?: {
  61616. w: number;
  61617. h: number;
  61618. };
  61619. updatable?: boolean;
  61620. }, scene?: Nullable<Scene>): Mesh;
  61621. /**
  61622. * Creates a ground mesh from a height map
  61623. * * The parameter `url` sets the URL of the height map image resource.
  61624. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61625. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61626. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61627. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61628. * * 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.
  61629. * * 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).
  61630. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61632. * @param name defines the name of the mesh
  61633. * @param url defines the url to the height map
  61634. * @param options defines the options used to create the mesh
  61635. * @param scene defines the hosting scene
  61636. * @returns the ground mesh
  61637. * @see https://doc.babylonjs.com/babylon101/height_map
  61638. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61639. */
  61640. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61641. width?: number;
  61642. height?: number;
  61643. subdivisions?: number;
  61644. minHeight?: number;
  61645. maxHeight?: number;
  61646. colorFilter?: Color3;
  61647. alphaFilter?: number;
  61648. updatable?: boolean;
  61649. onReady?: (mesh: GroundMesh) => void;
  61650. }, scene?: Nullable<Scene>): GroundMesh;
  61651. /**
  61652. * Creates a polygon mesh
  61653. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61654. * * 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
  61655. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  61658. * * Remember you can only change the shape positions, not their number when updating a polygon
  61659. * @param name defines the name of the mesh
  61660. * @param options defines the options used to create the mesh
  61661. * @param scene defines the hosting scene
  61662. * @param earcutInjection can be used to inject your own earcut reference
  61663. * @returns the polygon mesh
  61664. */
  61665. static CreatePolygon(name: string, options: {
  61666. shape: Vector3[];
  61667. holes?: Vector3[][];
  61668. depth?: number;
  61669. faceUV?: Vector4[];
  61670. faceColors?: Color4[];
  61671. updatable?: boolean;
  61672. sideOrientation?: number;
  61673. frontUVs?: Vector4;
  61674. backUVs?: Vector4;
  61675. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61676. /**
  61677. * Creates an extruded polygon mesh, with depth in the Y direction.
  61678. * * 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)
  61679. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61680. * @param name defines the name of the mesh
  61681. * @param options defines the options used to create the mesh
  61682. * @param scene defines the hosting scene
  61683. * @param earcutInjection can be used to inject your own earcut reference
  61684. * @returns the polygon mesh
  61685. */
  61686. static ExtrudePolygon(name: string, options: {
  61687. shape: Vector3[];
  61688. holes?: Vector3[][];
  61689. depth?: number;
  61690. faceUV?: Vector4[];
  61691. faceColors?: Color4[];
  61692. updatable?: boolean;
  61693. sideOrientation?: number;
  61694. frontUVs?: Vector4;
  61695. backUVs?: Vector4;
  61696. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61697. /**
  61698. * Creates a tube mesh.
  61699. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61700. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61701. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61702. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61703. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61704. * * 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)
  61705. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61706. * * 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
  61707. * * 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
  61708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61709. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61710. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61712. * @param name defines the name of the mesh
  61713. * @param options defines the options used to create the mesh
  61714. * @param scene defines the hosting scene
  61715. * @returns the tube mesh
  61716. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61717. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61718. */
  61719. static CreateTube(name: string, options: {
  61720. path: Vector3[];
  61721. radius?: number;
  61722. tessellation?: number;
  61723. radiusFunction?: {
  61724. (i: number, distance: number): number;
  61725. };
  61726. cap?: number;
  61727. arc?: number;
  61728. updatable?: boolean;
  61729. sideOrientation?: number;
  61730. frontUVs?: Vector4;
  61731. backUVs?: Vector4;
  61732. instance?: Mesh;
  61733. invertUV?: boolean;
  61734. }, scene?: Nullable<Scene>): Mesh;
  61735. /**
  61736. * Creates a polyhedron mesh
  61737. * * 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
  61738. * * The parameter `size` (positive float, default 1) sets the polygon size
  61739. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61740. * * 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`
  61741. * * 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
  61742. * * 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)`)
  61743. * * 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
  61744. * * 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
  61745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61746. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61748. * @param name defines the name of the mesh
  61749. * @param options defines the options used to create the mesh
  61750. * @param scene defines the hosting scene
  61751. * @returns the polyhedron mesh
  61752. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61753. */
  61754. static CreatePolyhedron(name: string, options: {
  61755. type?: number;
  61756. size?: number;
  61757. sizeX?: number;
  61758. sizeY?: number;
  61759. sizeZ?: number;
  61760. custom?: any;
  61761. faceUV?: Vector4[];
  61762. faceColors?: Color4[];
  61763. flat?: boolean;
  61764. updatable?: boolean;
  61765. sideOrientation?: number;
  61766. frontUVs?: Vector4;
  61767. backUVs?: Vector4;
  61768. }, scene?: Nullable<Scene>): Mesh;
  61769. /**
  61770. * Creates a decal mesh.
  61771. * 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
  61772. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61773. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61774. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61775. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61776. * @param name defines the name of the mesh
  61777. * @param sourceMesh defines the mesh where the decal must be applied
  61778. * @param options defines the options used to create the mesh
  61779. * @param scene defines the hosting scene
  61780. * @returns the decal mesh
  61781. * @see https://doc.babylonjs.com/how_to/decals
  61782. */
  61783. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61784. position?: Vector3;
  61785. normal?: Vector3;
  61786. size?: Vector3;
  61787. angle?: number;
  61788. }): Mesh;
  61789. }
  61790. }
  61791. declare module "babylonjs/Meshes/meshSimplification" {
  61792. import { Mesh } from "babylonjs/Meshes/mesh";
  61793. /**
  61794. * A simplifier interface for future simplification implementations
  61795. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61796. */
  61797. export interface ISimplifier {
  61798. /**
  61799. * Simplification of a given mesh according to the given settings.
  61800. * Since this requires computation, it is assumed that the function runs async.
  61801. * @param settings The settings of the simplification, including quality and distance
  61802. * @param successCallback A callback that will be called after the mesh was simplified.
  61803. * @param errorCallback in case of an error, this callback will be called. optional.
  61804. */
  61805. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61806. }
  61807. /**
  61808. * Expected simplification settings.
  61809. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61810. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61811. */
  61812. export interface ISimplificationSettings {
  61813. /**
  61814. * Gets or sets the expected quality
  61815. */
  61816. quality: number;
  61817. /**
  61818. * Gets or sets the distance when this optimized version should be used
  61819. */
  61820. distance: number;
  61821. /**
  61822. * Gets an already optimized mesh
  61823. */
  61824. optimizeMesh?: boolean;
  61825. }
  61826. /**
  61827. * Class used to specify simplification options
  61828. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61829. */
  61830. export class SimplificationSettings implements ISimplificationSettings {
  61831. /** expected quality */
  61832. quality: number;
  61833. /** distance when this optimized version should be used */
  61834. distance: number;
  61835. /** already optimized mesh */
  61836. optimizeMesh?: boolean | undefined;
  61837. /**
  61838. * Creates a SimplificationSettings
  61839. * @param quality expected quality
  61840. * @param distance distance when this optimized version should be used
  61841. * @param optimizeMesh already optimized mesh
  61842. */
  61843. constructor(
  61844. /** expected quality */
  61845. quality: number,
  61846. /** distance when this optimized version should be used */
  61847. distance: number,
  61848. /** already optimized mesh */
  61849. optimizeMesh?: boolean | undefined);
  61850. }
  61851. /**
  61852. * Interface used to define a simplification task
  61853. */
  61854. export interface ISimplificationTask {
  61855. /**
  61856. * Array of settings
  61857. */
  61858. settings: Array<ISimplificationSettings>;
  61859. /**
  61860. * Simplification type
  61861. */
  61862. simplificationType: SimplificationType;
  61863. /**
  61864. * Mesh to simplify
  61865. */
  61866. mesh: Mesh;
  61867. /**
  61868. * Callback called on success
  61869. */
  61870. successCallback?: () => void;
  61871. /**
  61872. * Defines if parallel processing can be used
  61873. */
  61874. parallelProcessing: boolean;
  61875. }
  61876. /**
  61877. * Queue used to order the simplification tasks
  61878. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61879. */
  61880. export class SimplificationQueue {
  61881. private _simplificationArray;
  61882. /**
  61883. * Gets a boolean indicating that the process is still running
  61884. */
  61885. running: boolean;
  61886. /**
  61887. * Creates a new queue
  61888. */
  61889. constructor();
  61890. /**
  61891. * Adds a new simplification task
  61892. * @param task defines a task to add
  61893. */
  61894. addTask(task: ISimplificationTask): void;
  61895. /**
  61896. * Execute next task
  61897. */
  61898. executeNext(): void;
  61899. /**
  61900. * Execute a simplification task
  61901. * @param task defines the task to run
  61902. */
  61903. runSimplification(task: ISimplificationTask): void;
  61904. private getSimplifier;
  61905. }
  61906. /**
  61907. * The implemented types of simplification
  61908. * At the moment only Quadratic Error Decimation is implemented
  61909. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61910. */
  61911. export enum SimplificationType {
  61912. /** Quadratic error decimation */
  61913. QUADRATIC = 0
  61914. }
  61915. }
  61916. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  61917. import { Scene } from "babylonjs/scene";
  61918. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  61919. import { ISceneComponent } from "babylonjs/sceneComponent";
  61920. module "babylonjs/scene" {
  61921. interface Scene {
  61922. /** @hidden (Backing field) */
  61923. _simplificationQueue: SimplificationQueue;
  61924. /**
  61925. * Gets or sets the simplification queue attached to the scene
  61926. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61927. */
  61928. simplificationQueue: SimplificationQueue;
  61929. }
  61930. }
  61931. module "babylonjs/Meshes/mesh" {
  61932. interface Mesh {
  61933. /**
  61934. * Simplify the mesh according to the given array of settings.
  61935. * Function will return immediately and will simplify async
  61936. * @param settings a collection of simplification settings
  61937. * @param parallelProcessing should all levels calculate parallel or one after the other
  61938. * @param simplificationType the type of simplification to run
  61939. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61940. * @returns the current mesh
  61941. */
  61942. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61943. }
  61944. }
  61945. /**
  61946. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61947. * created in a scene
  61948. */
  61949. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61950. /**
  61951. * The component name helpfull to identify the component in the list of scene components.
  61952. */
  61953. readonly name: string;
  61954. /**
  61955. * The scene the component belongs to.
  61956. */
  61957. scene: Scene;
  61958. /**
  61959. * Creates a new instance of the component for the given scene
  61960. * @param scene Defines the scene to register the component in
  61961. */
  61962. constructor(scene: Scene);
  61963. /**
  61964. * Registers the component in a given scene
  61965. */
  61966. register(): void;
  61967. /**
  61968. * Rebuilds the elements related to this component in case of
  61969. * context lost for instance.
  61970. */
  61971. rebuild(): void;
  61972. /**
  61973. * Disposes the component and the associated ressources
  61974. */
  61975. dispose(): void;
  61976. private _beforeCameraUpdate;
  61977. }
  61978. }
  61979. declare module "babylonjs/Meshes/Builders/index" {
  61980. export * from "babylonjs/Meshes/Builders/boxBuilder";
  61981. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  61982. export * from "babylonjs/Meshes/Builders/discBuilder";
  61983. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  61984. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  61985. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  61986. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  61987. export * from "babylonjs/Meshes/Builders/torusBuilder";
  61988. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  61989. export * from "babylonjs/Meshes/Builders/linesBuilder";
  61990. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  61991. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  61992. export * from "babylonjs/Meshes/Builders/latheBuilder";
  61993. export * from "babylonjs/Meshes/Builders/planeBuilder";
  61994. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  61995. export * from "babylonjs/Meshes/Builders/groundBuilder";
  61996. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  61997. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  61998. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  61999. export * from "babylonjs/Meshes/Builders/decalBuilder";
  62000. }
  62001. declare module "babylonjs/Meshes/index" {
  62002. export * from "babylonjs/Meshes/abstractMesh";
  62003. export * from "babylonjs/Meshes/buffer";
  62004. export * from "babylonjs/Meshes/Compression/index";
  62005. export * from "babylonjs/Meshes/csg";
  62006. export * from "babylonjs/Meshes/geometry";
  62007. export * from "babylonjs/Meshes/groundMesh";
  62008. export * from "babylonjs/Meshes/trailMesh";
  62009. export * from "babylonjs/Meshes/instancedMesh";
  62010. export * from "babylonjs/Meshes/linesMesh";
  62011. export * from "babylonjs/Meshes/mesh";
  62012. export * from "babylonjs/Meshes/mesh.vertexData";
  62013. export * from "babylonjs/Meshes/meshBuilder";
  62014. export * from "babylonjs/Meshes/meshSimplification";
  62015. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  62016. export * from "babylonjs/Meshes/polygonMesh";
  62017. export * from "babylonjs/Meshes/subMesh";
  62018. export * from "babylonjs/Meshes/meshLODLevel";
  62019. export * from "babylonjs/Meshes/transformNode";
  62020. export * from "babylonjs/Meshes/Builders/index";
  62021. export * from "babylonjs/Meshes/dataBuffer";
  62022. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  62023. }
  62024. declare module "babylonjs/Morph/index" {
  62025. export * from "babylonjs/Morph/morphTarget";
  62026. export * from "babylonjs/Morph/morphTargetManager";
  62027. }
  62028. declare module "babylonjs/Navigation/INavigationEngine" {
  62029. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62030. import { Vector3 } from "babylonjs/Maths/math";
  62031. import { Mesh } from "babylonjs/Meshes/mesh";
  62032. import { Scene } from "babylonjs/scene";
  62033. /**
  62034. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62035. */
  62036. export interface INavigationEnginePlugin {
  62037. /**
  62038. * plugin name
  62039. */
  62040. name: string;
  62041. /**
  62042. * Creates a navigation mesh
  62043. * @param meshes array of all the geometry used to compute the navigatio mesh
  62044. * @param parameters bunch of parameters used to filter geometry
  62045. */
  62046. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62047. /**
  62048. * Create a navigation mesh debug mesh
  62049. * @param scene is where the mesh will be added
  62050. * @returns debug display mesh
  62051. */
  62052. createDebugNavMesh(scene: Scene): Mesh;
  62053. /**
  62054. * Get a navigation mesh constrained position, closest to the parameter position
  62055. * @param position world position
  62056. * @returns the closest point to position constrained by the navigation mesh
  62057. */
  62058. getClosestPoint(position: Vector3): Vector3;
  62059. /**
  62060. * Get a navigation mesh constrained position, within a particular radius
  62061. * @param position world position
  62062. * @param maxRadius the maximum distance to the constrained world position
  62063. * @returns the closest point to position constrained by the navigation mesh
  62064. */
  62065. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62066. /**
  62067. * Compute the final position from a segment made of destination-position
  62068. * @param position world position
  62069. * @param destination world position
  62070. * @returns the resulting point along the navmesh
  62071. */
  62072. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62073. /**
  62074. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62075. * @param start world position
  62076. * @param end world position
  62077. * @returns array containing world position composing the path
  62078. */
  62079. computePath(start: Vector3, end: Vector3): Vector3[];
  62080. /**
  62081. * If this plugin is supported
  62082. * @returns true if plugin is supported
  62083. */
  62084. isSupported(): boolean;
  62085. /**
  62086. * Create a new Crowd so you can add agents
  62087. * @param maxAgents the maximum agent count in the crowd
  62088. * @param maxAgentRadius the maximum radius an agent can have
  62089. * @param scene to attach the crowd to
  62090. * @returns the crowd you can add agents to
  62091. */
  62092. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62093. /**
  62094. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62095. * The queries will try to find a solution within those bounds
  62096. * default is (1,1,1)
  62097. * @param extent x,y,z value that define the extent around the queries point of reference
  62098. */
  62099. setDefaultQueryExtent(extent: Vector3): void;
  62100. /**
  62101. * Get the Bounding box extent specified by setDefaultQueryExtent
  62102. * @returns the box extent values
  62103. */
  62104. getDefaultQueryExtent(): Vector3;
  62105. /**
  62106. * Release all resources
  62107. */
  62108. dispose(): void;
  62109. }
  62110. /**
  62111. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62112. */
  62113. export interface ICrowd {
  62114. /**
  62115. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62116. * You can attach anything to that node. The node position is updated in the scene update tick.
  62117. * @param pos world position that will be constrained by the navigation mesh
  62118. * @param parameters agent parameters
  62119. * @param transform hooked to the agent that will be update by the scene
  62120. * @returns agent index
  62121. */
  62122. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62123. /**
  62124. * Returns the agent position in world space
  62125. * @param index agent index returned by addAgent
  62126. * @returns world space position
  62127. */
  62128. getAgentPosition(index: number): Vector3;
  62129. /**
  62130. * Gets the agent velocity in world space
  62131. * @param index agent index returned by addAgent
  62132. * @returns world space velocity
  62133. */
  62134. getAgentVelocity(index: number): Vector3;
  62135. /**
  62136. * remove a particular agent previously created
  62137. * @param index agent index returned by addAgent
  62138. */
  62139. removeAgent(index: number): void;
  62140. /**
  62141. * get the list of all agents attached to this crowd
  62142. * @returns list of agent indices
  62143. */
  62144. getAgents(): number[];
  62145. /**
  62146. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62147. * @param deltaTime in seconds
  62148. */
  62149. update(deltaTime: number): void;
  62150. /**
  62151. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62152. * @param index agent index returned by addAgent
  62153. * @param destination targeted world position
  62154. */
  62155. agentGoto(index: number, destination: Vector3): void;
  62156. /**
  62157. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62158. * The queries will try to find a solution within those bounds
  62159. * default is (1,1,1)
  62160. * @param extent x,y,z value that define the extent around the queries point of reference
  62161. */
  62162. setDefaultQueryExtent(extent: Vector3): void;
  62163. /**
  62164. * Get the Bounding box extent specified by setDefaultQueryExtent
  62165. * @returns the box extent values
  62166. */
  62167. getDefaultQueryExtent(): Vector3;
  62168. /**
  62169. * Release all resources
  62170. */
  62171. dispose(): void;
  62172. }
  62173. /**
  62174. * Configures an agent
  62175. */
  62176. export interface IAgentParameters {
  62177. /**
  62178. * Agent radius. [Limit: >= 0]
  62179. */
  62180. radius: number;
  62181. /**
  62182. * Agent height. [Limit: > 0]
  62183. */
  62184. height: number;
  62185. /**
  62186. * Maximum allowed acceleration. [Limit: >= 0]
  62187. */
  62188. maxAcceleration: number;
  62189. /**
  62190. * Maximum allowed speed. [Limit: >= 0]
  62191. */
  62192. maxSpeed: number;
  62193. /**
  62194. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62195. */
  62196. collisionQueryRange: number;
  62197. /**
  62198. * The path visibility optimization range. [Limit: > 0]
  62199. */
  62200. pathOptimizationRange: number;
  62201. /**
  62202. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62203. */
  62204. separationWeight: number;
  62205. }
  62206. /**
  62207. * Configures the navigation mesh creation
  62208. */
  62209. export interface INavMeshParameters {
  62210. /**
  62211. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62212. */
  62213. cs: number;
  62214. /**
  62215. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62216. */
  62217. ch: number;
  62218. /**
  62219. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62220. */
  62221. walkableSlopeAngle: number;
  62222. /**
  62223. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62224. * be considered walkable. [Limit: >= 3] [Units: vx]
  62225. */
  62226. walkableHeight: number;
  62227. /**
  62228. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62229. */
  62230. walkableClimb: number;
  62231. /**
  62232. * The distance to erode/shrink the walkable area of the heightfield away from
  62233. * obstructions. [Limit: >=0] [Units: vx]
  62234. */
  62235. walkableRadius: number;
  62236. /**
  62237. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62238. */
  62239. maxEdgeLen: number;
  62240. /**
  62241. * The maximum distance a simplfied contour's border edges should deviate
  62242. * the original raw contour. [Limit: >=0] [Units: vx]
  62243. */
  62244. maxSimplificationError: number;
  62245. /**
  62246. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62247. */
  62248. minRegionArea: number;
  62249. /**
  62250. * Any regions with a span count smaller than this value will, if possible,
  62251. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62252. */
  62253. mergeRegionArea: number;
  62254. /**
  62255. * The maximum number of vertices allowed for polygons generated during the
  62256. * contour to polygon conversion process. [Limit: >= 3]
  62257. */
  62258. maxVertsPerPoly: number;
  62259. /**
  62260. * Sets the sampling distance to use when generating the detail mesh.
  62261. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62262. */
  62263. detailSampleDist: number;
  62264. /**
  62265. * The maximum distance the detail mesh surface should deviate from heightfield
  62266. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62267. */
  62268. detailSampleMaxError: number;
  62269. }
  62270. }
  62271. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  62272. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  62273. import { Mesh } from "babylonjs/Meshes/mesh";
  62274. import { Scene } from "babylonjs/scene";
  62275. import { Vector3 } from "babylonjs/Maths/math";
  62276. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62277. /**
  62278. * RecastJS navigation plugin
  62279. */
  62280. export class RecastJSPlugin implements INavigationEnginePlugin {
  62281. /**
  62282. * Reference to the Recast library
  62283. */
  62284. bjsRECAST: any;
  62285. /**
  62286. * plugin name
  62287. */
  62288. name: string;
  62289. /**
  62290. * the first navmesh created. We might extend this to support multiple navmeshes
  62291. */
  62292. navMesh: any;
  62293. /**
  62294. * Initializes the recastJS plugin
  62295. * @param recastInjection can be used to inject your own recast reference
  62296. */
  62297. constructor(recastInjection?: any);
  62298. /**
  62299. * Creates a navigation mesh
  62300. * @param meshes array of all the geometry used to compute the navigatio mesh
  62301. * @param parameters bunch of parameters used to filter geometry
  62302. */
  62303. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62304. /**
  62305. * Create a navigation mesh debug mesh
  62306. * @param scene is where the mesh will be added
  62307. * @returns debug display mesh
  62308. */
  62309. createDebugNavMesh(scene: Scene): Mesh;
  62310. /**
  62311. * Get a navigation mesh constrained position, closest to the parameter position
  62312. * @param position world position
  62313. * @returns the closest point to position constrained by the navigation mesh
  62314. */
  62315. getClosestPoint(position: Vector3): Vector3;
  62316. /**
  62317. * Get a navigation mesh constrained position, within a particular radius
  62318. * @param position world position
  62319. * @param maxRadius the maximum distance to the constrained world position
  62320. * @returns the closest point to position constrained by the navigation mesh
  62321. */
  62322. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62323. /**
  62324. * Compute the final position from a segment made of destination-position
  62325. * @param position world position
  62326. * @param destination world position
  62327. * @returns the resulting point along the navmesh
  62328. */
  62329. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62330. /**
  62331. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62332. * @param start world position
  62333. * @param end world position
  62334. * @returns array containing world position composing the path
  62335. */
  62336. computePath(start: Vector3, end: Vector3): Vector3[];
  62337. /**
  62338. * Create a new Crowd so you can add agents
  62339. * @param maxAgents the maximum agent count in the crowd
  62340. * @param maxAgentRadius the maximum radius an agent can have
  62341. * @param scene to attach the crowd to
  62342. * @returns the crowd you can add agents to
  62343. */
  62344. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62345. /**
  62346. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62347. * The queries will try to find a solution within those bounds
  62348. * default is (1,1,1)
  62349. * @param extent x,y,z value that define the extent around the queries point of reference
  62350. */
  62351. setDefaultQueryExtent(extent: Vector3): void;
  62352. /**
  62353. * Get the Bounding box extent specified by setDefaultQueryExtent
  62354. * @returns the box extent values
  62355. */
  62356. getDefaultQueryExtent(): Vector3;
  62357. /**
  62358. * Disposes
  62359. */
  62360. dispose(): void;
  62361. /**
  62362. * If this plugin is supported
  62363. * @returns true if plugin is supported
  62364. */
  62365. isSupported(): boolean;
  62366. }
  62367. /**
  62368. * Recast detour crowd implementation
  62369. */
  62370. export class RecastJSCrowd implements ICrowd {
  62371. /**
  62372. * Recast/detour plugin
  62373. */
  62374. bjsRECASTPlugin: RecastJSPlugin;
  62375. /**
  62376. * Link to the detour crowd
  62377. */
  62378. recastCrowd: any;
  62379. /**
  62380. * One transform per agent
  62381. */
  62382. transforms: TransformNode[];
  62383. /**
  62384. * All agents created
  62385. */
  62386. agents: number[];
  62387. /**
  62388. * Link to the scene is kept to unregister the crowd from the scene
  62389. */
  62390. private _scene;
  62391. /**
  62392. * Observer for crowd updates
  62393. */
  62394. private _onBeforeAnimationsObserver;
  62395. /**
  62396. * Constructor
  62397. * @param plugin recastJS plugin
  62398. * @param maxAgents the maximum agent count in the crowd
  62399. * @param maxAgentRadius the maximum radius an agent can have
  62400. * @param scene to attach the crowd to
  62401. * @returns the crowd you can add agents to
  62402. */
  62403. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62404. /**
  62405. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62406. * You can attach anything to that node. The node position is updated in the scene update tick.
  62407. * @param pos world position that will be constrained by the navigation mesh
  62408. * @param parameters agent parameters
  62409. * @param transform hooked to the agent that will be update by the scene
  62410. * @returns agent index
  62411. */
  62412. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62413. /**
  62414. * Returns the agent position in world space
  62415. * @param index agent index returned by addAgent
  62416. * @returns world space position
  62417. */
  62418. getAgentPosition(index: number): Vector3;
  62419. /**
  62420. * Returns the agent velocity in world space
  62421. * @param index agent index returned by addAgent
  62422. * @returns world space velocity
  62423. */
  62424. getAgentVelocity(index: number): Vector3;
  62425. /**
  62426. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62427. * @param index agent index returned by addAgent
  62428. * @param destination targeted world position
  62429. */
  62430. agentGoto(index: number, destination: Vector3): void;
  62431. /**
  62432. * remove a particular agent previously created
  62433. * @param index agent index returned by addAgent
  62434. */
  62435. removeAgent(index: number): void;
  62436. /**
  62437. * get the list of all agents attached to this crowd
  62438. * @returns list of agent indices
  62439. */
  62440. getAgents(): number[];
  62441. /**
  62442. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62443. * @param deltaTime in seconds
  62444. */
  62445. update(deltaTime: number): void;
  62446. /**
  62447. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62448. * The queries will try to find a solution within those bounds
  62449. * default is (1,1,1)
  62450. * @param extent x,y,z value that define the extent around the queries point of reference
  62451. */
  62452. setDefaultQueryExtent(extent: Vector3): void;
  62453. /**
  62454. * Get the Bounding box extent specified by setDefaultQueryExtent
  62455. * @returns the box extent values
  62456. */
  62457. getDefaultQueryExtent(): Vector3;
  62458. /**
  62459. * Release all resources
  62460. */
  62461. dispose(): void;
  62462. }
  62463. }
  62464. declare module "babylonjs/Navigation/Plugins/index" {
  62465. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  62466. }
  62467. declare module "babylonjs/Navigation/index" {
  62468. export * from "babylonjs/Navigation/INavigationEngine";
  62469. export * from "babylonjs/Navigation/Plugins/index";
  62470. }
  62471. declare module "babylonjs/Offline/database" {
  62472. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  62473. /**
  62474. * Class used to enable access to IndexedDB
  62475. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62476. */
  62477. export class Database implements IOfflineProvider {
  62478. private _callbackManifestChecked;
  62479. private _currentSceneUrl;
  62480. private _db;
  62481. private _enableSceneOffline;
  62482. private _enableTexturesOffline;
  62483. private _manifestVersionFound;
  62484. private _mustUpdateRessources;
  62485. private _hasReachedQuota;
  62486. private _isSupported;
  62487. private _idbFactory;
  62488. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62489. private static IsUASupportingBlobStorage;
  62490. /**
  62491. * Gets a boolean indicating if Database storate is enabled (off by default)
  62492. */
  62493. static IDBStorageEnabled: boolean;
  62494. /**
  62495. * Gets a boolean indicating if scene must be saved in the database
  62496. */
  62497. readonly enableSceneOffline: boolean;
  62498. /**
  62499. * Gets a boolean indicating if textures must be saved in the database
  62500. */
  62501. readonly enableTexturesOffline: boolean;
  62502. /**
  62503. * Creates a new Database
  62504. * @param urlToScene defines the url to load the scene
  62505. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62506. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62507. */
  62508. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62509. private static _ParseURL;
  62510. private static _ReturnFullUrlLocation;
  62511. private _checkManifestFile;
  62512. /**
  62513. * Open the database and make it available
  62514. * @param successCallback defines the callback to call on success
  62515. * @param errorCallback defines the callback to call on error
  62516. */
  62517. open(successCallback: () => void, errorCallback: () => void): void;
  62518. /**
  62519. * Loads an image from the database
  62520. * @param url defines the url to load from
  62521. * @param image defines the target DOM image
  62522. */
  62523. loadImage(url: string, image: HTMLImageElement): void;
  62524. private _loadImageFromDBAsync;
  62525. private _saveImageIntoDBAsync;
  62526. private _checkVersionFromDB;
  62527. private _loadVersionFromDBAsync;
  62528. private _saveVersionIntoDBAsync;
  62529. /**
  62530. * Loads a file from database
  62531. * @param url defines the URL to load from
  62532. * @param sceneLoaded defines a callback to call on success
  62533. * @param progressCallBack defines a callback to call when progress changed
  62534. * @param errorCallback defines a callback to call on error
  62535. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62536. */
  62537. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62538. private _loadFileAsync;
  62539. private _saveFileAsync;
  62540. /**
  62541. * Validates if xhr data is correct
  62542. * @param xhr defines the request to validate
  62543. * @param dataType defines the expected data type
  62544. * @returns true if data is correct
  62545. */
  62546. private static _ValidateXHRData;
  62547. }
  62548. }
  62549. declare module "babylonjs/Offline/index" {
  62550. export * from "babylonjs/Offline/database";
  62551. export * from "babylonjs/Offline/IOfflineProvider";
  62552. }
  62553. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  62554. /** @hidden */
  62555. export var gpuUpdateParticlesPixelShader: {
  62556. name: string;
  62557. shader: string;
  62558. };
  62559. }
  62560. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  62561. /** @hidden */
  62562. export var gpuUpdateParticlesVertexShader: {
  62563. name: string;
  62564. shader: string;
  62565. };
  62566. }
  62567. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  62568. /** @hidden */
  62569. export var clipPlaneFragmentDeclaration2: {
  62570. name: string;
  62571. shader: string;
  62572. };
  62573. }
  62574. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  62575. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  62576. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  62577. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62578. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  62579. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  62580. /** @hidden */
  62581. export var gpuRenderParticlesPixelShader: {
  62582. name: string;
  62583. shader: string;
  62584. };
  62585. }
  62586. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  62587. /** @hidden */
  62588. export var clipPlaneVertexDeclaration2: {
  62589. name: string;
  62590. shader: string;
  62591. };
  62592. }
  62593. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  62594. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  62595. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  62596. /** @hidden */
  62597. export var gpuRenderParticlesVertexShader: {
  62598. name: string;
  62599. shader: string;
  62600. };
  62601. }
  62602. declare module "babylonjs/Particles/gpuParticleSystem" {
  62603. import { Nullable } from "babylonjs/types";
  62604. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  62605. import { Observable } from "babylonjs/Misc/observable";
  62606. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62607. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62608. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  62609. import { Scene, IDisposable } from "babylonjs/scene";
  62610. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  62611. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62612. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  62613. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  62614. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  62615. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  62616. /**
  62617. * This represents a GPU particle system in Babylon
  62618. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62619. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62620. */
  62621. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62622. /**
  62623. * The layer mask we are rendering the particles through.
  62624. */
  62625. layerMask: number;
  62626. private _capacity;
  62627. private _activeCount;
  62628. private _currentActiveCount;
  62629. private _accumulatedCount;
  62630. private _renderEffect;
  62631. private _updateEffect;
  62632. private _buffer0;
  62633. private _buffer1;
  62634. private _spriteBuffer;
  62635. private _updateVAO;
  62636. private _renderVAO;
  62637. private _targetIndex;
  62638. private _sourceBuffer;
  62639. private _targetBuffer;
  62640. private _engine;
  62641. private _currentRenderId;
  62642. private _started;
  62643. private _stopped;
  62644. private _timeDelta;
  62645. private _randomTexture;
  62646. private _randomTexture2;
  62647. private _attributesStrideSize;
  62648. private _updateEffectOptions;
  62649. private _randomTextureSize;
  62650. private _actualFrame;
  62651. private readonly _rawTextureWidth;
  62652. /**
  62653. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62654. */
  62655. static readonly IsSupported: boolean;
  62656. /**
  62657. * An event triggered when the system is disposed.
  62658. */
  62659. onDisposeObservable: Observable<GPUParticleSystem>;
  62660. /**
  62661. * Gets the maximum number of particles active at the same time.
  62662. * @returns The max number of active particles.
  62663. */
  62664. getCapacity(): number;
  62665. /**
  62666. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62667. * to override the particles.
  62668. */
  62669. forceDepthWrite: boolean;
  62670. /**
  62671. * Gets or set the number of active particles
  62672. */
  62673. activeParticleCount: number;
  62674. private _preWarmDone;
  62675. /**
  62676. * Is this system ready to be used/rendered
  62677. * @return true if the system is ready
  62678. */
  62679. isReady(): boolean;
  62680. /**
  62681. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62682. * @returns True if it has been started, otherwise false.
  62683. */
  62684. isStarted(): boolean;
  62685. /**
  62686. * Starts the particle system and begins to emit
  62687. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62688. */
  62689. start(delay?: number): void;
  62690. /**
  62691. * Stops the particle system.
  62692. */
  62693. stop(): void;
  62694. /**
  62695. * Remove all active particles
  62696. */
  62697. reset(): void;
  62698. /**
  62699. * Returns the string "GPUParticleSystem"
  62700. * @returns a string containing the class name
  62701. */
  62702. getClassName(): string;
  62703. private _colorGradientsTexture;
  62704. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62705. /**
  62706. * Adds a new color gradient
  62707. * @param gradient defines the gradient to use (between 0 and 1)
  62708. * @param color1 defines the color to affect to the specified gradient
  62709. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62710. * @returns the current particle system
  62711. */
  62712. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62713. /**
  62714. * Remove a specific color gradient
  62715. * @param gradient defines the gradient to remove
  62716. * @returns the current particle system
  62717. */
  62718. removeColorGradient(gradient: number): GPUParticleSystem;
  62719. private _angularSpeedGradientsTexture;
  62720. private _sizeGradientsTexture;
  62721. private _velocityGradientsTexture;
  62722. private _limitVelocityGradientsTexture;
  62723. private _dragGradientsTexture;
  62724. private _addFactorGradient;
  62725. /**
  62726. * Adds a new size gradient
  62727. * @param gradient defines the gradient to use (between 0 and 1)
  62728. * @param factor defines the size factor to affect to the specified gradient
  62729. * @returns the current particle system
  62730. */
  62731. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62732. /**
  62733. * Remove a specific size gradient
  62734. * @param gradient defines the gradient to remove
  62735. * @returns the current particle system
  62736. */
  62737. removeSizeGradient(gradient: number): GPUParticleSystem;
  62738. /**
  62739. * Adds a new angular speed gradient
  62740. * @param gradient defines the gradient to use (between 0 and 1)
  62741. * @param factor defines the angular speed to affect to the specified gradient
  62742. * @returns the current particle system
  62743. */
  62744. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62745. /**
  62746. * Remove a specific angular speed gradient
  62747. * @param gradient defines the gradient to remove
  62748. * @returns the current particle system
  62749. */
  62750. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62751. /**
  62752. * Adds a new velocity gradient
  62753. * @param gradient defines the gradient to use (between 0 and 1)
  62754. * @param factor defines the velocity to affect to the specified gradient
  62755. * @returns the current particle system
  62756. */
  62757. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62758. /**
  62759. * Remove a specific velocity gradient
  62760. * @param gradient defines the gradient to remove
  62761. * @returns the current particle system
  62762. */
  62763. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62764. /**
  62765. * Adds a new limit velocity gradient
  62766. * @param gradient defines the gradient to use (between 0 and 1)
  62767. * @param factor defines the limit velocity value to affect to the specified gradient
  62768. * @returns the current particle system
  62769. */
  62770. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62771. /**
  62772. * Remove a specific limit velocity gradient
  62773. * @param gradient defines the gradient to remove
  62774. * @returns the current particle system
  62775. */
  62776. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62777. /**
  62778. * Adds a new drag gradient
  62779. * @param gradient defines the gradient to use (between 0 and 1)
  62780. * @param factor defines the drag value to affect to the specified gradient
  62781. * @returns the current particle system
  62782. */
  62783. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62784. /**
  62785. * Remove a specific drag gradient
  62786. * @param gradient defines the gradient to remove
  62787. * @returns the current particle system
  62788. */
  62789. removeDragGradient(gradient: number): GPUParticleSystem;
  62790. /**
  62791. * Not supported by GPUParticleSystem
  62792. * @param gradient defines the gradient to use (between 0 and 1)
  62793. * @param factor defines the emit rate value to affect to the specified gradient
  62794. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62795. * @returns the current particle system
  62796. */
  62797. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62798. /**
  62799. * Not supported by GPUParticleSystem
  62800. * @param gradient defines the gradient to remove
  62801. * @returns the current particle system
  62802. */
  62803. removeEmitRateGradient(gradient: number): IParticleSystem;
  62804. /**
  62805. * Not supported by GPUParticleSystem
  62806. * @param gradient defines the gradient to use (between 0 and 1)
  62807. * @param factor defines the start size value to affect to the specified gradient
  62808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62809. * @returns the current particle system
  62810. */
  62811. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62812. /**
  62813. * Not supported by GPUParticleSystem
  62814. * @param gradient defines the gradient to remove
  62815. * @returns the current particle system
  62816. */
  62817. removeStartSizeGradient(gradient: number): IParticleSystem;
  62818. /**
  62819. * Not supported by GPUParticleSystem
  62820. * @param gradient defines the gradient to use (between 0 and 1)
  62821. * @param min defines the color remap minimal range
  62822. * @param max defines the color remap maximal range
  62823. * @returns the current particle system
  62824. */
  62825. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62826. /**
  62827. * Not supported by GPUParticleSystem
  62828. * @param gradient defines the gradient to remove
  62829. * @returns the current particle system
  62830. */
  62831. removeColorRemapGradient(): IParticleSystem;
  62832. /**
  62833. * Not supported by GPUParticleSystem
  62834. * @param gradient defines the gradient to use (between 0 and 1)
  62835. * @param min defines the alpha remap minimal range
  62836. * @param max defines the alpha remap maximal range
  62837. * @returns the current particle system
  62838. */
  62839. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62840. /**
  62841. * Not supported by GPUParticleSystem
  62842. * @param gradient defines the gradient to remove
  62843. * @returns the current particle system
  62844. */
  62845. removeAlphaRemapGradient(): IParticleSystem;
  62846. /**
  62847. * Not supported by GPUParticleSystem
  62848. * @param gradient defines the gradient to use (between 0 and 1)
  62849. * @param color defines the color to affect to the specified gradient
  62850. * @returns the current particle system
  62851. */
  62852. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62853. /**
  62854. * Not supported by GPUParticleSystem
  62855. * @param gradient defines the gradient to remove
  62856. * @returns the current particle system
  62857. */
  62858. removeRampGradient(): IParticleSystem;
  62859. /**
  62860. * Not supported by GPUParticleSystem
  62861. * @returns the list of ramp gradients
  62862. */
  62863. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62864. /**
  62865. * Not supported by GPUParticleSystem
  62866. * Gets or sets a boolean indicating that ramp gradients must be used
  62867. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62868. */
  62869. useRampGradients: boolean;
  62870. /**
  62871. * Not supported by GPUParticleSystem
  62872. * @param gradient defines the gradient to use (between 0 and 1)
  62873. * @param factor defines the life time factor to affect to the specified gradient
  62874. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62875. * @returns the current particle system
  62876. */
  62877. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62878. /**
  62879. * Not supported by GPUParticleSystem
  62880. * @param gradient defines the gradient to remove
  62881. * @returns the current particle system
  62882. */
  62883. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62884. /**
  62885. * Instantiates a GPU particle system.
  62886. * 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.
  62887. * @param name The name of the particle system
  62888. * @param options The options used to create the system
  62889. * @param scene The scene the particle system belongs to
  62890. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62891. */
  62892. constructor(name: string, options: Partial<{
  62893. capacity: number;
  62894. randomTextureSize: number;
  62895. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62896. protected _reset(): void;
  62897. private _createUpdateVAO;
  62898. private _createRenderVAO;
  62899. private _initialize;
  62900. /** @hidden */
  62901. _recreateUpdateEffect(): void;
  62902. /** @hidden */
  62903. _recreateRenderEffect(): void;
  62904. /**
  62905. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62906. * @param preWarm defines if we are in the pre-warmimg phase
  62907. */
  62908. animate(preWarm?: boolean): void;
  62909. private _createFactorGradientTexture;
  62910. private _createSizeGradientTexture;
  62911. private _createAngularSpeedGradientTexture;
  62912. private _createVelocityGradientTexture;
  62913. private _createLimitVelocityGradientTexture;
  62914. private _createDragGradientTexture;
  62915. private _createColorGradientTexture;
  62916. /**
  62917. * Renders the particle system in its current state
  62918. * @param preWarm defines if the system should only update the particles but not render them
  62919. * @returns the current number of particles
  62920. */
  62921. render(preWarm?: boolean): number;
  62922. /**
  62923. * Rebuilds the particle system
  62924. */
  62925. rebuild(): void;
  62926. private _releaseBuffers;
  62927. private _releaseVAOs;
  62928. /**
  62929. * Disposes the particle system and free the associated resources
  62930. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62931. */
  62932. dispose(disposeTexture?: boolean): void;
  62933. /**
  62934. * Clones the particle system.
  62935. * @param name The name of the cloned object
  62936. * @param newEmitter The new emitter to use
  62937. * @returns the cloned particle system
  62938. */
  62939. clone(name: string, newEmitter: any): GPUParticleSystem;
  62940. /**
  62941. * Serializes the particle system to a JSON object.
  62942. * @returns the JSON object
  62943. */
  62944. serialize(): any;
  62945. /**
  62946. * Parses a JSON object to create a GPU particle system.
  62947. * @param parsedParticleSystem The JSON object to parse
  62948. * @param scene The scene to create the particle system in
  62949. * @param rootUrl The root url to use to load external dependencies like texture
  62950. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62951. * @returns the parsed GPU particle system
  62952. */
  62953. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62954. }
  62955. }
  62956. declare module "babylonjs/Particles/particleSystemSet" {
  62957. import { Nullable } from "babylonjs/types";
  62958. import { Color3 } from "babylonjs/Maths/math.color";
  62959. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62961. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62962. import { Scene, IDisposable } from "babylonjs/scene";
  62963. /**
  62964. * Represents a set of particle systems working together to create a specific effect
  62965. */
  62966. export class ParticleSystemSet implements IDisposable {
  62967. /**
  62968. * Gets or sets base Assets URL
  62969. */
  62970. static BaseAssetsUrl: string;
  62971. private _emitterCreationOptions;
  62972. private _emitterNode;
  62973. /**
  62974. * Gets the particle system list
  62975. */
  62976. systems: IParticleSystem[];
  62977. /**
  62978. * Gets the emitter node used with this set
  62979. */
  62980. readonly emitterNode: Nullable<TransformNode>;
  62981. /**
  62982. * Creates a new emitter mesh as a sphere
  62983. * @param options defines the options used to create the sphere
  62984. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62985. * @param scene defines the hosting scene
  62986. */
  62987. setEmitterAsSphere(options: {
  62988. diameter: number;
  62989. segments: number;
  62990. color: Color3;
  62991. }, renderingGroupId: number, scene: Scene): void;
  62992. /**
  62993. * Starts all particle systems of the set
  62994. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62995. */
  62996. start(emitter?: AbstractMesh): void;
  62997. /**
  62998. * Release all associated resources
  62999. */
  63000. dispose(): void;
  63001. /**
  63002. * Serialize the set into a JSON compatible object
  63003. * @returns a JSON compatible representation of the set
  63004. */
  63005. serialize(): any;
  63006. /**
  63007. * Parse a new ParticleSystemSet from a serialized source
  63008. * @param data defines a JSON compatible representation of the set
  63009. * @param scene defines the hosting scene
  63010. * @param gpu defines if we want GPU particles or CPU particles
  63011. * @returns a new ParticleSystemSet
  63012. */
  63013. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63014. }
  63015. }
  63016. declare module "babylonjs/Particles/particleHelper" {
  63017. import { Nullable } from "babylonjs/types";
  63018. import { Scene } from "babylonjs/scene";
  63019. import { Vector3 } from "babylonjs/Maths/math.vector";
  63020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63021. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63022. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  63023. /**
  63024. * This class is made for on one-liner static method to help creating particle system set.
  63025. */
  63026. export class ParticleHelper {
  63027. /**
  63028. * Gets or sets base Assets URL
  63029. */
  63030. static BaseAssetsUrl: string;
  63031. /**
  63032. * Create a default particle system that you can tweak
  63033. * @param emitter defines the emitter to use
  63034. * @param capacity defines the system capacity (default is 500 particles)
  63035. * @param scene defines the hosting scene
  63036. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63037. * @returns the new Particle system
  63038. */
  63039. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63040. /**
  63041. * This is the main static method (one-liner) of this helper to create different particle systems
  63042. * @param type This string represents the type to the particle system to create
  63043. * @param scene The scene where the particle system should live
  63044. * @param gpu If the system will use gpu
  63045. * @returns the ParticleSystemSet created
  63046. */
  63047. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63048. /**
  63049. * Static function used to export a particle system to a ParticleSystemSet variable.
  63050. * Please note that the emitter shape is not exported
  63051. * @param systems defines the particle systems to export
  63052. * @returns the created particle system set
  63053. */
  63054. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63055. }
  63056. }
  63057. declare module "babylonjs/Particles/particleSystemComponent" {
  63058. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63059. import { Effect } from "babylonjs/Materials/effect";
  63060. import "babylonjs/Shaders/particles.vertex";
  63061. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  63062. module "babylonjs/Engines/engine" {
  63063. interface Engine {
  63064. /**
  63065. * Create an effect to use with particle systems.
  63066. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63067. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63068. * @param uniformsNames defines a list of attribute names
  63069. * @param samplers defines an array of string used to represent textures
  63070. * @param defines defines the string containing the defines to use to compile the shaders
  63071. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63072. * @param onCompiled defines a function to call when the effect creation is successful
  63073. * @param onError defines a function to call when the effect creation has failed
  63074. * @returns the new Effect
  63075. */
  63076. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63077. }
  63078. }
  63079. module "babylonjs/Meshes/mesh" {
  63080. interface Mesh {
  63081. /**
  63082. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63083. * @returns an array of IParticleSystem
  63084. */
  63085. getEmittedParticleSystems(): IParticleSystem[];
  63086. /**
  63087. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63088. * @returns an array of IParticleSystem
  63089. */
  63090. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63091. }
  63092. }
  63093. /**
  63094. * @hidden
  63095. */
  63096. export var _IDoNeedToBeInTheBuild: number;
  63097. }
  63098. declare module "babylonjs/Particles/pointsCloudSystem" {
  63099. import { Color4 } from "babylonjs/Maths/math";
  63100. import { Mesh } from "babylonjs/Meshes/mesh";
  63101. import { Scene, IDisposable } from "babylonjs/scene";
  63102. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  63103. /** Defines the 4 color options */
  63104. export enum PointColor {
  63105. /** color value */
  63106. Color = 2,
  63107. /** uv value */
  63108. UV = 1,
  63109. /** random value */
  63110. Random = 0,
  63111. /** stated value */
  63112. Stated = 3
  63113. }
  63114. /**
  63115. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63116. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  63117. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63118. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63119. *
  63120. * Full documentation here : TO BE ENTERED
  63121. */
  63122. export class PointsCloudSystem implements IDisposable {
  63123. /**
  63124. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63125. * Example : var p = SPS.particles[i];
  63126. */
  63127. particles: CloudPoint[];
  63128. /**
  63129. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63130. */
  63131. nbParticles: number;
  63132. /**
  63133. * This a counter for your own usage. It's not set by any SPS functions.
  63134. */
  63135. counter: number;
  63136. /**
  63137. * The PCS name. This name is also given to the underlying mesh.
  63138. */
  63139. name: string;
  63140. /**
  63141. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63142. */
  63143. mesh: Mesh;
  63144. /**
  63145. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63146. * Please read :
  63147. */
  63148. vars: any;
  63149. /**
  63150. * @hidden
  63151. */
  63152. _size: number;
  63153. private _scene;
  63154. private _promises;
  63155. private _positions;
  63156. private _indices;
  63157. private _normals;
  63158. private _colors;
  63159. private _uvs;
  63160. private _indices32;
  63161. private _positions32;
  63162. private _colors32;
  63163. private _uvs32;
  63164. private _updatable;
  63165. private _isVisibilityBoxLocked;
  63166. private _alwaysVisible;
  63167. private _groups;
  63168. private _groupCounter;
  63169. private _computeParticleColor;
  63170. private _computeParticleTexture;
  63171. private _computeParticleRotation;
  63172. private _computeBoundingBox;
  63173. private _isReady;
  63174. /**
  63175. * Creates a PCS (Points Cloud System) object
  63176. * @param name (String) is the PCS name, this will be the underlying mesh name
  63177. * @param pointSize (number) is the size for each point
  63178. * @param scene (Scene) is the scene in which the PCS is added
  63179. * @param options defines the options of the PCS e.g.
  63180. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63181. */
  63182. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63183. updatable?: boolean;
  63184. });
  63185. /**
  63186. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63187. * If no points were added to the PCS, the returned mesh is just a single point.
  63188. * @returns a promise for the created mesh
  63189. */
  63190. buildMeshAsync(): Promise<Mesh>;
  63191. /**
  63192. * @hidden
  63193. */
  63194. private _buildMesh;
  63195. private _addParticle;
  63196. private _randomUnitVector;
  63197. private _getColorIndicesForCoord;
  63198. private _setPointsColorOrUV;
  63199. private _colorFromTexture;
  63200. private _calculateDensity;
  63201. /**
  63202. * Adds points to the PCS in random positions within a unit sphere
  63203. * @param nb (positive integer) the number of particles to be created from this model
  63204. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63205. * @returns the number of groups in the system
  63206. */
  63207. addPoints(nb: number, pointFunction?: any): number;
  63208. /**
  63209. * Adds points to the PCS from the surface of the model shape
  63210. * @param mesh is any Mesh object that will be used as a surface model for the points
  63211. * @param nb (positive integer) the number of particles to be created from this model
  63212. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63213. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63214. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63215. * @returns the number of groups in the system
  63216. */
  63217. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63218. /**
  63219. * Adds points to the PCS inside the model shape
  63220. * @param mesh is any Mesh object that will be used as a surface model for the points
  63221. * @param nb (positive integer) the number of particles to be created from this model
  63222. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63223. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63224. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63225. * @returns the number of groups in the system
  63226. */
  63227. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63228. /**
  63229. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63230. * This method calls `updateParticle()` for each particle of the SPS.
  63231. * For an animated SPS, it is usually called within the render loop.
  63232. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63233. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63234. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63235. * @returns the PCS.
  63236. */
  63237. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63238. /**
  63239. * Disposes the PCS.
  63240. */
  63241. dispose(): void;
  63242. /**
  63243. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63244. * doc :
  63245. * @returns the PCS.
  63246. */
  63247. refreshVisibleSize(): PointsCloudSystem;
  63248. /**
  63249. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63250. * @param size the size (float) of the visibility box
  63251. * note : this doesn't lock the PCS mesh bounding box.
  63252. * doc :
  63253. */
  63254. setVisibilityBox(size: number): void;
  63255. /**
  63256. * Gets whether the PCS is always visible or not
  63257. * doc :
  63258. */
  63259. /**
  63260. * Sets the PCS as always visible or not
  63261. * doc :
  63262. */
  63263. isAlwaysVisible: boolean;
  63264. /**
  63265. * Tells to `setParticles()` to compute the particle rotations or not
  63266. * Default value : false. The PCS is faster when it's set to false
  63267. * Note : particle rotations are only applied to parent particles
  63268. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63269. */
  63270. computeParticleRotation: boolean;
  63271. /**
  63272. * Tells to `setParticles()` to compute the particle colors or not.
  63273. * Default value : true. The PCS is faster when it's set to false.
  63274. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63275. */
  63276. /**
  63277. * Gets if `setParticles()` computes the particle colors or not.
  63278. * Default value : false. The PCS is faster when it's set to false.
  63279. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63280. */
  63281. computeParticleColor: boolean;
  63282. /**
  63283. * Gets if `setParticles()` computes the particle textures or not.
  63284. * Default value : false. The PCS is faster when it's set to false.
  63285. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63286. */
  63287. computeParticleTexture: boolean;
  63288. /**
  63289. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63290. */
  63291. /**
  63292. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63293. */
  63294. computeBoundingBox: boolean;
  63295. /**
  63296. * This function does nothing. It may be overwritten to set all the particle first values.
  63297. * The PCS doesn't call this function, you may have to call it by your own.
  63298. * doc :
  63299. */
  63300. initParticles(): void;
  63301. /**
  63302. * This function does nothing. It may be overwritten to recycle a particle
  63303. * The PCS doesn't call this function, you can to call it
  63304. * doc :
  63305. * @param particle The particle to recycle
  63306. * @returns the recycled particle
  63307. */
  63308. recycleParticle(particle: CloudPoint): CloudPoint;
  63309. /**
  63310. * Updates a particle : this function should be overwritten by the user.
  63311. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63312. * doc :
  63313. * @example : just set a particle position or velocity and recycle conditions
  63314. * @param particle The particle to update
  63315. * @returns the updated particle
  63316. */
  63317. updateParticle(particle: CloudPoint): CloudPoint;
  63318. /**
  63319. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63320. * This does nothing and may be overwritten by the user.
  63321. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63322. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63323. * @param update the boolean update value actually passed to setParticles()
  63324. */
  63325. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63326. /**
  63327. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63328. * This will be passed three parameters.
  63329. * This does nothing and may be overwritten by the user.
  63330. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63331. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63332. * @param update the boolean update value actually passed to setParticles()
  63333. */
  63334. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63335. }
  63336. }
  63337. declare module "babylonjs/Particles/cloudPoint" {
  63338. import { Nullable } from "babylonjs/types";
  63339. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  63340. import { Mesh } from "babylonjs/Meshes/mesh";
  63341. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  63342. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  63343. /**
  63344. * Represents one particle of a points cloud system.
  63345. */
  63346. export class CloudPoint {
  63347. /**
  63348. * particle global index
  63349. */
  63350. idx: number;
  63351. /**
  63352. * The color of the particle
  63353. */
  63354. color: Nullable<Color4>;
  63355. /**
  63356. * The world space position of the particle.
  63357. */
  63358. position: Vector3;
  63359. /**
  63360. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63361. */
  63362. rotation: Vector3;
  63363. /**
  63364. * The world space rotation quaternion of the particle.
  63365. */
  63366. rotationQuaternion: Nullable<Quaternion>;
  63367. /**
  63368. * The uv of the particle.
  63369. */
  63370. uv: Nullable<Vector2>;
  63371. /**
  63372. * The current speed of the particle.
  63373. */
  63374. velocity: Vector3;
  63375. /**
  63376. * The pivot point in the particle local space.
  63377. */
  63378. pivot: Vector3;
  63379. /**
  63380. * Must the particle be translated from its pivot point in its local space ?
  63381. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63382. * Default : false
  63383. */
  63384. translateFromPivot: boolean;
  63385. /**
  63386. * Index of this particle in the global "positions" array (Internal use)
  63387. * @hidden
  63388. */
  63389. _pos: number;
  63390. /**
  63391. * @hidden Index of this particle in the global "indices" array (Internal use)
  63392. */
  63393. _ind: number;
  63394. /**
  63395. * Group this particle belongs to
  63396. */
  63397. _group: PointsGroup;
  63398. /**
  63399. * Group id of this particle
  63400. */
  63401. groupId: number;
  63402. /**
  63403. * Index of the particle in its group id (Internal use)
  63404. */
  63405. idxInGroup: number;
  63406. /**
  63407. * @hidden Particle BoundingInfo object (Internal use)
  63408. */
  63409. _boundingInfo: BoundingInfo;
  63410. /**
  63411. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63412. */
  63413. _pcs: PointsCloudSystem;
  63414. /**
  63415. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63416. */
  63417. _stillInvisible: boolean;
  63418. /**
  63419. * @hidden Last computed particle rotation matrix
  63420. */
  63421. _rotationMatrix: number[];
  63422. /**
  63423. * Parent particle Id, if any.
  63424. * Default null.
  63425. */
  63426. parentId: Nullable<number>;
  63427. /**
  63428. * @hidden Internal global position in the PCS.
  63429. */
  63430. _globalPosition: Vector3;
  63431. /**
  63432. * Creates a Point Cloud object.
  63433. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63434. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63435. * @param group (PointsGroup) is the group the particle belongs to
  63436. * @param groupId (integer) is the group identifier in the PCS.
  63437. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63438. * @param pcs defines the PCS it is associated to
  63439. */
  63440. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63441. /**
  63442. * get point size
  63443. */
  63444. /**
  63445. * Set point size
  63446. */
  63447. size: Vector3;
  63448. /**
  63449. * Legacy support, changed quaternion to rotationQuaternion
  63450. */
  63451. /**
  63452. * Legacy support, changed quaternion to rotationQuaternion
  63453. */
  63454. quaternion: Nullable<Quaternion>;
  63455. /**
  63456. * Returns a boolean. True if the particle intersects a mesh, else false
  63457. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63458. * @param target is the object (point or mesh) what the intersection is computed against
  63459. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63460. * @returns true if it intersects
  63461. */
  63462. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63463. /**
  63464. * get the rotation matrix of the particle
  63465. * @hidden
  63466. */
  63467. getRotationMatrix(m: Matrix): void;
  63468. }
  63469. /**
  63470. * Represents a group of points in a points cloud system
  63471. * * PCS internal tool, don't use it manually.
  63472. */
  63473. export class PointsGroup {
  63474. /**
  63475. * The group id
  63476. * @hidden
  63477. */
  63478. groupID: number;
  63479. /**
  63480. * image data for group (internal use)
  63481. * @hidden
  63482. */
  63483. _groupImageData: Nullable<ArrayBufferView>;
  63484. /**
  63485. * Image Width (internal use)
  63486. * @hidden
  63487. */
  63488. _groupImgWidth: number;
  63489. /**
  63490. * Image Height (internal use)
  63491. * @hidden
  63492. */
  63493. _groupImgHeight: number;
  63494. /**
  63495. * Custom position function (internal use)
  63496. * @hidden
  63497. */
  63498. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63499. /**
  63500. * density per facet for surface points
  63501. * @hidden
  63502. */
  63503. _groupDensity: number[];
  63504. /**
  63505. * Only when points are colored by texture carries pointer to texture list array
  63506. * @hidden
  63507. */
  63508. _textureNb: number;
  63509. /**
  63510. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63511. * PCS internal tool, don't use it manually.
  63512. * @hidden
  63513. */
  63514. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63515. }
  63516. }
  63517. declare module "babylonjs/Particles/index" {
  63518. export * from "babylonjs/Particles/baseParticleSystem";
  63519. export * from "babylonjs/Particles/EmitterTypes/index";
  63520. export * from "babylonjs/Particles/gpuParticleSystem";
  63521. export * from "babylonjs/Particles/IParticleSystem";
  63522. export * from "babylonjs/Particles/particle";
  63523. export * from "babylonjs/Particles/particleHelper";
  63524. export * from "babylonjs/Particles/particleSystem";
  63525. export * from "babylonjs/Particles/particleSystemComponent";
  63526. export * from "babylonjs/Particles/particleSystemSet";
  63527. export * from "babylonjs/Particles/solidParticle";
  63528. export * from "babylonjs/Particles/solidParticleSystem";
  63529. export * from "babylonjs/Particles/cloudPoint";
  63530. export * from "babylonjs/Particles/pointsCloudSystem";
  63531. export * from "babylonjs/Particles/subEmitter";
  63532. }
  63533. declare module "babylonjs/Physics/physicsEngineComponent" {
  63534. import { Nullable } from "babylonjs/types";
  63535. import { Observable, Observer } from "babylonjs/Misc/observable";
  63536. import { Vector3 } from "babylonjs/Maths/math.vector";
  63537. import { Mesh } from "babylonjs/Meshes/mesh";
  63538. import { ISceneComponent } from "babylonjs/sceneComponent";
  63539. import { Scene } from "babylonjs/scene";
  63540. import { Node } from "babylonjs/node";
  63541. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63542. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63543. module "babylonjs/scene" {
  63544. interface Scene {
  63545. /** @hidden (Backing field) */
  63546. _physicsEngine: Nullable<IPhysicsEngine>;
  63547. /** @hidden */
  63548. _physicsTimeAccumulator: number;
  63549. /**
  63550. * Gets the current physics engine
  63551. * @returns a IPhysicsEngine or null if none attached
  63552. */
  63553. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63554. /**
  63555. * Enables physics to the current scene
  63556. * @param gravity defines the scene's gravity for the physics engine
  63557. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63558. * @return a boolean indicating if the physics engine was initialized
  63559. */
  63560. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63561. /**
  63562. * Disables and disposes the physics engine associated with the scene
  63563. */
  63564. disablePhysicsEngine(): void;
  63565. /**
  63566. * Gets a boolean indicating if there is an active physics engine
  63567. * @returns a boolean indicating if there is an active physics engine
  63568. */
  63569. isPhysicsEnabled(): boolean;
  63570. /**
  63571. * Deletes a physics compound impostor
  63572. * @param compound defines the compound to delete
  63573. */
  63574. deleteCompoundImpostor(compound: any): void;
  63575. /**
  63576. * An event triggered when physic simulation is about to be run
  63577. */
  63578. onBeforePhysicsObservable: Observable<Scene>;
  63579. /**
  63580. * An event triggered when physic simulation has been done
  63581. */
  63582. onAfterPhysicsObservable: Observable<Scene>;
  63583. }
  63584. }
  63585. module "babylonjs/Meshes/abstractMesh" {
  63586. interface AbstractMesh {
  63587. /** @hidden */
  63588. _physicsImpostor: Nullable<PhysicsImpostor>;
  63589. /**
  63590. * Gets or sets impostor used for physic simulation
  63591. * @see http://doc.babylonjs.com/features/physics_engine
  63592. */
  63593. physicsImpostor: Nullable<PhysicsImpostor>;
  63594. /**
  63595. * Gets the current physics impostor
  63596. * @see http://doc.babylonjs.com/features/physics_engine
  63597. * @returns a physics impostor or null
  63598. */
  63599. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63600. /** Apply a physic impulse to the mesh
  63601. * @param force defines the force to apply
  63602. * @param contactPoint defines where to apply the force
  63603. * @returns the current mesh
  63604. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63605. */
  63606. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63607. /**
  63608. * Creates a physic joint between two meshes
  63609. * @param otherMesh defines the other mesh to use
  63610. * @param pivot1 defines the pivot to use on this mesh
  63611. * @param pivot2 defines the pivot to use on the other mesh
  63612. * @param options defines additional options (can be plugin dependent)
  63613. * @returns the current mesh
  63614. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63615. */
  63616. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63617. /** @hidden */
  63618. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63619. }
  63620. }
  63621. /**
  63622. * Defines the physics engine scene component responsible to manage a physics engine
  63623. */
  63624. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63625. /**
  63626. * The component name helpful to identify the component in the list of scene components.
  63627. */
  63628. readonly name: string;
  63629. /**
  63630. * The scene the component belongs to.
  63631. */
  63632. scene: Scene;
  63633. /**
  63634. * Creates a new instance of the component for the given scene
  63635. * @param scene Defines the scene to register the component in
  63636. */
  63637. constructor(scene: Scene);
  63638. /**
  63639. * Registers the component in a given scene
  63640. */
  63641. register(): void;
  63642. /**
  63643. * Rebuilds the elements related to this component in case of
  63644. * context lost for instance.
  63645. */
  63646. rebuild(): void;
  63647. /**
  63648. * Disposes the component and the associated ressources
  63649. */
  63650. dispose(): void;
  63651. }
  63652. }
  63653. declare module "babylonjs/Physics/physicsHelper" {
  63654. import { Nullable } from "babylonjs/types";
  63655. import { Vector3 } from "babylonjs/Maths/math.vector";
  63656. import { Mesh } from "babylonjs/Meshes/mesh";
  63657. import { Scene } from "babylonjs/scene";
  63658. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63659. /**
  63660. * A helper for physics simulations
  63661. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63662. */
  63663. export class PhysicsHelper {
  63664. private _scene;
  63665. private _physicsEngine;
  63666. /**
  63667. * Initializes the Physics helper
  63668. * @param scene Babylon.js scene
  63669. */
  63670. constructor(scene: Scene);
  63671. /**
  63672. * Applies a radial explosion impulse
  63673. * @param origin the origin of the explosion
  63674. * @param radiusOrEventOptions the radius or the options of radial explosion
  63675. * @param strength the explosion strength
  63676. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63677. * @returns A physics radial explosion event, or null
  63678. */
  63679. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63680. /**
  63681. * Applies a radial explosion force
  63682. * @param origin the origin of the explosion
  63683. * @param radiusOrEventOptions the radius or the options of radial explosion
  63684. * @param strength the explosion strength
  63685. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63686. * @returns A physics radial explosion event, or null
  63687. */
  63688. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63689. /**
  63690. * Creates a gravitational field
  63691. * @param origin the origin of the explosion
  63692. * @param radiusOrEventOptions the radius or the options of radial explosion
  63693. * @param strength the explosion strength
  63694. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63695. * @returns A physics gravitational field event, or null
  63696. */
  63697. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63698. /**
  63699. * Creates a physics updraft event
  63700. * @param origin the origin of the updraft
  63701. * @param radiusOrEventOptions the radius or the options of the updraft
  63702. * @param strength the strength of the updraft
  63703. * @param height the height of the updraft
  63704. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63705. * @returns A physics updraft event, or null
  63706. */
  63707. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63708. /**
  63709. * Creates a physics vortex event
  63710. * @param origin the of the vortex
  63711. * @param radiusOrEventOptions the radius or the options of the vortex
  63712. * @param strength the strength of the vortex
  63713. * @param height the height of the vortex
  63714. * @returns a Physics vortex event, or null
  63715. * A physics vortex event or null
  63716. */
  63717. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63718. }
  63719. /**
  63720. * Represents a physics radial explosion event
  63721. */
  63722. class PhysicsRadialExplosionEvent {
  63723. private _scene;
  63724. private _options;
  63725. private _sphere;
  63726. private _dataFetched;
  63727. /**
  63728. * Initializes a radial explosioin event
  63729. * @param _scene BabylonJS scene
  63730. * @param _options The options for the vortex event
  63731. */
  63732. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63733. /**
  63734. * Returns the data related to the radial explosion event (sphere).
  63735. * @returns The radial explosion event data
  63736. */
  63737. getData(): PhysicsRadialExplosionEventData;
  63738. /**
  63739. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63740. * @param impostor A physics imposter
  63741. * @param origin the origin of the explosion
  63742. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63743. */
  63744. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63745. /**
  63746. * Triggers affecterd impostors callbacks
  63747. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63748. */
  63749. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63750. /**
  63751. * Disposes the sphere.
  63752. * @param force Specifies if the sphere should be disposed by force
  63753. */
  63754. dispose(force?: boolean): void;
  63755. /*** Helpers ***/
  63756. private _prepareSphere;
  63757. private _intersectsWithSphere;
  63758. }
  63759. /**
  63760. * Represents a gravitational field event
  63761. */
  63762. class PhysicsGravitationalFieldEvent {
  63763. private _physicsHelper;
  63764. private _scene;
  63765. private _origin;
  63766. private _options;
  63767. private _tickCallback;
  63768. private _sphere;
  63769. private _dataFetched;
  63770. /**
  63771. * Initializes the physics gravitational field event
  63772. * @param _physicsHelper A physics helper
  63773. * @param _scene BabylonJS scene
  63774. * @param _origin The origin position of the gravitational field event
  63775. * @param _options The options for the vortex event
  63776. */
  63777. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63778. /**
  63779. * Returns the data related to the gravitational field event (sphere).
  63780. * @returns A gravitational field event
  63781. */
  63782. getData(): PhysicsGravitationalFieldEventData;
  63783. /**
  63784. * Enables the gravitational field.
  63785. */
  63786. enable(): void;
  63787. /**
  63788. * Disables the gravitational field.
  63789. */
  63790. disable(): void;
  63791. /**
  63792. * Disposes the sphere.
  63793. * @param force The force to dispose from the gravitational field event
  63794. */
  63795. dispose(force?: boolean): void;
  63796. private _tick;
  63797. }
  63798. /**
  63799. * Represents a physics updraft event
  63800. */
  63801. class PhysicsUpdraftEvent {
  63802. private _scene;
  63803. private _origin;
  63804. private _options;
  63805. private _physicsEngine;
  63806. private _originTop;
  63807. private _originDirection;
  63808. private _tickCallback;
  63809. private _cylinder;
  63810. private _cylinderPosition;
  63811. private _dataFetched;
  63812. /**
  63813. * Initializes the physics updraft event
  63814. * @param _scene BabylonJS scene
  63815. * @param _origin The origin position of the updraft
  63816. * @param _options The options for the updraft event
  63817. */
  63818. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63819. /**
  63820. * Returns the data related to the updraft event (cylinder).
  63821. * @returns A physics updraft event
  63822. */
  63823. getData(): PhysicsUpdraftEventData;
  63824. /**
  63825. * Enables the updraft.
  63826. */
  63827. enable(): void;
  63828. /**
  63829. * Disables the updraft.
  63830. */
  63831. disable(): void;
  63832. /**
  63833. * Disposes the cylinder.
  63834. * @param force Specifies if the updraft should be disposed by force
  63835. */
  63836. dispose(force?: boolean): void;
  63837. private getImpostorHitData;
  63838. private _tick;
  63839. /*** Helpers ***/
  63840. private _prepareCylinder;
  63841. private _intersectsWithCylinder;
  63842. }
  63843. /**
  63844. * Represents a physics vortex event
  63845. */
  63846. class PhysicsVortexEvent {
  63847. private _scene;
  63848. private _origin;
  63849. private _options;
  63850. private _physicsEngine;
  63851. private _originTop;
  63852. private _tickCallback;
  63853. private _cylinder;
  63854. private _cylinderPosition;
  63855. private _dataFetched;
  63856. /**
  63857. * Initializes the physics vortex event
  63858. * @param _scene The BabylonJS scene
  63859. * @param _origin The origin position of the vortex
  63860. * @param _options The options for the vortex event
  63861. */
  63862. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63863. /**
  63864. * Returns the data related to the vortex event (cylinder).
  63865. * @returns The physics vortex event data
  63866. */
  63867. getData(): PhysicsVortexEventData;
  63868. /**
  63869. * Enables the vortex.
  63870. */
  63871. enable(): void;
  63872. /**
  63873. * Disables the cortex.
  63874. */
  63875. disable(): void;
  63876. /**
  63877. * Disposes the sphere.
  63878. * @param force
  63879. */
  63880. dispose(force?: boolean): void;
  63881. private getImpostorHitData;
  63882. private _tick;
  63883. /*** Helpers ***/
  63884. private _prepareCylinder;
  63885. private _intersectsWithCylinder;
  63886. }
  63887. /**
  63888. * Options fot the radial explosion event
  63889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63890. */
  63891. export class PhysicsRadialExplosionEventOptions {
  63892. /**
  63893. * The radius of the sphere for the radial explosion.
  63894. */
  63895. radius: number;
  63896. /**
  63897. * The strenth of the explosion.
  63898. */
  63899. strength: number;
  63900. /**
  63901. * The strenght of the force in correspondence to the distance of the affected object
  63902. */
  63903. falloff: PhysicsRadialImpulseFalloff;
  63904. /**
  63905. * Sphere options for the radial explosion.
  63906. */
  63907. sphere: {
  63908. segments: number;
  63909. diameter: number;
  63910. };
  63911. /**
  63912. * Sphere options for the radial explosion.
  63913. */
  63914. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63915. }
  63916. /**
  63917. * Options fot the updraft event
  63918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63919. */
  63920. export class PhysicsUpdraftEventOptions {
  63921. /**
  63922. * The radius of the cylinder for the vortex
  63923. */
  63924. radius: number;
  63925. /**
  63926. * The strenth of the updraft.
  63927. */
  63928. strength: number;
  63929. /**
  63930. * The height of the cylinder for the updraft.
  63931. */
  63932. height: number;
  63933. /**
  63934. * The mode for the the updraft.
  63935. */
  63936. updraftMode: PhysicsUpdraftMode;
  63937. }
  63938. /**
  63939. * Options fot the vortex event
  63940. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63941. */
  63942. export class PhysicsVortexEventOptions {
  63943. /**
  63944. * The radius of the cylinder for the vortex
  63945. */
  63946. radius: number;
  63947. /**
  63948. * The strenth of the vortex.
  63949. */
  63950. strength: number;
  63951. /**
  63952. * The height of the cylinder for the vortex.
  63953. */
  63954. height: number;
  63955. /**
  63956. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63957. */
  63958. centripetalForceThreshold: number;
  63959. /**
  63960. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63961. */
  63962. centripetalForceMultiplier: number;
  63963. /**
  63964. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63965. */
  63966. centrifugalForceMultiplier: number;
  63967. /**
  63968. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63969. */
  63970. updraftForceMultiplier: number;
  63971. }
  63972. /**
  63973. * The strenght of the force in correspondence to the distance of the affected object
  63974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63975. */
  63976. export enum PhysicsRadialImpulseFalloff {
  63977. /** Defines that impulse is constant in strength across it's whole radius */
  63978. Constant = 0,
  63979. /** Defines that impulse gets weaker if it's further from the origin */
  63980. Linear = 1
  63981. }
  63982. /**
  63983. * The strength of the force in correspondence to the distance of the affected object
  63984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63985. */
  63986. export enum PhysicsUpdraftMode {
  63987. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63988. Center = 0,
  63989. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63990. Perpendicular = 1
  63991. }
  63992. /**
  63993. * Interface for a physics hit data
  63994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63995. */
  63996. export interface PhysicsHitData {
  63997. /**
  63998. * The force applied at the contact point
  63999. */
  64000. force: Vector3;
  64001. /**
  64002. * The contact point
  64003. */
  64004. contactPoint: Vector3;
  64005. /**
  64006. * The distance from the origin to the contact point
  64007. */
  64008. distanceFromOrigin: number;
  64009. }
  64010. /**
  64011. * Interface for radial explosion event data
  64012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64013. */
  64014. export interface PhysicsRadialExplosionEventData {
  64015. /**
  64016. * A sphere used for the radial explosion event
  64017. */
  64018. sphere: Mesh;
  64019. }
  64020. /**
  64021. * Interface for gravitational field event data
  64022. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64023. */
  64024. export interface PhysicsGravitationalFieldEventData {
  64025. /**
  64026. * A sphere mesh used for the gravitational field event
  64027. */
  64028. sphere: Mesh;
  64029. }
  64030. /**
  64031. * Interface for updraft event data
  64032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64033. */
  64034. export interface PhysicsUpdraftEventData {
  64035. /**
  64036. * A cylinder used for the updraft event
  64037. */
  64038. cylinder: Mesh;
  64039. }
  64040. /**
  64041. * Interface for vortex event data
  64042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64043. */
  64044. export interface PhysicsVortexEventData {
  64045. /**
  64046. * A cylinder used for the vortex event
  64047. */
  64048. cylinder: Mesh;
  64049. }
  64050. /**
  64051. * Interface for an affected physics impostor
  64052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64053. */
  64054. export interface PhysicsAffectedImpostorWithData {
  64055. /**
  64056. * The impostor affected by the effect
  64057. */
  64058. impostor: PhysicsImpostor;
  64059. /**
  64060. * The data about the hit/horce from the explosion
  64061. */
  64062. hitData: PhysicsHitData;
  64063. }
  64064. }
  64065. declare module "babylonjs/Physics/Plugins/index" {
  64066. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  64067. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  64068. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  64069. }
  64070. declare module "babylonjs/Physics/index" {
  64071. export * from "babylonjs/Physics/IPhysicsEngine";
  64072. export * from "babylonjs/Physics/physicsEngine";
  64073. export * from "babylonjs/Physics/physicsEngineComponent";
  64074. export * from "babylonjs/Physics/physicsHelper";
  64075. export * from "babylonjs/Physics/physicsImpostor";
  64076. export * from "babylonjs/Physics/physicsJoint";
  64077. export * from "babylonjs/Physics/Plugins/index";
  64078. }
  64079. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  64080. /** @hidden */
  64081. export var blackAndWhitePixelShader: {
  64082. name: string;
  64083. shader: string;
  64084. };
  64085. }
  64086. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  64087. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64088. import { Camera } from "babylonjs/Cameras/camera";
  64089. import { Engine } from "babylonjs/Engines/engine";
  64090. import "babylonjs/Shaders/blackAndWhite.fragment";
  64091. /**
  64092. * Post process used to render in black and white
  64093. */
  64094. export class BlackAndWhitePostProcess extends PostProcess {
  64095. /**
  64096. * Linear about to convert he result to black and white (default: 1)
  64097. */
  64098. degree: number;
  64099. /**
  64100. * Creates a black and white post process
  64101. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64102. * @param name The name of the effect.
  64103. * @param options The required width/height ratio to downsize to before computing the render pass.
  64104. * @param camera The camera to apply the render pass to.
  64105. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64106. * @param engine The engine which the post process will be applied. (default: current engine)
  64107. * @param reusable If the post process can be reused on the same frame. (default: false)
  64108. */
  64109. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64110. }
  64111. }
  64112. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  64113. import { Nullable } from "babylonjs/types";
  64114. import { Camera } from "babylonjs/Cameras/camera";
  64115. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64116. import { Engine } from "babylonjs/Engines/engine";
  64117. /**
  64118. * This represents a set of one or more post processes in Babylon.
  64119. * A post process can be used to apply a shader to a texture after it is rendered.
  64120. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64121. */
  64122. export class PostProcessRenderEffect {
  64123. private _postProcesses;
  64124. private _getPostProcesses;
  64125. private _singleInstance;
  64126. private _cameras;
  64127. private _indicesForCamera;
  64128. /**
  64129. * Name of the effect
  64130. * @hidden
  64131. */
  64132. _name: string;
  64133. /**
  64134. * Instantiates a post process render effect.
  64135. * A post process can be used to apply a shader to a texture after it is rendered.
  64136. * @param engine The engine the effect is tied to
  64137. * @param name The name of the effect
  64138. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64139. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64140. */
  64141. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64142. /**
  64143. * Checks if all the post processes in the effect are supported.
  64144. */
  64145. readonly isSupported: boolean;
  64146. /**
  64147. * Updates the current state of the effect
  64148. * @hidden
  64149. */
  64150. _update(): void;
  64151. /**
  64152. * Attaches the effect on cameras
  64153. * @param cameras The camera to attach to.
  64154. * @hidden
  64155. */
  64156. _attachCameras(cameras: Camera): void;
  64157. /**
  64158. * Attaches the effect on cameras
  64159. * @param cameras The camera to attach to.
  64160. * @hidden
  64161. */
  64162. _attachCameras(cameras: Camera[]): void;
  64163. /**
  64164. * Detaches the effect on cameras
  64165. * @param cameras The camera to detatch from.
  64166. * @hidden
  64167. */
  64168. _detachCameras(cameras: Camera): void;
  64169. /**
  64170. * Detatches the effect on cameras
  64171. * @param cameras The camera to detatch from.
  64172. * @hidden
  64173. */
  64174. _detachCameras(cameras: Camera[]): void;
  64175. /**
  64176. * Enables the effect on given cameras
  64177. * @param cameras The camera to enable.
  64178. * @hidden
  64179. */
  64180. _enable(cameras: Camera): void;
  64181. /**
  64182. * Enables the effect on given cameras
  64183. * @param cameras The camera to enable.
  64184. * @hidden
  64185. */
  64186. _enable(cameras: Nullable<Camera[]>): void;
  64187. /**
  64188. * Disables the effect on the given cameras
  64189. * @param cameras The camera to disable.
  64190. * @hidden
  64191. */
  64192. _disable(cameras: Camera): void;
  64193. /**
  64194. * Disables the effect on the given cameras
  64195. * @param cameras The camera to disable.
  64196. * @hidden
  64197. */
  64198. _disable(cameras: Nullable<Camera[]>): void;
  64199. /**
  64200. * Gets a list of the post processes contained in the effect.
  64201. * @param camera The camera to get the post processes on.
  64202. * @returns The list of the post processes in the effect.
  64203. */
  64204. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64205. }
  64206. }
  64207. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  64208. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64209. /** @hidden */
  64210. export var extractHighlightsPixelShader: {
  64211. name: string;
  64212. shader: string;
  64213. };
  64214. }
  64215. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  64216. import { Nullable } from "babylonjs/types";
  64217. import { Camera } from "babylonjs/Cameras/camera";
  64218. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64219. import { Engine } from "babylonjs/Engines/engine";
  64220. import "babylonjs/Shaders/extractHighlights.fragment";
  64221. /**
  64222. * 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.
  64223. */
  64224. export class ExtractHighlightsPostProcess extends PostProcess {
  64225. /**
  64226. * The luminance threshold, pixels below this value will be set to black.
  64227. */
  64228. threshold: number;
  64229. /** @hidden */
  64230. _exposure: number;
  64231. /**
  64232. * Post process which has the input texture to be used when performing highlight extraction
  64233. * @hidden
  64234. */
  64235. _inputPostProcess: Nullable<PostProcess>;
  64236. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64237. }
  64238. }
  64239. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  64240. /** @hidden */
  64241. export var bloomMergePixelShader: {
  64242. name: string;
  64243. shader: string;
  64244. };
  64245. }
  64246. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  64247. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64248. import { Nullable } from "babylonjs/types";
  64249. import { Engine } from "babylonjs/Engines/engine";
  64250. import { Camera } from "babylonjs/Cameras/camera";
  64251. import "babylonjs/Shaders/bloomMerge.fragment";
  64252. /**
  64253. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64254. */
  64255. export class BloomMergePostProcess extends PostProcess {
  64256. /** Weight of the bloom to be added to the original input. */
  64257. weight: number;
  64258. /**
  64259. * Creates a new instance of @see BloomMergePostProcess
  64260. * @param name The name of the effect.
  64261. * @param originalFromInput Post process which's input will be used for the merge.
  64262. * @param blurred Blurred highlights post process which's output will be used.
  64263. * @param weight Weight of the bloom to be added to the original input.
  64264. * @param options The required width/height ratio to downsize to before computing the render pass.
  64265. * @param camera The camera to apply the render pass to.
  64266. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64267. * @param engine The engine which the post process will be applied. (default: current engine)
  64268. * @param reusable If the post process can be reused on the same frame. (default: false)
  64269. * @param textureType Type of textures used when performing the post process. (default: 0)
  64270. * @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)
  64271. */
  64272. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64273. /** Weight of the bloom to be added to the original input. */
  64274. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64275. }
  64276. }
  64277. declare module "babylonjs/PostProcesses/bloomEffect" {
  64278. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64279. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64280. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  64281. import { Camera } from "babylonjs/Cameras/camera";
  64282. import { Scene } from "babylonjs/scene";
  64283. /**
  64284. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64285. */
  64286. export class BloomEffect extends PostProcessRenderEffect {
  64287. private bloomScale;
  64288. /**
  64289. * @hidden Internal
  64290. */
  64291. _effects: Array<PostProcess>;
  64292. /**
  64293. * @hidden Internal
  64294. */
  64295. _downscale: ExtractHighlightsPostProcess;
  64296. private _blurX;
  64297. private _blurY;
  64298. private _merge;
  64299. /**
  64300. * The luminance threshold to find bright areas of the image to bloom.
  64301. */
  64302. threshold: number;
  64303. /**
  64304. * The strength of the bloom.
  64305. */
  64306. weight: number;
  64307. /**
  64308. * Specifies the size of the bloom blur kernel, relative to the final output size
  64309. */
  64310. kernel: number;
  64311. /**
  64312. * Creates a new instance of @see BloomEffect
  64313. * @param scene The scene the effect belongs to.
  64314. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64315. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64316. * @param bloomWeight The the strength of bloom.
  64317. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64318. * @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)
  64319. */
  64320. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64321. /**
  64322. * Disposes each of the internal effects for a given camera.
  64323. * @param camera The camera to dispose the effect on.
  64324. */
  64325. disposeEffects(camera: Camera): void;
  64326. /**
  64327. * @hidden Internal
  64328. */
  64329. _updateEffects(): void;
  64330. /**
  64331. * Internal
  64332. * @returns if all the contained post processes are ready.
  64333. * @hidden
  64334. */
  64335. _isReady(): boolean;
  64336. }
  64337. }
  64338. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  64339. /** @hidden */
  64340. export var chromaticAberrationPixelShader: {
  64341. name: string;
  64342. shader: string;
  64343. };
  64344. }
  64345. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  64346. import { Vector2 } from "babylonjs/Maths/math.vector";
  64347. import { Nullable } from "babylonjs/types";
  64348. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64349. import { Camera } from "babylonjs/Cameras/camera";
  64350. import { Engine } from "babylonjs/Engines/engine";
  64351. import "babylonjs/Shaders/chromaticAberration.fragment";
  64352. /**
  64353. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64354. */
  64355. export class ChromaticAberrationPostProcess extends PostProcess {
  64356. /**
  64357. * The amount of seperation of rgb channels (default: 30)
  64358. */
  64359. aberrationAmount: number;
  64360. /**
  64361. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64362. */
  64363. radialIntensity: number;
  64364. /**
  64365. * 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))
  64366. */
  64367. direction: Vector2;
  64368. /**
  64369. * 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))
  64370. */
  64371. centerPosition: Vector2;
  64372. /**
  64373. * Creates a new instance ChromaticAberrationPostProcess
  64374. * @param name The name of the effect.
  64375. * @param screenWidth The width of the screen to apply the effect on.
  64376. * @param screenHeight The height of the screen to apply the effect on.
  64377. * @param options The required width/height ratio to downsize to before computing the render pass.
  64378. * @param camera The camera to apply the render pass to.
  64379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64380. * @param engine The engine which the post process will be applied. (default: current engine)
  64381. * @param reusable If the post process can be reused on the same frame. (default: false)
  64382. * @param textureType Type of textures used when performing the post process. (default: 0)
  64383. * @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)
  64384. */
  64385. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64386. }
  64387. }
  64388. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  64389. /** @hidden */
  64390. export var circleOfConfusionPixelShader: {
  64391. name: string;
  64392. shader: string;
  64393. };
  64394. }
  64395. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  64396. import { Nullable } from "babylonjs/types";
  64397. import { Engine } from "babylonjs/Engines/engine";
  64398. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64399. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64400. import { Camera } from "babylonjs/Cameras/camera";
  64401. import "babylonjs/Shaders/circleOfConfusion.fragment";
  64402. /**
  64403. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64404. */
  64405. export class CircleOfConfusionPostProcess extends PostProcess {
  64406. /**
  64407. * 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.
  64408. */
  64409. lensSize: number;
  64410. /**
  64411. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64412. */
  64413. fStop: number;
  64414. /**
  64415. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64416. */
  64417. focusDistance: number;
  64418. /**
  64419. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64420. */
  64421. focalLength: number;
  64422. private _depthTexture;
  64423. /**
  64424. * Creates a new instance CircleOfConfusionPostProcess
  64425. * @param name The name of the effect.
  64426. * @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.
  64427. * @param options The required width/height ratio to downsize to before computing the render pass.
  64428. * @param camera The camera to apply the render pass to.
  64429. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64430. * @param engine The engine which the post process will be applied. (default: current engine)
  64431. * @param reusable If the post process can be reused on the same frame. (default: false)
  64432. * @param textureType Type of textures used when performing the post process. (default: 0)
  64433. * @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)
  64434. */
  64435. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64436. /**
  64437. * 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.
  64438. */
  64439. depthTexture: RenderTargetTexture;
  64440. }
  64441. }
  64442. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  64443. /** @hidden */
  64444. export var colorCorrectionPixelShader: {
  64445. name: string;
  64446. shader: string;
  64447. };
  64448. }
  64449. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  64450. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64451. import { Engine } from "babylonjs/Engines/engine";
  64452. import { Camera } from "babylonjs/Cameras/camera";
  64453. import "babylonjs/Shaders/colorCorrection.fragment";
  64454. /**
  64455. *
  64456. * This post-process allows the modification of rendered colors by using
  64457. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64458. *
  64459. * The object needs to be provided an url to a texture containing the color
  64460. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64461. * Use an image editing software to tweak the LUT to match your needs.
  64462. *
  64463. * For an example of a color LUT, see here:
  64464. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64465. * For explanations on color grading, see here:
  64466. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64467. *
  64468. */
  64469. export class ColorCorrectionPostProcess extends PostProcess {
  64470. private _colorTableTexture;
  64471. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64472. }
  64473. }
  64474. declare module "babylonjs/Shaders/convolution.fragment" {
  64475. /** @hidden */
  64476. export var convolutionPixelShader: {
  64477. name: string;
  64478. shader: string;
  64479. };
  64480. }
  64481. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  64482. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64483. import { Nullable } from "babylonjs/types";
  64484. import { Camera } from "babylonjs/Cameras/camera";
  64485. import { Engine } from "babylonjs/Engines/engine";
  64486. import "babylonjs/Shaders/convolution.fragment";
  64487. /**
  64488. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64489. * input texture to perform effects such as edge detection or sharpening
  64490. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64491. */
  64492. export class ConvolutionPostProcess extends PostProcess {
  64493. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64494. kernel: number[];
  64495. /**
  64496. * Creates a new instance ConvolutionPostProcess
  64497. * @param name The name of the effect.
  64498. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64499. * @param options The required width/height ratio to downsize to before computing the render pass.
  64500. * @param camera The camera to apply the render pass to.
  64501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64502. * @param engine The engine which the post process will be applied. (default: current engine)
  64503. * @param reusable If the post process can be reused on the same frame. (default: false)
  64504. * @param textureType Type of textures used when performing the post process. (default: 0)
  64505. */
  64506. constructor(name: string,
  64507. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64508. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64509. /**
  64510. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64511. */
  64512. static EdgeDetect0Kernel: number[];
  64513. /**
  64514. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64515. */
  64516. static EdgeDetect1Kernel: number[];
  64517. /**
  64518. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64519. */
  64520. static EdgeDetect2Kernel: number[];
  64521. /**
  64522. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64523. */
  64524. static SharpenKernel: number[];
  64525. /**
  64526. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64527. */
  64528. static EmbossKernel: number[];
  64529. /**
  64530. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64531. */
  64532. static GaussianKernel: number[];
  64533. }
  64534. }
  64535. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  64536. import { Nullable } from "babylonjs/types";
  64537. import { Vector2 } from "babylonjs/Maths/math.vector";
  64538. import { Camera } from "babylonjs/Cameras/camera";
  64539. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64540. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  64541. import { Engine } from "babylonjs/Engines/engine";
  64542. import { Scene } from "babylonjs/scene";
  64543. /**
  64544. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64545. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64546. * based on samples that have a large difference in distance than the center pixel.
  64547. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64548. */
  64549. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64550. direction: Vector2;
  64551. /**
  64552. * Creates a new instance CircleOfConfusionPostProcess
  64553. * @param name The name of the effect.
  64554. * @param scene The scene the effect belongs to.
  64555. * @param direction The direction the blur should be applied.
  64556. * @param kernel The size of the kernel used to blur.
  64557. * @param options The required width/height ratio to downsize to before computing the render pass.
  64558. * @param camera The camera to apply the render pass to.
  64559. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64560. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64561. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64562. * @param engine The engine which the post process will be applied. (default: current engine)
  64563. * @param reusable If the post process can be reused on the same frame. (default: false)
  64564. * @param textureType Type of textures used when performing the post process. (default: 0)
  64565. * @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)
  64566. */
  64567. 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);
  64568. }
  64569. }
  64570. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  64571. /** @hidden */
  64572. export var depthOfFieldMergePixelShader: {
  64573. name: string;
  64574. shader: string;
  64575. };
  64576. }
  64577. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  64578. import { Nullable } from "babylonjs/types";
  64579. import { Camera } from "babylonjs/Cameras/camera";
  64580. import { Effect } from "babylonjs/Materials/effect";
  64581. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64582. import { Engine } from "babylonjs/Engines/engine";
  64583. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  64584. /**
  64585. * Options to be set when merging outputs from the default pipeline.
  64586. */
  64587. export class DepthOfFieldMergePostProcessOptions {
  64588. /**
  64589. * The original image to merge on top of
  64590. */
  64591. originalFromInput: PostProcess;
  64592. /**
  64593. * Parameters to perform the merge of the depth of field effect
  64594. */
  64595. depthOfField?: {
  64596. circleOfConfusion: PostProcess;
  64597. blurSteps: Array<PostProcess>;
  64598. };
  64599. /**
  64600. * Parameters to perform the merge of bloom effect
  64601. */
  64602. bloom?: {
  64603. blurred: PostProcess;
  64604. weight: number;
  64605. };
  64606. }
  64607. /**
  64608. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64609. */
  64610. export class DepthOfFieldMergePostProcess extends PostProcess {
  64611. private blurSteps;
  64612. /**
  64613. * Creates a new instance of DepthOfFieldMergePostProcess
  64614. * @param name The name of the effect.
  64615. * @param originalFromInput Post process which's input will be used for the merge.
  64616. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64617. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64618. * @param options The required width/height ratio to downsize to before computing the render pass.
  64619. * @param camera The camera to apply the render pass to.
  64620. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64621. * @param engine The engine which the post process will be applied. (default: current engine)
  64622. * @param reusable If the post process can be reused on the same frame. (default: false)
  64623. * @param textureType Type of textures used when performing the post process. (default: 0)
  64624. * @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)
  64625. */
  64626. 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);
  64627. /**
  64628. * Updates the effect with the current post process compile time values and recompiles the shader.
  64629. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64630. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64631. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64632. * @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
  64633. * @param onCompiled Called when the shader has been compiled.
  64634. * @param onError Called if there is an error when compiling a shader.
  64635. */
  64636. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64637. }
  64638. }
  64639. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  64640. import { Nullable } from "babylonjs/types";
  64641. import { Camera } from "babylonjs/Cameras/camera";
  64642. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64643. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64644. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64645. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64646. import { Scene } from "babylonjs/scene";
  64647. /**
  64648. * Specifies the level of max blur that should be applied when using the depth of field effect
  64649. */
  64650. export enum DepthOfFieldEffectBlurLevel {
  64651. /**
  64652. * Subtle blur
  64653. */
  64654. Low = 0,
  64655. /**
  64656. * Medium blur
  64657. */
  64658. Medium = 1,
  64659. /**
  64660. * Large blur
  64661. */
  64662. High = 2
  64663. }
  64664. /**
  64665. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64666. */
  64667. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64668. private _circleOfConfusion;
  64669. /**
  64670. * @hidden Internal, blurs from high to low
  64671. */
  64672. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64673. private _depthOfFieldBlurY;
  64674. private _dofMerge;
  64675. /**
  64676. * @hidden Internal post processes in depth of field effect
  64677. */
  64678. _effects: Array<PostProcess>;
  64679. /**
  64680. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64681. */
  64682. focalLength: number;
  64683. /**
  64684. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64685. */
  64686. fStop: number;
  64687. /**
  64688. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64689. */
  64690. focusDistance: number;
  64691. /**
  64692. * 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.
  64693. */
  64694. lensSize: number;
  64695. /**
  64696. * Creates a new instance DepthOfFieldEffect
  64697. * @param scene The scene the effect belongs to.
  64698. * @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.
  64699. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64700. * @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)
  64701. */
  64702. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64703. /**
  64704. * Get the current class name of the current effet
  64705. * @returns "DepthOfFieldEffect"
  64706. */
  64707. getClassName(): string;
  64708. /**
  64709. * 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.
  64710. */
  64711. depthTexture: RenderTargetTexture;
  64712. /**
  64713. * Disposes each of the internal effects for a given camera.
  64714. * @param camera The camera to dispose the effect on.
  64715. */
  64716. disposeEffects(camera: Camera): void;
  64717. /**
  64718. * @hidden Internal
  64719. */
  64720. _updateEffects(): void;
  64721. /**
  64722. * Internal
  64723. * @returns if all the contained post processes are ready.
  64724. * @hidden
  64725. */
  64726. _isReady(): boolean;
  64727. }
  64728. }
  64729. declare module "babylonjs/Shaders/displayPass.fragment" {
  64730. /** @hidden */
  64731. export var displayPassPixelShader: {
  64732. name: string;
  64733. shader: string;
  64734. };
  64735. }
  64736. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  64737. import { Nullable } from "babylonjs/types";
  64738. import { Camera } from "babylonjs/Cameras/camera";
  64739. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64740. import { Engine } from "babylonjs/Engines/engine";
  64741. import "babylonjs/Shaders/displayPass.fragment";
  64742. /**
  64743. * DisplayPassPostProcess which produces an output the same as it's input
  64744. */
  64745. export class DisplayPassPostProcess extends PostProcess {
  64746. /**
  64747. * Creates the DisplayPassPostProcess
  64748. * @param name The name of the effect.
  64749. * @param options The required width/height ratio to downsize to before computing the render pass.
  64750. * @param camera The camera to apply the render pass to.
  64751. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64752. * @param engine The engine which the post process will be applied. (default: current engine)
  64753. * @param reusable If the post process can be reused on the same frame. (default: false)
  64754. */
  64755. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64756. }
  64757. }
  64758. declare module "babylonjs/Shaders/filter.fragment" {
  64759. /** @hidden */
  64760. export var filterPixelShader: {
  64761. name: string;
  64762. shader: string;
  64763. };
  64764. }
  64765. declare module "babylonjs/PostProcesses/filterPostProcess" {
  64766. import { Nullable } from "babylonjs/types";
  64767. import { Matrix } from "babylonjs/Maths/math.vector";
  64768. import { Camera } from "babylonjs/Cameras/camera";
  64769. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64770. import { Engine } from "babylonjs/Engines/engine";
  64771. import "babylonjs/Shaders/filter.fragment";
  64772. /**
  64773. * Applies a kernel filter to the image
  64774. */
  64775. export class FilterPostProcess extends PostProcess {
  64776. /** The matrix to be applied to the image */
  64777. kernelMatrix: Matrix;
  64778. /**
  64779. *
  64780. * @param name The name of the effect.
  64781. * @param kernelMatrix The matrix to be applied to the image
  64782. * @param options The required width/height ratio to downsize to before computing the render pass.
  64783. * @param camera The camera to apply the render pass to.
  64784. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64785. * @param engine The engine which the post process will be applied. (default: current engine)
  64786. * @param reusable If the post process can be reused on the same frame. (default: false)
  64787. */
  64788. constructor(name: string,
  64789. /** The matrix to be applied to the image */
  64790. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64791. }
  64792. }
  64793. declare module "babylonjs/Shaders/fxaa.fragment" {
  64794. /** @hidden */
  64795. export var fxaaPixelShader: {
  64796. name: string;
  64797. shader: string;
  64798. };
  64799. }
  64800. declare module "babylonjs/Shaders/fxaa.vertex" {
  64801. /** @hidden */
  64802. export var fxaaVertexShader: {
  64803. name: string;
  64804. shader: string;
  64805. };
  64806. }
  64807. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  64808. import { Nullable } from "babylonjs/types";
  64809. import { Camera } from "babylonjs/Cameras/camera";
  64810. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64811. import { Engine } from "babylonjs/Engines/engine";
  64812. import "babylonjs/Shaders/fxaa.fragment";
  64813. import "babylonjs/Shaders/fxaa.vertex";
  64814. /**
  64815. * Fxaa post process
  64816. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64817. */
  64818. export class FxaaPostProcess extends PostProcess {
  64819. /** @hidden */
  64820. texelWidth: number;
  64821. /** @hidden */
  64822. texelHeight: number;
  64823. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64824. private _getDefines;
  64825. }
  64826. }
  64827. declare module "babylonjs/Shaders/grain.fragment" {
  64828. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64829. /** @hidden */
  64830. export var grainPixelShader: {
  64831. name: string;
  64832. shader: string;
  64833. };
  64834. }
  64835. declare module "babylonjs/PostProcesses/grainPostProcess" {
  64836. import { Nullable } from "babylonjs/types";
  64837. import { Camera } from "babylonjs/Cameras/camera";
  64838. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64839. import { Engine } from "babylonjs/Engines/engine";
  64840. import "babylonjs/Shaders/grain.fragment";
  64841. /**
  64842. * The GrainPostProcess adds noise to the image at mid luminance levels
  64843. */
  64844. export class GrainPostProcess extends PostProcess {
  64845. /**
  64846. * The intensity of the grain added (default: 30)
  64847. */
  64848. intensity: number;
  64849. /**
  64850. * If the grain should be randomized on every frame
  64851. */
  64852. animated: boolean;
  64853. /**
  64854. * Creates a new instance of @see GrainPostProcess
  64855. * @param name The name of the effect.
  64856. * @param options The required width/height ratio to downsize to before computing the render pass.
  64857. * @param camera The camera to apply the render pass to.
  64858. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64859. * @param engine The engine which the post process will be applied. (default: current engine)
  64860. * @param reusable If the post process can be reused on the same frame. (default: false)
  64861. * @param textureType Type of textures used when performing the post process. (default: 0)
  64862. * @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)
  64863. */
  64864. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64865. }
  64866. }
  64867. declare module "babylonjs/Shaders/highlights.fragment" {
  64868. /** @hidden */
  64869. export var highlightsPixelShader: {
  64870. name: string;
  64871. shader: string;
  64872. };
  64873. }
  64874. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  64875. import { Nullable } from "babylonjs/types";
  64876. import { Camera } from "babylonjs/Cameras/camera";
  64877. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64878. import { Engine } from "babylonjs/Engines/engine";
  64879. import "babylonjs/Shaders/highlights.fragment";
  64880. /**
  64881. * Extracts highlights from the image
  64882. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64883. */
  64884. export class HighlightsPostProcess extends PostProcess {
  64885. /**
  64886. * Extracts highlights from the image
  64887. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64888. * @param name The name of the effect.
  64889. * @param options The required width/height ratio to downsize to before computing the render pass.
  64890. * @param camera The camera to apply the render pass to.
  64891. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64892. * @param engine The engine which the post process will be applied. (default: current engine)
  64893. * @param reusable If the post process can be reused on the same frame. (default: false)
  64894. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64895. */
  64896. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64897. }
  64898. }
  64899. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  64900. /** @hidden */
  64901. export var mrtFragmentDeclaration: {
  64902. name: string;
  64903. shader: string;
  64904. };
  64905. }
  64906. declare module "babylonjs/Shaders/geometry.fragment" {
  64907. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  64908. /** @hidden */
  64909. export var geometryPixelShader: {
  64910. name: string;
  64911. shader: string;
  64912. };
  64913. }
  64914. declare module "babylonjs/Shaders/geometry.vertex" {
  64915. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64916. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64917. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64918. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64919. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64920. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64921. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64922. /** @hidden */
  64923. export var geometryVertexShader: {
  64924. name: string;
  64925. shader: string;
  64926. };
  64927. }
  64928. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  64929. import { Matrix } from "babylonjs/Maths/math.vector";
  64930. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64931. import { Mesh } from "babylonjs/Meshes/mesh";
  64932. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  64933. import { Effect } from "babylonjs/Materials/effect";
  64934. import { Scene } from "babylonjs/scene";
  64935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64936. import "babylonjs/Shaders/geometry.fragment";
  64937. import "babylonjs/Shaders/geometry.vertex";
  64938. /** @hidden */
  64939. interface ISavedTransformationMatrix {
  64940. world: Matrix;
  64941. viewProjection: Matrix;
  64942. }
  64943. /**
  64944. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64945. */
  64946. export class GeometryBufferRenderer {
  64947. /**
  64948. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64949. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64950. */
  64951. static readonly POSITION_TEXTURE_TYPE: number;
  64952. /**
  64953. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64954. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64955. */
  64956. static readonly VELOCITY_TEXTURE_TYPE: number;
  64957. /**
  64958. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64959. * in order to compute objects velocities when enableVelocity is set to "true"
  64960. * @hidden
  64961. */
  64962. _previousTransformationMatrices: {
  64963. [index: number]: ISavedTransformationMatrix;
  64964. };
  64965. /**
  64966. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64967. * in order to compute objects velocities when enableVelocity is set to "true"
  64968. * @hidden
  64969. */
  64970. _previousBonesTransformationMatrices: {
  64971. [index: number]: Float32Array;
  64972. };
  64973. /**
  64974. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64975. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64976. */
  64977. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64978. private _scene;
  64979. private _multiRenderTarget;
  64980. private _ratio;
  64981. private _enablePosition;
  64982. private _enableVelocity;
  64983. private _positionIndex;
  64984. private _velocityIndex;
  64985. protected _effect: Effect;
  64986. protected _cachedDefines: string;
  64987. /**
  64988. * Set the render list (meshes to be rendered) used in the G buffer.
  64989. */
  64990. renderList: Mesh[];
  64991. /**
  64992. * Gets wether or not G buffer are supported by the running hardware.
  64993. * This requires draw buffer supports
  64994. */
  64995. readonly isSupported: boolean;
  64996. /**
  64997. * Returns the index of the given texture type in the G-Buffer textures array
  64998. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64999. * @returns the index of the given texture type in the G-Buffer textures array
  65000. */
  65001. getTextureIndex(textureType: number): number;
  65002. /**
  65003. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  65004. */
  65005. /**
  65006. * Sets whether or not objects positions are enabled for the G buffer.
  65007. */
  65008. enablePosition: boolean;
  65009. /**
  65010. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  65011. */
  65012. /**
  65013. * Sets wether or not objects velocities are enabled for the G buffer.
  65014. */
  65015. enableVelocity: boolean;
  65016. /**
  65017. * Gets the scene associated with the buffer.
  65018. */
  65019. readonly scene: Scene;
  65020. /**
  65021. * Gets the ratio used by the buffer during its creation.
  65022. * How big is the buffer related to the main canvas.
  65023. */
  65024. readonly ratio: number;
  65025. /** @hidden */
  65026. static _SceneComponentInitialization: (scene: Scene) => void;
  65027. /**
  65028. * Creates a new G Buffer for the scene
  65029. * @param scene The scene the buffer belongs to
  65030. * @param ratio How big is the buffer related to the main canvas.
  65031. */
  65032. constructor(scene: Scene, ratio?: number);
  65033. /**
  65034. * Checks wether everything is ready to render a submesh to the G buffer.
  65035. * @param subMesh the submesh to check readiness for
  65036. * @param useInstances is the mesh drawn using instance or not
  65037. * @returns true if ready otherwise false
  65038. */
  65039. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65040. /**
  65041. * Gets the current underlying G Buffer.
  65042. * @returns the buffer
  65043. */
  65044. getGBuffer(): MultiRenderTarget;
  65045. /**
  65046. * Gets the number of samples used to render the buffer (anti aliasing).
  65047. */
  65048. /**
  65049. * Sets the number of samples used to render the buffer (anti aliasing).
  65050. */
  65051. samples: number;
  65052. /**
  65053. * Disposes the renderer and frees up associated resources.
  65054. */
  65055. dispose(): void;
  65056. protected _createRenderTargets(): void;
  65057. private _copyBonesTransformationMatrices;
  65058. }
  65059. }
  65060. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  65061. import { Nullable } from "babylonjs/types";
  65062. import { Scene } from "babylonjs/scene";
  65063. import { ISceneComponent } from "babylonjs/sceneComponent";
  65064. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  65065. module "babylonjs/scene" {
  65066. interface Scene {
  65067. /** @hidden (Backing field) */
  65068. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65069. /**
  65070. * Gets or Sets the current geometry buffer associated to the scene.
  65071. */
  65072. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65073. /**
  65074. * Enables a GeometryBufferRender and associates it with the scene
  65075. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  65076. * @returns the GeometryBufferRenderer
  65077. */
  65078. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  65079. /**
  65080. * Disables the GeometryBufferRender associated with the scene
  65081. */
  65082. disableGeometryBufferRenderer(): void;
  65083. }
  65084. }
  65085. /**
  65086. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  65087. * in several rendering techniques.
  65088. */
  65089. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  65090. /**
  65091. * The component name helpful to identify the component in the list of scene components.
  65092. */
  65093. readonly name: string;
  65094. /**
  65095. * The scene the component belongs to.
  65096. */
  65097. scene: Scene;
  65098. /**
  65099. * Creates a new instance of the component for the given scene
  65100. * @param scene Defines the scene to register the component in
  65101. */
  65102. constructor(scene: Scene);
  65103. /**
  65104. * Registers the component in a given scene
  65105. */
  65106. register(): void;
  65107. /**
  65108. * Rebuilds the elements related to this component in case of
  65109. * context lost for instance.
  65110. */
  65111. rebuild(): void;
  65112. /**
  65113. * Disposes the component and the associated ressources
  65114. */
  65115. dispose(): void;
  65116. private _gatherRenderTargets;
  65117. }
  65118. }
  65119. declare module "babylonjs/Shaders/motionBlur.fragment" {
  65120. /** @hidden */
  65121. export var motionBlurPixelShader: {
  65122. name: string;
  65123. shader: string;
  65124. };
  65125. }
  65126. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  65127. import { Nullable } from "babylonjs/types";
  65128. import { Camera } from "babylonjs/Cameras/camera";
  65129. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65130. import { Scene } from "babylonjs/scene";
  65131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65132. import "babylonjs/Animations/animatable";
  65133. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  65134. import "babylonjs/Shaders/motionBlur.fragment";
  65135. import { Engine } from "babylonjs/Engines/engine";
  65136. /**
  65137. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65138. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65139. * As an example, all you have to do is to create the post-process:
  65140. * var mb = new BABYLON.MotionBlurPostProcess(
  65141. * 'mb', // The name of the effect.
  65142. * scene, // The scene containing the objects to blur according to their velocity.
  65143. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65144. * camera // The camera to apply the render pass to.
  65145. * );
  65146. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65147. */
  65148. export class MotionBlurPostProcess extends PostProcess {
  65149. /**
  65150. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65151. */
  65152. motionStrength: number;
  65153. /**
  65154. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65155. */
  65156. /**
  65157. * Sets the number of iterations to be used for motion blur quality
  65158. */
  65159. motionBlurSamples: number;
  65160. private _motionBlurSamples;
  65161. private _geometryBufferRenderer;
  65162. /**
  65163. * Creates a new instance MotionBlurPostProcess
  65164. * @param name The name of the effect.
  65165. * @param scene The scene containing the objects to blur according to their velocity.
  65166. * @param options The required width/height ratio to downsize to before computing the render pass.
  65167. * @param camera The camera to apply the render pass to.
  65168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65169. * @param engine The engine which the post process will be applied. (default: current engine)
  65170. * @param reusable If the post process can be reused on the same frame. (default: false)
  65171. * @param textureType Type of textures used when performing the post process. (default: 0)
  65172. * @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)
  65173. */
  65174. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65175. /**
  65176. * Excludes the given skinned mesh from computing bones velocities.
  65177. * 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.
  65178. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65179. */
  65180. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65181. /**
  65182. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65183. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65184. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65185. */
  65186. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65187. /**
  65188. * Disposes the post process.
  65189. * @param camera The camera to dispose the post process on.
  65190. */
  65191. dispose(camera?: Camera): void;
  65192. }
  65193. }
  65194. declare module "babylonjs/Shaders/refraction.fragment" {
  65195. /** @hidden */
  65196. export var refractionPixelShader: {
  65197. name: string;
  65198. shader: string;
  65199. };
  65200. }
  65201. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  65202. import { Color3 } from "babylonjs/Maths/math.color";
  65203. import { Camera } from "babylonjs/Cameras/camera";
  65204. import { Texture } from "babylonjs/Materials/Textures/texture";
  65205. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65206. import { Engine } from "babylonjs/Engines/engine";
  65207. import "babylonjs/Shaders/refraction.fragment";
  65208. /**
  65209. * Post process which applies a refractin texture
  65210. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65211. */
  65212. export class RefractionPostProcess extends PostProcess {
  65213. /** the base color of the refraction (used to taint the rendering) */
  65214. color: Color3;
  65215. /** simulated refraction depth */
  65216. depth: number;
  65217. /** the coefficient of the base color (0 to remove base color tainting) */
  65218. colorLevel: number;
  65219. private _refTexture;
  65220. private _ownRefractionTexture;
  65221. /**
  65222. * Gets or sets the refraction texture
  65223. * Please note that you are responsible for disposing the texture if you set it manually
  65224. */
  65225. refractionTexture: Texture;
  65226. /**
  65227. * Initializes the RefractionPostProcess
  65228. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65229. * @param name The name of the effect.
  65230. * @param refractionTextureUrl Url of the refraction texture to use
  65231. * @param color the base color of the refraction (used to taint the rendering)
  65232. * @param depth simulated refraction depth
  65233. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65234. * @param camera The camera to apply the render pass to.
  65235. * @param options The required width/height ratio to downsize to before computing the render pass.
  65236. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65237. * @param engine The engine which the post process will be applied. (default: current engine)
  65238. * @param reusable If the post process can be reused on the same frame. (default: false)
  65239. */
  65240. constructor(name: string, refractionTextureUrl: string,
  65241. /** the base color of the refraction (used to taint the rendering) */
  65242. color: Color3,
  65243. /** simulated refraction depth */
  65244. depth: number,
  65245. /** the coefficient of the base color (0 to remove base color tainting) */
  65246. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65247. /**
  65248. * Disposes of the post process
  65249. * @param camera Camera to dispose post process on
  65250. */
  65251. dispose(camera: Camera): void;
  65252. }
  65253. }
  65254. declare module "babylonjs/Shaders/sharpen.fragment" {
  65255. /** @hidden */
  65256. export var sharpenPixelShader: {
  65257. name: string;
  65258. shader: string;
  65259. };
  65260. }
  65261. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  65262. import { Nullable } from "babylonjs/types";
  65263. import { Camera } from "babylonjs/Cameras/camera";
  65264. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65265. import "babylonjs/Shaders/sharpen.fragment";
  65266. import { Engine } from "babylonjs/Engines/engine";
  65267. /**
  65268. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65269. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65270. */
  65271. export class SharpenPostProcess extends PostProcess {
  65272. /**
  65273. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65274. */
  65275. colorAmount: number;
  65276. /**
  65277. * How much sharpness should be applied (default: 0.3)
  65278. */
  65279. edgeAmount: number;
  65280. /**
  65281. * Creates a new instance ConvolutionPostProcess
  65282. * @param name The name of the effect.
  65283. * @param options The required width/height ratio to downsize to before computing the render pass.
  65284. * @param camera The camera to apply the render pass to.
  65285. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65286. * @param engine The engine which the post process will be applied. (default: current engine)
  65287. * @param reusable If the post process can be reused on the same frame. (default: false)
  65288. * @param textureType Type of textures used when performing the post process. (default: 0)
  65289. * @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)
  65290. */
  65291. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65292. }
  65293. }
  65294. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  65295. import { Nullable } from "babylonjs/types";
  65296. import { Camera } from "babylonjs/Cameras/camera";
  65297. import { Engine } from "babylonjs/Engines/engine";
  65298. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65299. import { IInspectable } from "babylonjs/Misc/iInspectable";
  65300. /**
  65301. * PostProcessRenderPipeline
  65302. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65303. */
  65304. export class PostProcessRenderPipeline {
  65305. private engine;
  65306. private _renderEffects;
  65307. private _renderEffectsForIsolatedPass;
  65308. /**
  65309. * List of inspectable custom properties (used by the Inspector)
  65310. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65311. */
  65312. inspectableCustomProperties: IInspectable[];
  65313. /**
  65314. * @hidden
  65315. */
  65316. protected _cameras: Camera[];
  65317. /** @hidden */
  65318. _name: string;
  65319. /**
  65320. * Gets pipeline name
  65321. */
  65322. readonly name: string;
  65323. /** Gets the list of attached cameras */
  65324. readonly cameras: Camera[];
  65325. /**
  65326. * Initializes a PostProcessRenderPipeline
  65327. * @param engine engine to add the pipeline to
  65328. * @param name name of the pipeline
  65329. */
  65330. constructor(engine: Engine, name: string);
  65331. /**
  65332. * Gets the class name
  65333. * @returns "PostProcessRenderPipeline"
  65334. */
  65335. getClassName(): string;
  65336. /**
  65337. * If all the render effects in the pipeline are supported
  65338. */
  65339. readonly isSupported: boolean;
  65340. /**
  65341. * Adds an effect to the pipeline
  65342. * @param renderEffect the effect to add
  65343. */
  65344. addEffect(renderEffect: PostProcessRenderEffect): void;
  65345. /** @hidden */
  65346. _rebuild(): void;
  65347. /** @hidden */
  65348. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65349. /** @hidden */
  65350. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65351. /** @hidden */
  65352. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65353. /** @hidden */
  65354. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65355. /** @hidden */
  65356. _attachCameras(cameras: Camera, unique: boolean): void;
  65357. /** @hidden */
  65358. _attachCameras(cameras: Camera[], unique: boolean): void;
  65359. /** @hidden */
  65360. _detachCameras(cameras: Camera): void;
  65361. /** @hidden */
  65362. _detachCameras(cameras: Nullable<Camera[]>): void;
  65363. /** @hidden */
  65364. _update(): void;
  65365. /** @hidden */
  65366. _reset(): void;
  65367. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65368. /**
  65369. * Disposes of the pipeline
  65370. */
  65371. dispose(): void;
  65372. }
  65373. }
  65374. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  65375. import { Camera } from "babylonjs/Cameras/camera";
  65376. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65377. /**
  65378. * PostProcessRenderPipelineManager class
  65379. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65380. */
  65381. export class PostProcessRenderPipelineManager {
  65382. private _renderPipelines;
  65383. /**
  65384. * Initializes a PostProcessRenderPipelineManager
  65385. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65386. */
  65387. constructor();
  65388. /**
  65389. * Gets the list of supported render pipelines
  65390. */
  65391. readonly supportedPipelines: PostProcessRenderPipeline[];
  65392. /**
  65393. * Adds a pipeline to the manager
  65394. * @param renderPipeline The pipeline to add
  65395. */
  65396. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65397. /**
  65398. * Attaches a camera to the pipeline
  65399. * @param renderPipelineName The name of the pipeline to attach to
  65400. * @param cameras the camera to attach
  65401. * @param unique if the camera can be attached multiple times to the pipeline
  65402. */
  65403. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65404. /**
  65405. * Detaches a camera from the pipeline
  65406. * @param renderPipelineName The name of the pipeline to detach from
  65407. * @param cameras the camera to detach
  65408. */
  65409. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65410. /**
  65411. * Enables an effect by name on a pipeline
  65412. * @param renderPipelineName the name of the pipeline to enable the effect in
  65413. * @param renderEffectName the name of the effect to enable
  65414. * @param cameras the cameras that the effect should be enabled on
  65415. */
  65416. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65417. /**
  65418. * Disables an effect by name on a pipeline
  65419. * @param renderPipelineName the name of the pipeline to disable the effect in
  65420. * @param renderEffectName the name of the effect to disable
  65421. * @param cameras the cameras that the effect should be disabled on
  65422. */
  65423. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65424. /**
  65425. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65426. */
  65427. update(): void;
  65428. /** @hidden */
  65429. _rebuild(): void;
  65430. /**
  65431. * Disposes of the manager and pipelines
  65432. */
  65433. dispose(): void;
  65434. }
  65435. }
  65436. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  65437. import { ISceneComponent } from "babylonjs/sceneComponent";
  65438. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  65439. import { Scene } from "babylonjs/scene";
  65440. module "babylonjs/scene" {
  65441. interface Scene {
  65442. /** @hidden (Backing field) */
  65443. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65444. /**
  65445. * Gets the postprocess render pipeline manager
  65446. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65447. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65448. */
  65449. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65450. }
  65451. }
  65452. /**
  65453. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65454. */
  65455. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65456. /**
  65457. * The component name helpfull to identify the component in the list of scene components.
  65458. */
  65459. readonly name: string;
  65460. /**
  65461. * The scene the component belongs to.
  65462. */
  65463. scene: Scene;
  65464. /**
  65465. * Creates a new instance of the component for the given scene
  65466. * @param scene Defines the scene to register the component in
  65467. */
  65468. constructor(scene: Scene);
  65469. /**
  65470. * Registers the component in a given scene
  65471. */
  65472. register(): void;
  65473. /**
  65474. * Rebuilds the elements related to this component in case of
  65475. * context lost for instance.
  65476. */
  65477. rebuild(): void;
  65478. /**
  65479. * Disposes the component and the associated ressources
  65480. */
  65481. dispose(): void;
  65482. private _gatherRenderTargets;
  65483. }
  65484. }
  65485. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  65486. import { Nullable } from "babylonjs/types";
  65487. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65488. import { Camera } from "babylonjs/Cameras/camera";
  65489. import { IDisposable } from "babylonjs/scene";
  65490. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  65491. import { Scene } from "babylonjs/scene";
  65492. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  65493. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65494. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65495. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  65496. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  65497. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65498. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  65499. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65500. import { Animation } from "babylonjs/Animations/animation";
  65501. /**
  65502. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65503. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65504. */
  65505. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65506. private _scene;
  65507. private _camerasToBeAttached;
  65508. /**
  65509. * ID of the sharpen post process,
  65510. */
  65511. private readonly SharpenPostProcessId;
  65512. /**
  65513. * @ignore
  65514. * ID of the image processing post process;
  65515. */
  65516. readonly ImageProcessingPostProcessId: string;
  65517. /**
  65518. * @ignore
  65519. * ID of the Fast Approximate Anti-Aliasing post process;
  65520. */
  65521. readonly FxaaPostProcessId: string;
  65522. /**
  65523. * ID of the chromatic aberration post process,
  65524. */
  65525. private readonly ChromaticAberrationPostProcessId;
  65526. /**
  65527. * ID of the grain post process
  65528. */
  65529. private readonly GrainPostProcessId;
  65530. /**
  65531. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65532. */
  65533. sharpen: SharpenPostProcess;
  65534. private _sharpenEffect;
  65535. private bloom;
  65536. /**
  65537. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65538. */
  65539. depthOfField: DepthOfFieldEffect;
  65540. /**
  65541. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65542. */
  65543. fxaa: FxaaPostProcess;
  65544. /**
  65545. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65546. */
  65547. imageProcessing: ImageProcessingPostProcess;
  65548. /**
  65549. * Chromatic aberration post process which will shift rgb colors in the image
  65550. */
  65551. chromaticAberration: ChromaticAberrationPostProcess;
  65552. private _chromaticAberrationEffect;
  65553. /**
  65554. * Grain post process which add noise to the image
  65555. */
  65556. grain: GrainPostProcess;
  65557. private _grainEffect;
  65558. /**
  65559. * Glow post process which adds a glow to emissive areas of the image
  65560. */
  65561. private _glowLayer;
  65562. /**
  65563. * Animations which can be used to tweak settings over a period of time
  65564. */
  65565. animations: Animation[];
  65566. private _imageProcessingConfigurationObserver;
  65567. private _sharpenEnabled;
  65568. private _bloomEnabled;
  65569. private _depthOfFieldEnabled;
  65570. private _depthOfFieldBlurLevel;
  65571. private _fxaaEnabled;
  65572. private _imageProcessingEnabled;
  65573. private _defaultPipelineTextureType;
  65574. private _bloomScale;
  65575. private _chromaticAberrationEnabled;
  65576. private _grainEnabled;
  65577. private _buildAllowed;
  65578. /**
  65579. * Gets active scene
  65580. */
  65581. readonly scene: Scene;
  65582. /**
  65583. * Enable or disable the sharpen process from the pipeline
  65584. */
  65585. sharpenEnabled: boolean;
  65586. private _resizeObserver;
  65587. private _hardwareScaleLevel;
  65588. private _bloomKernel;
  65589. /**
  65590. * Specifies the size of the bloom blur kernel, relative to the final output size
  65591. */
  65592. bloomKernel: number;
  65593. /**
  65594. * Specifies the weight of the bloom in the final rendering
  65595. */
  65596. private _bloomWeight;
  65597. /**
  65598. * Specifies the luma threshold for the area that will be blurred by the bloom
  65599. */
  65600. private _bloomThreshold;
  65601. private _hdr;
  65602. /**
  65603. * The strength of the bloom.
  65604. */
  65605. bloomWeight: number;
  65606. /**
  65607. * The strength of the bloom.
  65608. */
  65609. bloomThreshold: number;
  65610. /**
  65611. * The scale of the bloom, lower value will provide better performance.
  65612. */
  65613. bloomScale: number;
  65614. /**
  65615. * Enable or disable the bloom from the pipeline
  65616. */
  65617. bloomEnabled: boolean;
  65618. private _rebuildBloom;
  65619. /**
  65620. * If the depth of field is enabled.
  65621. */
  65622. depthOfFieldEnabled: boolean;
  65623. /**
  65624. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65625. */
  65626. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  65627. /**
  65628. * If the anti aliasing is enabled.
  65629. */
  65630. fxaaEnabled: boolean;
  65631. private _samples;
  65632. /**
  65633. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65634. */
  65635. samples: number;
  65636. /**
  65637. * If image processing is enabled.
  65638. */
  65639. imageProcessingEnabled: boolean;
  65640. /**
  65641. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65642. */
  65643. glowLayerEnabled: boolean;
  65644. /**
  65645. * Gets the glow layer (or null if not defined)
  65646. */
  65647. readonly glowLayer: Nullable<GlowLayer>;
  65648. /**
  65649. * Enable or disable the chromaticAberration process from the pipeline
  65650. */
  65651. chromaticAberrationEnabled: boolean;
  65652. /**
  65653. * Enable or disable the grain process from the pipeline
  65654. */
  65655. grainEnabled: boolean;
  65656. /**
  65657. * @constructor
  65658. * @param name - The rendering pipeline name (default: "")
  65659. * @param hdr - If high dynamic range textures should be used (default: true)
  65660. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65661. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65662. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65663. */
  65664. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65665. /**
  65666. * Get the class name
  65667. * @returns "DefaultRenderingPipeline"
  65668. */
  65669. getClassName(): string;
  65670. /**
  65671. * Force the compilation of the entire pipeline.
  65672. */
  65673. prepare(): void;
  65674. private _hasCleared;
  65675. private _prevPostProcess;
  65676. private _prevPrevPostProcess;
  65677. private _setAutoClearAndTextureSharing;
  65678. private _depthOfFieldSceneObserver;
  65679. private _buildPipeline;
  65680. private _disposePostProcesses;
  65681. /**
  65682. * Adds a camera to the pipeline
  65683. * @param camera the camera to be added
  65684. */
  65685. addCamera(camera: Camera): void;
  65686. /**
  65687. * Removes a camera from the pipeline
  65688. * @param camera the camera to remove
  65689. */
  65690. removeCamera(camera: Camera): void;
  65691. /**
  65692. * Dispose of the pipeline and stop all post processes
  65693. */
  65694. dispose(): void;
  65695. /**
  65696. * Serialize the rendering pipeline (Used when exporting)
  65697. * @returns the serialized object
  65698. */
  65699. serialize(): any;
  65700. /**
  65701. * Parse the serialized pipeline
  65702. * @param source Source pipeline.
  65703. * @param scene The scene to load the pipeline to.
  65704. * @param rootUrl The URL of the serialized pipeline.
  65705. * @returns An instantiated pipeline from the serialized object.
  65706. */
  65707. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65708. }
  65709. }
  65710. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  65711. /** @hidden */
  65712. export var lensHighlightsPixelShader: {
  65713. name: string;
  65714. shader: string;
  65715. };
  65716. }
  65717. declare module "babylonjs/Shaders/depthOfField.fragment" {
  65718. /** @hidden */
  65719. export var depthOfFieldPixelShader: {
  65720. name: string;
  65721. shader: string;
  65722. };
  65723. }
  65724. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  65725. import { Camera } from "babylonjs/Cameras/camera";
  65726. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65727. import { Scene } from "babylonjs/scene";
  65728. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65729. import "babylonjs/Shaders/chromaticAberration.fragment";
  65730. import "babylonjs/Shaders/lensHighlights.fragment";
  65731. import "babylonjs/Shaders/depthOfField.fragment";
  65732. /**
  65733. * BABYLON.JS Chromatic Aberration GLSL Shader
  65734. * Author: Olivier Guyot
  65735. * Separates very slightly R, G and B colors on the edges of the screen
  65736. * Inspired by Francois Tarlier & Martins Upitis
  65737. */
  65738. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65739. /**
  65740. * @ignore
  65741. * The chromatic aberration PostProcess id in the pipeline
  65742. */
  65743. LensChromaticAberrationEffect: string;
  65744. /**
  65745. * @ignore
  65746. * The highlights enhancing PostProcess id in the pipeline
  65747. */
  65748. HighlightsEnhancingEffect: string;
  65749. /**
  65750. * @ignore
  65751. * The depth-of-field PostProcess id in the pipeline
  65752. */
  65753. LensDepthOfFieldEffect: string;
  65754. private _scene;
  65755. private _depthTexture;
  65756. private _grainTexture;
  65757. private _chromaticAberrationPostProcess;
  65758. private _highlightsPostProcess;
  65759. private _depthOfFieldPostProcess;
  65760. private _edgeBlur;
  65761. private _grainAmount;
  65762. private _chromaticAberration;
  65763. private _distortion;
  65764. private _highlightsGain;
  65765. private _highlightsThreshold;
  65766. private _dofDistance;
  65767. private _dofAperture;
  65768. private _dofDarken;
  65769. private _dofPentagon;
  65770. private _blurNoise;
  65771. /**
  65772. * @constructor
  65773. *
  65774. * Effect parameters are as follow:
  65775. * {
  65776. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65777. * edge_blur: number; // from 0 to x (1 for realism)
  65778. * distortion: number; // from 0 to x (1 for realism)
  65779. * grain_amount: number; // from 0 to 1
  65780. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65781. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65782. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65783. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65784. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65785. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65786. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65787. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65788. * }
  65789. * Note: if an effect parameter is unset, effect is disabled
  65790. *
  65791. * @param name The rendering pipeline name
  65792. * @param parameters - An object containing all parameters (see above)
  65793. * @param scene The scene linked to this pipeline
  65794. * @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)
  65795. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65796. */
  65797. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65798. /**
  65799. * Get the class name
  65800. * @returns "LensRenderingPipeline"
  65801. */
  65802. getClassName(): string;
  65803. /**
  65804. * Gets associated scene
  65805. */
  65806. readonly scene: Scene;
  65807. /**
  65808. * Gets or sets the edge blur
  65809. */
  65810. edgeBlur: number;
  65811. /**
  65812. * Gets or sets the grain amount
  65813. */
  65814. grainAmount: number;
  65815. /**
  65816. * Gets or sets the chromatic aberration amount
  65817. */
  65818. chromaticAberration: number;
  65819. /**
  65820. * Gets or sets the depth of field aperture
  65821. */
  65822. dofAperture: number;
  65823. /**
  65824. * Gets or sets the edge distortion
  65825. */
  65826. edgeDistortion: number;
  65827. /**
  65828. * Gets or sets the depth of field distortion
  65829. */
  65830. dofDistortion: number;
  65831. /**
  65832. * Gets or sets the darken out of focus amount
  65833. */
  65834. darkenOutOfFocus: number;
  65835. /**
  65836. * Gets or sets a boolean indicating if blur noise is enabled
  65837. */
  65838. blurNoise: boolean;
  65839. /**
  65840. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65841. */
  65842. pentagonBokeh: boolean;
  65843. /**
  65844. * Gets or sets the highlight grain amount
  65845. */
  65846. highlightsGain: number;
  65847. /**
  65848. * Gets or sets the highlight threshold
  65849. */
  65850. highlightsThreshold: number;
  65851. /**
  65852. * Sets the amount of blur at the edges
  65853. * @param amount blur amount
  65854. */
  65855. setEdgeBlur(amount: number): void;
  65856. /**
  65857. * Sets edge blur to 0
  65858. */
  65859. disableEdgeBlur(): void;
  65860. /**
  65861. * Sets the amout of grain
  65862. * @param amount Amount of grain
  65863. */
  65864. setGrainAmount(amount: number): void;
  65865. /**
  65866. * Set grain amount to 0
  65867. */
  65868. disableGrain(): void;
  65869. /**
  65870. * Sets the chromatic aberration amount
  65871. * @param amount amount of chromatic aberration
  65872. */
  65873. setChromaticAberration(amount: number): void;
  65874. /**
  65875. * Sets chromatic aberration amount to 0
  65876. */
  65877. disableChromaticAberration(): void;
  65878. /**
  65879. * Sets the EdgeDistortion amount
  65880. * @param amount amount of EdgeDistortion
  65881. */
  65882. setEdgeDistortion(amount: number): void;
  65883. /**
  65884. * Sets edge distortion to 0
  65885. */
  65886. disableEdgeDistortion(): void;
  65887. /**
  65888. * Sets the FocusDistance amount
  65889. * @param amount amount of FocusDistance
  65890. */
  65891. setFocusDistance(amount: number): void;
  65892. /**
  65893. * Disables depth of field
  65894. */
  65895. disableDepthOfField(): void;
  65896. /**
  65897. * Sets the Aperture amount
  65898. * @param amount amount of Aperture
  65899. */
  65900. setAperture(amount: number): void;
  65901. /**
  65902. * Sets the DarkenOutOfFocus amount
  65903. * @param amount amount of DarkenOutOfFocus
  65904. */
  65905. setDarkenOutOfFocus(amount: number): void;
  65906. private _pentagonBokehIsEnabled;
  65907. /**
  65908. * Creates a pentagon bokeh effect
  65909. */
  65910. enablePentagonBokeh(): void;
  65911. /**
  65912. * Disables the pentagon bokeh effect
  65913. */
  65914. disablePentagonBokeh(): void;
  65915. /**
  65916. * Enables noise blur
  65917. */
  65918. enableNoiseBlur(): void;
  65919. /**
  65920. * Disables noise blur
  65921. */
  65922. disableNoiseBlur(): void;
  65923. /**
  65924. * Sets the HighlightsGain amount
  65925. * @param amount amount of HighlightsGain
  65926. */
  65927. setHighlightsGain(amount: number): void;
  65928. /**
  65929. * Sets the HighlightsThreshold amount
  65930. * @param amount amount of HighlightsThreshold
  65931. */
  65932. setHighlightsThreshold(amount: number): void;
  65933. /**
  65934. * Disables highlights
  65935. */
  65936. disableHighlights(): void;
  65937. /**
  65938. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65939. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65940. */
  65941. dispose(disableDepthRender?: boolean): void;
  65942. private _createChromaticAberrationPostProcess;
  65943. private _createHighlightsPostProcess;
  65944. private _createDepthOfFieldPostProcess;
  65945. private _createGrainTexture;
  65946. }
  65947. }
  65948. declare module "babylonjs/Shaders/ssao2.fragment" {
  65949. /** @hidden */
  65950. export var ssao2PixelShader: {
  65951. name: string;
  65952. shader: string;
  65953. };
  65954. }
  65955. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  65956. /** @hidden */
  65957. export var ssaoCombinePixelShader: {
  65958. name: string;
  65959. shader: string;
  65960. };
  65961. }
  65962. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  65963. import { Camera } from "babylonjs/Cameras/camera";
  65964. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65965. import { Scene } from "babylonjs/scene";
  65966. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65967. import "babylonjs/Shaders/ssao2.fragment";
  65968. import "babylonjs/Shaders/ssaoCombine.fragment";
  65969. /**
  65970. * Render pipeline to produce ssao effect
  65971. */
  65972. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65973. /**
  65974. * @ignore
  65975. * The PassPostProcess id in the pipeline that contains the original scene color
  65976. */
  65977. SSAOOriginalSceneColorEffect: string;
  65978. /**
  65979. * @ignore
  65980. * The SSAO PostProcess id in the pipeline
  65981. */
  65982. SSAORenderEffect: string;
  65983. /**
  65984. * @ignore
  65985. * The horizontal blur PostProcess id in the pipeline
  65986. */
  65987. SSAOBlurHRenderEffect: string;
  65988. /**
  65989. * @ignore
  65990. * The vertical blur PostProcess id in the pipeline
  65991. */
  65992. SSAOBlurVRenderEffect: string;
  65993. /**
  65994. * @ignore
  65995. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65996. */
  65997. SSAOCombineRenderEffect: string;
  65998. /**
  65999. * The output strength of the SSAO post-process. Default value is 1.0.
  66000. */
  66001. totalStrength: number;
  66002. /**
  66003. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  66004. */
  66005. maxZ: number;
  66006. /**
  66007. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  66008. */
  66009. minZAspect: number;
  66010. private _samples;
  66011. /**
  66012. * Number of samples used for the SSAO calculations. Default value is 8
  66013. */
  66014. samples: number;
  66015. private _textureSamples;
  66016. /**
  66017. * Number of samples to use for antialiasing
  66018. */
  66019. textureSamples: number;
  66020. /**
  66021. * Ratio object used for SSAO ratio and blur ratio
  66022. */
  66023. private _ratio;
  66024. /**
  66025. * Dynamically generated sphere sampler.
  66026. */
  66027. private _sampleSphere;
  66028. /**
  66029. * Blur filter offsets
  66030. */
  66031. private _samplerOffsets;
  66032. private _expensiveBlur;
  66033. /**
  66034. * If bilateral blur should be used
  66035. */
  66036. expensiveBlur: boolean;
  66037. /**
  66038. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  66039. */
  66040. radius: number;
  66041. /**
  66042. * The base color of the SSAO post-process
  66043. * The final result is "base + ssao" between [0, 1]
  66044. */
  66045. base: number;
  66046. /**
  66047. * Support test.
  66048. */
  66049. static readonly IsSupported: boolean;
  66050. private _scene;
  66051. private _depthTexture;
  66052. private _normalTexture;
  66053. private _randomTexture;
  66054. private _originalColorPostProcess;
  66055. private _ssaoPostProcess;
  66056. private _blurHPostProcess;
  66057. private _blurVPostProcess;
  66058. private _ssaoCombinePostProcess;
  66059. /**
  66060. * Gets active scene
  66061. */
  66062. readonly scene: Scene;
  66063. /**
  66064. * @constructor
  66065. * @param name The rendering pipeline name
  66066. * @param scene The scene linked to this pipeline
  66067. * @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 }
  66068. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66069. */
  66070. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66071. /**
  66072. * Get the class name
  66073. * @returns "SSAO2RenderingPipeline"
  66074. */
  66075. getClassName(): string;
  66076. /**
  66077. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66078. */
  66079. dispose(disableGeometryBufferRenderer?: boolean): void;
  66080. private _createBlurPostProcess;
  66081. /** @hidden */
  66082. _rebuild(): void;
  66083. private _bits;
  66084. private _radicalInverse_VdC;
  66085. private _hammersley;
  66086. private _hemisphereSample_uniform;
  66087. private _generateHemisphere;
  66088. private _createSSAOPostProcess;
  66089. private _createSSAOCombinePostProcess;
  66090. private _createRandomTexture;
  66091. /**
  66092. * Serialize the rendering pipeline (Used when exporting)
  66093. * @returns the serialized object
  66094. */
  66095. serialize(): any;
  66096. /**
  66097. * Parse the serialized pipeline
  66098. * @param source Source pipeline.
  66099. * @param scene The scene to load the pipeline to.
  66100. * @param rootUrl The URL of the serialized pipeline.
  66101. * @returns An instantiated pipeline from the serialized object.
  66102. */
  66103. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  66104. }
  66105. }
  66106. declare module "babylonjs/Shaders/ssao.fragment" {
  66107. /** @hidden */
  66108. export var ssaoPixelShader: {
  66109. name: string;
  66110. shader: string;
  66111. };
  66112. }
  66113. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  66114. import { Camera } from "babylonjs/Cameras/camera";
  66115. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66116. import { Scene } from "babylonjs/scene";
  66117. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66118. import "babylonjs/Shaders/ssao.fragment";
  66119. import "babylonjs/Shaders/ssaoCombine.fragment";
  66120. /**
  66121. * Render pipeline to produce ssao effect
  66122. */
  66123. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  66124. /**
  66125. * @ignore
  66126. * The PassPostProcess id in the pipeline that contains the original scene color
  66127. */
  66128. SSAOOriginalSceneColorEffect: string;
  66129. /**
  66130. * @ignore
  66131. * The SSAO PostProcess id in the pipeline
  66132. */
  66133. SSAORenderEffect: string;
  66134. /**
  66135. * @ignore
  66136. * The horizontal blur PostProcess id in the pipeline
  66137. */
  66138. SSAOBlurHRenderEffect: string;
  66139. /**
  66140. * @ignore
  66141. * The vertical blur PostProcess id in the pipeline
  66142. */
  66143. SSAOBlurVRenderEffect: string;
  66144. /**
  66145. * @ignore
  66146. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66147. */
  66148. SSAOCombineRenderEffect: string;
  66149. /**
  66150. * The output strength of the SSAO post-process. Default value is 1.0.
  66151. */
  66152. totalStrength: number;
  66153. /**
  66154. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66155. */
  66156. radius: number;
  66157. /**
  66158. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66159. * Must not be equal to fallOff and superior to fallOff.
  66160. * Default value is 0.0075
  66161. */
  66162. area: number;
  66163. /**
  66164. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66165. * Must not be equal to area and inferior to area.
  66166. * Default value is 0.000001
  66167. */
  66168. fallOff: number;
  66169. /**
  66170. * The base color of the SSAO post-process
  66171. * The final result is "base + ssao" between [0, 1]
  66172. */
  66173. base: number;
  66174. private _scene;
  66175. private _depthTexture;
  66176. private _randomTexture;
  66177. private _originalColorPostProcess;
  66178. private _ssaoPostProcess;
  66179. private _blurHPostProcess;
  66180. private _blurVPostProcess;
  66181. private _ssaoCombinePostProcess;
  66182. private _firstUpdate;
  66183. /**
  66184. * Gets active scene
  66185. */
  66186. readonly scene: Scene;
  66187. /**
  66188. * @constructor
  66189. * @param name - The rendering pipeline name
  66190. * @param scene - The scene linked to this pipeline
  66191. * @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 }
  66192. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66193. */
  66194. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66195. /**
  66196. * Get the class name
  66197. * @returns "SSAORenderingPipeline"
  66198. */
  66199. getClassName(): string;
  66200. /**
  66201. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66202. */
  66203. dispose(disableDepthRender?: boolean): void;
  66204. private _createBlurPostProcess;
  66205. /** @hidden */
  66206. _rebuild(): void;
  66207. private _createSSAOPostProcess;
  66208. private _createSSAOCombinePostProcess;
  66209. private _createRandomTexture;
  66210. }
  66211. }
  66212. declare module "babylonjs/Shaders/standard.fragment" {
  66213. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66214. /** @hidden */
  66215. export var standardPixelShader: {
  66216. name: string;
  66217. shader: string;
  66218. };
  66219. }
  66220. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  66221. import { Nullable } from "babylonjs/types";
  66222. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66223. import { Camera } from "babylonjs/Cameras/camera";
  66224. import { Texture } from "babylonjs/Materials/Textures/texture";
  66225. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66226. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66227. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  66228. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  66229. import { IDisposable } from "babylonjs/scene";
  66230. import { SpotLight } from "babylonjs/Lights/spotLight";
  66231. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  66232. import { Scene } from "babylonjs/scene";
  66233. import { Animation } from "babylonjs/Animations/animation";
  66234. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66235. import "babylonjs/Shaders/standard.fragment";
  66236. /**
  66237. * Standard rendering pipeline
  66238. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66239. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66240. */
  66241. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66242. /**
  66243. * Public members
  66244. */
  66245. /**
  66246. * Post-process which contains the original scene color before the pipeline applies all the effects
  66247. */
  66248. originalPostProcess: Nullable<PostProcess>;
  66249. /**
  66250. * Post-process used to down scale an image x4
  66251. */
  66252. downSampleX4PostProcess: Nullable<PostProcess>;
  66253. /**
  66254. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66255. */
  66256. brightPassPostProcess: Nullable<PostProcess>;
  66257. /**
  66258. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66259. */
  66260. blurHPostProcesses: PostProcess[];
  66261. /**
  66262. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66263. */
  66264. blurVPostProcesses: PostProcess[];
  66265. /**
  66266. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66267. */
  66268. textureAdderPostProcess: Nullable<PostProcess>;
  66269. /**
  66270. * Post-process used to create volumetric lighting effect
  66271. */
  66272. volumetricLightPostProcess: Nullable<PostProcess>;
  66273. /**
  66274. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66275. */
  66276. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66277. /**
  66278. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66279. */
  66280. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66281. /**
  66282. * Post-process used to merge the volumetric light effect and the real scene color
  66283. */
  66284. volumetricLightMergePostProces: Nullable<PostProcess>;
  66285. /**
  66286. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66287. */
  66288. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66289. /**
  66290. * Base post-process used to calculate the average luminance of the final image for HDR
  66291. */
  66292. luminancePostProcess: Nullable<PostProcess>;
  66293. /**
  66294. * Post-processes used to create down sample post-processes in order to get
  66295. * the average luminance of the final image for HDR
  66296. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66297. */
  66298. luminanceDownSamplePostProcesses: PostProcess[];
  66299. /**
  66300. * Post-process used to create a HDR effect (light adaptation)
  66301. */
  66302. hdrPostProcess: Nullable<PostProcess>;
  66303. /**
  66304. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66305. */
  66306. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66307. /**
  66308. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66309. */
  66310. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66311. /**
  66312. * Post-process used to merge the final HDR post-process and the real scene color
  66313. */
  66314. hdrFinalPostProcess: Nullable<PostProcess>;
  66315. /**
  66316. * Post-process used to create a lens flare effect
  66317. */
  66318. lensFlarePostProcess: Nullable<PostProcess>;
  66319. /**
  66320. * Post-process that merges the result of the lens flare post-process and the real scene color
  66321. */
  66322. lensFlareComposePostProcess: Nullable<PostProcess>;
  66323. /**
  66324. * Post-process used to create a motion blur effect
  66325. */
  66326. motionBlurPostProcess: Nullable<PostProcess>;
  66327. /**
  66328. * Post-process used to create a depth of field effect
  66329. */
  66330. depthOfFieldPostProcess: Nullable<PostProcess>;
  66331. /**
  66332. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66333. */
  66334. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66335. /**
  66336. * Represents the brightness threshold in order to configure the illuminated surfaces
  66337. */
  66338. brightThreshold: number;
  66339. /**
  66340. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66341. */
  66342. blurWidth: number;
  66343. /**
  66344. * Sets if the blur for highlighted surfaces must be only horizontal
  66345. */
  66346. horizontalBlur: boolean;
  66347. /**
  66348. * Gets the overall exposure used by the pipeline
  66349. */
  66350. /**
  66351. * Sets the overall exposure used by the pipeline
  66352. */
  66353. exposure: number;
  66354. /**
  66355. * Texture used typically to simulate "dirty" on camera lens
  66356. */
  66357. lensTexture: Nullable<Texture>;
  66358. /**
  66359. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66360. */
  66361. volumetricLightCoefficient: number;
  66362. /**
  66363. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66364. */
  66365. volumetricLightPower: number;
  66366. /**
  66367. * Used the set the blur intensity to smooth the volumetric lights
  66368. */
  66369. volumetricLightBlurScale: number;
  66370. /**
  66371. * Light (spot or directional) used to generate the volumetric lights rays
  66372. * The source light must have a shadow generate so the pipeline can get its
  66373. * depth map
  66374. */
  66375. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66376. /**
  66377. * For eye adaptation, represents the minimum luminance the eye can see
  66378. */
  66379. hdrMinimumLuminance: number;
  66380. /**
  66381. * For eye adaptation, represents the decrease luminance speed
  66382. */
  66383. hdrDecreaseRate: number;
  66384. /**
  66385. * For eye adaptation, represents the increase luminance speed
  66386. */
  66387. hdrIncreaseRate: number;
  66388. /**
  66389. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66390. */
  66391. /**
  66392. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66393. */
  66394. hdrAutoExposure: boolean;
  66395. /**
  66396. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66397. */
  66398. lensColorTexture: Nullable<Texture>;
  66399. /**
  66400. * The overall strengh for the lens flare effect
  66401. */
  66402. lensFlareStrength: number;
  66403. /**
  66404. * Dispersion coefficient for lens flare ghosts
  66405. */
  66406. lensFlareGhostDispersal: number;
  66407. /**
  66408. * Main lens flare halo width
  66409. */
  66410. lensFlareHaloWidth: number;
  66411. /**
  66412. * Based on the lens distortion effect, defines how much the lens flare result
  66413. * is distorted
  66414. */
  66415. lensFlareDistortionStrength: number;
  66416. /**
  66417. * Configures the blur intensity used for for lens flare (halo)
  66418. */
  66419. lensFlareBlurWidth: number;
  66420. /**
  66421. * Lens star texture must be used to simulate rays on the flares and is available
  66422. * in the documentation
  66423. */
  66424. lensStarTexture: Nullable<Texture>;
  66425. /**
  66426. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66427. * flare effect by taking account of the dirt texture
  66428. */
  66429. lensFlareDirtTexture: Nullable<Texture>;
  66430. /**
  66431. * Represents the focal length for the depth of field effect
  66432. */
  66433. depthOfFieldDistance: number;
  66434. /**
  66435. * Represents the blur intensity for the blurred part of the depth of field effect
  66436. */
  66437. depthOfFieldBlurWidth: number;
  66438. /**
  66439. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66440. */
  66441. /**
  66442. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66443. */
  66444. motionStrength: number;
  66445. /**
  66446. * Gets wether or not the motion blur post-process is object based or screen based.
  66447. */
  66448. /**
  66449. * Sets wether or not the motion blur post-process should be object based or screen based
  66450. */
  66451. objectBasedMotionBlur: boolean;
  66452. /**
  66453. * List of animations for the pipeline (IAnimatable implementation)
  66454. */
  66455. animations: Animation[];
  66456. /**
  66457. * Private members
  66458. */
  66459. private _scene;
  66460. private _currentDepthOfFieldSource;
  66461. private _basePostProcess;
  66462. private _fixedExposure;
  66463. private _currentExposure;
  66464. private _hdrAutoExposure;
  66465. private _hdrCurrentLuminance;
  66466. private _motionStrength;
  66467. private _isObjectBasedMotionBlur;
  66468. private _floatTextureType;
  66469. private _camerasToBeAttached;
  66470. private _ratio;
  66471. private _bloomEnabled;
  66472. private _depthOfFieldEnabled;
  66473. private _vlsEnabled;
  66474. private _lensFlareEnabled;
  66475. private _hdrEnabled;
  66476. private _motionBlurEnabled;
  66477. private _fxaaEnabled;
  66478. private _motionBlurSamples;
  66479. private _volumetricLightStepsCount;
  66480. private _samples;
  66481. /**
  66482. * @ignore
  66483. * Specifies if the bloom pipeline is enabled
  66484. */
  66485. BloomEnabled: boolean;
  66486. /**
  66487. * @ignore
  66488. * Specifies if the depth of field pipeline is enabed
  66489. */
  66490. DepthOfFieldEnabled: boolean;
  66491. /**
  66492. * @ignore
  66493. * Specifies if the lens flare pipeline is enabed
  66494. */
  66495. LensFlareEnabled: boolean;
  66496. /**
  66497. * @ignore
  66498. * Specifies if the HDR pipeline is enabled
  66499. */
  66500. HDREnabled: boolean;
  66501. /**
  66502. * @ignore
  66503. * Specifies if the volumetric lights scattering effect is enabled
  66504. */
  66505. VLSEnabled: boolean;
  66506. /**
  66507. * @ignore
  66508. * Specifies if the motion blur effect is enabled
  66509. */
  66510. MotionBlurEnabled: boolean;
  66511. /**
  66512. * Specifies if anti-aliasing is enabled
  66513. */
  66514. fxaaEnabled: boolean;
  66515. /**
  66516. * Specifies the number of steps used to calculate the volumetric lights
  66517. * Typically in interval [50, 200]
  66518. */
  66519. volumetricLightStepsCount: number;
  66520. /**
  66521. * Specifies the number of samples used for the motion blur effect
  66522. * Typically in interval [16, 64]
  66523. */
  66524. motionBlurSamples: number;
  66525. /**
  66526. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66527. */
  66528. samples: number;
  66529. /**
  66530. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66531. * @constructor
  66532. * @param name The rendering pipeline name
  66533. * @param scene The scene linked to this pipeline
  66534. * @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)
  66535. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66536. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66537. */
  66538. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66539. private _buildPipeline;
  66540. private _createDownSampleX4PostProcess;
  66541. private _createBrightPassPostProcess;
  66542. private _createBlurPostProcesses;
  66543. private _createTextureAdderPostProcess;
  66544. private _createVolumetricLightPostProcess;
  66545. private _createLuminancePostProcesses;
  66546. private _createHdrPostProcess;
  66547. private _createLensFlarePostProcess;
  66548. private _createDepthOfFieldPostProcess;
  66549. private _createMotionBlurPostProcess;
  66550. private _getDepthTexture;
  66551. private _disposePostProcesses;
  66552. /**
  66553. * Dispose of the pipeline and stop all post processes
  66554. */
  66555. dispose(): void;
  66556. /**
  66557. * Serialize the rendering pipeline (Used when exporting)
  66558. * @returns the serialized object
  66559. */
  66560. serialize(): any;
  66561. /**
  66562. * Parse the serialized pipeline
  66563. * @param source Source pipeline.
  66564. * @param scene The scene to load the pipeline to.
  66565. * @param rootUrl The URL of the serialized pipeline.
  66566. * @returns An instantiated pipeline from the serialized object.
  66567. */
  66568. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66569. /**
  66570. * Luminance steps
  66571. */
  66572. static LuminanceSteps: number;
  66573. }
  66574. }
  66575. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  66576. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  66577. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  66578. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  66579. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  66580. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  66581. }
  66582. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  66583. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  66584. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66585. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66586. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  66587. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66588. }
  66589. declare module "babylonjs/Shaders/tonemap.fragment" {
  66590. /** @hidden */
  66591. export var tonemapPixelShader: {
  66592. name: string;
  66593. shader: string;
  66594. };
  66595. }
  66596. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  66597. import { Camera } from "babylonjs/Cameras/camera";
  66598. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66599. import "babylonjs/Shaders/tonemap.fragment";
  66600. import { Engine } from "babylonjs/Engines/engine";
  66601. /** Defines operator used for tonemapping */
  66602. export enum TonemappingOperator {
  66603. /** Hable */
  66604. Hable = 0,
  66605. /** Reinhard */
  66606. Reinhard = 1,
  66607. /** HejiDawson */
  66608. HejiDawson = 2,
  66609. /** Photographic */
  66610. Photographic = 3
  66611. }
  66612. /**
  66613. * Defines a post process to apply tone mapping
  66614. */
  66615. export class TonemapPostProcess extends PostProcess {
  66616. private _operator;
  66617. /** Defines the required exposure adjustement */
  66618. exposureAdjustment: number;
  66619. /**
  66620. * Creates a new TonemapPostProcess
  66621. * @param name defines the name of the postprocess
  66622. * @param _operator defines the operator to use
  66623. * @param exposureAdjustment defines the required exposure adjustement
  66624. * @param camera defines the camera to use (can be null)
  66625. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66626. * @param engine defines the hosting engine (can be ignore if camera is set)
  66627. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66628. */
  66629. constructor(name: string, _operator: TonemappingOperator,
  66630. /** Defines the required exposure adjustement */
  66631. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66632. }
  66633. }
  66634. declare module "babylonjs/Shaders/depth.vertex" {
  66635. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66636. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66637. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66638. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66639. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66640. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66641. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66642. /** @hidden */
  66643. export var depthVertexShader: {
  66644. name: string;
  66645. shader: string;
  66646. };
  66647. }
  66648. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  66649. /** @hidden */
  66650. export var volumetricLightScatteringPixelShader: {
  66651. name: string;
  66652. shader: string;
  66653. };
  66654. }
  66655. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  66656. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66657. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66658. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66659. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66660. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66661. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66662. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66663. /** @hidden */
  66664. export var volumetricLightScatteringPassVertexShader: {
  66665. name: string;
  66666. shader: string;
  66667. };
  66668. }
  66669. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  66670. /** @hidden */
  66671. export var volumetricLightScatteringPassPixelShader: {
  66672. name: string;
  66673. shader: string;
  66674. };
  66675. }
  66676. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  66677. import { Vector3 } from "babylonjs/Maths/math.vector";
  66678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66679. import { Mesh } from "babylonjs/Meshes/mesh";
  66680. import { Camera } from "babylonjs/Cameras/camera";
  66681. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66682. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66683. import { Scene } from "babylonjs/scene";
  66684. import "babylonjs/Meshes/Builders/planeBuilder";
  66685. import "babylonjs/Shaders/depth.vertex";
  66686. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  66687. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  66688. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  66689. import { Engine } from "babylonjs/Engines/engine";
  66690. /**
  66691. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66692. */
  66693. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66694. private _volumetricLightScatteringPass;
  66695. private _volumetricLightScatteringRTT;
  66696. private _viewPort;
  66697. private _screenCoordinates;
  66698. private _cachedDefines;
  66699. /**
  66700. * If not undefined, the mesh position is computed from the attached node position
  66701. */
  66702. attachedNode: {
  66703. position: Vector3;
  66704. };
  66705. /**
  66706. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66707. */
  66708. customMeshPosition: Vector3;
  66709. /**
  66710. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66711. */
  66712. useCustomMeshPosition: boolean;
  66713. /**
  66714. * If the post-process should inverse the light scattering direction
  66715. */
  66716. invert: boolean;
  66717. /**
  66718. * The internal mesh used by the post-process
  66719. */
  66720. mesh: Mesh;
  66721. /**
  66722. * @hidden
  66723. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66724. */
  66725. useDiffuseColor: boolean;
  66726. /**
  66727. * Array containing the excluded meshes not rendered in the internal pass
  66728. */
  66729. excludedMeshes: AbstractMesh[];
  66730. /**
  66731. * Controls the overall intensity of the post-process
  66732. */
  66733. exposure: number;
  66734. /**
  66735. * Dissipates each sample's contribution in range [0, 1]
  66736. */
  66737. decay: number;
  66738. /**
  66739. * Controls the overall intensity of each sample
  66740. */
  66741. weight: number;
  66742. /**
  66743. * Controls the density of each sample
  66744. */
  66745. density: number;
  66746. /**
  66747. * @constructor
  66748. * @param name The post-process name
  66749. * @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)
  66750. * @param camera The camera that the post-process will be attached to
  66751. * @param mesh The mesh used to create the light scattering
  66752. * @param samples The post-process quality, default 100
  66753. * @param samplingModeThe post-process filtering mode
  66754. * @param engine The babylon engine
  66755. * @param reusable If the post-process is reusable
  66756. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66757. */
  66758. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66759. /**
  66760. * Returns the string "VolumetricLightScatteringPostProcess"
  66761. * @returns "VolumetricLightScatteringPostProcess"
  66762. */
  66763. getClassName(): string;
  66764. private _isReady;
  66765. /**
  66766. * Sets the new light position for light scattering effect
  66767. * @param position The new custom light position
  66768. */
  66769. setCustomMeshPosition(position: Vector3): void;
  66770. /**
  66771. * Returns the light position for light scattering effect
  66772. * @return Vector3 The custom light position
  66773. */
  66774. getCustomMeshPosition(): Vector3;
  66775. /**
  66776. * Disposes the internal assets and detaches the post-process from the camera
  66777. */
  66778. dispose(camera: Camera): void;
  66779. /**
  66780. * Returns the render target texture used by the post-process
  66781. * @return the render target texture used by the post-process
  66782. */
  66783. getPass(): RenderTargetTexture;
  66784. private _meshExcluded;
  66785. private _createPass;
  66786. private _updateMeshScreenCoordinates;
  66787. /**
  66788. * Creates a default mesh for the Volumeric Light Scattering post-process
  66789. * @param name The mesh name
  66790. * @param scene The scene where to create the mesh
  66791. * @return the default mesh
  66792. */
  66793. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66794. }
  66795. }
  66796. declare module "babylonjs/PostProcesses/index" {
  66797. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  66798. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  66799. export * from "babylonjs/PostProcesses/bloomEffect";
  66800. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  66801. export * from "babylonjs/PostProcesses/blurPostProcess";
  66802. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  66803. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  66804. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  66805. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  66806. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  66807. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  66808. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  66809. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  66810. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  66811. export * from "babylonjs/PostProcesses/filterPostProcess";
  66812. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  66813. export * from "babylonjs/PostProcesses/grainPostProcess";
  66814. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  66815. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  66816. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  66817. export * from "babylonjs/PostProcesses/passPostProcess";
  66818. export * from "babylonjs/PostProcesses/postProcess";
  66819. export * from "babylonjs/PostProcesses/postProcessManager";
  66820. export * from "babylonjs/PostProcesses/refractionPostProcess";
  66821. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  66822. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  66823. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  66824. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  66825. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  66826. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  66827. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  66828. }
  66829. declare module "babylonjs/Probes/index" {
  66830. export * from "babylonjs/Probes/reflectionProbe";
  66831. }
  66832. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  66833. import { Scene } from "babylonjs/scene";
  66834. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66835. import { SmartArray } from "babylonjs/Misc/smartArray";
  66836. import { ISceneComponent } from "babylonjs/sceneComponent";
  66837. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  66838. import "babylonjs/Meshes/Builders/boxBuilder";
  66839. import "babylonjs/Shaders/color.fragment";
  66840. import "babylonjs/Shaders/color.vertex";
  66841. import { Color3 } from "babylonjs/Maths/math.color";
  66842. module "babylonjs/scene" {
  66843. interface Scene {
  66844. /** @hidden (Backing field) */
  66845. _boundingBoxRenderer: BoundingBoxRenderer;
  66846. /** @hidden (Backing field) */
  66847. _forceShowBoundingBoxes: boolean;
  66848. /**
  66849. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66850. */
  66851. forceShowBoundingBoxes: boolean;
  66852. /**
  66853. * Gets the bounding box renderer associated with the scene
  66854. * @returns a BoundingBoxRenderer
  66855. */
  66856. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66857. }
  66858. }
  66859. module "babylonjs/Meshes/abstractMesh" {
  66860. interface AbstractMesh {
  66861. /** @hidden (Backing field) */
  66862. _showBoundingBox: boolean;
  66863. /**
  66864. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66865. */
  66866. showBoundingBox: boolean;
  66867. }
  66868. }
  66869. /**
  66870. * Component responsible of rendering the bounding box of the meshes in a scene.
  66871. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66872. */
  66873. export class BoundingBoxRenderer implements ISceneComponent {
  66874. /**
  66875. * The component name helpfull to identify the component in the list of scene components.
  66876. */
  66877. readonly name: string;
  66878. /**
  66879. * The scene the component belongs to.
  66880. */
  66881. scene: Scene;
  66882. /**
  66883. * Color of the bounding box lines placed in front of an object
  66884. */
  66885. frontColor: Color3;
  66886. /**
  66887. * Color of the bounding box lines placed behind an object
  66888. */
  66889. backColor: Color3;
  66890. /**
  66891. * Defines if the renderer should show the back lines or not
  66892. */
  66893. showBackLines: boolean;
  66894. /**
  66895. * @hidden
  66896. */
  66897. renderList: SmartArray<BoundingBox>;
  66898. private _colorShader;
  66899. private _vertexBuffers;
  66900. private _indexBuffer;
  66901. private _fillIndexBuffer;
  66902. private _fillIndexData;
  66903. /**
  66904. * Instantiates a new bounding box renderer in a scene.
  66905. * @param scene the scene the renderer renders in
  66906. */
  66907. constructor(scene: Scene);
  66908. /**
  66909. * Registers the component in a given scene
  66910. */
  66911. register(): void;
  66912. private _evaluateSubMesh;
  66913. private _activeMesh;
  66914. private _prepareRessources;
  66915. private _createIndexBuffer;
  66916. /**
  66917. * Rebuilds the elements related to this component in case of
  66918. * context lost for instance.
  66919. */
  66920. rebuild(): void;
  66921. /**
  66922. * @hidden
  66923. */
  66924. reset(): void;
  66925. /**
  66926. * Render the bounding boxes of a specific rendering group
  66927. * @param renderingGroupId defines the rendering group to render
  66928. */
  66929. render(renderingGroupId: number): void;
  66930. /**
  66931. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66932. * @param mesh Define the mesh to render the occlusion bounding box for
  66933. */
  66934. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66935. /**
  66936. * Dispose and release the resources attached to this renderer.
  66937. */
  66938. dispose(): void;
  66939. }
  66940. }
  66941. declare module "babylonjs/Shaders/depth.fragment" {
  66942. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66943. /** @hidden */
  66944. export var depthPixelShader: {
  66945. name: string;
  66946. shader: string;
  66947. };
  66948. }
  66949. declare module "babylonjs/Rendering/depthRenderer" {
  66950. import { Nullable } from "babylonjs/types";
  66951. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66952. import { Scene } from "babylonjs/scene";
  66953. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66954. import { Camera } from "babylonjs/Cameras/camera";
  66955. import "babylonjs/Shaders/depth.fragment";
  66956. import "babylonjs/Shaders/depth.vertex";
  66957. /**
  66958. * This represents a depth renderer in Babylon.
  66959. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  66960. */
  66961. export class DepthRenderer {
  66962. private _scene;
  66963. private _depthMap;
  66964. private _effect;
  66965. private readonly _storeNonLinearDepth;
  66966. private readonly _clearColor;
  66967. /** Get if the depth renderer is using packed depth or not */
  66968. readonly isPacked: boolean;
  66969. private _cachedDefines;
  66970. private _camera;
  66971. /**
  66972. * Specifiess that the depth renderer will only be used within
  66973. * the camera it is created for.
  66974. * This can help forcing its rendering during the camera processing.
  66975. */
  66976. useOnlyInActiveCamera: boolean;
  66977. /** @hidden */
  66978. static _SceneComponentInitialization: (scene: Scene) => void;
  66979. /**
  66980. * Instantiates a depth renderer
  66981. * @param scene The scene the renderer belongs to
  66982. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  66983. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  66984. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66985. */
  66986. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  66987. /**
  66988. * Creates the depth rendering effect and checks if the effect is ready.
  66989. * @param subMesh The submesh to be used to render the depth map of
  66990. * @param useInstances If multiple world instances should be used
  66991. * @returns if the depth renderer is ready to render the depth map
  66992. */
  66993. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66994. /**
  66995. * Gets the texture which the depth map will be written to.
  66996. * @returns The depth map texture
  66997. */
  66998. getDepthMap(): RenderTargetTexture;
  66999. /**
  67000. * Disposes of the depth renderer.
  67001. */
  67002. dispose(): void;
  67003. }
  67004. }
  67005. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  67006. import { Nullable } from "babylonjs/types";
  67007. import { Scene } from "babylonjs/scene";
  67008. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  67009. import { Camera } from "babylonjs/Cameras/camera";
  67010. import { ISceneComponent } from "babylonjs/sceneComponent";
  67011. module "babylonjs/scene" {
  67012. interface Scene {
  67013. /** @hidden (Backing field) */
  67014. _depthRenderer: {
  67015. [id: string]: DepthRenderer;
  67016. };
  67017. /**
  67018. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  67019. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  67020. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67021. * @returns the created depth renderer
  67022. */
  67023. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  67024. /**
  67025. * Disables a depth renderer for a given camera
  67026. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  67027. */
  67028. disableDepthRenderer(camera?: Nullable<Camera>): void;
  67029. }
  67030. }
  67031. /**
  67032. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  67033. * in several rendering techniques.
  67034. */
  67035. export class DepthRendererSceneComponent implements ISceneComponent {
  67036. /**
  67037. * The component name helpfull to identify the component in the list of scene components.
  67038. */
  67039. readonly name: string;
  67040. /**
  67041. * The scene the component belongs to.
  67042. */
  67043. scene: Scene;
  67044. /**
  67045. * Creates a new instance of the component for the given scene
  67046. * @param scene Defines the scene to register the component in
  67047. */
  67048. constructor(scene: Scene);
  67049. /**
  67050. * Registers the component in a given scene
  67051. */
  67052. register(): void;
  67053. /**
  67054. * Rebuilds the elements related to this component in case of
  67055. * context lost for instance.
  67056. */
  67057. rebuild(): void;
  67058. /**
  67059. * Disposes the component and the associated ressources
  67060. */
  67061. dispose(): void;
  67062. private _gatherRenderTargets;
  67063. private _gatherActiveCameraRenderTargets;
  67064. }
  67065. }
  67066. declare module "babylonjs/Shaders/outline.fragment" {
  67067. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  67068. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  67069. /** @hidden */
  67070. export var outlinePixelShader: {
  67071. name: string;
  67072. shader: string;
  67073. };
  67074. }
  67075. declare module "babylonjs/Shaders/outline.vertex" {
  67076. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67077. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67078. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67079. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67080. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  67081. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67082. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67083. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67084. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  67085. /** @hidden */
  67086. export var outlineVertexShader: {
  67087. name: string;
  67088. shader: string;
  67089. };
  67090. }
  67091. declare module "babylonjs/Rendering/outlineRenderer" {
  67092. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67093. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  67094. import { Scene } from "babylonjs/scene";
  67095. import { ISceneComponent } from "babylonjs/sceneComponent";
  67096. import "babylonjs/Shaders/outline.fragment";
  67097. import "babylonjs/Shaders/outline.vertex";
  67098. module "babylonjs/scene" {
  67099. interface Scene {
  67100. /** @hidden */
  67101. _outlineRenderer: OutlineRenderer;
  67102. /**
  67103. * Gets the outline renderer associated with the scene
  67104. * @returns a OutlineRenderer
  67105. */
  67106. getOutlineRenderer(): OutlineRenderer;
  67107. }
  67108. }
  67109. module "babylonjs/Meshes/abstractMesh" {
  67110. interface AbstractMesh {
  67111. /** @hidden (Backing field) */
  67112. _renderOutline: boolean;
  67113. /**
  67114. * Gets or sets a boolean indicating if the outline must be rendered as well
  67115. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  67116. */
  67117. renderOutline: boolean;
  67118. /** @hidden (Backing field) */
  67119. _renderOverlay: boolean;
  67120. /**
  67121. * Gets or sets a boolean indicating if the overlay must be rendered as well
  67122. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  67123. */
  67124. renderOverlay: boolean;
  67125. }
  67126. }
  67127. /**
  67128. * This class is responsible to draw bothe outline/overlay of meshes.
  67129. * It should not be used directly but through the available method on mesh.
  67130. */
  67131. export class OutlineRenderer implements ISceneComponent {
  67132. /**
  67133. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  67134. */
  67135. private static _StencilReference;
  67136. /**
  67137. * The name of the component. Each component must have a unique name.
  67138. */
  67139. name: string;
  67140. /**
  67141. * The scene the component belongs to.
  67142. */
  67143. scene: Scene;
  67144. /**
  67145. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  67146. */
  67147. zOffset: number;
  67148. private _engine;
  67149. private _effect;
  67150. private _cachedDefines;
  67151. private _savedDepthWrite;
  67152. /**
  67153. * Instantiates a new outline renderer. (There could be only one per scene).
  67154. * @param scene Defines the scene it belongs to
  67155. */
  67156. constructor(scene: Scene);
  67157. /**
  67158. * Register the component to one instance of a scene.
  67159. */
  67160. register(): void;
  67161. /**
  67162. * Rebuilds the elements related to this component in case of
  67163. * context lost for instance.
  67164. */
  67165. rebuild(): void;
  67166. /**
  67167. * Disposes the component and the associated ressources.
  67168. */
  67169. dispose(): void;
  67170. /**
  67171. * Renders the outline in the canvas.
  67172. * @param subMesh Defines the sumesh to render
  67173. * @param batch Defines the batch of meshes in case of instances
  67174. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67175. */
  67176. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67177. /**
  67178. * Returns whether or not the outline renderer is ready for a given submesh.
  67179. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67180. * @param subMesh Defines the submesh to check readyness for
  67181. * @param useInstances Defines wheter wee are trying to render instances or not
  67182. * @returns true if ready otherwise false
  67183. */
  67184. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67185. private _beforeRenderingMesh;
  67186. private _afterRenderingMesh;
  67187. }
  67188. }
  67189. declare module "babylonjs/Rendering/index" {
  67190. export * from "babylonjs/Rendering/boundingBoxRenderer";
  67191. export * from "babylonjs/Rendering/depthRenderer";
  67192. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  67193. export * from "babylonjs/Rendering/edgesRenderer";
  67194. export * from "babylonjs/Rendering/geometryBufferRenderer";
  67195. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  67196. export * from "babylonjs/Rendering/outlineRenderer";
  67197. export * from "babylonjs/Rendering/renderingGroup";
  67198. export * from "babylonjs/Rendering/renderingManager";
  67199. export * from "babylonjs/Rendering/utilityLayerRenderer";
  67200. }
  67201. declare module "babylonjs/Sprites/ISprites" {
  67202. /**
  67203. * Defines the basic options interface of a Sprite Frame Source Size.
  67204. */
  67205. export interface ISpriteJSONSpriteSourceSize {
  67206. /**
  67207. * number of the original width of the Frame
  67208. */
  67209. w: number;
  67210. /**
  67211. * number of the original height of the Frame
  67212. */
  67213. h: number;
  67214. }
  67215. /**
  67216. * Defines the basic options interface of a Sprite Frame Data.
  67217. */
  67218. export interface ISpriteJSONSpriteFrameData {
  67219. /**
  67220. * number of the x offset of the Frame
  67221. */
  67222. x: number;
  67223. /**
  67224. * number of the y offset of the Frame
  67225. */
  67226. y: number;
  67227. /**
  67228. * number of the width of the Frame
  67229. */
  67230. w: number;
  67231. /**
  67232. * number of the height of the Frame
  67233. */
  67234. h: number;
  67235. }
  67236. /**
  67237. * Defines the basic options interface of a JSON Sprite.
  67238. */
  67239. export interface ISpriteJSONSprite {
  67240. /**
  67241. * string name of the Frame
  67242. */
  67243. filename: string;
  67244. /**
  67245. * ISpriteJSONSpriteFrame basic object of the frame data
  67246. */
  67247. frame: ISpriteJSONSpriteFrameData;
  67248. /**
  67249. * boolean to flag is the frame was rotated.
  67250. */
  67251. rotated: boolean;
  67252. /**
  67253. * boolean to flag is the frame was trimmed.
  67254. */
  67255. trimmed: boolean;
  67256. /**
  67257. * ISpriteJSONSpriteFrame basic object of the source data
  67258. */
  67259. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67260. /**
  67261. * ISpriteJSONSpriteFrame basic object of the source data
  67262. */
  67263. sourceSize: ISpriteJSONSpriteSourceSize;
  67264. }
  67265. /**
  67266. * Defines the basic options interface of a JSON atlas.
  67267. */
  67268. export interface ISpriteJSONAtlas {
  67269. /**
  67270. * Array of objects that contain the frame data.
  67271. */
  67272. frames: Array<ISpriteJSONSprite>;
  67273. /**
  67274. * object basic object containing the sprite meta data.
  67275. */
  67276. meta?: object;
  67277. }
  67278. }
  67279. declare module "babylonjs/Shaders/spriteMap.fragment" {
  67280. /** @hidden */
  67281. export var spriteMapPixelShader: {
  67282. name: string;
  67283. shader: string;
  67284. };
  67285. }
  67286. declare module "babylonjs/Shaders/spriteMap.vertex" {
  67287. /** @hidden */
  67288. export var spriteMapVertexShader: {
  67289. name: string;
  67290. shader: string;
  67291. };
  67292. }
  67293. declare module "babylonjs/Sprites/spriteMap" {
  67294. import { IDisposable, Scene } from "babylonjs/scene";
  67295. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  67296. import { Texture } from "babylonjs/Materials/Textures/texture";
  67297. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  67298. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  67299. import "babylonjs/Meshes/Builders/planeBuilder";
  67300. import "babylonjs/Shaders/spriteMap.fragment";
  67301. import "babylonjs/Shaders/spriteMap.vertex";
  67302. /**
  67303. * Defines the basic options interface of a SpriteMap
  67304. */
  67305. export interface ISpriteMapOptions {
  67306. /**
  67307. * Vector2 of the number of cells in the grid.
  67308. */
  67309. stageSize?: Vector2;
  67310. /**
  67311. * Vector2 of the size of the output plane in World Units.
  67312. */
  67313. outputSize?: Vector2;
  67314. /**
  67315. * Vector3 of the position of the output plane in World Units.
  67316. */
  67317. outputPosition?: Vector3;
  67318. /**
  67319. * Vector3 of the rotation of the output plane.
  67320. */
  67321. outputRotation?: Vector3;
  67322. /**
  67323. * number of layers that the system will reserve in resources.
  67324. */
  67325. layerCount?: number;
  67326. /**
  67327. * number of max animation frames a single cell will reserve in resources.
  67328. */
  67329. maxAnimationFrames?: number;
  67330. /**
  67331. * number cell index of the base tile when the system compiles.
  67332. */
  67333. baseTile?: number;
  67334. /**
  67335. * boolean flip the sprite after its been repositioned by the framing data.
  67336. */
  67337. flipU?: boolean;
  67338. /**
  67339. * Vector3 scalar of the global RGB values of the SpriteMap.
  67340. */
  67341. colorMultiply?: Vector3;
  67342. }
  67343. /**
  67344. * Defines the IDisposable interface in order to be cleanable from resources.
  67345. */
  67346. export interface ISpriteMap extends IDisposable {
  67347. /**
  67348. * String name of the SpriteMap.
  67349. */
  67350. name: string;
  67351. /**
  67352. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67353. */
  67354. atlasJSON: ISpriteJSONAtlas;
  67355. /**
  67356. * Texture of the SpriteMap.
  67357. */
  67358. spriteSheet: Texture;
  67359. /**
  67360. * The parameters to initialize the SpriteMap with.
  67361. */
  67362. options: ISpriteMapOptions;
  67363. }
  67364. /**
  67365. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67366. */
  67367. export class SpriteMap implements ISpriteMap {
  67368. /** The Name of the spriteMap */
  67369. name: string;
  67370. /** The JSON file with the frame and meta data */
  67371. atlasJSON: ISpriteJSONAtlas;
  67372. /** The systems Sprite Sheet Texture */
  67373. spriteSheet: Texture;
  67374. /** Arguments passed with the Constructor */
  67375. options: ISpriteMapOptions;
  67376. /** Public Sprite Storage array, parsed from atlasJSON */
  67377. sprites: Array<ISpriteJSONSprite>;
  67378. /** Returns the Number of Sprites in the System */
  67379. readonly spriteCount: number;
  67380. /** Returns the Position of Output Plane*/
  67381. /** Returns the Position of Output Plane*/
  67382. position: Vector3;
  67383. /** Returns the Rotation of Output Plane*/
  67384. /** Returns the Rotation of Output Plane*/
  67385. rotation: Vector3;
  67386. /** Sets the AnimationMap*/
  67387. /** Sets the AnimationMap*/
  67388. animationMap: RawTexture;
  67389. /** Scene that the SpriteMap was created in */
  67390. private _scene;
  67391. /** Texture Buffer of Float32 that holds tile frame data*/
  67392. private _frameMap;
  67393. /** Texture Buffers of Float32 that holds tileMap data*/
  67394. private _tileMaps;
  67395. /** Texture Buffer of Float32 that holds Animation Data*/
  67396. private _animationMap;
  67397. /** Custom ShaderMaterial Central to the System*/
  67398. private _material;
  67399. /** Custom ShaderMaterial Central to the System*/
  67400. private _output;
  67401. /** Systems Time Ticker*/
  67402. private _time;
  67403. /**
  67404. * Creates a new SpriteMap
  67405. * @param name defines the SpriteMaps Name
  67406. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67407. * @param spriteSheet is the Texture that the Sprites are on.
  67408. * @param options a basic deployment configuration
  67409. * @param scene The Scene that the map is deployed on
  67410. */
  67411. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67412. /**
  67413. * Returns tileID location
  67414. * @returns Vector2 the cell position ID
  67415. */
  67416. getTileID(): Vector2;
  67417. /**
  67418. * Gets the UV location of the mouse over the SpriteMap.
  67419. * @returns Vector2 the UV position of the mouse interaction
  67420. */
  67421. getMousePosition(): Vector2;
  67422. /**
  67423. * Creates the "frame" texture Buffer
  67424. * -------------------------------------
  67425. * Structure of frames
  67426. * "filename": "Falling-Water-2.png",
  67427. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67428. * "rotated": true,
  67429. * "trimmed": true,
  67430. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67431. * "sourceSize": {"w":32,"h":32}
  67432. * @returns RawTexture of the frameMap
  67433. */
  67434. private _createFrameBuffer;
  67435. /**
  67436. * Creates the tileMap texture Buffer
  67437. * @param buffer normally and array of numbers, or a false to generate from scratch
  67438. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67439. * @returns RawTexture of the tileMap
  67440. */
  67441. private _createTileBuffer;
  67442. /**
  67443. * Modifies the data of the tileMaps
  67444. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67445. * @param pos is the iVector2 Coordinates of the Tile
  67446. * @param tile The SpriteIndex of the new Tile
  67447. */
  67448. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67449. /**
  67450. * Creates the animationMap texture Buffer
  67451. * @param buffer normally and array of numbers, or a false to generate from scratch
  67452. * @returns RawTexture of the animationMap
  67453. */
  67454. private _createTileAnimationBuffer;
  67455. /**
  67456. * Modifies the data of the animationMap
  67457. * @param cellID is the Index of the Sprite
  67458. * @param _frame is the target Animation frame
  67459. * @param toCell is the Target Index of the next frame of the animation
  67460. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67461. * @param speed is a global scalar of the time variable on the map.
  67462. */
  67463. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67464. /**
  67465. * Exports the .tilemaps file
  67466. */
  67467. saveTileMaps(): void;
  67468. /**
  67469. * Imports the .tilemaps file
  67470. * @param url of the .tilemaps file
  67471. */
  67472. loadTileMaps(url: string): void;
  67473. /**
  67474. * Release associated resources
  67475. */
  67476. dispose(): void;
  67477. }
  67478. }
  67479. declare module "babylonjs/Sprites/spritePackedManager" {
  67480. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  67481. import { Scene } from "babylonjs/scene";
  67482. /**
  67483. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67484. * @see http://doc.babylonjs.com/babylon101/sprites
  67485. */
  67486. export class SpritePackedManager extends SpriteManager {
  67487. /** defines the packed manager's name */
  67488. name: string;
  67489. /**
  67490. * Creates a new sprite manager from a packed sprite sheet
  67491. * @param name defines the manager's name
  67492. * @param imgUrl defines the sprite sheet url
  67493. * @param capacity defines the maximum allowed number of sprites
  67494. * @param scene defines the hosting scene
  67495. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67496. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67497. * @param samplingMode defines the smapling mode to use with spritesheet
  67498. * @param fromPacked set to true; do not alter
  67499. */
  67500. constructor(
  67501. /** defines the packed manager's name */
  67502. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67503. }
  67504. }
  67505. declare module "babylonjs/Sprites/index" {
  67506. export * from "babylonjs/Sprites/sprite";
  67507. export * from "babylonjs/Sprites/ISprites";
  67508. export * from "babylonjs/Sprites/spriteManager";
  67509. export * from "babylonjs/Sprites/spriteMap";
  67510. export * from "babylonjs/Sprites/spritePackedManager";
  67511. export * from "babylonjs/Sprites/spriteSceneComponent";
  67512. }
  67513. declare module "babylonjs/States/index" {
  67514. export * from "babylonjs/States/alphaCullingState";
  67515. export * from "babylonjs/States/depthCullingState";
  67516. export * from "babylonjs/States/stencilState";
  67517. }
  67518. declare module "babylonjs/Misc/assetsManager" {
  67519. import { Scene } from "babylonjs/scene";
  67520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67521. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  67522. import { Skeleton } from "babylonjs/Bones/skeleton";
  67523. import { Observable } from "babylonjs/Misc/observable";
  67524. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67525. import { Texture } from "babylonjs/Materials/Textures/texture";
  67526. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  67527. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  67528. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  67529. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  67530. /**
  67531. * Defines the list of states available for a task inside a AssetsManager
  67532. */
  67533. export enum AssetTaskState {
  67534. /**
  67535. * Initialization
  67536. */
  67537. INIT = 0,
  67538. /**
  67539. * Running
  67540. */
  67541. RUNNING = 1,
  67542. /**
  67543. * Done
  67544. */
  67545. DONE = 2,
  67546. /**
  67547. * Error
  67548. */
  67549. ERROR = 3
  67550. }
  67551. /**
  67552. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67553. */
  67554. export abstract class AbstractAssetTask {
  67555. /**
  67556. * Task name
  67557. */ name: string;
  67558. /**
  67559. * Callback called when the task is successful
  67560. */
  67561. onSuccess: (task: any) => void;
  67562. /**
  67563. * Callback called when the task is not successful
  67564. */
  67565. onError: (task: any, message?: string, exception?: any) => void;
  67566. /**
  67567. * Creates a new AssetsManager
  67568. * @param name defines the name of the task
  67569. */
  67570. constructor(
  67571. /**
  67572. * Task name
  67573. */ name: string);
  67574. private _isCompleted;
  67575. private _taskState;
  67576. private _errorObject;
  67577. /**
  67578. * Get if the task is completed
  67579. */
  67580. readonly isCompleted: boolean;
  67581. /**
  67582. * Gets the current state of the task
  67583. */
  67584. readonly taskState: AssetTaskState;
  67585. /**
  67586. * Gets the current error object (if task is in error)
  67587. */
  67588. readonly errorObject: {
  67589. message?: string;
  67590. exception?: any;
  67591. };
  67592. /**
  67593. * Internal only
  67594. * @hidden
  67595. */
  67596. _setErrorObject(message?: string, exception?: any): void;
  67597. /**
  67598. * Execute the current task
  67599. * @param scene defines the scene where you want your assets to be loaded
  67600. * @param onSuccess is a callback called when the task is successfully executed
  67601. * @param onError is a callback called if an error occurs
  67602. */
  67603. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67604. /**
  67605. * Execute the current task
  67606. * @param scene defines the scene where you want your assets to be loaded
  67607. * @param onSuccess is a callback called when the task is successfully executed
  67608. * @param onError is a callback called if an error occurs
  67609. */
  67610. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67611. /**
  67612. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67613. * This can be used with failed tasks that have the reason for failure fixed.
  67614. */
  67615. reset(): void;
  67616. private onErrorCallback;
  67617. private onDoneCallback;
  67618. }
  67619. /**
  67620. * Define the interface used by progress events raised during assets loading
  67621. */
  67622. export interface IAssetsProgressEvent {
  67623. /**
  67624. * Defines the number of remaining tasks to process
  67625. */
  67626. remainingCount: number;
  67627. /**
  67628. * Defines the total number of tasks
  67629. */
  67630. totalCount: number;
  67631. /**
  67632. * Defines the task that was just processed
  67633. */
  67634. task: AbstractAssetTask;
  67635. }
  67636. /**
  67637. * Class used to share progress information about assets loading
  67638. */
  67639. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67640. /**
  67641. * Defines the number of remaining tasks to process
  67642. */
  67643. remainingCount: number;
  67644. /**
  67645. * Defines the total number of tasks
  67646. */
  67647. totalCount: number;
  67648. /**
  67649. * Defines the task that was just processed
  67650. */
  67651. task: AbstractAssetTask;
  67652. /**
  67653. * Creates a AssetsProgressEvent
  67654. * @param remainingCount defines the number of remaining tasks to process
  67655. * @param totalCount defines the total number of tasks
  67656. * @param task defines the task that was just processed
  67657. */
  67658. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67659. }
  67660. /**
  67661. * Define a task used by AssetsManager to load meshes
  67662. */
  67663. export class MeshAssetTask extends AbstractAssetTask {
  67664. /**
  67665. * Defines the name of the task
  67666. */
  67667. name: string;
  67668. /**
  67669. * Defines the list of mesh's names you want to load
  67670. */
  67671. meshesNames: any;
  67672. /**
  67673. * Defines the root url to use as a base to load your meshes and associated resources
  67674. */
  67675. rootUrl: string;
  67676. /**
  67677. * Defines the filename of the scene to load from
  67678. */
  67679. sceneFilename: string;
  67680. /**
  67681. * Gets the list of loaded meshes
  67682. */
  67683. loadedMeshes: Array<AbstractMesh>;
  67684. /**
  67685. * Gets the list of loaded particle systems
  67686. */
  67687. loadedParticleSystems: Array<IParticleSystem>;
  67688. /**
  67689. * Gets the list of loaded skeletons
  67690. */
  67691. loadedSkeletons: Array<Skeleton>;
  67692. /**
  67693. * Gets the list of loaded animation groups
  67694. */
  67695. loadedAnimationGroups: Array<AnimationGroup>;
  67696. /**
  67697. * Callback called when the task is successful
  67698. */
  67699. onSuccess: (task: MeshAssetTask) => void;
  67700. /**
  67701. * Callback called when the task is successful
  67702. */
  67703. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67704. /**
  67705. * Creates a new MeshAssetTask
  67706. * @param name defines the name of the task
  67707. * @param meshesNames defines the list of mesh's names you want to load
  67708. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67709. * @param sceneFilename defines the filename of the scene to load from
  67710. */
  67711. constructor(
  67712. /**
  67713. * Defines the name of the task
  67714. */
  67715. name: string,
  67716. /**
  67717. * Defines the list of mesh's names you want to load
  67718. */
  67719. meshesNames: any,
  67720. /**
  67721. * Defines the root url to use as a base to load your meshes and associated resources
  67722. */
  67723. rootUrl: string,
  67724. /**
  67725. * Defines the filename of the scene to load from
  67726. */
  67727. sceneFilename: string);
  67728. /**
  67729. * Execute the current task
  67730. * @param scene defines the scene where you want your assets to be loaded
  67731. * @param onSuccess is a callback called when the task is successfully executed
  67732. * @param onError is a callback called if an error occurs
  67733. */
  67734. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67735. }
  67736. /**
  67737. * Define a task used by AssetsManager to load text content
  67738. */
  67739. export class TextFileAssetTask extends AbstractAssetTask {
  67740. /**
  67741. * Defines the name of the task
  67742. */
  67743. name: string;
  67744. /**
  67745. * Defines the location of the file to load
  67746. */
  67747. url: string;
  67748. /**
  67749. * Gets the loaded text string
  67750. */
  67751. text: string;
  67752. /**
  67753. * Callback called when the task is successful
  67754. */
  67755. onSuccess: (task: TextFileAssetTask) => void;
  67756. /**
  67757. * Callback called when the task is successful
  67758. */
  67759. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67760. /**
  67761. * Creates a new TextFileAssetTask object
  67762. * @param name defines the name of the task
  67763. * @param url defines the location of the file to load
  67764. */
  67765. constructor(
  67766. /**
  67767. * Defines the name of the task
  67768. */
  67769. name: string,
  67770. /**
  67771. * Defines the location of the file to load
  67772. */
  67773. url: string);
  67774. /**
  67775. * Execute the current task
  67776. * @param scene defines the scene where you want your assets to be loaded
  67777. * @param onSuccess is a callback called when the task is successfully executed
  67778. * @param onError is a callback called if an error occurs
  67779. */
  67780. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67781. }
  67782. /**
  67783. * Define a task used by AssetsManager to load binary data
  67784. */
  67785. export class BinaryFileAssetTask extends AbstractAssetTask {
  67786. /**
  67787. * Defines the name of the task
  67788. */
  67789. name: string;
  67790. /**
  67791. * Defines the location of the file to load
  67792. */
  67793. url: string;
  67794. /**
  67795. * Gets the lodaded data (as an array buffer)
  67796. */
  67797. data: ArrayBuffer;
  67798. /**
  67799. * Callback called when the task is successful
  67800. */
  67801. onSuccess: (task: BinaryFileAssetTask) => void;
  67802. /**
  67803. * Callback called when the task is successful
  67804. */
  67805. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67806. /**
  67807. * Creates a new BinaryFileAssetTask object
  67808. * @param name defines the name of the new task
  67809. * @param url defines the location of the file to load
  67810. */
  67811. constructor(
  67812. /**
  67813. * Defines the name of the task
  67814. */
  67815. name: string,
  67816. /**
  67817. * Defines the location of the file to load
  67818. */
  67819. url: string);
  67820. /**
  67821. * Execute the current task
  67822. * @param scene defines the scene where you want your assets to be loaded
  67823. * @param onSuccess is a callback called when the task is successfully executed
  67824. * @param onError is a callback called if an error occurs
  67825. */
  67826. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67827. }
  67828. /**
  67829. * Define a task used by AssetsManager to load images
  67830. */
  67831. export class ImageAssetTask extends AbstractAssetTask {
  67832. /**
  67833. * Defines the name of the task
  67834. */
  67835. name: string;
  67836. /**
  67837. * Defines the location of the image to load
  67838. */
  67839. url: string;
  67840. /**
  67841. * Gets the loaded images
  67842. */
  67843. image: HTMLImageElement;
  67844. /**
  67845. * Callback called when the task is successful
  67846. */
  67847. onSuccess: (task: ImageAssetTask) => void;
  67848. /**
  67849. * Callback called when the task is successful
  67850. */
  67851. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67852. /**
  67853. * Creates a new ImageAssetTask
  67854. * @param name defines the name of the task
  67855. * @param url defines the location of the image to load
  67856. */
  67857. constructor(
  67858. /**
  67859. * Defines the name of the task
  67860. */
  67861. name: string,
  67862. /**
  67863. * Defines the location of the image to load
  67864. */
  67865. url: string);
  67866. /**
  67867. * Execute the current task
  67868. * @param scene defines the scene where you want your assets to be loaded
  67869. * @param onSuccess is a callback called when the task is successfully executed
  67870. * @param onError is a callback called if an error occurs
  67871. */
  67872. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67873. }
  67874. /**
  67875. * Defines the interface used by texture loading tasks
  67876. */
  67877. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67878. /**
  67879. * Gets the loaded texture
  67880. */
  67881. texture: TEX;
  67882. }
  67883. /**
  67884. * Define a task used by AssetsManager to load 2D textures
  67885. */
  67886. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67887. /**
  67888. * Defines the name of the task
  67889. */
  67890. name: string;
  67891. /**
  67892. * Defines the location of the file to load
  67893. */
  67894. url: string;
  67895. /**
  67896. * Defines if mipmap should not be generated (default is false)
  67897. */
  67898. noMipmap?: boolean | undefined;
  67899. /**
  67900. * Defines if texture must be inverted on Y axis (default is false)
  67901. */
  67902. invertY?: boolean | undefined;
  67903. /**
  67904. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67905. */
  67906. samplingMode: number;
  67907. /**
  67908. * Gets the loaded texture
  67909. */
  67910. texture: Texture;
  67911. /**
  67912. * Callback called when the task is successful
  67913. */
  67914. onSuccess: (task: TextureAssetTask) => void;
  67915. /**
  67916. * Callback called when the task is successful
  67917. */
  67918. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67919. /**
  67920. * Creates a new TextureAssetTask object
  67921. * @param name defines the name of the task
  67922. * @param url defines the location of the file to load
  67923. * @param noMipmap defines if mipmap should not be generated (default is false)
  67924. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67925. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67926. */
  67927. constructor(
  67928. /**
  67929. * Defines the name of the task
  67930. */
  67931. name: string,
  67932. /**
  67933. * Defines the location of the file to load
  67934. */
  67935. url: string,
  67936. /**
  67937. * Defines if mipmap should not be generated (default is false)
  67938. */
  67939. noMipmap?: boolean | undefined,
  67940. /**
  67941. * Defines if texture must be inverted on Y axis (default is false)
  67942. */
  67943. invertY?: boolean | undefined,
  67944. /**
  67945. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67946. */
  67947. samplingMode?: number);
  67948. /**
  67949. * Execute the current task
  67950. * @param scene defines the scene where you want your assets to be loaded
  67951. * @param onSuccess is a callback called when the task is successfully executed
  67952. * @param onError is a callback called if an error occurs
  67953. */
  67954. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67955. }
  67956. /**
  67957. * Define a task used by AssetsManager to load cube textures
  67958. */
  67959. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67960. /**
  67961. * Defines the name of the task
  67962. */
  67963. name: string;
  67964. /**
  67965. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67966. */
  67967. url: string;
  67968. /**
  67969. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67970. */
  67971. extensions?: string[] | undefined;
  67972. /**
  67973. * Defines if mipmaps should not be generated (default is false)
  67974. */
  67975. noMipmap?: boolean | undefined;
  67976. /**
  67977. * Defines the explicit list of files (undefined by default)
  67978. */
  67979. files?: string[] | undefined;
  67980. /**
  67981. * Gets the loaded texture
  67982. */
  67983. texture: CubeTexture;
  67984. /**
  67985. * Callback called when the task is successful
  67986. */
  67987. onSuccess: (task: CubeTextureAssetTask) => void;
  67988. /**
  67989. * Callback called when the task is successful
  67990. */
  67991. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67992. /**
  67993. * Creates a new CubeTextureAssetTask
  67994. * @param name defines the name of the task
  67995. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67996. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67997. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67998. * @param files defines the explicit list of files (undefined by default)
  67999. */
  68000. constructor(
  68001. /**
  68002. * Defines the name of the task
  68003. */
  68004. name: string,
  68005. /**
  68006. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68007. */
  68008. url: string,
  68009. /**
  68010. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68011. */
  68012. extensions?: string[] | undefined,
  68013. /**
  68014. * Defines if mipmaps should not be generated (default is false)
  68015. */
  68016. noMipmap?: boolean | undefined,
  68017. /**
  68018. * Defines the explicit list of files (undefined by default)
  68019. */
  68020. files?: string[] | undefined);
  68021. /**
  68022. * Execute the current task
  68023. * @param scene defines the scene where you want your assets to be loaded
  68024. * @param onSuccess is a callback called when the task is successfully executed
  68025. * @param onError is a callback called if an error occurs
  68026. */
  68027. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68028. }
  68029. /**
  68030. * Define a task used by AssetsManager to load HDR cube textures
  68031. */
  68032. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  68033. /**
  68034. * Defines the name of the task
  68035. */
  68036. name: string;
  68037. /**
  68038. * Defines the location of the file to load
  68039. */
  68040. url: string;
  68041. /**
  68042. * Defines the desired size (the more it increases the longer the generation will be)
  68043. */
  68044. size: number;
  68045. /**
  68046. * Defines if mipmaps should not be generated (default is false)
  68047. */
  68048. noMipmap: boolean;
  68049. /**
  68050. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68051. */
  68052. generateHarmonics: boolean;
  68053. /**
  68054. * 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)
  68055. */
  68056. gammaSpace: boolean;
  68057. /**
  68058. * Internal Use Only
  68059. */
  68060. reserved: boolean;
  68061. /**
  68062. * Gets the loaded texture
  68063. */
  68064. texture: HDRCubeTexture;
  68065. /**
  68066. * Callback called when the task is successful
  68067. */
  68068. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  68069. /**
  68070. * Callback called when the task is successful
  68071. */
  68072. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  68073. /**
  68074. * Creates a new HDRCubeTextureAssetTask object
  68075. * @param name defines the name of the task
  68076. * @param url defines the location of the file to load
  68077. * @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.
  68078. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68079. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68080. * @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)
  68081. * @param reserved Internal use only
  68082. */
  68083. constructor(
  68084. /**
  68085. * Defines the name of the task
  68086. */
  68087. name: string,
  68088. /**
  68089. * Defines the location of the file to load
  68090. */
  68091. url: string,
  68092. /**
  68093. * Defines the desired size (the more it increases the longer the generation will be)
  68094. */
  68095. size: number,
  68096. /**
  68097. * Defines if mipmaps should not be generated (default is false)
  68098. */
  68099. noMipmap?: boolean,
  68100. /**
  68101. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68102. */
  68103. generateHarmonics?: boolean,
  68104. /**
  68105. * 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)
  68106. */
  68107. gammaSpace?: boolean,
  68108. /**
  68109. * Internal Use Only
  68110. */
  68111. reserved?: boolean);
  68112. /**
  68113. * Execute the current task
  68114. * @param scene defines the scene where you want your assets to be loaded
  68115. * @param onSuccess is a callback called when the task is successfully executed
  68116. * @param onError is a callback called if an error occurs
  68117. */
  68118. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68119. }
  68120. /**
  68121. * Define a task used by AssetsManager to load Equirectangular cube textures
  68122. */
  68123. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  68124. /**
  68125. * Defines the name of the task
  68126. */
  68127. name: string;
  68128. /**
  68129. * Defines the location of the file to load
  68130. */
  68131. url: string;
  68132. /**
  68133. * Defines the desired size (the more it increases the longer the generation will be)
  68134. */
  68135. size: number;
  68136. /**
  68137. * Defines if mipmaps should not be generated (default is false)
  68138. */
  68139. noMipmap: boolean;
  68140. /**
  68141. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68142. * but the standard material would require them in Gamma space) (default is true)
  68143. */
  68144. gammaSpace: boolean;
  68145. /**
  68146. * Gets the loaded texture
  68147. */
  68148. texture: EquiRectangularCubeTexture;
  68149. /**
  68150. * Callback called when the task is successful
  68151. */
  68152. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  68153. /**
  68154. * Callback called when the task is successful
  68155. */
  68156. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  68157. /**
  68158. * Creates a new EquiRectangularCubeTextureAssetTask object
  68159. * @param name defines the name of the task
  68160. * @param url defines the location of the file to load
  68161. * @param size defines the desired size (the more it increases the longer the generation will be)
  68162. * If the size is omitted this implies you are using a preprocessed cubemap.
  68163. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68164. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  68165. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68166. * (default is true)
  68167. */
  68168. constructor(
  68169. /**
  68170. * Defines the name of the task
  68171. */
  68172. name: string,
  68173. /**
  68174. * Defines the location of the file to load
  68175. */
  68176. url: string,
  68177. /**
  68178. * Defines the desired size (the more it increases the longer the generation will be)
  68179. */
  68180. size: number,
  68181. /**
  68182. * Defines if mipmaps should not be generated (default is false)
  68183. */
  68184. noMipmap?: boolean,
  68185. /**
  68186. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68187. * but the standard material would require them in Gamma space) (default is true)
  68188. */
  68189. gammaSpace?: boolean);
  68190. /**
  68191. * Execute the current task
  68192. * @param scene defines the scene where you want your assets to be loaded
  68193. * @param onSuccess is a callback called when the task is successfully executed
  68194. * @param onError is a callback called if an error occurs
  68195. */
  68196. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68197. }
  68198. /**
  68199. * This class can be used to easily import assets into a scene
  68200. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68201. */
  68202. export class AssetsManager {
  68203. private _scene;
  68204. private _isLoading;
  68205. protected _tasks: AbstractAssetTask[];
  68206. protected _waitingTasksCount: number;
  68207. protected _totalTasksCount: number;
  68208. /**
  68209. * Callback called when all tasks are processed
  68210. */
  68211. onFinish: (tasks: AbstractAssetTask[]) => void;
  68212. /**
  68213. * Callback called when a task is successful
  68214. */
  68215. onTaskSuccess: (task: AbstractAssetTask) => void;
  68216. /**
  68217. * Callback called when a task had an error
  68218. */
  68219. onTaskError: (task: AbstractAssetTask) => void;
  68220. /**
  68221. * Callback called when a task is done (whatever the result is)
  68222. */
  68223. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68224. /**
  68225. * Observable called when all tasks are processed
  68226. */
  68227. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68228. /**
  68229. * Observable called when a task had an error
  68230. */
  68231. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68232. /**
  68233. * Observable called when all tasks were executed
  68234. */
  68235. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68236. /**
  68237. * Observable called when a task is done (whatever the result is)
  68238. */
  68239. onProgressObservable: Observable<IAssetsProgressEvent>;
  68240. /**
  68241. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68242. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68243. */
  68244. useDefaultLoadingScreen: boolean;
  68245. /**
  68246. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68247. * when all assets have been downloaded.
  68248. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68249. */
  68250. autoHideLoadingUI: boolean;
  68251. /**
  68252. * Creates a new AssetsManager
  68253. * @param scene defines the scene to work on
  68254. */
  68255. constructor(scene: Scene);
  68256. /**
  68257. * Add a MeshAssetTask to the list of active tasks
  68258. * @param taskName defines the name of the new task
  68259. * @param meshesNames defines the name of meshes to load
  68260. * @param rootUrl defines the root url to use to locate files
  68261. * @param sceneFilename defines the filename of the scene file
  68262. * @returns a new MeshAssetTask object
  68263. */
  68264. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68265. /**
  68266. * Add a TextFileAssetTask to the list of active tasks
  68267. * @param taskName defines the name of the new task
  68268. * @param url defines the url of the file to load
  68269. * @returns a new TextFileAssetTask object
  68270. */
  68271. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68272. /**
  68273. * Add a BinaryFileAssetTask to the list of active tasks
  68274. * @param taskName defines the name of the new task
  68275. * @param url defines the url of the file to load
  68276. * @returns a new BinaryFileAssetTask object
  68277. */
  68278. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68279. /**
  68280. * Add a ImageAssetTask to the list of active tasks
  68281. * @param taskName defines the name of the new task
  68282. * @param url defines the url of the file to load
  68283. * @returns a new ImageAssetTask object
  68284. */
  68285. addImageTask(taskName: string, url: string): ImageAssetTask;
  68286. /**
  68287. * Add a TextureAssetTask to the list of active tasks
  68288. * @param taskName defines the name of the new task
  68289. * @param url defines the url of the file to load
  68290. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68291. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68292. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68293. * @returns a new TextureAssetTask object
  68294. */
  68295. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68296. /**
  68297. * Add a CubeTextureAssetTask to the list of active tasks
  68298. * @param taskName defines the name of the new task
  68299. * @param url defines the url of the file to load
  68300. * @param extensions defines the extension to use to load the cube map (can be null)
  68301. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68302. * @param files defines the list of files to load (can be null)
  68303. * @returns a new CubeTextureAssetTask object
  68304. */
  68305. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68306. /**
  68307. *
  68308. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68309. * @param taskName defines the name of the new task
  68310. * @param url defines the url of the file to load
  68311. * @param size defines the size you want for the cubemap (can be null)
  68312. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68313. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68314. * @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)
  68315. * @param reserved Internal use only
  68316. * @returns a new HDRCubeTextureAssetTask object
  68317. */
  68318. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68319. /**
  68320. *
  68321. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68322. * @param taskName defines the name of the new task
  68323. * @param url defines the url of the file to load
  68324. * @param size defines the size you want for the cubemap (can be null)
  68325. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68326. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68327. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68328. * @returns a new EquiRectangularCubeTextureAssetTask object
  68329. */
  68330. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68331. /**
  68332. * Remove a task from the assets manager.
  68333. * @param task the task to remove
  68334. */
  68335. removeTask(task: AbstractAssetTask): void;
  68336. private _decreaseWaitingTasksCount;
  68337. private _runTask;
  68338. /**
  68339. * Reset the AssetsManager and remove all tasks
  68340. * @return the current instance of the AssetsManager
  68341. */
  68342. reset(): AssetsManager;
  68343. /**
  68344. * Start the loading process
  68345. * @return the current instance of the AssetsManager
  68346. */
  68347. load(): AssetsManager;
  68348. /**
  68349. * Start the loading process as an async operation
  68350. * @return a promise returning the list of failed tasks
  68351. */
  68352. loadAsync(): Promise<void>;
  68353. }
  68354. }
  68355. declare module "babylonjs/Misc/deferred" {
  68356. /**
  68357. * Wrapper class for promise with external resolve and reject.
  68358. */
  68359. export class Deferred<T> {
  68360. /**
  68361. * The promise associated with this deferred object.
  68362. */
  68363. readonly promise: Promise<T>;
  68364. private _resolve;
  68365. private _reject;
  68366. /**
  68367. * The resolve method of the promise associated with this deferred object.
  68368. */
  68369. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  68370. /**
  68371. * The reject method of the promise associated with this deferred object.
  68372. */
  68373. readonly reject: (reason?: any) => void;
  68374. /**
  68375. * Constructor for this deferred object.
  68376. */
  68377. constructor();
  68378. }
  68379. }
  68380. declare module "babylonjs/Misc/meshExploder" {
  68381. import { Mesh } from "babylonjs/Meshes/mesh";
  68382. /**
  68383. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68384. */
  68385. export class MeshExploder {
  68386. private _centerMesh;
  68387. private _meshes;
  68388. private _meshesOrigins;
  68389. private _toCenterVectors;
  68390. private _scaledDirection;
  68391. private _newPosition;
  68392. private _centerPosition;
  68393. /**
  68394. * Explodes meshes from a center mesh.
  68395. * @param meshes The meshes to explode.
  68396. * @param centerMesh The mesh to be center of explosion.
  68397. */
  68398. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68399. private _setCenterMesh;
  68400. /**
  68401. * Get class name
  68402. * @returns "MeshExploder"
  68403. */
  68404. getClassName(): string;
  68405. /**
  68406. * "Exploded meshes"
  68407. * @returns Array of meshes with the centerMesh at index 0.
  68408. */
  68409. getMeshes(): Array<Mesh>;
  68410. /**
  68411. * Explodes meshes giving a specific direction
  68412. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68413. */
  68414. explode(direction?: number): void;
  68415. }
  68416. }
  68417. declare module "babylonjs/Misc/filesInput" {
  68418. import { Engine } from "babylonjs/Engines/engine";
  68419. import { Scene } from "babylonjs/scene";
  68420. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  68421. /**
  68422. * Class used to help managing file picking and drag'n'drop
  68423. */
  68424. export class FilesInput {
  68425. /**
  68426. * List of files ready to be loaded
  68427. */
  68428. static readonly FilesToLoad: {
  68429. [key: string]: File;
  68430. };
  68431. /**
  68432. * Callback called when a file is processed
  68433. */
  68434. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68435. private _engine;
  68436. private _currentScene;
  68437. private _sceneLoadedCallback;
  68438. private _progressCallback;
  68439. private _additionalRenderLoopLogicCallback;
  68440. private _textureLoadingCallback;
  68441. private _startingProcessingFilesCallback;
  68442. private _onReloadCallback;
  68443. private _errorCallback;
  68444. private _elementToMonitor;
  68445. private _sceneFileToLoad;
  68446. private _filesToLoad;
  68447. /**
  68448. * Creates a new FilesInput
  68449. * @param engine defines the rendering engine
  68450. * @param scene defines the hosting scene
  68451. * @param sceneLoadedCallback callback called when scene is loaded
  68452. * @param progressCallback callback called to track progress
  68453. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68454. * @param textureLoadingCallback callback called when a texture is loading
  68455. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68456. * @param onReloadCallback callback called when a reload is requested
  68457. * @param errorCallback callback call if an error occurs
  68458. */
  68459. 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);
  68460. private _dragEnterHandler;
  68461. private _dragOverHandler;
  68462. private _dropHandler;
  68463. /**
  68464. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68465. * @param elementToMonitor defines the DOM element to track
  68466. */
  68467. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68468. /**
  68469. * Release all associated resources
  68470. */
  68471. dispose(): void;
  68472. private renderFunction;
  68473. private drag;
  68474. private drop;
  68475. private _traverseFolder;
  68476. private _processFiles;
  68477. /**
  68478. * Load files from a drop event
  68479. * @param event defines the drop event to use as source
  68480. */
  68481. loadFiles(event: any): void;
  68482. private _processReload;
  68483. /**
  68484. * Reload the current scene from the loaded files
  68485. */
  68486. reload(): void;
  68487. }
  68488. }
  68489. declare module "babylonjs/Misc/HighDynamicRange/index" {
  68490. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  68491. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  68492. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  68493. }
  68494. declare module "babylonjs/Misc/sceneOptimizer" {
  68495. import { Scene, IDisposable } from "babylonjs/scene";
  68496. import { Observable } from "babylonjs/Misc/observable";
  68497. /**
  68498. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68499. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68500. */
  68501. export class SceneOptimization {
  68502. /**
  68503. * Defines the priority of this optimization (0 by default which means first in the list)
  68504. */
  68505. priority: number;
  68506. /**
  68507. * Gets a string describing the action executed by the current optimization
  68508. * @returns description string
  68509. */
  68510. getDescription(): string;
  68511. /**
  68512. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68513. * @param scene defines the current scene where to apply this optimization
  68514. * @param optimizer defines the current optimizer
  68515. * @returns true if everything that can be done was applied
  68516. */
  68517. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68518. /**
  68519. * Creates the SceneOptimization object
  68520. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68521. * @param desc defines the description associated with the optimization
  68522. */
  68523. constructor(
  68524. /**
  68525. * Defines the priority of this optimization (0 by default which means first in the list)
  68526. */
  68527. priority?: number);
  68528. }
  68529. /**
  68530. * Defines an optimization used to reduce the size of render target textures
  68531. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68532. */
  68533. export class TextureOptimization extends SceneOptimization {
  68534. /**
  68535. * Defines the priority of this optimization (0 by default which means first in the list)
  68536. */
  68537. priority: number;
  68538. /**
  68539. * 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
  68540. */
  68541. maximumSize: number;
  68542. /**
  68543. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68544. */
  68545. step: number;
  68546. /**
  68547. * Gets a string describing the action executed by the current optimization
  68548. * @returns description string
  68549. */
  68550. getDescription(): string;
  68551. /**
  68552. * Creates the TextureOptimization object
  68553. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68554. * @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
  68555. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68556. */
  68557. constructor(
  68558. /**
  68559. * Defines the priority of this optimization (0 by default which means first in the list)
  68560. */
  68561. priority?: number,
  68562. /**
  68563. * 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
  68564. */
  68565. maximumSize?: number,
  68566. /**
  68567. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68568. */
  68569. step?: number);
  68570. /**
  68571. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68572. * @param scene defines the current scene where to apply this optimization
  68573. * @param optimizer defines the current optimizer
  68574. * @returns true if everything that can be done was applied
  68575. */
  68576. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68577. }
  68578. /**
  68579. * Defines an optimization used to increase or decrease the rendering resolution
  68580. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68581. */
  68582. export class HardwareScalingOptimization extends SceneOptimization {
  68583. /**
  68584. * Defines the priority of this optimization (0 by default which means first in the list)
  68585. */
  68586. priority: number;
  68587. /**
  68588. * Defines the maximum scale to use (2 by default)
  68589. */
  68590. maximumScale: number;
  68591. /**
  68592. * Defines the step to use between two passes (0.5 by default)
  68593. */
  68594. step: number;
  68595. private _currentScale;
  68596. private _directionOffset;
  68597. /**
  68598. * Gets a string describing the action executed by the current optimization
  68599. * @return description string
  68600. */
  68601. getDescription(): string;
  68602. /**
  68603. * Creates the HardwareScalingOptimization object
  68604. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68605. * @param maximumScale defines the maximum scale to use (2 by default)
  68606. * @param step defines the step to use between two passes (0.5 by default)
  68607. */
  68608. constructor(
  68609. /**
  68610. * Defines the priority of this optimization (0 by default which means first in the list)
  68611. */
  68612. priority?: number,
  68613. /**
  68614. * Defines the maximum scale to use (2 by default)
  68615. */
  68616. maximumScale?: number,
  68617. /**
  68618. * Defines the step to use between two passes (0.5 by default)
  68619. */
  68620. step?: number);
  68621. /**
  68622. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68623. * @param scene defines the current scene where to apply this optimization
  68624. * @param optimizer defines the current optimizer
  68625. * @returns true if everything that can be done was applied
  68626. */
  68627. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68628. }
  68629. /**
  68630. * Defines an optimization used to remove shadows
  68631. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68632. */
  68633. export class ShadowsOptimization extends SceneOptimization {
  68634. /**
  68635. * Gets a string describing the action executed by the current optimization
  68636. * @return description string
  68637. */
  68638. getDescription(): string;
  68639. /**
  68640. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68641. * @param scene defines the current scene where to apply this optimization
  68642. * @param optimizer defines the current optimizer
  68643. * @returns true if everything that can be done was applied
  68644. */
  68645. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68646. }
  68647. /**
  68648. * Defines an optimization used to turn post-processes off
  68649. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68650. */
  68651. export class PostProcessesOptimization extends SceneOptimization {
  68652. /**
  68653. * Gets a string describing the action executed by the current optimization
  68654. * @return description string
  68655. */
  68656. getDescription(): string;
  68657. /**
  68658. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68659. * @param scene defines the current scene where to apply this optimization
  68660. * @param optimizer defines the current optimizer
  68661. * @returns true if everything that can be done was applied
  68662. */
  68663. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68664. }
  68665. /**
  68666. * Defines an optimization used to turn lens flares off
  68667. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68668. */
  68669. export class LensFlaresOptimization extends SceneOptimization {
  68670. /**
  68671. * Gets a string describing the action executed by the current optimization
  68672. * @return description string
  68673. */
  68674. getDescription(): string;
  68675. /**
  68676. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68677. * @param scene defines the current scene where to apply this optimization
  68678. * @param optimizer defines the current optimizer
  68679. * @returns true if everything that can be done was applied
  68680. */
  68681. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68682. }
  68683. /**
  68684. * Defines an optimization based on user defined callback.
  68685. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68686. */
  68687. export class CustomOptimization extends SceneOptimization {
  68688. /**
  68689. * Callback called to apply the custom optimization.
  68690. */
  68691. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68692. /**
  68693. * Callback called to get custom description
  68694. */
  68695. onGetDescription: () => string;
  68696. /**
  68697. * Gets a string describing the action executed by the current optimization
  68698. * @returns description string
  68699. */
  68700. getDescription(): string;
  68701. /**
  68702. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68703. * @param scene defines the current scene where to apply this optimization
  68704. * @param optimizer defines the current optimizer
  68705. * @returns true if everything that can be done was applied
  68706. */
  68707. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68708. }
  68709. /**
  68710. * Defines an optimization used to turn particles off
  68711. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68712. */
  68713. export class ParticlesOptimization extends SceneOptimization {
  68714. /**
  68715. * Gets a string describing the action executed by the current optimization
  68716. * @return description string
  68717. */
  68718. getDescription(): string;
  68719. /**
  68720. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68721. * @param scene defines the current scene where to apply this optimization
  68722. * @param optimizer defines the current optimizer
  68723. * @returns true if everything that can be done was applied
  68724. */
  68725. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68726. }
  68727. /**
  68728. * Defines an optimization used to turn render targets off
  68729. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68730. */
  68731. export class RenderTargetsOptimization extends SceneOptimization {
  68732. /**
  68733. * Gets a string describing the action executed by the current optimization
  68734. * @return description string
  68735. */
  68736. getDescription(): string;
  68737. /**
  68738. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68739. * @param scene defines the current scene where to apply this optimization
  68740. * @param optimizer defines the current optimizer
  68741. * @returns true if everything that can be done was applied
  68742. */
  68743. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68744. }
  68745. /**
  68746. * Defines an optimization used to merge meshes with compatible materials
  68747. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68748. */
  68749. export class MergeMeshesOptimization extends SceneOptimization {
  68750. private static _UpdateSelectionTree;
  68751. /**
  68752. * Gets or sets a boolean which defines if optimization octree has to be updated
  68753. */
  68754. /**
  68755. * Gets or sets a boolean which defines if optimization octree has to be updated
  68756. */
  68757. static UpdateSelectionTree: boolean;
  68758. /**
  68759. * Gets a string describing the action executed by the current optimization
  68760. * @return description string
  68761. */
  68762. getDescription(): string;
  68763. private _canBeMerged;
  68764. /**
  68765. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68766. * @param scene defines the current scene where to apply this optimization
  68767. * @param optimizer defines the current optimizer
  68768. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68769. * @returns true if everything that can be done was applied
  68770. */
  68771. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68772. }
  68773. /**
  68774. * Defines a list of options used by SceneOptimizer
  68775. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68776. */
  68777. export class SceneOptimizerOptions {
  68778. /**
  68779. * Defines the target frame rate to reach (60 by default)
  68780. */
  68781. targetFrameRate: number;
  68782. /**
  68783. * Defines the interval between two checkes (2000ms by default)
  68784. */
  68785. trackerDuration: number;
  68786. /**
  68787. * Gets the list of optimizations to apply
  68788. */
  68789. optimizations: SceneOptimization[];
  68790. /**
  68791. * Creates a new list of options used by SceneOptimizer
  68792. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68793. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68794. */
  68795. constructor(
  68796. /**
  68797. * Defines the target frame rate to reach (60 by default)
  68798. */
  68799. targetFrameRate?: number,
  68800. /**
  68801. * Defines the interval between two checkes (2000ms by default)
  68802. */
  68803. trackerDuration?: number);
  68804. /**
  68805. * Add a new optimization
  68806. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68807. * @returns the current SceneOptimizerOptions
  68808. */
  68809. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68810. /**
  68811. * Add a new custom optimization
  68812. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68813. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68814. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68815. * @returns the current SceneOptimizerOptions
  68816. */
  68817. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68818. /**
  68819. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68820. * @param targetFrameRate defines the target frame rate (60 by default)
  68821. * @returns a SceneOptimizerOptions object
  68822. */
  68823. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68824. /**
  68825. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68826. * @param targetFrameRate defines the target frame rate (60 by default)
  68827. * @returns a SceneOptimizerOptions object
  68828. */
  68829. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68830. /**
  68831. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68832. * @param targetFrameRate defines the target frame rate (60 by default)
  68833. * @returns a SceneOptimizerOptions object
  68834. */
  68835. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68836. }
  68837. /**
  68838. * Class used to run optimizations in order to reach a target frame rate
  68839. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68840. */
  68841. export class SceneOptimizer implements IDisposable {
  68842. private _isRunning;
  68843. private _options;
  68844. private _scene;
  68845. private _currentPriorityLevel;
  68846. private _targetFrameRate;
  68847. private _trackerDuration;
  68848. private _currentFrameRate;
  68849. private _sceneDisposeObserver;
  68850. private _improvementMode;
  68851. /**
  68852. * Defines an observable called when the optimizer reaches the target frame rate
  68853. */
  68854. onSuccessObservable: Observable<SceneOptimizer>;
  68855. /**
  68856. * Defines an observable called when the optimizer enables an optimization
  68857. */
  68858. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68859. /**
  68860. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68861. */
  68862. onFailureObservable: Observable<SceneOptimizer>;
  68863. /**
  68864. * Gets a boolean indicating if the optimizer is in improvement mode
  68865. */
  68866. readonly isInImprovementMode: boolean;
  68867. /**
  68868. * Gets the current priority level (0 at start)
  68869. */
  68870. readonly currentPriorityLevel: number;
  68871. /**
  68872. * Gets the current frame rate checked by the SceneOptimizer
  68873. */
  68874. readonly currentFrameRate: number;
  68875. /**
  68876. * Gets or sets the current target frame rate (60 by default)
  68877. */
  68878. /**
  68879. * Gets or sets the current target frame rate (60 by default)
  68880. */
  68881. targetFrameRate: number;
  68882. /**
  68883. * Gets or sets the current interval between two checks (every 2000ms by default)
  68884. */
  68885. /**
  68886. * Gets or sets the current interval between two checks (every 2000ms by default)
  68887. */
  68888. trackerDuration: number;
  68889. /**
  68890. * Gets the list of active optimizations
  68891. */
  68892. readonly optimizations: SceneOptimization[];
  68893. /**
  68894. * Creates a new SceneOptimizer
  68895. * @param scene defines the scene to work on
  68896. * @param options defines the options to use with the SceneOptimizer
  68897. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68898. * @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)
  68899. */
  68900. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68901. /**
  68902. * Stops the current optimizer
  68903. */
  68904. stop(): void;
  68905. /**
  68906. * Reset the optimizer to initial step (current priority level = 0)
  68907. */
  68908. reset(): void;
  68909. /**
  68910. * Start the optimizer. By default it will try to reach a specific framerate
  68911. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68912. */
  68913. start(): void;
  68914. private _checkCurrentState;
  68915. /**
  68916. * Release all resources
  68917. */
  68918. dispose(): void;
  68919. /**
  68920. * Helper function to create a SceneOptimizer with one single line of code
  68921. * @param scene defines the scene to work on
  68922. * @param options defines the options to use with the SceneOptimizer
  68923. * @param onSuccess defines a callback to call on success
  68924. * @param onFailure defines a callback to call on failure
  68925. * @returns the new SceneOptimizer object
  68926. */
  68927. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68928. }
  68929. }
  68930. declare module "babylonjs/Misc/sceneSerializer" {
  68931. import { Scene } from "babylonjs/scene";
  68932. /**
  68933. * Class used to serialize a scene into a string
  68934. */
  68935. export class SceneSerializer {
  68936. /**
  68937. * Clear cache used by a previous serialization
  68938. */
  68939. static ClearCache(): void;
  68940. /**
  68941. * Serialize a scene into a JSON compatible object
  68942. * @param scene defines the scene to serialize
  68943. * @returns a JSON compatible object
  68944. */
  68945. static Serialize(scene: Scene): any;
  68946. /**
  68947. * Serialize a mesh into a JSON compatible object
  68948. * @param toSerialize defines the mesh to serialize
  68949. * @param withParents defines if parents must be serialized as well
  68950. * @param withChildren defines if children must be serialized as well
  68951. * @returns a JSON compatible object
  68952. */
  68953. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68954. }
  68955. }
  68956. declare module "babylonjs/Misc/textureTools" {
  68957. import { Texture } from "babylonjs/Materials/Textures/texture";
  68958. /**
  68959. * Class used to host texture specific utilities
  68960. */
  68961. export class TextureTools {
  68962. /**
  68963. * Uses the GPU to create a copy texture rescaled at a given size
  68964. * @param texture Texture to copy from
  68965. * @param width defines the desired width
  68966. * @param height defines the desired height
  68967. * @param useBilinearMode defines if bilinear mode has to be used
  68968. * @return the generated texture
  68969. */
  68970. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68971. }
  68972. }
  68973. declare module "babylonjs/Misc/videoRecorder" {
  68974. import { Nullable } from "babylonjs/types";
  68975. import { Engine } from "babylonjs/Engines/engine";
  68976. /**
  68977. * This represents the different options available for the video capture.
  68978. */
  68979. export interface VideoRecorderOptions {
  68980. /** Defines the mime type of the video. */
  68981. mimeType: string;
  68982. /** Defines the FPS the video should be recorded at. */
  68983. fps: number;
  68984. /** Defines the chunk size for the recording data. */
  68985. recordChunckSize: number;
  68986. /** The audio tracks to attach to the recording. */
  68987. audioTracks?: MediaStreamTrack[];
  68988. }
  68989. /**
  68990. * This can help with recording videos from BabylonJS.
  68991. * This is based on the available WebRTC functionalities of the browser.
  68992. *
  68993. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68994. */
  68995. export class VideoRecorder {
  68996. private static readonly _defaultOptions;
  68997. /**
  68998. * Returns whether or not the VideoRecorder is available in your browser.
  68999. * @param engine Defines the Babylon Engine.
  69000. * @returns true if supported otherwise false.
  69001. */
  69002. static IsSupported(engine: Engine): boolean;
  69003. private readonly _options;
  69004. private _canvas;
  69005. private _mediaRecorder;
  69006. private _recordedChunks;
  69007. private _fileName;
  69008. private _resolve;
  69009. private _reject;
  69010. /**
  69011. * True when a recording is already in progress.
  69012. */
  69013. readonly isRecording: boolean;
  69014. /**
  69015. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  69016. * @param engine Defines the BabylonJS Engine you wish to record.
  69017. * @param options Defines options that can be used to customize the capture.
  69018. */
  69019. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  69020. /**
  69021. * Stops the current recording before the default capture timeout passed in the startRecording function.
  69022. */
  69023. stopRecording(): void;
  69024. /**
  69025. * Starts recording the canvas for a max duration specified in parameters.
  69026. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  69027. * If null no automatic download will start and you can rely on the promise to get the data back.
  69028. * @param maxDuration Defines the maximum recording time in seconds.
  69029. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  69030. * @return A promise callback at the end of the recording with the video data in Blob.
  69031. */
  69032. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  69033. /**
  69034. * Releases internal resources used during the recording.
  69035. */
  69036. dispose(): void;
  69037. private _handleDataAvailable;
  69038. private _handleError;
  69039. private _handleStop;
  69040. }
  69041. }
  69042. declare module "babylonjs/Misc/screenshotTools" {
  69043. import { Camera } from "babylonjs/Cameras/camera";
  69044. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  69045. import { Engine } from "babylonjs/Engines/engine";
  69046. /**
  69047. * Class containing a set of static utilities functions for screenshots
  69048. */
  69049. export class ScreenshotTools {
  69050. /**
  69051. * Captures a screenshot of the current rendering
  69052. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69053. * @param engine defines the rendering engine
  69054. * @param camera defines the source camera
  69055. * @param size This parameter can be set to a single number or to an object with the
  69056. * following (optional) properties: precision, width, height. If a single number is passed,
  69057. * it will be used for both width and height. If an object is passed, the screenshot size
  69058. * will be derived from the parameters. The precision property is a multiplier allowing
  69059. * rendering at a higher or lower resolution
  69060. * @param successCallback defines the callback receives a single parameter which contains the
  69061. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69062. * src parameter of an <img> to display it
  69063. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69064. * Check your browser for supported MIME types
  69065. */
  69066. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  69067. /**
  69068. * Captures a screenshot of the current rendering
  69069. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69070. * @param engine defines the rendering engine
  69071. * @param camera defines the source camera
  69072. * @param size This parameter can be set to a single number or to an object with the
  69073. * following (optional) properties: precision, width, height. If a single number is passed,
  69074. * it will be used for both width and height. If an object is passed, the screenshot size
  69075. * will be derived from the parameters. The precision property is a multiplier allowing
  69076. * rendering at a higher or lower resolution
  69077. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69078. * Check your browser for supported MIME types
  69079. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69080. * to the src parameter of an <img> to display it
  69081. */
  69082. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  69083. /**
  69084. * Generates an image screenshot from the specified camera.
  69085. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69086. * @param engine The engine to use for rendering
  69087. * @param camera The camera to use for rendering
  69088. * @param size This parameter can be set to a single number or to an object with the
  69089. * following (optional) properties: precision, width, height. If a single number is passed,
  69090. * it will be used for both width and height. If an object is passed, the screenshot size
  69091. * will be derived from the parameters. The precision property is a multiplier allowing
  69092. * rendering at a higher or lower resolution
  69093. * @param successCallback The callback receives a single parameter which contains the
  69094. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69095. * src parameter of an <img> to display it
  69096. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69097. * Check your browser for supported MIME types
  69098. * @param samples Texture samples (default: 1)
  69099. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69100. * @param fileName A name for for the downloaded file.
  69101. */
  69102. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  69103. /**
  69104. * Generates an image screenshot from the specified camera.
  69105. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69106. * @param engine The engine to use for rendering
  69107. * @param camera The camera to use for rendering
  69108. * @param size This parameter can be set to a single number or to an object with the
  69109. * following (optional) properties: precision, width, height. If a single number is passed,
  69110. * it will be used for both width and height. If an object is passed, the screenshot size
  69111. * will be derived from the parameters. The precision property is a multiplier allowing
  69112. * rendering at a higher or lower resolution
  69113. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69114. * Check your browser for supported MIME types
  69115. * @param samples Texture samples (default: 1)
  69116. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69117. * @param fileName A name for for the downloaded file.
  69118. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69119. * to the src parameter of an <img> to display it
  69120. */
  69121. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  69122. /**
  69123. * Gets height and width for screenshot size
  69124. * @private
  69125. */
  69126. private static _getScreenshotSize;
  69127. }
  69128. }
  69129. declare module "babylonjs/Misc/dataReader" {
  69130. /**
  69131. * Interface for a data buffer
  69132. */
  69133. export interface IDataBuffer {
  69134. /**
  69135. * Reads bytes from the data buffer.
  69136. * @param byteOffset The byte offset to read
  69137. * @param byteLength The byte length to read
  69138. * @returns A promise that resolves when the bytes are read
  69139. */
  69140. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  69141. /**
  69142. * The byte length of the buffer.
  69143. */
  69144. readonly byteLength: number;
  69145. }
  69146. /**
  69147. * Utility class for reading from a data buffer
  69148. */
  69149. export class DataReader {
  69150. /**
  69151. * The data buffer associated with this data reader.
  69152. */
  69153. readonly buffer: IDataBuffer;
  69154. /**
  69155. * The current byte offset from the beginning of the data buffer.
  69156. */
  69157. byteOffset: number;
  69158. private _dataView;
  69159. private _dataByteOffset;
  69160. /**
  69161. * Constructor
  69162. * @param buffer The buffer to read
  69163. */
  69164. constructor(buffer: IDataBuffer);
  69165. /**
  69166. * Loads the given byte length.
  69167. * @param byteLength The byte length to load
  69168. * @returns A promise that resolves when the load is complete
  69169. */
  69170. loadAsync(byteLength: number): Promise<void>;
  69171. /**
  69172. * Read a unsigned 32-bit integer from the currently loaded data range.
  69173. * @returns The 32-bit integer read
  69174. */
  69175. readUint32(): number;
  69176. /**
  69177. * Read a byte array from the currently loaded data range.
  69178. * @param byteLength The byte length to read
  69179. * @returns The byte array read
  69180. */
  69181. readUint8Array(byteLength: number): Uint8Array;
  69182. /**
  69183. * Read a string from the currently loaded data range.
  69184. * @param byteLength The byte length to read
  69185. * @returns The string read
  69186. */
  69187. readString(byteLength: number): string;
  69188. /**
  69189. * Skips the given byte length the currently loaded data range.
  69190. * @param byteLength The byte length to skip
  69191. */
  69192. skipBytes(byteLength: number): void;
  69193. }
  69194. }
  69195. declare module "babylonjs/Misc/index" {
  69196. export * from "babylonjs/Misc/andOrNotEvaluator";
  69197. export * from "babylonjs/Misc/assetsManager";
  69198. export * from "babylonjs/Misc/basis";
  69199. export * from "babylonjs/Misc/dds";
  69200. export * from "babylonjs/Misc/decorators";
  69201. export * from "babylonjs/Misc/deferred";
  69202. export * from "babylonjs/Misc/environmentTextureTools";
  69203. export * from "babylonjs/Misc/meshExploder";
  69204. export * from "babylonjs/Misc/filesInput";
  69205. export * from "babylonjs/Misc/HighDynamicRange/index";
  69206. export * from "babylonjs/Misc/khronosTextureContainer";
  69207. export * from "babylonjs/Misc/observable";
  69208. export * from "babylonjs/Misc/performanceMonitor";
  69209. export * from "babylonjs/Misc/promise";
  69210. export * from "babylonjs/Misc/sceneOptimizer";
  69211. export * from "babylonjs/Misc/sceneSerializer";
  69212. export * from "babylonjs/Misc/smartArray";
  69213. export * from "babylonjs/Misc/stringDictionary";
  69214. export * from "babylonjs/Misc/tags";
  69215. export * from "babylonjs/Misc/textureTools";
  69216. export * from "babylonjs/Misc/tga";
  69217. export * from "babylonjs/Misc/tools";
  69218. export * from "babylonjs/Misc/videoRecorder";
  69219. export * from "babylonjs/Misc/virtualJoystick";
  69220. export * from "babylonjs/Misc/workerPool";
  69221. export * from "babylonjs/Misc/logger";
  69222. export * from "babylonjs/Misc/typeStore";
  69223. export * from "babylonjs/Misc/filesInputStore";
  69224. export * from "babylonjs/Misc/deepCopier";
  69225. export * from "babylonjs/Misc/pivotTools";
  69226. export * from "babylonjs/Misc/precisionDate";
  69227. export * from "babylonjs/Misc/screenshotTools";
  69228. export * from "babylonjs/Misc/typeStore";
  69229. export * from "babylonjs/Misc/webRequest";
  69230. export * from "babylonjs/Misc/iInspectable";
  69231. export * from "babylonjs/Misc/brdfTextureTools";
  69232. export * from "babylonjs/Misc/rgbdTextureTools";
  69233. export * from "babylonjs/Misc/gradients";
  69234. export * from "babylonjs/Misc/perfCounter";
  69235. export * from "babylonjs/Misc/fileRequest";
  69236. export * from "babylonjs/Misc/customAnimationFrameRequester";
  69237. export * from "babylonjs/Misc/retryStrategy";
  69238. export * from "babylonjs/Misc/interfaces/screenshotSize";
  69239. export * from "babylonjs/Misc/canvasGenerator";
  69240. export * from "babylonjs/Misc/fileTools";
  69241. export * from "babylonjs/Misc/stringTools";
  69242. export * from "babylonjs/Misc/dataReader";
  69243. }
  69244. declare module "babylonjs/index" {
  69245. export * from "babylonjs/abstractScene";
  69246. export * from "babylonjs/Actions/index";
  69247. export * from "babylonjs/Animations/index";
  69248. export * from "babylonjs/assetContainer";
  69249. export * from "babylonjs/Audio/index";
  69250. export * from "babylonjs/Behaviors/index";
  69251. export * from "babylonjs/Bones/index";
  69252. export * from "babylonjs/Cameras/index";
  69253. export * from "babylonjs/Collisions/index";
  69254. export * from "babylonjs/Culling/index";
  69255. export * from "babylonjs/Debug/index";
  69256. export * from "babylonjs/Engines/index";
  69257. export * from "babylonjs/Events/index";
  69258. export * from "babylonjs/Gamepads/index";
  69259. export * from "babylonjs/Gizmos/index";
  69260. export * from "babylonjs/Helpers/index";
  69261. export * from "babylonjs/Instrumentation/index";
  69262. export * from "babylonjs/Layers/index";
  69263. export * from "babylonjs/LensFlares/index";
  69264. export * from "babylonjs/Lights/index";
  69265. export * from "babylonjs/Loading/index";
  69266. export * from "babylonjs/Materials/index";
  69267. export * from "babylonjs/Maths/index";
  69268. export * from "babylonjs/Meshes/index";
  69269. export * from "babylonjs/Morph/index";
  69270. export * from "babylonjs/Navigation/index";
  69271. export * from "babylonjs/node";
  69272. export * from "babylonjs/Offline/index";
  69273. export * from "babylonjs/Particles/index";
  69274. export * from "babylonjs/Physics/index";
  69275. export * from "babylonjs/PostProcesses/index";
  69276. export * from "babylonjs/Probes/index";
  69277. export * from "babylonjs/Rendering/index";
  69278. export * from "babylonjs/scene";
  69279. export * from "babylonjs/sceneComponent";
  69280. export * from "babylonjs/Sprites/index";
  69281. export * from "babylonjs/States/index";
  69282. export * from "babylonjs/Misc/index";
  69283. export * from "babylonjs/types";
  69284. }
  69285. declare module "babylonjs/Animations/pathCursor" {
  69286. import { Vector3 } from "babylonjs/Maths/math.vector";
  69287. import { Path2 } from "babylonjs/Maths/math.path";
  69288. /**
  69289. * A cursor which tracks a point on a path
  69290. */
  69291. export class PathCursor {
  69292. private path;
  69293. /**
  69294. * Stores path cursor callbacks for when an onchange event is triggered
  69295. */
  69296. private _onchange;
  69297. /**
  69298. * The value of the path cursor
  69299. */
  69300. value: number;
  69301. /**
  69302. * The animation array of the path cursor
  69303. */
  69304. animations: Animation[];
  69305. /**
  69306. * Initializes the path cursor
  69307. * @param path The path to track
  69308. */
  69309. constructor(path: Path2);
  69310. /**
  69311. * Gets the cursor point on the path
  69312. * @returns A point on the path cursor at the cursor location
  69313. */
  69314. getPoint(): Vector3;
  69315. /**
  69316. * Moves the cursor ahead by the step amount
  69317. * @param step The amount to move the cursor forward
  69318. * @returns This path cursor
  69319. */
  69320. moveAhead(step?: number): PathCursor;
  69321. /**
  69322. * Moves the cursor behind by the step amount
  69323. * @param step The amount to move the cursor back
  69324. * @returns This path cursor
  69325. */
  69326. moveBack(step?: number): PathCursor;
  69327. /**
  69328. * Moves the cursor by the step amount
  69329. * If the step amount is greater than one, an exception is thrown
  69330. * @param step The amount to move the cursor
  69331. * @returns This path cursor
  69332. */
  69333. move(step: number): PathCursor;
  69334. /**
  69335. * Ensures that the value is limited between zero and one
  69336. * @returns This path cursor
  69337. */
  69338. private ensureLimits;
  69339. /**
  69340. * Runs onchange callbacks on change (used by the animation engine)
  69341. * @returns This path cursor
  69342. */
  69343. private raiseOnChange;
  69344. /**
  69345. * Executes a function on change
  69346. * @param f A path cursor onchange callback
  69347. * @returns This path cursor
  69348. */
  69349. onchange(f: (cursor: PathCursor) => void): PathCursor;
  69350. }
  69351. }
  69352. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  69353. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  69354. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  69355. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  69356. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  69357. }
  69358. declare module "babylonjs/Engines/Processors/Expressions/index" {
  69359. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  69360. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  69361. }
  69362. declare module "babylonjs/Engines/Processors/index" {
  69363. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  69364. export * from "babylonjs/Engines/Processors/Expressions/index";
  69365. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  69366. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  69367. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  69368. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  69369. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  69370. export * from "babylonjs/Engines/Processors/shaderProcessor";
  69371. }
  69372. declare module "babylonjs/Legacy/legacy" {
  69373. import * as Babylon from "babylonjs/index";
  69374. export * from "babylonjs/index";
  69375. }
  69376. declare module "babylonjs/Shaders/blur.fragment" {
  69377. /** @hidden */
  69378. export var blurPixelShader: {
  69379. name: string;
  69380. shader: string;
  69381. };
  69382. }
  69383. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  69384. /** @hidden */
  69385. export var pointCloudVertexDeclaration: {
  69386. name: string;
  69387. shader: string;
  69388. };
  69389. }
  69390. declare module "babylonjs" {
  69391. export * from "babylonjs/Legacy/legacy";
  69392. }
  69393. declare module BABYLON {
  69394. /** Alias type for value that can be null */
  69395. export type Nullable<T> = T | null;
  69396. /**
  69397. * Alias type for number that are floats
  69398. * @ignorenaming
  69399. */
  69400. export type float = number;
  69401. /**
  69402. * Alias type for number that are doubles.
  69403. * @ignorenaming
  69404. */
  69405. export type double = number;
  69406. /**
  69407. * Alias type for number that are integer
  69408. * @ignorenaming
  69409. */
  69410. export type int = number;
  69411. /** Alias type for number array or Float32Array */
  69412. export type FloatArray = number[] | Float32Array;
  69413. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  69414. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  69415. /**
  69416. * Alias for types that can be used by a Buffer or VertexBuffer.
  69417. */
  69418. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  69419. /**
  69420. * Alias type for primitive types
  69421. * @ignorenaming
  69422. */
  69423. type Primitive = undefined | null | boolean | string | number | Function;
  69424. /**
  69425. * Type modifier to make all the properties of an object Readonly
  69426. */
  69427. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  69428. /**
  69429. * Type modifier to make all the properties of an object Readonly recursively
  69430. */
  69431. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  69432. /**
  69433. * Type modifier to make object properties readonly.
  69434. */
  69435. export type DeepImmutableObject<T> = {
  69436. readonly [K in keyof T]: DeepImmutable<T[K]>;
  69437. };
  69438. /** @hidden */
  69439. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  69440. }
  69441. }
  69442. declare module BABYLON {
  69443. /**
  69444. * A class serves as a medium between the observable and its observers
  69445. */
  69446. export class EventState {
  69447. /**
  69448. * Create a new EventState
  69449. * @param mask defines the mask associated with this state
  69450. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  69451. * @param target defines the original target of the state
  69452. * @param currentTarget defines the current target of the state
  69453. */
  69454. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  69455. /**
  69456. * Initialize the current event state
  69457. * @param mask defines the mask associated with this state
  69458. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  69459. * @param target defines the original target of the state
  69460. * @param currentTarget defines the current target of the state
  69461. * @returns the current event state
  69462. */
  69463. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  69464. /**
  69465. * An Observer can set this property to true to prevent subsequent observers of being notified
  69466. */
  69467. skipNextObservers: boolean;
  69468. /**
  69469. * Get the mask value that were used to trigger the event corresponding to this EventState object
  69470. */
  69471. mask: number;
  69472. /**
  69473. * The object that originally notified the event
  69474. */
  69475. target?: any;
  69476. /**
  69477. * The current object in the bubbling phase
  69478. */
  69479. currentTarget?: any;
  69480. /**
  69481. * This will be populated with the return value of the last function that was executed.
  69482. * If it is the first function in the callback chain it will be the event data.
  69483. */
  69484. lastReturnValue?: any;
  69485. }
  69486. /**
  69487. * Represent an Observer registered to a given Observable object.
  69488. */
  69489. export class Observer<T> {
  69490. /**
  69491. * Defines the callback to call when the observer is notified
  69492. */
  69493. callback: (eventData: T, eventState: EventState) => void;
  69494. /**
  69495. * Defines the mask of the observer (used to filter notifications)
  69496. */
  69497. mask: number;
  69498. /**
  69499. * Defines the current scope used to restore the JS context
  69500. */
  69501. scope: any;
  69502. /** @hidden */
  69503. _willBeUnregistered: boolean;
  69504. /**
  69505. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  69506. */
  69507. unregisterOnNextCall: boolean;
  69508. /**
  69509. * Creates a new observer
  69510. * @param callback defines the callback to call when the observer is notified
  69511. * @param mask defines the mask of the observer (used to filter notifications)
  69512. * @param scope defines the current scope used to restore the JS context
  69513. */
  69514. constructor(
  69515. /**
  69516. * Defines the callback to call when the observer is notified
  69517. */
  69518. callback: (eventData: T, eventState: EventState) => void,
  69519. /**
  69520. * Defines the mask of the observer (used to filter notifications)
  69521. */
  69522. mask: number,
  69523. /**
  69524. * Defines the current scope used to restore the JS context
  69525. */
  69526. scope?: any);
  69527. }
  69528. /**
  69529. * Represent a list of observers registered to multiple Observables object.
  69530. */
  69531. export class MultiObserver<T> {
  69532. private _observers;
  69533. private _observables;
  69534. /**
  69535. * Release associated resources
  69536. */
  69537. dispose(): void;
  69538. /**
  69539. * Raise a callback when one of the observable will notify
  69540. * @param observables defines a list of observables to watch
  69541. * @param callback defines the callback to call on notification
  69542. * @param mask defines the mask used to filter notifications
  69543. * @param scope defines the current scope used to restore the JS context
  69544. * @returns the new MultiObserver
  69545. */
  69546. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  69547. }
  69548. /**
  69549. * The Observable class is a simple implementation of the Observable pattern.
  69550. *
  69551. * 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.
  69552. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  69553. * 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).
  69554. * 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.
  69555. */
  69556. export class Observable<T> {
  69557. private _observers;
  69558. private _eventState;
  69559. private _onObserverAdded;
  69560. /**
  69561. * Gets the list of observers
  69562. */
  69563. readonly observers: Array<Observer<T>>;
  69564. /**
  69565. * Creates a new observable
  69566. * @param onObserverAdded defines a callback to call when a new observer is added
  69567. */
  69568. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  69569. /**
  69570. * Create a new Observer with the specified callback
  69571. * @param callback the callback that will be executed for that Observer
  69572. * @param mask the mask used to filter observers
  69573. * @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.
  69574. * @param scope optional scope for the callback to be called from
  69575. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  69576. * @returns the new observer created for the callback
  69577. */
  69578. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  69579. /**
  69580. * Create a new Observer with the specified callback and unregisters after the next notification
  69581. * @param callback the callback that will be executed for that Observer
  69582. * @returns the new observer created for the callback
  69583. */
  69584. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  69585. /**
  69586. * Remove an Observer from the Observable object
  69587. * @param observer the instance of the Observer to remove
  69588. * @returns false if it doesn't belong to this Observable
  69589. */
  69590. remove(observer: Nullable<Observer<T>>): boolean;
  69591. /**
  69592. * Remove a callback from the Observable object
  69593. * @param callback the callback to remove
  69594. * @param scope optional scope. If used only the callbacks with this scope will be removed
  69595. * @returns false if it doesn't belong to this Observable
  69596. */
  69597. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  69598. private _deferUnregister;
  69599. private _remove;
  69600. /**
  69601. * Moves the observable to the top of the observer list making it get called first when notified
  69602. * @param observer the observer to move
  69603. */
  69604. makeObserverTopPriority(observer: Observer<T>): void;
  69605. /**
  69606. * Moves the observable to the bottom of the observer list making it get called last when notified
  69607. * @param observer the observer to move
  69608. */
  69609. makeObserverBottomPriority(observer: Observer<T>): void;
  69610. /**
  69611. * Notify all Observers by calling their respective callback with the given data
  69612. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  69613. * @param eventData defines the data to send to all observers
  69614. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  69615. * @param target defines the original target of the state
  69616. * @param currentTarget defines the current target of the state
  69617. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  69618. */
  69619. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  69620. /**
  69621. * Calling this will execute each callback, expecting it to be a promise or return a value.
  69622. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  69623. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  69624. * and it is crucial that all callbacks will be executed.
  69625. * The order of the callbacks is kept, callbacks are not executed parallel.
  69626. *
  69627. * @param eventData The data to be sent to each callback
  69628. * @param mask is used to filter observers defaults to -1
  69629. * @param target defines the callback target (see EventState)
  69630. * @param currentTarget defines he current object in the bubbling phase
  69631. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  69632. */
  69633. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  69634. /**
  69635. * Notify a specific observer
  69636. * @param observer defines the observer to notify
  69637. * @param eventData defines the data to be sent to each callback
  69638. * @param mask is used to filter observers defaults to -1
  69639. */
  69640. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  69641. /**
  69642. * Gets a boolean indicating if the observable has at least one observer
  69643. * @returns true is the Observable has at least one Observer registered
  69644. */
  69645. hasObservers(): boolean;
  69646. /**
  69647. * Clear the list of observers
  69648. */
  69649. clear(): void;
  69650. /**
  69651. * Clone the current observable
  69652. * @returns a new observable
  69653. */
  69654. clone(): Observable<T>;
  69655. /**
  69656. * Does this observable handles observer registered with a given mask
  69657. * @param mask defines the mask to be tested
  69658. * @return whether or not one observer registered with the given mask is handeled
  69659. **/
  69660. hasSpecificMask(mask?: number): boolean;
  69661. }
  69662. }
  69663. declare module BABYLON {
  69664. /**
  69665. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  69666. * Babylon.js
  69667. */
  69668. export class DomManagement {
  69669. /**
  69670. * Checks if the window object exists
  69671. * @returns true if the window object exists
  69672. */
  69673. static IsWindowObjectExist(): boolean;
  69674. /**
  69675. * Checks if the navigator object exists
  69676. * @returns true if the navigator object exists
  69677. */
  69678. static IsNavigatorAvailable(): boolean;
  69679. /**
  69680. * Extracts text content from a DOM element hierarchy
  69681. * @param element defines the root element
  69682. * @returns a string
  69683. */
  69684. static GetDOMTextContent(element: HTMLElement): string;
  69685. }
  69686. }
  69687. declare module BABYLON {
  69688. /**
  69689. * Logger used througouht the application to allow configuration of
  69690. * the log level required for the messages.
  69691. */
  69692. export class Logger {
  69693. /**
  69694. * No log
  69695. */
  69696. static readonly NoneLogLevel: number;
  69697. /**
  69698. * Only message logs
  69699. */
  69700. static readonly MessageLogLevel: number;
  69701. /**
  69702. * Only warning logs
  69703. */
  69704. static readonly WarningLogLevel: number;
  69705. /**
  69706. * Only error logs
  69707. */
  69708. static readonly ErrorLogLevel: number;
  69709. /**
  69710. * All logs
  69711. */
  69712. static readonly AllLogLevel: number;
  69713. private static _LogCache;
  69714. /**
  69715. * Gets a value indicating the number of loading errors
  69716. * @ignorenaming
  69717. */
  69718. static errorsCount: number;
  69719. /**
  69720. * Callback called when a new log is added
  69721. */
  69722. static OnNewCacheEntry: (entry: string) => void;
  69723. private static _AddLogEntry;
  69724. private static _FormatMessage;
  69725. private static _LogDisabled;
  69726. private static _LogEnabled;
  69727. private static _WarnDisabled;
  69728. private static _WarnEnabled;
  69729. private static _ErrorDisabled;
  69730. private static _ErrorEnabled;
  69731. /**
  69732. * Log a message to the console
  69733. */
  69734. static Log: (message: string) => void;
  69735. /**
  69736. * Write a warning message to the console
  69737. */
  69738. static Warn: (message: string) => void;
  69739. /**
  69740. * Write an error message to the console
  69741. */
  69742. static Error: (message: string) => void;
  69743. /**
  69744. * Gets current log cache (list of logs)
  69745. */
  69746. static readonly LogCache: string;
  69747. /**
  69748. * Clears the log cache
  69749. */
  69750. static ClearLogCache(): void;
  69751. /**
  69752. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  69753. */
  69754. static LogLevels: number;
  69755. }
  69756. }
  69757. declare module BABYLON {
  69758. /** @hidden */
  69759. export class _TypeStore {
  69760. /** @hidden */
  69761. static RegisteredTypes: {
  69762. [key: string]: Object;
  69763. };
  69764. /** @hidden */
  69765. static GetClass(fqdn: string): any;
  69766. }
  69767. }
  69768. declare module BABYLON {
  69769. /**
  69770. * Helper to manipulate strings
  69771. */
  69772. export class StringTools {
  69773. /**
  69774. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  69775. * @param str Source string
  69776. * @param suffix Suffix to search for in the source string
  69777. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69778. */
  69779. static EndsWith(str: string, suffix: string): boolean;
  69780. /**
  69781. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  69782. * @param str Source string
  69783. * @param suffix Suffix to search for in the source string
  69784. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69785. */
  69786. static StartsWith(str: string, suffix: string): boolean;
  69787. /**
  69788. * Decodes a buffer into a string
  69789. * @param buffer The buffer to decode
  69790. * @returns The decoded string
  69791. */
  69792. static Decode(buffer: Uint8Array | Uint16Array): string;
  69793. /**
  69794. * Encode a buffer to a base64 string
  69795. * @param buffer defines the buffer to encode
  69796. * @returns the encoded string
  69797. */
  69798. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  69799. }
  69800. }
  69801. declare module BABYLON {
  69802. /**
  69803. * Class containing a set of static utilities functions for deep copy.
  69804. */
  69805. export class DeepCopier {
  69806. /**
  69807. * Tries to copy an object by duplicating every property
  69808. * @param source defines the source object
  69809. * @param destination defines the target object
  69810. * @param doNotCopyList defines a list of properties to avoid
  69811. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  69812. */
  69813. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  69814. }
  69815. }
  69816. declare module BABYLON {
  69817. /**
  69818. * Class containing a set of static utilities functions for precision date
  69819. */
  69820. export class PrecisionDate {
  69821. /**
  69822. * Gets either window.performance.now() if supported or Date.now() else
  69823. */
  69824. static readonly Now: number;
  69825. }
  69826. }
  69827. declare module BABYLON {
  69828. /** @hidden */
  69829. export class _DevTools {
  69830. static WarnImport(name: string): string;
  69831. }
  69832. }
  69833. declare module BABYLON {
  69834. /**
  69835. * Interface used to define the mechanism to get data from the network
  69836. */
  69837. export interface IWebRequest {
  69838. /**
  69839. * Returns client's response url
  69840. */
  69841. responseURL: string;
  69842. /**
  69843. * Returns client's status
  69844. */
  69845. status: number;
  69846. /**
  69847. * Returns client's status as a text
  69848. */
  69849. statusText: string;
  69850. }
  69851. }
  69852. declare module BABYLON {
  69853. /**
  69854. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  69855. */
  69856. export class WebRequest implements IWebRequest {
  69857. private _xhr;
  69858. /**
  69859. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  69860. * i.e. when loading files, where the server/service expects an Authorization header
  69861. */
  69862. static CustomRequestHeaders: {
  69863. [key: string]: string;
  69864. };
  69865. /**
  69866. * Add callback functions in this array to update all the requests before they get sent to the network
  69867. */
  69868. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  69869. private _injectCustomRequestHeaders;
  69870. /**
  69871. * Gets or sets a function to be called when loading progress changes
  69872. */
  69873. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  69874. /**
  69875. * Returns client's state
  69876. */
  69877. readonly readyState: number;
  69878. /**
  69879. * Returns client's status
  69880. */
  69881. readonly status: number;
  69882. /**
  69883. * Returns client's status as a text
  69884. */
  69885. readonly statusText: string;
  69886. /**
  69887. * Returns client's response
  69888. */
  69889. readonly response: any;
  69890. /**
  69891. * Returns client's response url
  69892. */
  69893. readonly responseURL: string;
  69894. /**
  69895. * Returns client's response as text
  69896. */
  69897. readonly responseText: string;
  69898. /**
  69899. * Gets or sets the expected response type
  69900. */
  69901. responseType: XMLHttpRequestResponseType;
  69902. /** @hidden */
  69903. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  69904. /** @hidden */
  69905. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  69906. /**
  69907. * Cancels any network activity
  69908. */
  69909. abort(): void;
  69910. /**
  69911. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  69912. * @param body defines an optional request body
  69913. */
  69914. send(body?: Document | BodyInit | null): void;
  69915. /**
  69916. * Sets the request method, request URL
  69917. * @param method defines the method to use (GET, POST, etc..)
  69918. * @param url defines the url to connect with
  69919. */
  69920. open(method: string, url: string): void;
  69921. /**
  69922. * Sets the value of a request header.
  69923. * @param name The name of the header whose value is to be set
  69924. * @param value The value to set as the body of the header
  69925. */
  69926. setRequestHeader(name: string, value: string): void;
  69927. /**
  69928. * Get the string containing the text of a particular header's value.
  69929. * @param name The name of the header
  69930. * @returns The string containing the text of the given header name
  69931. */
  69932. getResponseHeader(name: string): Nullable<string>;
  69933. }
  69934. }
  69935. declare module BABYLON {
  69936. /**
  69937. * File request interface
  69938. */
  69939. export interface IFileRequest {
  69940. /**
  69941. * Raised when the request is complete (success or error).
  69942. */
  69943. onCompleteObservable: Observable<IFileRequest>;
  69944. /**
  69945. * Aborts the request for a file.
  69946. */
  69947. abort: () => void;
  69948. }
  69949. }
  69950. declare module BABYLON {
  69951. /**
  69952. * Define options used to create a render target texture
  69953. */
  69954. export class RenderTargetCreationOptions {
  69955. /**
  69956. * Specifies is mipmaps must be generated
  69957. */
  69958. generateMipMaps?: boolean;
  69959. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69960. generateDepthBuffer?: boolean;
  69961. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69962. generateStencilBuffer?: boolean;
  69963. /** Defines texture type (int by default) */
  69964. type?: number;
  69965. /** Defines sampling mode (trilinear by default) */
  69966. samplingMode?: number;
  69967. /** Defines format (RGBA by default) */
  69968. format?: number;
  69969. }
  69970. }
  69971. declare module BABYLON {
  69972. /**
  69973. * @hidden
  69974. **/
  69975. export class _TimeToken {
  69976. _startTimeQuery: Nullable<WebGLQuery>;
  69977. _endTimeQuery: Nullable<WebGLQuery>;
  69978. _timeElapsedQuery: Nullable<WebGLQuery>;
  69979. _timeElapsedQueryEnded: boolean;
  69980. }
  69981. }
  69982. declare module BABYLON {
  69983. /** Defines the cross module used constants to avoid circular dependncies */
  69984. export class Constants {
  69985. /** Defines that alpha blending is disabled */
  69986. static readonly ALPHA_DISABLE: number;
  69987. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  69988. static readonly ALPHA_ADD: number;
  69989. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69990. static readonly ALPHA_COMBINE: number;
  69991. /** Defines that alpha blending is DEST - SRC * DEST */
  69992. static readonly ALPHA_SUBTRACT: number;
  69993. /** Defines that alpha blending is SRC * DEST */
  69994. static readonly ALPHA_MULTIPLY: number;
  69995. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  69996. static readonly ALPHA_MAXIMIZED: number;
  69997. /** Defines that alpha blending is SRC + DEST */
  69998. static readonly ALPHA_ONEONE: number;
  69999. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  70000. static readonly ALPHA_PREMULTIPLIED: number;
  70001. /**
  70002. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  70003. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  70004. */
  70005. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  70006. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  70007. static readonly ALPHA_INTERPOLATE: number;
  70008. /**
  70009. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  70010. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  70011. */
  70012. static readonly ALPHA_SCREENMODE: number;
  70013. /**
  70014. * Defines that alpha blending is SRC + DST
  70015. * Alpha will be set to SRC ALPHA + DST ALPHA
  70016. */
  70017. static readonly ALPHA_ONEONE_ONEONE: number;
  70018. /**
  70019. * Defines that alpha blending is SRC * DST ALPHA + DST
  70020. * Alpha will be set to 0
  70021. */
  70022. static readonly ALPHA_ALPHATOCOLOR: number;
  70023. /**
  70024. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  70025. */
  70026. static readonly ALPHA_REVERSEONEMINUS: number;
  70027. /**
  70028. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  70029. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  70030. */
  70031. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  70032. /**
  70033. * Defines that alpha blending is SRC + DST
  70034. * Alpha will be set to SRC ALPHA
  70035. */
  70036. static readonly ALPHA_ONEONE_ONEZERO: number;
  70037. /**
  70038. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  70039. * Alpha will be set to DST ALPHA
  70040. */
  70041. static readonly ALPHA_EXCLUSION: number;
  70042. /** Defines that alpha blending equation a SUM */
  70043. static readonly ALPHA_EQUATION_ADD: number;
  70044. /** Defines that alpha blending equation a SUBSTRACTION */
  70045. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  70046. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  70047. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  70048. /** Defines that alpha blending equation a MAX operation */
  70049. static readonly ALPHA_EQUATION_MAX: number;
  70050. /** Defines that alpha blending equation a MIN operation */
  70051. static readonly ALPHA_EQUATION_MIN: number;
  70052. /**
  70053. * Defines that alpha blending equation a DARKEN operation:
  70054. * It takes the min of the src and sums the alpha channels.
  70055. */
  70056. static readonly ALPHA_EQUATION_DARKEN: number;
  70057. /** Defines that the ressource is not delayed*/
  70058. static readonly DELAYLOADSTATE_NONE: number;
  70059. /** Defines that the ressource was successfully delay loaded */
  70060. static readonly DELAYLOADSTATE_LOADED: number;
  70061. /** Defines that the ressource is currently delay loading */
  70062. static readonly DELAYLOADSTATE_LOADING: number;
  70063. /** Defines that the ressource is delayed and has not started loading */
  70064. static readonly DELAYLOADSTATE_NOTLOADED: number;
  70065. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  70066. static readonly NEVER: number;
  70067. /** 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 */
  70068. static readonly ALWAYS: number;
  70069. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  70070. static readonly LESS: number;
  70071. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  70072. static readonly EQUAL: number;
  70073. /** 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 */
  70074. static readonly LEQUAL: number;
  70075. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  70076. static readonly GREATER: number;
  70077. /** 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 */
  70078. static readonly GEQUAL: number;
  70079. /** 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 */
  70080. static readonly NOTEQUAL: number;
  70081. /** Passed to stencilOperation to specify that stencil value must be kept */
  70082. static readonly KEEP: number;
  70083. /** Passed to stencilOperation to specify that stencil value must be replaced */
  70084. static readonly REPLACE: number;
  70085. /** Passed to stencilOperation to specify that stencil value must be incremented */
  70086. static readonly INCR: number;
  70087. /** Passed to stencilOperation to specify that stencil value must be decremented */
  70088. static readonly DECR: number;
  70089. /** Passed to stencilOperation to specify that stencil value must be inverted */
  70090. static readonly INVERT: number;
  70091. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  70092. static readonly INCR_WRAP: number;
  70093. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  70094. static readonly DECR_WRAP: number;
  70095. /** Texture is not repeating outside of 0..1 UVs */
  70096. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  70097. /** Texture is repeating outside of 0..1 UVs */
  70098. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  70099. /** Texture is repeating and mirrored */
  70100. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  70101. /** ALPHA */
  70102. static readonly TEXTUREFORMAT_ALPHA: number;
  70103. /** LUMINANCE */
  70104. static readonly TEXTUREFORMAT_LUMINANCE: number;
  70105. /** LUMINANCE_ALPHA */
  70106. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  70107. /** RGB */
  70108. static readonly TEXTUREFORMAT_RGB: number;
  70109. /** RGBA */
  70110. static readonly TEXTUREFORMAT_RGBA: number;
  70111. /** RED */
  70112. static readonly TEXTUREFORMAT_RED: number;
  70113. /** RED (2nd reference) */
  70114. static readonly TEXTUREFORMAT_R: number;
  70115. /** RG */
  70116. static readonly TEXTUREFORMAT_RG: number;
  70117. /** RED_INTEGER */
  70118. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  70119. /** RED_INTEGER (2nd reference) */
  70120. static readonly TEXTUREFORMAT_R_INTEGER: number;
  70121. /** RG_INTEGER */
  70122. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  70123. /** RGB_INTEGER */
  70124. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  70125. /** RGBA_INTEGER */
  70126. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  70127. /** UNSIGNED_BYTE */
  70128. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  70129. /** UNSIGNED_BYTE (2nd reference) */
  70130. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  70131. /** FLOAT */
  70132. static readonly TEXTURETYPE_FLOAT: number;
  70133. /** HALF_FLOAT */
  70134. static readonly TEXTURETYPE_HALF_FLOAT: number;
  70135. /** BYTE */
  70136. static readonly TEXTURETYPE_BYTE: number;
  70137. /** SHORT */
  70138. static readonly TEXTURETYPE_SHORT: number;
  70139. /** UNSIGNED_SHORT */
  70140. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  70141. /** INT */
  70142. static readonly TEXTURETYPE_INT: number;
  70143. /** UNSIGNED_INT */
  70144. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  70145. /** UNSIGNED_SHORT_4_4_4_4 */
  70146. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  70147. /** UNSIGNED_SHORT_5_5_5_1 */
  70148. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  70149. /** UNSIGNED_SHORT_5_6_5 */
  70150. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  70151. /** UNSIGNED_INT_2_10_10_10_REV */
  70152. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  70153. /** UNSIGNED_INT_24_8 */
  70154. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  70155. /** UNSIGNED_INT_10F_11F_11F_REV */
  70156. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  70157. /** UNSIGNED_INT_5_9_9_9_REV */
  70158. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  70159. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  70160. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70161. /** nearest is mag = nearest and min = nearest and mip = nearest */
  70162. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  70163. /** Bilinear is mag = linear and min = linear and mip = nearest */
  70164. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  70165. /** Trilinear is mag = linear and min = linear and mip = linear */
  70166. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  70167. /** nearest is mag = nearest and min = nearest and mip = linear */
  70168. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  70169. /** Bilinear is mag = linear and min = linear and mip = nearest */
  70170. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  70171. /** Trilinear is mag = linear and min = linear and mip = linear */
  70172. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  70173. /** mag = nearest and min = nearest and mip = nearest */
  70174. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  70175. /** mag = nearest and min = linear and mip = nearest */
  70176. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  70177. /** mag = nearest and min = linear and mip = linear */
  70178. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  70179. /** mag = nearest and min = linear and mip = none */
  70180. static readonly TEXTURE_NEAREST_LINEAR: number;
  70181. /** mag = nearest and min = nearest and mip = none */
  70182. static readonly TEXTURE_NEAREST_NEAREST: number;
  70183. /** mag = linear and min = nearest and mip = nearest */
  70184. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  70185. /** mag = linear and min = nearest and mip = linear */
  70186. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  70187. /** mag = linear and min = linear and mip = none */
  70188. static readonly TEXTURE_LINEAR_LINEAR: number;
  70189. /** mag = linear and min = nearest and mip = none */
  70190. static readonly TEXTURE_LINEAR_NEAREST: number;
  70191. /** Explicit coordinates mode */
  70192. static readonly TEXTURE_EXPLICIT_MODE: number;
  70193. /** Spherical coordinates mode */
  70194. static readonly TEXTURE_SPHERICAL_MODE: number;
  70195. /** Planar coordinates mode */
  70196. static readonly TEXTURE_PLANAR_MODE: number;
  70197. /** Cubic coordinates mode */
  70198. static readonly TEXTURE_CUBIC_MODE: number;
  70199. /** Projection coordinates mode */
  70200. static readonly TEXTURE_PROJECTION_MODE: number;
  70201. /** Skybox coordinates mode */
  70202. static readonly TEXTURE_SKYBOX_MODE: number;
  70203. /** Inverse Cubic coordinates mode */
  70204. static readonly TEXTURE_INVCUBIC_MODE: number;
  70205. /** Equirectangular coordinates mode */
  70206. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  70207. /** Equirectangular Fixed coordinates mode */
  70208. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  70209. /** Equirectangular Fixed Mirrored coordinates mode */
  70210. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  70211. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  70212. static readonly SCALEMODE_FLOOR: number;
  70213. /** Defines that texture rescaling will look for the nearest power of 2 size */
  70214. static readonly SCALEMODE_NEAREST: number;
  70215. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  70216. static readonly SCALEMODE_CEILING: number;
  70217. /**
  70218. * The dirty texture flag value
  70219. */
  70220. static readonly MATERIAL_TextureDirtyFlag: number;
  70221. /**
  70222. * The dirty light flag value
  70223. */
  70224. static readonly MATERIAL_LightDirtyFlag: number;
  70225. /**
  70226. * The dirty fresnel flag value
  70227. */
  70228. static readonly MATERIAL_FresnelDirtyFlag: number;
  70229. /**
  70230. * The dirty attribute flag value
  70231. */
  70232. static readonly MATERIAL_AttributesDirtyFlag: number;
  70233. /**
  70234. * The dirty misc flag value
  70235. */
  70236. static readonly MATERIAL_MiscDirtyFlag: number;
  70237. /**
  70238. * The all dirty flag value
  70239. */
  70240. static readonly MATERIAL_AllDirtyFlag: number;
  70241. /**
  70242. * Returns the triangle fill mode
  70243. */
  70244. static readonly MATERIAL_TriangleFillMode: number;
  70245. /**
  70246. * Returns the wireframe mode
  70247. */
  70248. static readonly MATERIAL_WireFrameFillMode: number;
  70249. /**
  70250. * Returns the point fill mode
  70251. */
  70252. static readonly MATERIAL_PointFillMode: number;
  70253. /**
  70254. * Returns the point list draw mode
  70255. */
  70256. static readonly MATERIAL_PointListDrawMode: number;
  70257. /**
  70258. * Returns the line list draw mode
  70259. */
  70260. static readonly MATERIAL_LineListDrawMode: number;
  70261. /**
  70262. * Returns the line loop draw mode
  70263. */
  70264. static readonly MATERIAL_LineLoopDrawMode: number;
  70265. /**
  70266. * Returns the line strip draw mode
  70267. */
  70268. static readonly MATERIAL_LineStripDrawMode: number;
  70269. /**
  70270. * Returns the triangle strip draw mode
  70271. */
  70272. static readonly MATERIAL_TriangleStripDrawMode: number;
  70273. /**
  70274. * Returns the triangle fan draw mode
  70275. */
  70276. static readonly MATERIAL_TriangleFanDrawMode: number;
  70277. /**
  70278. * Stores the clock-wise side orientation
  70279. */
  70280. static readonly MATERIAL_ClockWiseSideOrientation: number;
  70281. /**
  70282. * Stores the counter clock-wise side orientation
  70283. */
  70284. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  70285. /**
  70286. * Nothing
  70287. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70288. */
  70289. static readonly ACTION_NothingTrigger: number;
  70290. /**
  70291. * On pick
  70292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70293. */
  70294. static readonly ACTION_OnPickTrigger: number;
  70295. /**
  70296. * On left pick
  70297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70298. */
  70299. static readonly ACTION_OnLeftPickTrigger: number;
  70300. /**
  70301. * On right pick
  70302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70303. */
  70304. static readonly ACTION_OnRightPickTrigger: number;
  70305. /**
  70306. * On center pick
  70307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70308. */
  70309. static readonly ACTION_OnCenterPickTrigger: number;
  70310. /**
  70311. * On pick down
  70312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70313. */
  70314. static readonly ACTION_OnPickDownTrigger: number;
  70315. /**
  70316. * On double pick
  70317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70318. */
  70319. static readonly ACTION_OnDoublePickTrigger: number;
  70320. /**
  70321. * On pick up
  70322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70323. */
  70324. static readonly ACTION_OnPickUpTrigger: number;
  70325. /**
  70326. * On pick out.
  70327. * This trigger will only be raised if you also declared a OnPickDown
  70328. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70329. */
  70330. static readonly ACTION_OnPickOutTrigger: number;
  70331. /**
  70332. * On long press
  70333. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70334. */
  70335. static readonly ACTION_OnLongPressTrigger: number;
  70336. /**
  70337. * On pointer over
  70338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70339. */
  70340. static readonly ACTION_OnPointerOverTrigger: number;
  70341. /**
  70342. * On pointer out
  70343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70344. */
  70345. static readonly ACTION_OnPointerOutTrigger: number;
  70346. /**
  70347. * On every frame
  70348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70349. */
  70350. static readonly ACTION_OnEveryFrameTrigger: number;
  70351. /**
  70352. * On intersection enter
  70353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70354. */
  70355. static readonly ACTION_OnIntersectionEnterTrigger: number;
  70356. /**
  70357. * On intersection exit
  70358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70359. */
  70360. static readonly ACTION_OnIntersectionExitTrigger: number;
  70361. /**
  70362. * On key down
  70363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70364. */
  70365. static readonly ACTION_OnKeyDownTrigger: number;
  70366. /**
  70367. * On key up
  70368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70369. */
  70370. static readonly ACTION_OnKeyUpTrigger: number;
  70371. /**
  70372. * Billboard mode will only apply to Y axis
  70373. */
  70374. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  70375. /**
  70376. * Billboard mode will apply to all axes
  70377. */
  70378. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  70379. /**
  70380. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  70381. */
  70382. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  70383. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  70384. * Test order :
  70385. * Is the bounding sphere outside the frustum ?
  70386. * If not, are the bounding box vertices outside the frustum ?
  70387. * It not, then the cullable object is in the frustum.
  70388. */
  70389. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  70390. /** Culling strategy : Bounding Sphere Only.
  70391. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  70392. * It's also less accurate than the standard because some not visible objects can still be selected.
  70393. * Test : is the bounding sphere outside the frustum ?
  70394. * If not, then the cullable object is in the frustum.
  70395. */
  70396. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  70397. /** Culling strategy : Optimistic Inclusion.
  70398. * This in an inclusion test first, then the standard exclusion test.
  70399. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  70400. * 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.
  70401. * Anyway, it's as accurate as the standard strategy.
  70402. * Test :
  70403. * Is the cullable object bounding sphere center in the frustum ?
  70404. * If not, apply the default culling strategy.
  70405. */
  70406. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  70407. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  70408. * This in an inclusion test first, then the bounding sphere only exclusion test.
  70409. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  70410. * 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.
  70411. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  70412. * Test :
  70413. * Is the cullable object bounding sphere center in the frustum ?
  70414. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  70415. */
  70416. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  70417. /**
  70418. * No logging while loading
  70419. */
  70420. static readonly SCENELOADER_NO_LOGGING: number;
  70421. /**
  70422. * Minimal logging while loading
  70423. */
  70424. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  70425. /**
  70426. * Summary logging while loading
  70427. */
  70428. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  70429. /**
  70430. * Detailled logging while loading
  70431. */
  70432. static readonly SCENELOADER_DETAILED_LOGGING: number;
  70433. }
  70434. }
  70435. declare module BABYLON {
  70436. /**
  70437. * This represents the required contract to create a new type of texture loader.
  70438. */
  70439. export interface IInternalTextureLoader {
  70440. /**
  70441. * Defines wether the loader supports cascade loading the different faces.
  70442. */
  70443. supportCascades: boolean;
  70444. /**
  70445. * This returns if the loader support the current file information.
  70446. * @param extension defines the file extension of the file being loaded
  70447. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70448. * @param fallback defines the fallback internal texture if any
  70449. * @param isBase64 defines whether the texture is encoded as a base64
  70450. * @param isBuffer defines whether the texture data are stored as a buffer
  70451. * @returns true if the loader can load the specified file
  70452. */
  70453. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70454. /**
  70455. * Transform the url before loading if required.
  70456. * @param rootUrl the url of the texture
  70457. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70458. * @returns the transformed texture
  70459. */
  70460. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70461. /**
  70462. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70463. * @param rootUrl the url of the texture
  70464. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70465. * @returns the fallback texture
  70466. */
  70467. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70468. /**
  70469. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70470. * @param data contains the texture data
  70471. * @param texture defines the BabylonJS internal texture
  70472. * @param createPolynomials will be true if polynomials have been requested
  70473. * @param onLoad defines the callback to trigger once the texture is ready
  70474. * @param onError defines the callback to trigger in case of error
  70475. */
  70476. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70477. /**
  70478. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70479. * @param data contains the texture data
  70480. * @param texture defines the BabylonJS internal texture
  70481. * @param callback defines the method to call once ready to upload
  70482. */
  70483. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70484. }
  70485. }
  70486. declare module BABYLON {
  70487. /**
  70488. * Class used to store and describe the pipeline context associated with an effect
  70489. */
  70490. export interface IPipelineContext {
  70491. /**
  70492. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  70493. */
  70494. isAsync: boolean;
  70495. /**
  70496. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  70497. */
  70498. isReady: boolean;
  70499. /** @hidden */
  70500. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  70501. }
  70502. }
  70503. declare module BABYLON {
  70504. /**
  70505. * Class used to store gfx data (like WebGLBuffer)
  70506. */
  70507. export class DataBuffer {
  70508. /**
  70509. * Gets or sets the number of objects referencing this buffer
  70510. */
  70511. references: number;
  70512. /** Gets or sets the size of the underlying buffer */
  70513. capacity: number;
  70514. /**
  70515. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  70516. */
  70517. is32Bits: boolean;
  70518. /**
  70519. * Gets the underlying buffer
  70520. */
  70521. readonly underlyingResource: any;
  70522. }
  70523. }
  70524. declare module BABYLON {
  70525. /** @hidden */
  70526. export interface IShaderProcessor {
  70527. attributeProcessor?: (attribute: string) => string;
  70528. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  70529. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  70530. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  70531. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  70532. lineProcessor?: (line: string, isFragment: boolean) => string;
  70533. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70534. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70535. }
  70536. }
  70537. declare module BABYLON {
  70538. /** @hidden */
  70539. export interface ProcessingOptions {
  70540. defines: string[];
  70541. indexParameters: any;
  70542. isFragment: boolean;
  70543. shouldUseHighPrecisionShader: boolean;
  70544. supportsUniformBuffers: boolean;
  70545. shadersRepository: string;
  70546. includesShadersStore: {
  70547. [key: string]: string;
  70548. };
  70549. processor?: IShaderProcessor;
  70550. version: string;
  70551. platformName: string;
  70552. lookForClosingBracketForUniformBuffer?: boolean;
  70553. }
  70554. }
  70555. declare module BABYLON {
  70556. /** @hidden */
  70557. export class ShaderCodeNode {
  70558. line: string;
  70559. children: ShaderCodeNode[];
  70560. additionalDefineKey?: string;
  70561. additionalDefineValue?: string;
  70562. isValid(preprocessors: {
  70563. [key: string]: string;
  70564. }): boolean;
  70565. process(preprocessors: {
  70566. [key: string]: string;
  70567. }, options: ProcessingOptions): string;
  70568. }
  70569. }
  70570. declare module BABYLON {
  70571. /** @hidden */
  70572. export class ShaderCodeCursor {
  70573. private _lines;
  70574. lineIndex: number;
  70575. readonly currentLine: string;
  70576. readonly canRead: boolean;
  70577. lines: string[];
  70578. }
  70579. }
  70580. declare module BABYLON {
  70581. /** @hidden */
  70582. export class ShaderCodeConditionNode extends ShaderCodeNode {
  70583. process(preprocessors: {
  70584. [key: string]: string;
  70585. }, options: ProcessingOptions): string;
  70586. }
  70587. }
  70588. declare module BABYLON {
  70589. /** @hidden */
  70590. export class ShaderDefineExpression {
  70591. isTrue(preprocessors: {
  70592. [key: string]: string;
  70593. }): boolean;
  70594. }
  70595. }
  70596. declare module BABYLON {
  70597. /** @hidden */
  70598. export class ShaderCodeTestNode extends ShaderCodeNode {
  70599. testExpression: ShaderDefineExpression;
  70600. isValid(preprocessors: {
  70601. [key: string]: string;
  70602. }): boolean;
  70603. }
  70604. }
  70605. declare module BABYLON {
  70606. /** @hidden */
  70607. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  70608. define: string;
  70609. not: boolean;
  70610. constructor(define: string, not?: boolean);
  70611. isTrue(preprocessors: {
  70612. [key: string]: string;
  70613. }): boolean;
  70614. }
  70615. }
  70616. declare module BABYLON {
  70617. /** @hidden */
  70618. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  70619. leftOperand: ShaderDefineExpression;
  70620. rightOperand: ShaderDefineExpression;
  70621. isTrue(preprocessors: {
  70622. [key: string]: string;
  70623. }): boolean;
  70624. }
  70625. }
  70626. declare module BABYLON {
  70627. /** @hidden */
  70628. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  70629. leftOperand: ShaderDefineExpression;
  70630. rightOperand: ShaderDefineExpression;
  70631. isTrue(preprocessors: {
  70632. [key: string]: string;
  70633. }): boolean;
  70634. }
  70635. }
  70636. declare module BABYLON {
  70637. /** @hidden */
  70638. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  70639. define: string;
  70640. operand: string;
  70641. testValue: string;
  70642. constructor(define: string, operand: string, testValue: string);
  70643. isTrue(preprocessors: {
  70644. [key: string]: string;
  70645. }): boolean;
  70646. }
  70647. }
  70648. declare module BABYLON {
  70649. /**
  70650. * Class used to enable access to offline support
  70651. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70652. */
  70653. export interface IOfflineProvider {
  70654. /**
  70655. * Gets a boolean indicating if scene must be saved in the database
  70656. */
  70657. enableSceneOffline: boolean;
  70658. /**
  70659. * Gets a boolean indicating if textures must be saved in the database
  70660. */
  70661. enableTexturesOffline: boolean;
  70662. /**
  70663. * Open the offline support and make it available
  70664. * @param successCallback defines the callback to call on success
  70665. * @param errorCallback defines the callback to call on error
  70666. */
  70667. open(successCallback: () => void, errorCallback: () => void): void;
  70668. /**
  70669. * Loads an image from the offline support
  70670. * @param url defines the url to load from
  70671. * @param image defines the target DOM image
  70672. */
  70673. loadImage(url: string, image: HTMLImageElement): void;
  70674. /**
  70675. * Loads a file from offline support
  70676. * @param url defines the URL to load from
  70677. * @param sceneLoaded defines a callback to call on success
  70678. * @param progressCallBack defines a callback to call when progress changed
  70679. * @param errorCallback defines a callback to call on error
  70680. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70681. */
  70682. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70683. }
  70684. }
  70685. declare module BABYLON {
  70686. /**
  70687. * Class used to help managing file picking and drag'n'drop
  70688. * File Storage
  70689. */
  70690. export class FilesInputStore {
  70691. /**
  70692. * List of files ready to be loaded
  70693. */
  70694. static FilesToLoad: {
  70695. [key: string]: File;
  70696. };
  70697. }
  70698. }
  70699. declare module BABYLON {
  70700. /**
  70701. * Class used to define a retry strategy when error happens while loading assets
  70702. */
  70703. export class RetryStrategy {
  70704. /**
  70705. * Function used to defines an exponential back off strategy
  70706. * @param maxRetries defines the maximum number of retries (3 by default)
  70707. * @param baseInterval defines the interval between retries
  70708. * @returns the strategy function to use
  70709. */
  70710. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  70711. }
  70712. }
  70713. declare module BABYLON {
  70714. /**
  70715. * @ignore
  70716. * Application error to support additional information when loading a file
  70717. */
  70718. export abstract class BaseError extends Error {
  70719. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  70720. }
  70721. }
  70722. declare module BABYLON {
  70723. /** @ignore */
  70724. export class LoadFileError extends BaseError {
  70725. request?: WebRequest;
  70726. file?: File;
  70727. /**
  70728. * Creates a new LoadFileError
  70729. * @param message defines the message of the error
  70730. * @param request defines the optional web request
  70731. * @param file defines the optional file
  70732. */
  70733. constructor(message: string, object?: WebRequest | File);
  70734. }
  70735. /** @ignore */
  70736. export class RequestFileError extends BaseError {
  70737. request: WebRequest;
  70738. /**
  70739. * Creates a new LoadFileError
  70740. * @param message defines the message of the error
  70741. * @param request defines the optional web request
  70742. */
  70743. constructor(message: string, request: WebRequest);
  70744. }
  70745. /** @ignore */
  70746. export class ReadFileError extends BaseError {
  70747. file: File;
  70748. /**
  70749. * Creates a new ReadFileError
  70750. * @param message defines the message of the error
  70751. * @param file defines the optional file
  70752. */
  70753. constructor(message: string, file: File);
  70754. }
  70755. /**
  70756. * @hidden
  70757. */
  70758. export class FileTools {
  70759. /**
  70760. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  70761. */
  70762. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  70763. /**
  70764. * Gets or sets the base URL to use to load assets
  70765. */
  70766. static BaseUrl: string;
  70767. /**
  70768. * Default behaviour for cors in the application.
  70769. * It can be a string if the expected behavior is identical in the entire app.
  70770. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  70771. */
  70772. static CorsBehavior: string | ((url: string | string[]) => string);
  70773. /**
  70774. * Gets or sets a function used to pre-process url before using them to load assets
  70775. */
  70776. static PreprocessUrl: (url: string) => string;
  70777. /**
  70778. * Removes unwanted characters from an url
  70779. * @param url defines the url to clean
  70780. * @returns the cleaned url
  70781. */
  70782. private static _CleanUrl;
  70783. /**
  70784. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  70785. * @param url define the url we are trying
  70786. * @param element define the dom element where to configure the cors policy
  70787. */
  70788. static SetCorsBehavior(url: string | string[], element: {
  70789. crossOrigin: string | null;
  70790. }): void;
  70791. /**
  70792. * Loads an image as an HTMLImageElement.
  70793. * @param input url string, ArrayBuffer, or Blob to load
  70794. * @param onLoad callback called when the image successfully loads
  70795. * @param onError callback called when the image fails to load
  70796. * @param offlineProvider offline provider for caching
  70797. * @param mimeType optional mime type
  70798. * @returns the HTMLImageElement of the loaded image
  70799. */
  70800. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  70801. /**
  70802. * Reads a file from a File object
  70803. * @param file defines the file to load
  70804. * @param onSuccess defines the callback to call when data is loaded
  70805. * @param onProgress defines the callback to call during loading process
  70806. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  70807. * @param onError defines the callback to call when an error occurs
  70808. * @returns a file request object
  70809. */
  70810. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  70811. /**
  70812. * Loads a file from a url
  70813. * @param url url to load
  70814. * @param onSuccess callback called when the file successfully loads
  70815. * @param onProgress callback called while file is loading (if the server supports this mode)
  70816. * @param offlineProvider defines the offline provider for caching
  70817. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70818. * @param onError callback called when the file fails to load
  70819. * @returns a file request object
  70820. */
  70821. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  70822. /**
  70823. * Loads a file
  70824. * @param url url to load
  70825. * @param onSuccess callback called when the file successfully loads
  70826. * @param onProgress callback called while file is loading (if the server supports this mode)
  70827. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70828. * @param onError callback called when the file fails to load
  70829. * @param onOpened callback called when the web request is opened
  70830. * @returns a file request object
  70831. */
  70832. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  70833. /**
  70834. * Checks if the loaded document was accessed via `file:`-Protocol.
  70835. * @returns boolean
  70836. */
  70837. static IsFileURL(): boolean;
  70838. }
  70839. }
  70840. declare module BABYLON {
  70841. /** @hidden */
  70842. export class ShaderProcessor {
  70843. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  70844. private static _ProcessPrecision;
  70845. private static _ExtractOperation;
  70846. private static _BuildSubExpression;
  70847. private static _BuildExpression;
  70848. private static _MoveCursorWithinIf;
  70849. private static _MoveCursor;
  70850. private static _EvaluatePreProcessors;
  70851. private static _PreparePreProcessors;
  70852. private static _ProcessShaderConversion;
  70853. private static _ProcessIncludes;
  70854. }
  70855. }
  70856. declare module BABYLON {
  70857. /**
  70858. * @hidden
  70859. */
  70860. export interface IColor4Like {
  70861. r: float;
  70862. g: float;
  70863. b: float;
  70864. a: float;
  70865. }
  70866. /**
  70867. * @hidden
  70868. */
  70869. export interface IColor3Like {
  70870. r: float;
  70871. g: float;
  70872. b: float;
  70873. }
  70874. /**
  70875. * @hidden
  70876. */
  70877. export interface IVector4Like {
  70878. x: float;
  70879. y: float;
  70880. z: float;
  70881. w: float;
  70882. }
  70883. /**
  70884. * @hidden
  70885. */
  70886. export interface IVector3Like {
  70887. x: float;
  70888. y: float;
  70889. z: float;
  70890. }
  70891. /**
  70892. * @hidden
  70893. */
  70894. export interface IVector2Like {
  70895. x: float;
  70896. y: float;
  70897. }
  70898. /**
  70899. * @hidden
  70900. */
  70901. export interface IMatrixLike {
  70902. toArray(): DeepImmutable<Float32Array>;
  70903. updateFlag: int;
  70904. }
  70905. /**
  70906. * @hidden
  70907. */
  70908. export interface IViewportLike {
  70909. x: float;
  70910. y: float;
  70911. width: float;
  70912. height: float;
  70913. }
  70914. /**
  70915. * @hidden
  70916. */
  70917. export interface IPlaneLike {
  70918. normal: IVector3Like;
  70919. d: float;
  70920. normalize(): void;
  70921. }
  70922. }
  70923. declare module BABYLON {
  70924. /**
  70925. * Interface used to define common properties for effect fallbacks
  70926. */
  70927. export interface IEffectFallbacks {
  70928. /**
  70929. * Removes the defines that should be removed when falling back.
  70930. * @param currentDefines defines the current define statements for the shader.
  70931. * @param effect defines the current effect we try to compile
  70932. * @returns The resulting defines with defines of the current rank removed.
  70933. */
  70934. reduce(currentDefines: string, effect: Effect): string;
  70935. /**
  70936. * Removes the fallback from the bound mesh.
  70937. */
  70938. unBindMesh(): void;
  70939. /**
  70940. * Checks to see if more fallbacks are still availible.
  70941. */
  70942. hasMoreFallbacks: boolean;
  70943. }
  70944. }
  70945. declare module BABYLON {
  70946. /**
  70947. * Class used to evalaute queries containing `and` and `or` operators
  70948. */
  70949. export class AndOrNotEvaluator {
  70950. /**
  70951. * Evaluate a query
  70952. * @param query defines the query to evaluate
  70953. * @param evaluateCallback defines the callback used to filter result
  70954. * @returns true if the query matches
  70955. */
  70956. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  70957. private static _HandleParenthesisContent;
  70958. private static _SimplifyNegation;
  70959. }
  70960. }
  70961. declare module BABYLON {
  70962. /**
  70963. * Class used to store custom tags
  70964. */
  70965. export class Tags {
  70966. /**
  70967. * Adds support for tags on the given object
  70968. * @param obj defines the object to use
  70969. */
  70970. static EnableFor(obj: any): void;
  70971. /**
  70972. * Removes tags support
  70973. * @param obj defines the object to use
  70974. */
  70975. static DisableFor(obj: any): void;
  70976. /**
  70977. * Gets a boolean indicating if the given object has tags
  70978. * @param obj defines the object to use
  70979. * @returns a boolean
  70980. */
  70981. static HasTags(obj: any): boolean;
  70982. /**
  70983. * Gets the tags available on a given object
  70984. * @param obj defines the object to use
  70985. * @param asString defines if the tags must be returned as a string instead of an array of strings
  70986. * @returns the tags
  70987. */
  70988. static GetTags(obj: any, asString?: boolean): any;
  70989. /**
  70990. * Adds tags to an object
  70991. * @param obj defines the object to use
  70992. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  70993. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  70994. */
  70995. static AddTagsTo(obj: any, tagsString: string): void;
  70996. /**
  70997. * @hidden
  70998. */
  70999. static _AddTagTo(obj: any, tag: string): void;
  71000. /**
  71001. * Removes specific tags from a specific object
  71002. * @param obj defines the object to use
  71003. * @param tagsString defines the tags to remove
  71004. */
  71005. static RemoveTagsFrom(obj: any, tagsString: string): void;
  71006. /**
  71007. * @hidden
  71008. */
  71009. static _RemoveTagFrom(obj: any, tag: string): void;
  71010. /**
  71011. * Defines if tags hosted on an object match a given query
  71012. * @param obj defines the object to use
  71013. * @param tagsQuery defines the tag query
  71014. * @returns a boolean
  71015. */
  71016. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  71017. }
  71018. }
  71019. declare module BABYLON {
  71020. /**
  71021. * Scalar computation library
  71022. */
  71023. export class Scalar {
  71024. /**
  71025. * Two pi constants convenient for computation.
  71026. */
  71027. static TwoPi: number;
  71028. /**
  71029. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  71030. * @param a number
  71031. * @param b number
  71032. * @param epsilon (default = 1.401298E-45)
  71033. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  71034. */
  71035. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  71036. /**
  71037. * Returns a string : the upper case translation of the number i to hexadecimal.
  71038. * @param i number
  71039. * @returns the upper case translation of the number i to hexadecimal.
  71040. */
  71041. static ToHex(i: number): string;
  71042. /**
  71043. * Returns -1 if value is negative and +1 is value is positive.
  71044. * @param value the value
  71045. * @returns the value itself if it's equal to zero.
  71046. */
  71047. static Sign(value: number): number;
  71048. /**
  71049. * Returns the value itself if it's between min and max.
  71050. * Returns min if the value is lower than min.
  71051. * Returns max if the value is greater than max.
  71052. * @param value the value to clmap
  71053. * @param min the min value to clamp to (default: 0)
  71054. * @param max the max value to clamp to (default: 1)
  71055. * @returns the clamped value
  71056. */
  71057. static Clamp(value: number, min?: number, max?: number): number;
  71058. /**
  71059. * the log2 of value.
  71060. * @param value the value to compute log2 of
  71061. * @returns the log2 of value.
  71062. */
  71063. static Log2(value: number): number;
  71064. /**
  71065. * Loops the value, so that it is never larger than length and never smaller than 0.
  71066. *
  71067. * This is similar to the modulo operator but it works with floating point numbers.
  71068. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  71069. * With t = 5 and length = 2.5, the result would be 0.0.
  71070. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  71071. * @param value the value
  71072. * @param length the length
  71073. * @returns the looped value
  71074. */
  71075. static Repeat(value: number, length: number): number;
  71076. /**
  71077. * Normalize the value between 0.0 and 1.0 using min and max values
  71078. * @param value value to normalize
  71079. * @param min max to normalize between
  71080. * @param max min to normalize between
  71081. * @returns the normalized value
  71082. */
  71083. static Normalize(value: number, min: number, max: number): number;
  71084. /**
  71085. * Denormalize the value from 0.0 and 1.0 using min and max values
  71086. * @param normalized value to denormalize
  71087. * @param min max to denormalize between
  71088. * @param max min to denormalize between
  71089. * @returns the denormalized value
  71090. */
  71091. static Denormalize(normalized: number, min: number, max: number): number;
  71092. /**
  71093. * Calculates the shortest difference between two given angles given in degrees.
  71094. * @param current current angle in degrees
  71095. * @param target target angle in degrees
  71096. * @returns the delta
  71097. */
  71098. static DeltaAngle(current: number, target: number): number;
  71099. /**
  71100. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  71101. * @param tx value
  71102. * @param length length
  71103. * @returns The returned value will move back and forth between 0 and length
  71104. */
  71105. static PingPong(tx: number, length: number): number;
  71106. /**
  71107. * Interpolates between min and max with smoothing at the limits.
  71108. *
  71109. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  71110. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  71111. * @param from from
  71112. * @param to to
  71113. * @param tx value
  71114. * @returns the smooth stepped value
  71115. */
  71116. static SmoothStep(from: number, to: number, tx: number): number;
  71117. /**
  71118. * Moves a value current towards target.
  71119. *
  71120. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  71121. * Negative values of maxDelta pushes the value away from target.
  71122. * @param current current value
  71123. * @param target target value
  71124. * @param maxDelta max distance to move
  71125. * @returns resulting value
  71126. */
  71127. static MoveTowards(current: number, target: number, maxDelta: number): number;
  71128. /**
  71129. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  71130. *
  71131. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  71132. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  71133. * @param current current value
  71134. * @param target target value
  71135. * @param maxDelta max distance to move
  71136. * @returns resulting angle
  71137. */
  71138. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  71139. /**
  71140. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  71141. * @param start start value
  71142. * @param end target value
  71143. * @param amount amount to lerp between
  71144. * @returns the lerped value
  71145. */
  71146. static Lerp(start: number, end: number, amount: number): number;
  71147. /**
  71148. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  71149. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  71150. * @param start start value
  71151. * @param end target value
  71152. * @param amount amount to lerp between
  71153. * @returns the lerped value
  71154. */
  71155. static LerpAngle(start: number, end: number, amount: number): number;
  71156. /**
  71157. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  71158. * @param a start value
  71159. * @param b target value
  71160. * @param value value between a and b
  71161. * @returns the inverseLerp value
  71162. */
  71163. static InverseLerp(a: number, b: number, value: number): number;
  71164. /**
  71165. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  71166. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  71167. * @param value1 spline value
  71168. * @param tangent1 spline value
  71169. * @param value2 spline value
  71170. * @param tangent2 spline value
  71171. * @param amount input value
  71172. * @returns hermite result
  71173. */
  71174. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  71175. /**
  71176. * Returns a random float number between and min and max values
  71177. * @param min min value of random
  71178. * @param max max value of random
  71179. * @returns random value
  71180. */
  71181. static RandomRange(min: number, max: number): number;
  71182. /**
  71183. * This function returns percentage of a number in a given range.
  71184. *
  71185. * RangeToPercent(40,20,60) will return 0.5 (50%)
  71186. * RangeToPercent(34,0,100) will return 0.34 (34%)
  71187. * @param number to convert to percentage
  71188. * @param min min range
  71189. * @param max max range
  71190. * @returns the percentage
  71191. */
  71192. static RangeToPercent(number: number, min: number, max: number): number;
  71193. /**
  71194. * This function returns number that corresponds to the percentage in a given range.
  71195. *
  71196. * PercentToRange(0.34,0,100) will return 34.
  71197. * @param percent to convert to number
  71198. * @param min min range
  71199. * @param max max range
  71200. * @returns the number
  71201. */
  71202. static PercentToRange(percent: number, min: number, max: number): number;
  71203. /**
  71204. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  71205. * @param angle The angle to normalize in radian.
  71206. * @return The converted angle.
  71207. */
  71208. static NormalizeRadians(angle: number): number;
  71209. }
  71210. }
  71211. declare module BABYLON {
  71212. /**
  71213. * Constant used to convert a value to gamma space
  71214. * @ignorenaming
  71215. */
  71216. export const ToGammaSpace: number;
  71217. /**
  71218. * Constant used to convert a value to linear space
  71219. * @ignorenaming
  71220. */
  71221. export const ToLinearSpace = 2.2;
  71222. /**
  71223. * Constant used to define the minimal number value in Babylon.js
  71224. * @ignorenaming
  71225. */
  71226. let Epsilon: number;
  71227. }
  71228. declare module BABYLON {
  71229. /**
  71230. * Class used to represent a viewport on screen
  71231. */
  71232. export class Viewport {
  71233. /** viewport left coordinate */
  71234. x: number;
  71235. /** viewport top coordinate */
  71236. y: number;
  71237. /**viewport width */
  71238. width: number;
  71239. /** viewport height */
  71240. height: number;
  71241. /**
  71242. * Creates a Viewport object located at (x, y) and sized (width, height)
  71243. * @param x defines viewport left coordinate
  71244. * @param y defines viewport top coordinate
  71245. * @param width defines the viewport width
  71246. * @param height defines the viewport height
  71247. */
  71248. constructor(
  71249. /** viewport left coordinate */
  71250. x: number,
  71251. /** viewport top coordinate */
  71252. y: number,
  71253. /**viewport width */
  71254. width: number,
  71255. /** viewport height */
  71256. height: number);
  71257. /**
  71258. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  71259. * @param renderWidth defines the rendering width
  71260. * @param renderHeight defines the rendering height
  71261. * @returns a new Viewport
  71262. */
  71263. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  71264. /**
  71265. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  71266. * @param renderWidth defines the rendering width
  71267. * @param renderHeight defines the rendering height
  71268. * @param ref defines the target viewport
  71269. * @returns the current viewport
  71270. */
  71271. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  71272. /**
  71273. * Returns a new Viewport copied from the current one
  71274. * @returns a new Viewport
  71275. */
  71276. clone(): Viewport;
  71277. }
  71278. }
  71279. declare module BABYLON {
  71280. /**
  71281. * Class containing a set of static utilities functions for arrays.
  71282. */
  71283. export class ArrayTools {
  71284. /**
  71285. * Returns an array of the given size filled with element built from the given constructor and the paramters
  71286. * @param size the number of element to construct and put in the array
  71287. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  71288. * @returns a new array filled with new objects
  71289. */
  71290. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  71291. }
  71292. }
  71293. declare module BABYLON {
  71294. /**
  71295. * Class representing a vector containing 2 coordinates
  71296. */
  71297. export class Vector2 {
  71298. /** defines the first coordinate */
  71299. x: number;
  71300. /** defines the second coordinate */
  71301. y: number;
  71302. /**
  71303. * Creates a new Vector2 from the given x and y coordinates
  71304. * @param x defines the first coordinate
  71305. * @param y defines the second coordinate
  71306. */
  71307. constructor(
  71308. /** defines the first coordinate */
  71309. x?: number,
  71310. /** defines the second coordinate */
  71311. y?: number);
  71312. /**
  71313. * Gets a string with the Vector2 coordinates
  71314. * @returns a string with the Vector2 coordinates
  71315. */
  71316. toString(): string;
  71317. /**
  71318. * Gets class name
  71319. * @returns the string "Vector2"
  71320. */
  71321. getClassName(): string;
  71322. /**
  71323. * Gets current vector hash code
  71324. * @returns the Vector2 hash code as a number
  71325. */
  71326. getHashCode(): number;
  71327. /**
  71328. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  71329. * @param array defines the source array
  71330. * @param index defines the offset in source array
  71331. * @returns the current Vector2
  71332. */
  71333. toArray(array: FloatArray, index?: number): Vector2;
  71334. /**
  71335. * Copy the current vector to an array
  71336. * @returns a new array with 2 elements: the Vector2 coordinates.
  71337. */
  71338. asArray(): number[];
  71339. /**
  71340. * Sets the Vector2 coordinates with the given Vector2 coordinates
  71341. * @param source defines the source Vector2
  71342. * @returns the current updated Vector2
  71343. */
  71344. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  71345. /**
  71346. * Sets the Vector2 coordinates with the given floats
  71347. * @param x defines the first coordinate
  71348. * @param y defines the second coordinate
  71349. * @returns the current updated Vector2
  71350. */
  71351. copyFromFloats(x: number, y: number): Vector2;
  71352. /**
  71353. * Sets the Vector2 coordinates with the given floats
  71354. * @param x defines the first coordinate
  71355. * @param y defines the second coordinate
  71356. * @returns the current updated Vector2
  71357. */
  71358. set(x: number, y: number): Vector2;
  71359. /**
  71360. * Add another vector with the current one
  71361. * @param otherVector defines the other vector
  71362. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  71363. */
  71364. add(otherVector: DeepImmutable<Vector2>): Vector2;
  71365. /**
  71366. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  71367. * @param otherVector defines the other vector
  71368. * @param result defines the target vector
  71369. * @returns the unmodified current Vector2
  71370. */
  71371. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  71372. /**
  71373. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  71374. * @param otherVector defines the other vector
  71375. * @returns the current updated Vector2
  71376. */
  71377. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  71378. /**
  71379. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  71380. * @param otherVector defines the other vector
  71381. * @returns a new Vector2
  71382. */
  71383. addVector3(otherVector: Vector3): Vector2;
  71384. /**
  71385. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  71386. * @param otherVector defines the other vector
  71387. * @returns a new Vector2
  71388. */
  71389. subtract(otherVector: Vector2): Vector2;
  71390. /**
  71391. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  71392. * @param otherVector defines the other vector
  71393. * @param result defines the target vector
  71394. * @returns the unmodified current Vector2
  71395. */
  71396. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  71397. /**
  71398. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  71399. * @param otherVector defines the other vector
  71400. * @returns the current updated Vector2
  71401. */
  71402. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  71403. /**
  71404. * Multiplies in place the current Vector2 coordinates by the given ones
  71405. * @param otherVector defines the other vector
  71406. * @returns the current updated Vector2
  71407. */
  71408. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  71409. /**
  71410. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  71411. * @param otherVector defines the other vector
  71412. * @returns a new Vector2
  71413. */
  71414. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  71415. /**
  71416. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  71417. * @param otherVector defines the other vector
  71418. * @param result defines the target vector
  71419. * @returns the unmodified current Vector2
  71420. */
  71421. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  71422. /**
  71423. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  71424. * @param x defines the first coordinate
  71425. * @param y defines the second coordinate
  71426. * @returns a new Vector2
  71427. */
  71428. multiplyByFloats(x: number, y: number): Vector2;
  71429. /**
  71430. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  71431. * @param otherVector defines the other vector
  71432. * @returns a new Vector2
  71433. */
  71434. divide(otherVector: Vector2): Vector2;
  71435. /**
  71436. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  71437. * @param otherVector defines the other vector
  71438. * @param result defines the target vector
  71439. * @returns the unmodified current Vector2
  71440. */
  71441. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  71442. /**
  71443. * Divides the current Vector2 coordinates by the given ones
  71444. * @param otherVector defines the other vector
  71445. * @returns the current updated Vector2
  71446. */
  71447. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  71448. /**
  71449. * Gets a new Vector2 with current Vector2 negated coordinates
  71450. * @returns a new Vector2
  71451. */
  71452. negate(): Vector2;
  71453. /**
  71454. * Multiply the Vector2 coordinates by scale
  71455. * @param scale defines the scaling factor
  71456. * @returns the current updated Vector2
  71457. */
  71458. scaleInPlace(scale: number): Vector2;
  71459. /**
  71460. * Returns a new Vector2 scaled by "scale" from the current Vector2
  71461. * @param scale defines the scaling factor
  71462. * @returns a new Vector2
  71463. */
  71464. scale(scale: number): Vector2;
  71465. /**
  71466. * Scale the current Vector2 values by a factor to a given Vector2
  71467. * @param scale defines the scale factor
  71468. * @param result defines the Vector2 object where to store the result
  71469. * @returns the unmodified current Vector2
  71470. */
  71471. scaleToRef(scale: number, result: Vector2): Vector2;
  71472. /**
  71473. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  71474. * @param scale defines the scale factor
  71475. * @param result defines the Vector2 object where to store the result
  71476. * @returns the unmodified current Vector2
  71477. */
  71478. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  71479. /**
  71480. * Gets a boolean if two vectors are equals
  71481. * @param otherVector defines the other vector
  71482. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  71483. */
  71484. equals(otherVector: DeepImmutable<Vector2>): boolean;
  71485. /**
  71486. * Gets a boolean if two vectors are equals (using an epsilon value)
  71487. * @param otherVector defines the other vector
  71488. * @param epsilon defines the minimal distance to consider equality
  71489. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  71490. */
  71491. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  71492. /**
  71493. * Gets a new Vector2 from current Vector2 floored values
  71494. * @returns a new Vector2
  71495. */
  71496. floor(): Vector2;
  71497. /**
  71498. * Gets a new Vector2 from current Vector2 floored values
  71499. * @returns a new Vector2
  71500. */
  71501. fract(): Vector2;
  71502. /**
  71503. * Gets the length of the vector
  71504. * @returns the vector length (float)
  71505. */
  71506. length(): number;
  71507. /**
  71508. * Gets the vector squared length
  71509. * @returns the vector squared length (float)
  71510. */
  71511. lengthSquared(): number;
  71512. /**
  71513. * Normalize the vector
  71514. * @returns the current updated Vector2
  71515. */
  71516. normalize(): Vector2;
  71517. /**
  71518. * Gets a new Vector2 copied from the Vector2
  71519. * @returns a new Vector2
  71520. */
  71521. clone(): Vector2;
  71522. /**
  71523. * Gets a new Vector2(0, 0)
  71524. * @returns a new Vector2
  71525. */
  71526. static Zero(): Vector2;
  71527. /**
  71528. * Gets a new Vector2(1, 1)
  71529. * @returns a new Vector2
  71530. */
  71531. static One(): Vector2;
  71532. /**
  71533. * Gets a new Vector2 set from the given index element of the given array
  71534. * @param array defines the data source
  71535. * @param offset defines the offset in the data source
  71536. * @returns a new Vector2
  71537. */
  71538. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  71539. /**
  71540. * Sets "result" from the given index element of the given array
  71541. * @param array defines the data source
  71542. * @param offset defines the offset in the data source
  71543. * @param result defines the target vector
  71544. */
  71545. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  71546. /**
  71547. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  71548. * @param value1 defines 1st point of control
  71549. * @param value2 defines 2nd point of control
  71550. * @param value3 defines 3rd point of control
  71551. * @param value4 defines 4th point of control
  71552. * @param amount defines the interpolation factor
  71553. * @returns a new Vector2
  71554. */
  71555. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  71556. /**
  71557. * 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".
  71558. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  71559. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  71560. * @param value defines the value to clamp
  71561. * @param min defines the lower limit
  71562. * @param max defines the upper limit
  71563. * @returns a new Vector2
  71564. */
  71565. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  71566. /**
  71567. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  71568. * @param value1 defines the 1st control point
  71569. * @param tangent1 defines the outgoing tangent
  71570. * @param value2 defines the 2nd control point
  71571. * @param tangent2 defines the incoming tangent
  71572. * @param amount defines the interpolation factor
  71573. * @returns a new Vector2
  71574. */
  71575. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  71576. /**
  71577. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  71578. * @param start defines the start vector
  71579. * @param end defines the end vector
  71580. * @param amount defines the interpolation factor
  71581. * @returns a new Vector2
  71582. */
  71583. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  71584. /**
  71585. * Gets the dot product of the vector "left" and the vector "right"
  71586. * @param left defines first vector
  71587. * @param right defines second vector
  71588. * @returns the dot product (float)
  71589. */
  71590. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  71591. /**
  71592. * Returns a new Vector2 equal to the normalized given vector
  71593. * @param vector defines the vector to normalize
  71594. * @returns a new Vector2
  71595. */
  71596. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  71597. /**
  71598. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  71599. * @param left defines 1st vector
  71600. * @param right defines 2nd vector
  71601. * @returns a new Vector2
  71602. */
  71603. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  71604. /**
  71605. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  71606. * @param left defines 1st vector
  71607. * @param right defines 2nd vector
  71608. * @returns a new Vector2
  71609. */
  71610. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  71611. /**
  71612. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  71613. * @param vector defines the vector to transform
  71614. * @param transformation defines the matrix to apply
  71615. * @returns a new Vector2
  71616. */
  71617. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  71618. /**
  71619. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  71620. * @param vector defines the vector to transform
  71621. * @param transformation defines the matrix to apply
  71622. * @param result defines the target vector
  71623. */
  71624. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  71625. /**
  71626. * Determines if a given vector is included in a triangle
  71627. * @param p defines the vector to test
  71628. * @param p0 defines 1st triangle point
  71629. * @param p1 defines 2nd triangle point
  71630. * @param p2 defines 3rd triangle point
  71631. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  71632. */
  71633. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  71634. /**
  71635. * Gets the distance between the vectors "value1" and "value2"
  71636. * @param value1 defines first vector
  71637. * @param value2 defines second vector
  71638. * @returns the distance between vectors
  71639. */
  71640. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  71641. /**
  71642. * Returns the squared distance between the vectors "value1" and "value2"
  71643. * @param value1 defines first vector
  71644. * @param value2 defines second vector
  71645. * @returns the squared distance between vectors
  71646. */
  71647. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  71648. /**
  71649. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  71650. * @param value1 defines first vector
  71651. * @param value2 defines second vector
  71652. * @returns a new Vector2
  71653. */
  71654. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  71655. /**
  71656. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  71657. * @param p defines the middle point
  71658. * @param segA defines one point of the segment
  71659. * @param segB defines the other point of the segment
  71660. * @returns the shortest distance
  71661. */
  71662. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  71663. }
  71664. /**
  71665. * Class used to store (x,y,z) vector representation
  71666. * A Vector3 is the main object used in 3D geometry
  71667. * It can represent etiher the coordinates of a point the space, either a direction
  71668. * Reminder: js uses a left handed forward facing system
  71669. */
  71670. export class Vector3 {
  71671. /**
  71672. * Defines the first coordinates (on X axis)
  71673. */
  71674. x: number;
  71675. /**
  71676. * Defines the second coordinates (on Y axis)
  71677. */
  71678. y: number;
  71679. /**
  71680. * Defines the third coordinates (on Z axis)
  71681. */
  71682. z: number;
  71683. private static _UpReadOnly;
  71684. private static _ZeroReadOnly;
  71685. /**
  71686. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  71687. * @param x defines the first coordinates (on X axis)
  71688. * @param y defines the second coordinates (on Y axis)
  71689. * @param z defines the third coordinates (on Z axis)
  71690. */
  71691. constructor(
  71692. /**
  71693. * Defines the first coordinates (on X axis)
  71694. */
  71695. x?: number,
  71696. /**
  71697. * Defines the second coordinates (on Y axis)
  71698. */
  71699. y?: number,
  71700. /**
  71701. * Defines the third coordinates (on Z axis)
  71702. */
  71703. z?: number);
  71704. /**
  71705. * Creates a string representation of the Vector3
  71706. * @returns a string with the Vector3 coordinates.
  71707. */
  71708. toString(): string;
  71709. /**
  71710. * Gets the class name
  71711. * @returns the string "Vector3"
  71712. */
  71713. getClassName(): string;
  71714. /**
  71715. * Creates the Vector3 hash code
  71716. * @returns a number which tends to be unique between Vector3 instances
  71717. */
  71718. getHashCode(): number;
  71719. /**
  71720. * Creates an array containing three elements : the coordinates of the Vector3
  71721. * @returns a new array of numbers
  71722. */
  71723. asArray(): number[];
  71724. /**
  71725. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  71726. * @param array defines the destination array
  71727. * @param index defines the offset in the destination array
  71728. * @returns the current Vector3
  71729. */
  71730. toArray(array: FloatArray, index?: number): Vector3;
  71731. /**
  71732. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  71733. * @returns a new Quaternion object, computed from the Vector3 coordinates
  71734. */
  71735. toQuaternion(): Quaternion;
  71736. /**
  71737. * Adds the given vector to the current Vector3
  71738. * @param otherVector defines the second operand
  71739. * @returns the current updated Vector3
  71740. */
  71741. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71742. /**
  71743. * Adds the given coordinates to the current Vector3
  71744. * @param x defines the x coordinate of the operand
  71745. * @param y defines the y coordinate of the operand
  71746. * @param z defines the z coordinate of the operand
  71747. * @returns the current updated Vector3
  71748. */
  71749. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71750. /**
  71751. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  71752. * @param otherVector defines the second operand
  71753. * @returns the resulting Vector3
  71754. */
  71755. add(otherVector: DeepImmutable<Vector3>): Vector3;
  71756. /**
  71757. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  71758. * @param otherVector defines the second operand
  71759. * @param result defines the Vector3 object where to store the result
  71760. * @returns the current Vector3
  71761. */
  71762. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71763. /**
  71764. * Subtract the given vector from the current Vector3
  71765. * @param otherVector defines the second operand
  71766. * @returns the current updated Vector3
  71767. */
  71768. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71769. /**
  71770. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  71771. * @param otherVector defines the second operand
  71772. * @returns the resulting Vector3
  71773. */
  71774. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  71775. /**
  71776. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  71777. * @param otherVector defines the second operand
  71778. * @param result defines the Vector3 object where to store the result
  71779. * @returns the current Vector3
  71780. */
  71781. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71782. /**
  71783. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  71784. * @param x defines the x coordinate of the operand
  71785. * @param y defines the y coordinate of the operand
  71786. * @param z defines the z coordinate of the operand
  71787. * @returns the resulting Vector3
  71788. */
  71789. subtractFromFloats(x: number, y: number, z: number): Vector3;
  71790. /**
  71791. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  71792. * @param x defines the x coordinate of the operand
  71793. * @param y defines the y coordinate of the operand
  71794. * @param z defines the z coordinate of the operand
  71795. * @param result defines the Vector3 object where to store the result
  71796. * @returns the current Vector3
  71797. */
  71798. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  71799. /**
  71800. * Gets a new Vector3 set with the current Vector3 negated coordinates
  71801. * @returns a new Vector3
  71802. */
  71803. negate(): Vector3;
  71804. /**
  71805. * Multiplies the Vector3 coordinates by the float "scale"
  71806. * @param scale defines the multiplier factor
  71807. * @returns the current updated Vector3
  71808. */
  71809. scaleInPlace(scale: number): Vector3;
  71810. /**
  71811. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  71812. * @param scale defines the multiplier factor
  71813. * @returns a new Vector3
  71814. */
  71815. scale(scale: number): Vector3;
  71816. /**
  71817. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  71818. * @param scale defines the multiplier factor
  71819. * @param result defines the Vector3 object where to store the result
  71820. * @returns the current Vector3
  71821. */
  71822. scaleToRef(scale: number, result: Vector3): Vector3;
  71823. /**
  71824. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  71825. * @param scale defines the scale factor
  71826. * @param result defines the Vector3 object where to store the result
  71827. * @returns the unmodified current Vector3
  71828. */
  71829. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  71830. /**
  71831. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  71832. * @param otherVector defines the second operand
  71833. * @returns true if both vectors are equals
  71834. */
  71835. equals(otherVector: DeepImmutable<Vector3>): boolean;
  71836. /**
  71837. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  71838. * @param otherVector defines the second operand
  71839. * @param epsilon defines the minimal distance to define values as equals
  71840. * @returns true if both vectors are distant less than epsilon
  71841. */
  71842. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  71843. /**
  71844. * Returns true if the current Vector3 coordinates equals the given floats
  71845. * @param x defines the x coordinate of the operand
  71846. * @param y defines the y coordinate of the operand
  71847. * @param z defines the z coordinate of the operand
  71848. * @returns true if both vectors are equals
  71849. */
  71850. equalsToFloats(x: number, y: number, z: number): boolean;
  71851. /**
  71852. * Multiplies the current Vector3 coordinates by the given ones
  71853. * @param otherVector defines the second operand
  71854. * @returns the current updated Vector3
  71855. */
  71856. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71857. /**
  71858. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  71859. * @param otherVector defines the second operand
  71860. * @returns the new Vector3
  71861. */
  71862. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  71863. /**
  71864. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  71865. * @param otherVector defines the second operand
  71866. * @param result defines the Vector3 object where to store the result
  71867. * @returns the current Vector3
  71868. */
  71869. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71870. /**
  71871. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  71872. * @param x defines the x coordinate of the operand
  71873. * @param y defines the y coordinate of the operand
  71874. * @param z defines the z coordinate of the operand
  71875. * @returns the new Vector3
  71876. */
  71877. multiplyByFloats(x: number, y: number, z: number): Vector3;
  71878. /**
  71879. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  71880. * @param otherVector defines the second operand
  71881. * @returns the new Vector3
  71882. */
  71883. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  71884. /**
  71885. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  71886. * @param otherVector defines the second operand
  71887. * @param result defines the Vector3 object where to store the result
  71888. * @returns the current Vector3
  71889. */
  71890. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71891. /**
  71892. * Divides the current Vector3 coordinates by the given ones.
  71893. * @param otherVector defines the second operand
  71894. * @returns the current updated Vector3
  71895. */
  71896. divideInPlace(otherVector: Vector3): Vector3;
  71897. /**
  71898. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  71899. * @param other defines the second operand
  71900. * @returns the current updated Vector3
  71901. */
  71902. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  71903. /**
  71904. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  71905. * @param other defines the second operand
  71906. * @returns the current updated Vector3
  71907. */
  71908. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  71909. /**
  71910. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  71911. * @param x defines the x coordinate of the operand
  71912. * @param y defines the y coordinate of the operand
  71913. * @param z defines the z coordinate of the operand
  71914. * @returns the current updated Vector3
  71915. */
  71916. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71917. /**
  71918. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  71919. * @param x defines the x coordinate of the operand
  71920. * @param y defines the y coordinate of the operand
  71921. * @param z defines the z coordinate of the operand
  71922. * @returns the current updated Vector3
  71923. */
  71924. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71925. /**
  71926. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  71927. * Check if is non uniform within a certain amount of decimal places to account for this
  71928. * @param epsilon the amount the values can differ
  71929. * @returns if the the vector is non uniform to a certain number of decimal places
  71930. */
  71931. isNonUniformWithinEpsilon(epsilon: number): boolean;
  71932. /**
  71933. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  71934. */
  71935. readonly isNonUniform: boolean;
  71936. /**
  71937. * Gets a new Vector3 from current Vector3 floored values
  71938. * @returns a new Vector3
  71939. */
  71940. floor(): Vector3;
  71941. /**
  71942. * Gets a new Vector3 from current Vector3 floored values
  71943. * @returns a new Vector3
  71944. */
  71945. fract(): Vector3;
  71946. /**
  71947. * Gets the length of the Vector3
  71948. * @returns the length of the Vector3
  71949. */
  71950. length(): number;
  71951. /**
  71952. * Gets the squared length of the Vector3
  71953. * @returns squared length of the Vector3
  71954. */
  71955. lengthSquared(): number;
  71956. /**
  71957. * Normalize the current Vector3.
  71958. * Please note that this is an in place operation.
  71959. * @returns the current updated Vector3
  71960. */
  71961. normalize(): Vector3;
  71962. /**
  71963. * Reorders the x y z properties of the vector in place
  71964. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  71965. * @returns the current updated vector
  71966. */
  71967. reorderInPlace(order: string): this;
  71968. /**
  71969. * Rotates the vector around 0,0,0 by a quaternion
  71970. * @param quaternion the rotation quaternion
  71971. * @param result vector to store the result
  71972. * @returns the resulting vector
  71973. */
  71974. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  71975. /**
  71976. * Rotates a vector around a given point
  71977. * @param quaternion the rotation quaternion
  71978. * @param point the point to rotate around
  71979. * @param result vector to store the result
  71980. * @returns the resulting vector
  71981. */
  71982. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  71983. /**
  71984. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  71985. * The cross product is then orthogonal to both current and "other"
  71986. * @param other defines the right operand
  71987. * @returns the cross product
  71988. */
  71989. cross(other: Vector3): Vector3;
  71990. /**
  71991. * Normalize the current Vector3 with the given input length.
  71992. * Please note that this is an in place operation.
  71993. * @param len the length of the vector
  71994. * @returns the current updated Vector3
  71995. */
  71996. normalizeFromLength(len: number): Vector3;
  71997. /**
  71998. * Normalize the current Vector3 to a new vector
  71999. * @returns the new Vector3
  72000. */
  72001. normalizeToNew(): Vector3;
  72002. /**
  72003. * Normalize the current Vector3 to the reference
  72004. * @param reference define the Vector3 to update
  72005. * @returns the updated Vector3
  72006. */
  72007. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  72008. /**
  72009. * Creates a new Vector3 copied from the current Vector3
  72010. * @returns the new Vector3
  72011. */
  72012. clone(): Vector3;
  72013. /**
  72014. * Copies the given vector coordinates to the current Vector3 ones
  72015. * @param source defines the source Vector3
  72016. * @returns the current updated Vector3
  72017. */
  72018. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  72019. /**
  72020. * Copies the given floats to the current Vector3 coordinates
  72021. * @param x defines the x coordinate of the operand
  72022. * @param y defines the y coordinate of the operand
  72023. * @param z defines the z coordinate of the operand
  72024. * @returns the current updated Vector3
  72025. */
  72026. copyFromFloats(x: number, y: number, z: number): Vector3;
  72027. /**
  72028. * Copies the given floats to the current Vector3 coordinates
  72029. * @param x defines the x coordinate of the operand
  72030. * @param y defines the y coordinate of the operand
  72031. * @param z defines the z coordinate of the operand
  72032. * @returns the current updated Vector3
  72033. */
  72034. set(x: number, y: number, z: number): Vector3;
  72035. /**
  72036. * Copies the given float to the current Vector3 coordinates
  72037. * @param v defines the x, y and z coordinates of the operand
  72038. * @returns the current updated Vector3
  72039. */
  72040. setAll(v: number): Vector3;
  72041. /**
  72042. * Get the clip factor between two vectors
  72043. * @param vector0 defines the first operand
  72044. * @param vector1 defines the second operand
  72045. * @param axis defines the axis to use
  72046. * @param size defines the size along the axis
  72047. * @returns the clip factor
  72048. */
  72049. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  72050. /**
  72051. * Get angle between two vectors
  72052. * @param vector0 angle between vector0 and vector1
  72053. * @param vector1 angle between vector0 and vector1
  72054. * @param normal direction of the normal
  72055. * @return the angle between vector0 and vector1
  72056. */
  72057. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  72058. /**
  72059. * Returns a new Vector3 set from the index "offset" of the given array
  72060. * @param array defines the source array
  72061. * @param offset defines the offset in the source array
  72062. * @returns the new Vector3
  72063. */
  72064. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  72065. /**
  72066. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  72067. * @param array defines the source array
  72068. * @param offset defines the offset in the source array
  72069. * @returns the new Vector3
  72070. * @deprecated Please use FromArray instead.
  72071. */
  72072. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  72073. /**
  72074. * Sets the given vector "result" with the element values from the index "offset" of the given array
  72075. * @param array defines the source array
  72076. * @param offset defines the offset in the source array
  72077. * @param result defines the Vector3 where to store the result
  72078. */
  72079. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  72080. /**
  72081. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  72082. * @param array defines the source array
  72083. * @param offset defines the offset in the source array
  72084. * @param result defines the Vector3 where to store the result
  72085. * @deprecated Please use FromArrayToRef instead.
  72086. */
  72087. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  72088. /**
  72089. * Sets the given vector "result" with the given floats.
  72090. * @param x defines the x coordinate of the source
  72091. * @param y defines the y coordinate of the source
  72092. * @param z defines the z coordinate of the source
  72093. * @param result defines the Vector3 where to store the result
  72094. */
  72095. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  72096. /**
  72097. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  72098. * @returns a new empty Vector3
  72099. */
  72100. static Zero(): Vector3;
  72101. /**
  72102. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  72103. * @returns a new unit Vector3
  72104. */
  72105. static One(): Vector3;
  72106. /**
  72107. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  72108. * @returns a new up Vector3
  72109. */
  72110. static Up(): Vector3;
  72111. /**
  72112. * Gets a up Vector3 that must not be updated
  72113. */
  72114. static readonly UpReadOnly: DeepImmutable<Vector3>;
  72115. /**
  72116. * Gets a zero Vector3 that must not be updated
  72117. */
  72118. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  72119. /**
  72120. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  72121. * @returns a new down Vector3
  72122. */
  72123. static Down(): Vector3;
  72124. /**
  72125. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  72126. * @returns a new forward Vector3
  72127. */
  72128. static Forward(): Vector3;
  72129. /**
  72130. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  72131. * @returns a new forward Vector3
  72132. */
  72133. static Backward(): Vector3;
  72134. /**
  72135. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  72136. * @returns a new right Vector3
  72137. */
  72138. static Right(): Vector3;
  72139. /**
  72140. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  72141. * @returns a new left Vector3
  72142. */
  72143. static Left(): Vector3;
  72144. /**
  72145. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  72146. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  72147. * @param vector defines the Vector3 to transform
  72148. * @param transformation defines the transformation matrix
  72149. * @returns the transformed Vector3
  72150. */
  72151. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  72152. /**
  72153. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  72154. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  72155. * @param vector defines the Vector3 to transform
  72156. * @param transformation defines the transformation matrix
  72157. * @param result defines the Vector3 where to store the result
  72158. */
  72159. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  72160. /**
  72161. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  72162. * This method computes tranformed coordinates only, not transformed direction vectors
  72163. * @param x define the x coordinate of the source vector
  72164. * @param y define the y coordinate of the source vector
  72165. * @param z define the z coordinate of the source vector
  72166. * @param transformation defines the transformation matrix
  72167. * @param result defines the Vector3 where to store the result
  72168. */
  72169. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  72170. /**
  72171. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  72172. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  72173. * @param vector defines the Vector3 to transform
  72174. * @param transformation defines the transformation matrix
  72175. * @returns the new Vector3
  72176. */
  72177. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  72178. /**
  72179. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  72180. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  72181. * @param vector defines the Vector3 to transform
  72182. * @param transformation defines the transformation matrix
  72183. * @param result defines the Vector3 where to store the result
  72184. */
  72185. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  72186. /**
  72187. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  72188. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  72189. * @param x define the x coordinate of the source vector
  72190. * @param y define the y coordinate of the source vector
  72191. * @param z define the z coordinate of the source vector
  72192. * @param transformation defines the transformation matrix
  72193. * @param result defines the Vector3 where to store the result
  72194. */
  72195. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  72196. /**
  72197. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  72198. * @param value1 defines the first control point
  72199. * @param value2 defines the second control point
  72200. * @param value3 defines the third control point
  72201. * @param value4 defines the fourth control point
  72202. * @param amount defines the amount on the spline to use
  72203. * @returns the new Vector3
  72204. */
  72205. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  72206. /**
  72207. * 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"
  72208. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  72209. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  72210. * @param value defines the current value
  72211. * @param min defines the lower range value
  72212. * @param max defines the upper range value
  72213. * @returns the new Vector3
  72214. */
  72215. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  72216. /**
  72217. * 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"
  72218. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  72219. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  72220. * @param value defines the current value
  72221. * @param min defines the lower range value
  72222. * @param max defines the upper range value
  72223. * @param result defines the Vector3 where to store the result
  72224. */
  72225. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  72226. /**
  72227. * Checks if a given vector is inside a specific range
  72228. * @param v defines the vector to test
  72229. * @param min defines the minimum range
  72230. * @param max defines the maximum range
  72231. */
  72232. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  72233. /**
  72234. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  72235. * @param value1 defines the first control point
  72236. * @param tangent1 defines the first tangent vector
  72237. * @param value2 defines the second control point
  72238. * @param tangent2 defines the second tangent vector
  72239. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  72240. * @returns the new Vector3
  72241. */
  72242. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  72243. /**
  72244. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  72245. * @param start defines the start value
  72246. * @param end defines the end value
  72247. * @param amount max defines amount between both (between 0 and 1)
  72248. * @returns the new Vector3
  72249. */
  72250. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  72251. /**
  72252. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  72253. * @param start defines the start value
  72254. * @param end defines the end value
  72255. * @param amount max defines amount between both (between 0 and 1)
  72256. * @param result defines the Vector3 where to store the result
  72257. */
  72258. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  72259. /**
  72260. * Returns the dot product (float) between the vectors "left" and "right"
  72261. * @param left defines the left operand
  72262. * @param right defines the right operand
  72263. * @returns the dot product
  72264. */
  72265. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  72266. /**
  72267. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  72268. * The cross product is then orthogonal to both "left" and "right"
  72269. * @param left defines the left operand
  72270. * @param right defines the right operand
  72271. * @returns the cross product
  72272. */
  72273. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  72274. /**
  72275. * Sets the given vector "result" with the cross product of "left" and "right"
  72276. * The cross product is then orthogonal to both "left" and "right"
  72277. * @param left defines the left operand
  72278. * @param right defines the right operand
  72279. * @param result defines the Vector3 where to store the result
  72280. */
  72281. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  72282. /**
  72283. * Returns a new Vector3 as the normalization of the given vector
  72284. * @param vector defines the Vector3 to normalize
  72285. * @returns the new Vector3
  72286. */
  72287. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  72288. /**
  72289. * Sets the given vector "result" with the normalization of the given first vector
  72290. * @param vector defines the Vector3 to normalize
  72291. * @param result defines the Vector3 where to store the result
  72292. */
  72293. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  72294. /**
  72295. * Project a Vector3 onto screen space
  72296. * @param vector defines the Vector3 to project
  72297. * @param world defines the world matrix to use
  72298. * @param transform defines the transform (view x projection) matrix to use
  72299. * @param viewport defines the screen viewport to use
  72300. * @returns the new Vector3
  72301. */
  72302. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  72303. /** @hidden */
  72304. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  72305. /**
  72306. * Unproject from screen space to object space
  72307. * @param source defines the screen space Vector3 to use
  72308. * @param viewportWidth defines the current width of the viewport
  72309. * @param viewportHeight defines the current height of the viewport
  72310. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72311. * @param transform defines the transform (view x projection) matrix to use
  72312. * @returns the new Vector3
  72313. */
  72314. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  72315. /**
  72316. * Unproject from screen space to object space
  72317. * @param source defines the screen space Vector3 to use
  72318. * @param viewportWidth defines the current width of the viewport
  72319. * @param viewportHeight defines the current height of the viewport
  72320. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72321. * @param view defines the view matrix to use
  72322. * @param projection defines the projection matrix to use
  72323. * @returns the new Vector3
  72324. */
  72325. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  72326. /**
  72327. * Unproject from screen space to object space
  72328. * @param source defines the screen space Vector3 to use
  72329. * @param viewportWidth defines the current width of the viewport
  72330. * @param viewportHeight defines the current height of the viewport
  72331. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72332. * @param view defines the view matrix to use
  72333. * @param projection defines the projection matrix to use
  72334. * @param result defines the Vector3 where to store the result
  72335. */
  72336. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  72337. /**
  72338. * Unproject from screen space to object space
  72339. * @param sourceX defines the screen space x coordinate to use
  72340. * @param sourceY defines the screen space y coordinate to use
  72341. * @param sourceZ defines the screen space z coordinate to use
  72342. * @param viewportWidth defines the current width of the viewport
  72343. * @param viewportHeight defines the current height of the viewport
  72344. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72345. * @param view defines the view matrix to use
  72346. * @param projection defines the projection matrix to use
  72347. * @param result defines the Vector3 where to store the result
  72348. */
  72349. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  72350. /**
  72351. * Gets the minimal coordinate values between two Vector3
  72352. * @param left defines the first operand
  72353. * @param right defines the second operand
  72354. * @returns the new Vector3
  72355. */
  72356. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  72357. /**
  72358. * Gets the maximal coordinate values between two Vector3
  72359. * @param left defines the first operand
  72360. * @param right defines the second operand
  72361. * @returns the new Vector3
  72362. */
  72363. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  72364. /**
  72365. * Returns the distance between the vectors "value1" and "value2"
  72366. * @param value1 defines the first operand
  72367. * @param value2 defines the second operand
  72368. * @returns the distance
  72369. */
  72370. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  72371. /**
  72372. * Returns the squared distance between the vectors "value1" and "value2"
  72373. * @param value1 defines the first operand
  72374. * @param value2 defines the second operand
  72375. * @returns the squared distance
  72376. */
  72377. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  72378. /**
  72379. * Returns a new Vector3 located at the center between "value1" and "value2"
  72380. * @param value1 defines the first operand
  72381. * @param value2 defines the second operand
  72382. * @returns the new Vector3
  72383. */
  72384. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  72385. /**
  72386. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  72387. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  72388. * to something in order to rotate it from its local system to the given target system
  72389. * Note: axis1, axis2 and axis3 are normalized during this operation
  72390. * @param axis1 defines the first axis
  72391. * @param axis2 defines the second axis
  72392. * @param axis3 defines the third axis
  72393. * @returns a new Vector3
  72394. */
  72395. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  72396. /**
  72397. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  72398. * @param axis1 defines the first axis
  72399. * @param axis2 defines the second axis
  72400. * @param axis3 defines the third axis
  72401. * @param ref defines the Vector3 where to store the result
  72402. */
  72403. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  72404. }
  72405. /**
  72406. * Vector4 class created for EulerAngle class conversion to Quaternion
  72407. */
  72408. export class Vector4 {
  72409. /** x value of the vector */
  72410. x: number;
  72411. /** y value of the vector */
  72412. y: number;
  72413. /** z value of the vector */
  72414. z: number;
  72415. /** w value of the vector */
  72416. w: number;
  72417. /**
  72418. * Creates a Vector4 object from the given floats.
  72419. * @param x x value of the vector
  72420. * @param y y value of the vector
  72421. * @param z z value of the vector
  72422. * @param w w value of the vector
  72423. */
  72424. constructor(
  72425. /** x value of the vector */
  72426. x: number,
  72427. /** y value of the vector */
  72428. y: number,
  72429. /** z value of the vector */
  72430. z: number,
  72431. /** w value of the vector */
  72432. w: number);
  72433. /**
  72434. * Returns the string with the Vector4 coordinates.
  72435. * @returns a string containing all the vector values
  72436. */
  72437. toString(): string;
  72438. /**
  72439. * Returns the string "Vector4".
  72440. * @returns "Vector4"
  72441. */
  72442. getClassName(): string;
  72443. /**
  72444. * Returns the Vector4 hash code.
  72445. * @returns a unique hash code
  72446. */
  72447. getHashCode(): number;
  72448. /**
  72449. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  72450. * @returns the resulting array
  72451. */
  72452. asArray(): number[];
  72453. /**
  72454. * Populates the given array from the given index with the Vector4 coordinates.
  72455. * @param array array to populate
  72456. * @param index index of the array to start at (default: 0)
  72457. * @returns the Vector4.
  72458. */
  72459. toArray(array: FloatArray, index?: number): Vector4;
  72460. /**
  72461. * Adds the given vector to the current Vector4.
  72462. * @param otherVector the vector to add
  72463. * @returns the updated Vector4.
  72464. */
  72465. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  72466. /**
  72467. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  72468. * @param otherVector the vector to add
  72469. * @returns the resulting vector
  72470. */
  72471. add(otherVector: DeepImmutable<Vector4>): Vector4;
  72472. /**
  72473. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  72474. * @param otherVector the vector to add
  72475. * @param result the vector to store the result
  72476. * @returns the current Vector4.
  72477. */
  72478. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72479. /**
  72480. * Subtract in place the given vector from the current Vector4.
  72481. * @param otherVector the vector to subtract
  72482. * @returns the updated Vector4.
  72483. */
  72484. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  72485. /**
  72486. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  72487. * @param otherVector the vector to add
  72488. * @returns the new vector with the result
  72489. */
  72490. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  72491. /**
  72492. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  72493. * @param otherVector the vector to subtract
  72494. * @param result the vector to store the result
  72495. * @returns the current Vector4.
  72496. */
  72497. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72498. /**
  72499. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72500. */
  72501. /**
  72502. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72503. * @param x value to subtract
  72504. * @param y value to subtract
  72505. * @param z value to subtract
  72506. * @param w value to subtract
  72507. * @returns new vector containing the result
  72508. */
  72509. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  72510. /**
  72511. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72512. * @param x value to subtract
  72513. * @param y value to subtract
  72514. * @param z value to subtract
  72515. * @param w value to subtract
  72516. * @param result the vector to store the result in
  72517. * @returns the current Vector4.
  72518. */
  72519. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  72520. /**
  72521. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  72522. * @returns a new vector with the negated values
  72523. */
  72524. negate(): Vector4;
  72525. /**
  72526. * Multiplies the current Vector4 coordinates by scale (float).
  72527. * @param scale the number to scale with
  72528. * @returns the updated Vector4.
  72529. */
  72530. scaleInPlace(scale: number): Vector4;
  72531. /**
  72532. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  72533. * @param scale the number to scale with
  72534. * @returns a new vector with the result
  72535. */
  72536. scale(scale: number): Vector4;
  72537. /**
  72538. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  72539. * @param scale the number to scale with
  72540. * @param result a vector to store the result in
  72541. * @returns the current Vector4.
  72542. */
  72543. scaleToRef(scale: number, result: Vector4): Vector4;
  72544. /**
  72545. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  72546. * @param scale defines the scale factor
  72547. * @param result defines the Vector4 object where to store the result
  72548. * @returns the unmodified current Vector4
  72549. */
  72550. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  72551. /**
  72552. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  72553. * @param otherVector the vector to compare against
  72554. * @returns true if they are equal
  72555. */
  72556. equals(otherVector: DeepImmutable<Vector4>): boolean;
  72557. /**
  72558. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  72559. * @param otherVector vector to compare against
  72560. * @param epsilon (Default: very small number)
  72561. * @returns true if they are equal
  72562. */
  72563. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  72564. /**
  72565. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  72566. * @param x x value to compare against
  72567. * @param y y value to compare against
  72568. * @param z z value to compare against
  72569. * @param w w value to compare against
  72570. * @returns true if equal
  72571. */
  72572. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  72573. /**
  72574. * Multiplies in place the current Vector4 by the given one.
  72575. * @param otherVector vector to multiple with
  72576. * @returns the updated Vector4.
  72577. */
  72578. multiplyInPlace(otherVector: Vector4): Vector4;
  72579. /**
  72580. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  72581. * @param otherVector vector to multiple with
  72582. * @returns resulting new vector
  72583. */
  72584. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  72585. /**
  72586. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  72587. * @param otherVector vector to multiple with
  72588. * @param result vector to store the result
  72589. * @returns the current Vector4.
  72590. */
  72591. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72592. /**
  72593. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  72594. * @param x x value multiply with
  72595. * @param y y value multiply with
  72596. * @param z z value multiply with
  72597. * @param w w value multiply with
  72598. * @returns resulting new vector
  72599. */
  72600. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  72601. /**
  72602. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  72603. * @param otherVector vector to devide with
  72604. * @returns resulting new vector
  72605. */
  72606. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  72607. /**
  72608. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  72609. * @param otherVector vector to devide with
  72610. * @param result vector to store the result
  72611. * @returns the current Vector4.
  72612. */
  72613. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72614. /**
  72615. * Divides the current Vector3 coordinates by the given ones.
  72616. * @param otherVector vector to devide with
  72617. * @returns the updated Vector3.
  72618. */
  72619. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  72620. /**
  72621. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  72622. * @param other defines the second operand
  72623. * @returns the current updated Vector4
  72624. */
  72625. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  72626. /**
  72627. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  72628. * @param other defines the second operand
  72629. * @returns the current updated Vector4
  72630. */
  72631. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  72632. /**
  72633. * Gets a new Vector4 from current Vector4 floored values
  72634. * @returns a new Vector4
  72635. */
  72636. floor(): Vector4;
  72637. /**
  72638. * Gets a new Vector4 from current Vector3 floored values
  72639. * @returns a new Vector4
  72640. */
  72641. fract(): Vector4;
  72642. /**
  72643. * Returns the Vector4 length (float).
  72644. * @returns the length
  72645. */
  72646. length(): number;
  72647. /**
  72648. * Returns the Vector4 squared length (float).
  72649. * @returns the length squared
  72650. */
  72651. lengthSquared(): number;
  72652. /**
  72653. * Normalizes in place the Vector4.
  72654. * @returns the updated Vector4.
  72655. */
  72656. normalize(): Vector4;
  72657. /**
  72658. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  72659. * @returns this converted to a new vector3
  72660. */
  72661. toVector3(): Vector3;
  72662. /**
  72663. * Returns a new Vector4 copied from the current one.
  72664. * @returns the new cloned vector
  72665. */
  72666. clone(): Vector4;
  72667. /**
  72668. * Updates the current Vector4 with the given one coordinates.
  72669. * @param source the source vector to copy from
  72670. * @returns the updated Vector4.
  72671. */
  72672. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  72673. /**
  72674. * Updates the current Vector4 coordinates with the given floats.
  72675. * @param x float to copy from
  72676. * @param y float to copy from
  72677. * @param z float to copy from
  72678. * @param w float to copy from
  72679. * @returns the updated Vector4.
  72680. */
  72681. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  72682. /**
  72683. * Updates the current Vector4 coordinates with the given floats.
  72684. * @param x float to set from
  72685. * @param y float to set from
  72686. * @param z float to set from
  72687. * @param w float to set from
  72688. * @returns the updated Vector4.
  72689. */
  72690. set(x: number, y: number, z: number, w: number): Vector4;
  72691. /**
  72692. * Copies the given float to the current Vector3 coordinates
  72693. * @param v defines the x, y, z and w coordinates of the operand
  72694. * @returns the current updated Vector3
  72695. */
  72696. setAll(v: number): Vector4;
  72697. /**
  72698. * Returns a new Vector4 set from the starting index of the given array.
  72699. * @param array the array to pull values from
  72700. * @param offset the offset into the array to start at
  72701. * @returns the new vector
  72702. */
  72703. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  72704. /**
  72705. * Updates the given vector "result" from the starting index of the given array.
  72706. * @param array the array to pull values from
  72707. * @param offset the offset into the array to start at
  72708. * @param result the vector to store the result in
  72709. */
  72710. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  72711. /**
  72712. * Updates the given vector "result" from the starting index of the given Float32Array.
  72713. * @param array the array to pull values from
  72714. * @param offset the offset into the array to start at
  72715. * @param result the vector to store the result in
  72716. */
  72717. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  72718. /**
  72719. * Updates the given vector "result" coordinates from the given floats.
  72720. * @param x float to set from
  72721. * @param y float to set from
  72722. * @param z float to set from
  72723. * @param w float to set from
  72724. * @param result the vector to the floats in
  72725. */
  72726. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  72727. /**
  72728. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  72729. * @returns the new vector
  72730. */
  72731. static Zero(): Vector4;
  72732. /**
  72733. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  72734. * @returns the new vector
  72735. */
  72736. static One(): Vector4;
  72737. /**
  72738. * Returns a new normalized Vector4 from the given one.
  72739. * @param vector the vector to normalize
  72740. * @returns the vector
  72741. */
  72742. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  72743. /**
  72744. * Updates the given vector "result" from the normalization of the given one.
  72745. * @param vector the vector to normalize
  72746. * @param result the vector to store the result in
  72747. */
  72748. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  72749. /**
  72750. * Returns a vector with the minimum values from the left and right vectors
  72751. * @param left left vector to minimize
  72752. * @param right right vector to minimize
  72753. * @returns a new vector with the minimum of the left and right vector values
  72754. */
  72755. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  72756. /**
  72757. * Returns a vector with the maximum values from the left and right vectors
  72758. * @param left left vector to maximize
  72759. * @param right right vector to maximize
  72760. * @returns a new vector with the maximum of the left and right vector values
  72761. */
  72762. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  72763. /**
  72764. * Returns the distance (float) between the vectors "value1" and "value2".
  72765. * @param value1 value to calulate the distance between
  72766. * @param value2 value to calulate the distance between
  72767. * @return the distance between the two vectors
  72768. */
  72769. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  72770. /**
  72771. * Returns the squared distance (float) between the vectors "value1" and "value2".
  72772. * @param value1 value to calulate the distance between
  72773. * @param value2 value to calulate the distance between
  72774. * @return the distance between the two vectors squared
  72775. */
  72776. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  72777. /**
  72778. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  72779. * @param value1 value to calulate the center between
  72780. * @param value2 value to calulate the center between
  72781. * @return the center between the two vectors
  72782. */
  72783. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  72784. /**
  72785. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  72786. * This methods computes transformed normalized direction vectors only.
  72787. * @param vector the vector to transform
  72788. * @param transformation the transformation matrix to apply
  72789. * @returns the new vector
  72790. */
  72791. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  72792. /**
  72793. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  72794. * This methods computes transformed normalized direction vectors only.
  72795. * @param vector the vector to transform
  72796. * @param transformation the transformation matrix to apply
  72797. * @param result the vector to store the result in
  72798. */
  72799. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  72800. /**
  72801. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  72802. * This methods computes transformed normalized direction vectors only.
  72803. * @param x value to transform
  72804. * @param y value to transform
  72805. * @param z value to transform
  72806. * @param w value to transform
  72807. * @param transformation the transformation matrix to apply
  72808. * @param result the vector to store the results in
  72809. */
  72810. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  72811. /**
  72812. * Creates a new Vector4 from a Vector3
  72813. * @param source defines the source data
  72814. * @param w defines the 4th component (default is 0)
  72815. * @returns a new Vector4
  72816. */
  72817. static FromVector3(source: Vector3, w?: number): Vector4;
  72818. }
  72819. /**
  72820. * Class used to store quaternion data
  72821. * @see https://en.wikipedia.org/wiki/Quaternion
  72822. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  72823. */
  72824. export class Quaternion {
  72825. /** defines the first component (0 by default) */
  72826. x: number;
  72827. /** defines the second component (0 by default) */
  72828. y: number;
  72829. /** defines the third component (0 by default) */
  72830. z: number;
  72831. /** defines the fourth component (1.0 by default) */
  72832. w: number;
  72833. /**
  72834. * Creates a new Quaternion from the given floats
  72835. * @param x defines the first component (0 by default)
  72836. * @param y defines the second component (0 by default)
  72837. * @param z defines the third component (0 by default)
  72838. * @param w defines the fourth component (1.0 by default)
  72839. */
  72840. constructor(
  72841. /** defines the first component (0 by default) */
  72842. x?: number,
  72843. /** defines the second component (0 by default) */
  72844. y?: number,
  72845. /** defines the third component (0 by default) */
  72846. z?: number,
  72847. /** defines the fourth component (1.0 by default) */
  72848. w?: number);
  72849. /**
  72850. * Gets a string representation for the current quaternion
  72851. * @returns a string with the Quaternion coordinates
  72852. */
  72853. toString(): string;
  72854. /**
  72855. * Gets the class name of the quaternion
  72856. * @returns the string "Quaternion"
  72857. */
  72858. getClassName(): string;
  72859. /**
  72860. * Gets a hash code for this quaternion
  72861. * @returns the quaternion hash code
  72862. */
  72863. getHashCode(): number;
  72864. /**
  72865. * Copy the quaternion to an array
  72866. * @returns a new array populated with 4 elements from the quaternion coordinates
  72867. */
  72868. asArray(): number[];
  72869. /**
  72870. * Check if two quaternions are equals
  72871. * @param otherQuaternion defines the second operand
  72872. * @return true if the current quaternion and the given one coordinates are strictly equals
  72873. */
  72874. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  72875. /**
  72876. * Clone the current quaternion
  72877. * @returns a new quaternion copied from the current one
  72878. */
  72879. clone(): Quaternion;
  72880. /**
  72881. * Copy a quaternion to the current one
  72882. * @param other defines the other quaternion
  72883. * @returns the updated current quaternion
  72884. */
  72885. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  72886. /**
  72887. * Updates the current quaternion with the given float coordinates
  72888. * @param x defines the x coordinate
  72889. * @param y defines the y coordinate
  72890. * @param z defines the z coordinate
  72891. * @param w defines the w coordinate
  72892. * @returns the updated current quaternion
  72893. */
  72894. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  72895. /**
  72896. * Updates the current quaternion from the given float coordinates
  72897. * @param x defines the x coordinate
  72898. * @param y defines the y coordinate
  72899. * @param z defines the z coordinate
  72900. * @param w defines the w coordinate
  72901. * @returns the updated current quaternion
  72902. */
  72903. set(x: number, y: number, z: number, w: number): Quaternion;
  72904. /**
  72905. * Adds two quaternions
  72906. * @param other defines the second operand
  72907. * @returns a new quaternion as the addition result of the given one and the current quaternion
  72908. */
  72909. add(other: DeepImmutable<Quaternion>): Quaternion;
  72910. /**
  72911. * Add a quaternion to the current one
  72912. * @param other defines the quaternion to add
  72913. * @returns the current quaternion
  72914. */
  72915. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  72916. /**
  72917. * Subtract two quaternions
  72918. * @param other defines the second operand
  72919. * @returns a new quaternion as the subtraction result of the given one from the current one
  72920. */
  72921. subtract(other: Quaternion): Quaternion;
  72922. /**
  72923. * Multiplies the current quaternion by a scale factor
  72924. * @param value defines the scale factor
  72925. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  72926. */
  72927. scale(value: number): Quaternion;
  72928. /**
  72929. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  72930. * @param scale defines the scale factor
  72931. * @param result defines the Quaternion object where to store the result
  72932. * @returns the unmodified current quaternion
  72933. */
  72934. scaleToRef(scale: number, result: Quaternion): Quaternion;
  72935. /**
  72936. * Multiplies in place the current quaternion by a scale factor
  72937. * @param value defines the scale factor
  72938. * @returns the current modified quaternion
  72939. */
  72940. scaleInPlace(value: number): Quaternion;
  72941. /**
  72942. * Scale the current quaternion values by a factor and add the result to a given quaternion
  72943. * @param scale defines the scale factor
  72944. * @param result defines the Quaternion object where to store the result
  72945. * @returns the unmodified current quaternion
  72946. */
  72947. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  72948. /**
  72949. * Multiplies two quaternions
  72950. * @param q1 defines the second operand
  72951. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  72952. */
  72953. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  72954. /**
  72955. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  72956. * @param q1 defines the second operand
  72957. * @param result defines the target quaternion
  72958. * @returns the current quaternion
  72959. */
  72960. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  72961. /**
  72962. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  72963. * @param q1 defines the second operand
  72964. * @returns the currentupdated quaternion
  72965. */
  72966. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  72967. /**
  72968. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  72969. * @param ref defines the target quaternion
  72970. * @returns the current quaternion
  72971. */
  72972. conjugateToRef(ref: Quaternion): Quaternion;
  72973. /**
  72974. * Conjugates in place (1-q) the current quaternion
  72975. * @returns the current updated quaternion
  72976. */
  72977. conjugateInPlace(): Quaternion;
  72978. /**
  72979. * Conjugates in place (1-q) the current quaternion
  72980. * @returns a new quaternion
  72981. */
  72982. conjugate(): Quaternion;
  72983. /**
  72984. * Gets length of current quaternion
  72985. * @returns the quaternion length (float)
  72986. */
  72987. length(): number;
  72988. /**
  72989. * Normalize in place the current quaternion
  72990. * @returns the current updated quaternion
  72991. */
  72992. normalize(): Quaternion;
  72993. /**
  72994. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  72995. * @param order is a reserved parameter and is ignore for now
  72996. * @returns a new Vector3 containing the Euler angles
  72997. */
  72998. toEulerAngles(order?: string): Vector3;
  72999. /**
  73000. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  73001. * @param result defines the vector which will be filled with the Euler angles
  73002. * @param order is a reserved parameter and is ignore for now
  73003. * @returns the current unchanged quaternion
  73004. */
  73005. toEulerAnglesToRef(result: Vector3): Quaternion;
  73006. /**
  73007. * Updates the given rotation matrix with the current quaternion values
  73008. * @param result defines the target matrix
  73009. * @returns the current unchanged quaternion
  73010. */
  73011. toRotationMatrix(result: Matrix): Quaternion;
  73012. /**
  73013. * Updates the current quaternion from the given rotation matrix values
  73014. * @param matrix defines the source matrix
  73015. * @returns the current updated quaternion
  73016. */
  73017. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  73018. /**
  73019. * Creates a new quaternion from a rotation matrix
  73020. * @param matrix defines the source matrix
  73021. * @returns a new quaternion created from the given rotation matrix values
  73022. */
  73023. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  73024. /**
  73025. * Updates the given quaternion with the given rotation matrix values
  73026. * @param matrix defines the source matrix
  73027. * @param result defines the target quaternion
  73028. */
  73029. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  73030. /**
  73031. * Returns the dot product (float) between the quaternions "left" and "right"
  73032. * @param left defines the left operand
  73033. * @param right defines the right operand
  73034. * @returns the dot product
  73035. */
  73036. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  73037. /**
  73038. * Checks if the two quaternions are close to each other
  73039. * @param quat0 defines the first quaternion to check
  73040. * @param quat1 defines the second quaternion to check
  73041. * @returns true if the two quaternions are close to each other
  73042. */
  73043. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  73044. /**
  73045. * Creates an empty quaternion
  73046. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  73047. */
  73048. static Zero(): Quaternion;
  73049. /**
  73050. * Inverse a given quaternion
  73051. * @param q defines the source quaternion
  73052. * @returns a new quaternion as the inverted current quaternion
  73053. */
  73054. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  73055. /**
  73056. * Inverse a given quaternion
  73057. * @param q defines the source quaternion
  73058. * @param result the quaternion the result will be stored in
  73059. * @returns the result quaternion
  73060. */
  73061. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  73062. /**
  73063. * Creates an identity quaternion
  73064. * @returns the identity quaternion
  73065. */
  73066. static Identity(): Quaternion;
  73067. /**
  73068. * Gets a boolean indicating if the given quaternion is identity
  73069. * @param quaternion defines the quaternion to check
  73070. * @returns true if the quaternion is identity
  73071. */
  73072. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  73073. /**
  73074. * Creates a quaternion from a rotation around an axis
  73075. * @param axis defines the axis to use
  73076. * @param angle defines the angle to use
  73077. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  73078. */
  73079. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  73080. /**
  73081. * Creates a rotation around an axis and stores it into the given quaternion
  73082. * @param axis defines the axis to use
  73083. * @param angle defines the angle to use
  73084. * @param result defines the target quaternion
  73085. * @returns the target quaternion
  73086. */
  73087. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  73088. /**
  73089. * Creates a new quaternion from data stored into an array
  73090. * @param array defines the data source
  73091. * @param offset defines the offset in the source array where the data starts
  73092. * @returns a new quaternion
  73093. */
  73094. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  73095. /**
  73096. * Create a quaternion from Euler rotation angles
  73097. * @param x Pitch
  73098. * @param y Yaw
  73099. * @param z Roll
  73100. * @returns the new Quaternion
  73101. */
  73102. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  73103. /**
  73104. * Updates a quaternion from Euler rotation angles
  73105. * @param x Pitch
  73106. * @param y Yaw
  73107. * @param z Roll
  73108. * @param result the quaternion to store the result
  73109. * @returns the updated quaternion
  73110. */
  73111. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  73112. /**
  73113. * Create a quaternion from Euler rotation vector
  73114. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  73115. * @returns the new Quaternion
  73116. */
  73117. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  73118. /**
  73119. * Updates a quaternion from Euler rotation vector
  73120. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  73121. * @param result the quaternion to store the result
  73122. * @returns the updated quaternion
  73123. */
  73124. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  73125. /**
  73126. * Creates a new quaternion from the given Euler float angles (y, x, z)
  73127. * @param yaw defines the rotation around Y axis
  73128. * @param pitch defines the rotation around X axis
  73129. * @param roll defines the rotation around Z axis
  73130. * @returns the new quaternion
  73131. */
  73132. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  73133. /**
  73134. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  73135. * @param yaw defines the rotation around Y axis
  73136. * @param pitch defines the rotation around X axis
  73137. * @param roll defines the rotation around Z axis
  73138. * @param result defines the target quaternion
  73139. */
  73140. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  73141. /**
  73142. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  73143. * @param alpha defines the rotation around first axis
  73144. * @param beta defines the rotation around second axis
  73145. * @param gamma defines the rotation around third axis
  73146. * @returns the new quaternion
  73147. */
  73148. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  73149. /**
  73150. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  73151. * @param alpha defines the rotation around first axis
  73152. * @param beta defines the rotation around second axis
  73153. * @param gamma defines the rotation around third axis
  73154. * @param result defines the target quaternion
  73155. */
  73156. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  73157. /**
  73158. * 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)
  73159. * @param axis1 defines the first axis
  73160. * @param axis2 defines the second axis
  73161. * @param axis3 defines the third axis
  73162. * @returns the new quaternion
  73163. */
  73164. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  73165. /**
  73166. * 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
  73167. * @param axis1 defines the first axis
  73168. * @param axis2 defines the second axis
  73169. * @param axis3 defines the third axis
  73170. * @param ref defines the target quaternion
  73171. */
  73172. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  73173. /**
  73174. * Interpolates between two quaternions
  73175. * @param left defines first quaternion
  73176. * @param right defines second quaternion
  73177. * @param amount defines the gradient to use
  73178. * @returns the new interpolated quaternion
  73179. */
  73180. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  73181. /**
  73182. * Interpolates between two quaternions and stores it into a target quaternion
  73183. * @param left defines first quaternion
  73184. * @param right defines second quaternion
  73185. * @param amount defines the gradient to use
  73186. * @param result defines the target quaternion
  73187. */
  73188. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  73189. /**
  73190. * Interpolate between two quaternions using Hermite interpolation
  73191. * @param value1 defines first quaternion
  73192. * @param tangent1 defines the incoming tangent
  73193. * @param value2 defines second quaternion
  73194. * @param tangent2 defines the outgoing tangent
  73195. * @param amount defines the target quaternion
  73196. * @returns the new interpolated quaternion
  73197. */
  73198. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  73199. }
  73200. /**
  73201. * Class used to store matrix data (4x4)
  73202. */
  73203. export class Matrix {
  73204. private static _updateFlagSeed;
  73205. private static _identityReadOnly;
  73206. private _isIdentity;
  73207. private _isIdentityDirty;
  73208. private _isIdentity3x2;
  73209. private _isIdentity3x2Dirty;
  73210. /**
  73211. * Gets the update flag of the matrix which is an unique number for the matrix.
  73212. * It will be incremented every time the matrix data change.
  73213. * You can use it to speed the comparison between two versions of the same matrix.
  73214. */
  73215. updateFlag: number;
  73216. private readonly _m;
  73217. /**
  73218. * Gets the internal data of the matrix
  73219. */
  73220. readonly m: DeepImmutable<Float32Array>;
  73221. /** @hidden */
  73222. _markAsUpdated(): void;
  73223. /** @hidden */
  73224. private _updateIdentityStatus;
  73225. /**
  73226. * Creates an empty matrix (filled with zeros)
  73227. */
  73228. constructor();
  73229. /**
  73230. * Check if the current matrix is identity
  73231. * @returns true is the matrix is the identity matrix
  73232. */
  73233. isIdentity(): boolean;
  73234. /**
  73235. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  73236. * @returns true is the matrix is the identity matrix
  73237. */
  73238. isIdentityAs3x2(): boolean;
  73239. /**
  73240. * Gets the determinant of the matrix
  73241. * @returns the matrix determinant
  73242. */
  73243. determinant(): number;
  73244. /**
  73245. * Returns the matrix as a Float32Array
  73246. * @returns the matrix underlying array
  73247. */
  73248. toArray(): DeepImmutable<Float32Array>;
  73249. /**
  73250. * Returns the matrix as a Float32Array
  73251. * @returns the matrix underlying array.
  73252. */
  73253. asArray(): DeepImmutable<Float32Array>;
  73254. /**
  73255. * Inverts the current matrix in place
  73256. * @returns the current inverted matrix
  73257. */
  73258. invert(): Matrix;
  73259. /**
  73260. * Sets all the matrix elements to zero
  73261. * @returns the current matrix
  73262. */
  73263. reset(): Matrix;
  73264. /**
  73265. * Adds the current matrix with a second one
  73266. * @param other defines the matrix to add
  73267. * @returns a new matrix as the addition of the current matrix and the given one
  73268. */
  73269. add(other: DeepImmutable<Matrix>): Matrix;
  73270. /**
  73271. * Sets the given matrix "result" to the addition of the current matrix and the given one
  73272. * @param other defines the matrix to add
  73273. * @param result defines the target matrix
  73274. * @returns the current matrix
  73275. */
  73276. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  73277. /**
  73278. * Adds in place the given matrix to the current matrix
  73279. * @param other defines the second operand
  73280. * @returns the current updated matrix
  73281. */
  73282. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  73283. /**
  73284. * Sets the given matrix to the current inverted Matrix
  73285. * @param other defines the target matrix
  73286. * @returns the unmodified current matrix
  73287. */
  73288. invertToRef(other: Matrix): Matrix;
  73289. /**
  73290. * add a value at the specified position in the current Matrix
  73291. * @param index the index of the value within the matrix. between 0 and 15.
  73292. * @param value the value to be added
  73293. * @returns the current updated matrix
  73294. */
  73295. addAtIndex(index: number, value: number): Matrix;
  73296. /**
  73297. * mutiply the specified position in the current Matrix by a value
  73298. * @param index the index of the value within the matrix. between 0 and 15.
  73299. * @param value the value to be added
  73300. * @returns the current updated matrix
  73301. */
  73302. multiplyAtIndex(index: number, value: number): Matrix;
  73303. /**
  73304. * Inserts the translation vector (using 3 floats) in the current matrix
  73305. * @param x defines the 1st component of the translation
  73306. * @param y defines the 2nd component of the translation
  73307. * @param z defines the 3rd component of the translation
  73308. * @returns the current updated matrix
  73309. */
  73310. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  73311. /**
  73312. * Adds the translation vector (using 3 floats) in the current matrix
  73313. * @param x defines the 1st component of the translation
  73314. * @param y defines the 2nd component of the translation
  73315. * @param z defines the 3rd component of the translation
  73316. * @returns the current updated matrix
  73317. */
  73318. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  73319. /**
  73320. * Inserts the translation vector in the current matrix
  73321. * @param vector3 defines the translation to insert
  73322. * @returns the current updated matrix
  73323. */
  73324. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  73325. /**
  73326. * Gets the translation value of the current matrix
  73327. * @returns a new Vector3 as the extracted translation from the matrix
  73328. */
  73329. getTranslation(): Vector3;
  73330. /**
  73331. * Fill a Vector3 with the extracted translation from the matrix
  73332. * @param result defines the Vector3 where to store the translation
  73333. * @returns the current matrix
  73334. */
  73335. getTranslationToRef(result: Vector3): Matrix;
  73336. /**
  73337. * Remove rotation and scaling part from the matrix
  73338. * @returns the updated matrix
  73339. */
  73340. removeRotationAndScaling(): Matrix;
  73341. /**
  73342. * Multiply two matrices
  73343. * @param other defines the second operand
  73344. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  73345. */
  73346. multiply(other: DeepImmutable<Matrix>): Matrix;
  73347. /**
  73348. * Copy the current matrix from the given one
  73349. * @param other defines the source matrix
  73350. * @returns the current updated matrix
  73351. */
  73352. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  73353. /**
  73354. * Populates the given array from the starting index with the current matrix values
  73355. * @param array defines the target array
  73356. * @param offset defines the offset in the target array where to start storing values
  73357. * @returns the current matrix
  73358. */
  73359. copyToArray(array: Float32Array, offset?: number): Matrix;
  73360. /**
  73361. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  73362. * @param other defines the second operand
  73363. * @param result defines the matrix where to store the multiplication
  73364. * @returns the current matrix
  73365. */
  73366. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  73367. /**
  73368. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  73369. * @param other defines the second operand
  73370. * @param result defines the array where to store the multiplication
  73371. * @param offset defines the offset in the target array where to start storing values
  73372. * @returns the current matrix
  73373. */
  73374. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  73375. /**
  73376. * Check equality between this matrix and a second one
  73377. * @param value defines the second matrix to compare
  73378. * @returns true is the current matrix and the given one values are strictly equal
  73379. */
  73380. equals(value: DeepImmutable<Matrix>): boolean;
  73381. /**
  73382. * Clone the current matrix
  73383. * @returns a new matrix from the current matrix
  73384. */
  73385. clone(): Matrix;
  73386. /**
  73387. * Returns the name of the current matrix class
  73388. * @returns the string "Matrix"
  73389. */
  73390. getClassName(): string;
  73391. /**
  73392. * Gets the hash code of the current matrix
  73393. * @returns the hash code
  73394. */
  73395. getHashCode(): number;
  73396. /**
  73397. * Decomposes the current Matrix into a translation, rotation and scaling components
  73398. * @param scale defines the scale vector3 given as a reference to update
  73399. * @param rotation defines the rotation quaternion given as a reference to update
  73400. * @param translation defines the translation vector3 given as a reference to update
  73401. * @returns true if operation was successful
  73402. */
  73403. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  73404. /**
  73405. * Gets specific row of the matrix
  73406. * @param index defines the number of the row to get
  73407. * @returns the index-th row of the current matrix as a new Vector4
  73408. */
  73409. getRow(index: number): Nullable<Vector4>;
  73410. /**
  73411. * Sets the index-th row of the current matrix to the vector4 values
  73412. * @param index defines the number of the row to set
  73413. * @param row defines the target vector4
  73414. * @returns the updated current matrix
  73415. */
  73416. setRow(index: number, row: Vector4): Matrix;
  73417. /**
  73418. * Compute the transpose of the matrix
  73419. * @returns the new transposed matrix
  73420. */
  73421. transpose(): Matrix;
  73422. /**
  73423. * Compute the transpose of the matrix and store it in a given matrix
  73424. * @param result defines the target matrix
  73425. * @returns the current matrix
  73426. */
  73427. transposeToRef(result: Matrix): Matrix;
  73428. /**
  73429. * Sets the index-th row of the current matrix with the given 4 x float values
  73430. * @param index defines the row index
  73431. * @param x defines the x component to set
  73432. * @param y defines the y component to set
  73433. * @param z defines the z component to set
  73434. * @param w defines the w component to set
  73435. * @returns the updated current matrix
  73436. */
  73437. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  73438. /**
  73439. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  73440. * @param scale defines the scale factor
  73441. * @returns a new matrix
  73442. */
  73443. scale(scale: number): Matrix;
  73444. /**
  73445. * Scale the current matrix values by a factor to a given result matrix
  73446. * @param scale defines the scale factor
  73447. * @param result defines the matrix to store the result
  73448. * @returns the current matrix
  73449. */
  73450. scaleToRef(scale: number, result: Matrix): Matrix;
  73451. /**
  73452. * Scale the current matrix values by a factor and add the result to a given matrix
  73453. * @param scale defines the scale factor
  73454. * @param result defines the Matrix to store the result
  73455. * @returns the current matrix
  73456. */
  73457. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  73458. /**
  73459. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  73460. * @param ref matrix to store the result
  73461. */
  73462. toNormalMatrix(ref: Matrix): void;
  73463. /**
  73464. * Gets only rotation part of the current matrix
  73465. * @returns a new matrix sets to the extracted rotation matrix from the current one
  73466. */
  73467. getRotationMatrix(): Matrix;
  73468. /**
  73469. * Extracts the rotation matrix from the current one and sets it as the given "result"
  73470. * @param result defines the target matrix to store data to
  73471. * @returns the current matrix
  73472. */
  73473. getRotationMatrixToRef(result: Matrix): Matrix;
  73474. /**
  73475. * Toggles model matrix from being right handed to left handed in place and vice versa
  73476. */
  73477. toggleModelMatrixHandInPlace(): void;
  73478. /**
  73479. * Toggles projection matrix from being right handed to left handed in place and vice versa
  73480. */
  73481. toggleProjectionMatrixHandInPlace(): void;
  73482. /**
  73483. * Creates a matrix from an array
  73484. * @param array defines the source array
  73485. * @param offset defines an offset in the source array
  73486. * @returns a new Matrix set from the starting index of the given array
  73487. */
  73488. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  73489. /**
  73490. * Copy the content of an array into a given matrix
  73491. * @param array defines the source array
  73492. * @param offset defines an offset in the source array
  73493. * @param result defines the target matrix
  73494. */
  73495. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  73496. /**
  73497. * Stores an array into a matrix after having multiplied each component by a given factor
  73498. * @param array defines the source array
  73499. * @param offset defines the offset in the source array
  73500. * @param scale defines the scaling factor
  73501. * @param result defines the target matrix
  73502. */
  73503. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  73504. /**
  73505. * Gets an identity matrix that must not be updated
  73506. */
  73507. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  73508. /**
  73509. * Stores a list of values (16) inside a given matrix
  73510. * @param initialM11 defines 1st value of 1st row
  73511. * @param initialM12 defines 2nd value of 1st row
  73512. * @param initialM13 defines 3rd value of 1st row
  73513. * @param initialM14 defines 4th value of 1st row
  73514. * @param initialM21 defines 1st value of 2nd row
  73515. * @param initialM22 defines 2nd value of 2nd row
  73516. * @param initialM23 defines 3rd value of 2nd row
  73517. * @param initialM24 defines 4th value of 2nd row
  73518. * @param initialM31 defines 1st value of 3rd row
  73519. * @param initialM32 defines 2nd value of 3rd row
  73520. * @param initialM33 defines 3rd value of 3rd row
  73521. * @param initialM34 defines 4th value of 3rd row
  73522. * @param initialM41 defines 1st value of 4th row
  73523. * @param initialM42 defines 2nd value of 4th row
  73524. * @param initialM43 defines 3rd value of 4th row
  73525. * @param initialM44 defines 4th value of 4th row
  73526. * @param result defines the target matrix
  73527. */
  73528. 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;
  73529. /**
  73530. * Creates new matrix from a list of values (16)
  73531. * @param initialM11 defines 1st value of 1st row
  73532. * @param initialM12 defines 2nd value of 1st row
  73533. * @param initialM13 defines 3rd value of 1st row
  73534. * @param initialM14 defines 4th value of 1st row
  73535. * @param initialM21 defines 1st value of 2nd row
  73536. * @param initialM22 defines 2nd value of 2nd row
  73537. * @param initialM23 defines 3rd value of 2nd row
  73538. * @param initialM24 defines 4th value of 2nd row
  73539. * @param initialM31 defines 1st value of 3rd row
  73540. * @param initialM32 defines 2nd value of 3rd row
  73541. * @param initialM33 defines 3rd value of 3rd row
  73542. * @param initialM34 defines 4th value of 3rd row
  73543. * @param initialM41 defines 1st value of 4th row
  73544. * @param initialM42 defines 2nd value of 4th row
  73545. * @param initialM43 defines 3rd value of 4th row
  73546. * @param initialM44 defines 4th value of 4th row
  73547. * @returns the new matrix
  73548. */
  73549. 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;
  73550. /**
  73551. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  73552. * @param scale defines the scale vector3
  73553. * @param rotation defines the rotation quaternion
  73554. * @param translation defines the translation vector3
  73555. * @returns a new matrix
  73556. */
  73557. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  73558. /**
  73559. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  73560. * @param scale defines the scale vector3
  73561. * @param rotation defines the rotation quaternion
  73562. * @param translation defines the translation vector3
  73563. * @param result defines the target matrix
  73564. */
  73565. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  73566. /**
  73567. * Creates a new identity matrix
  73568. * @returns a new identity matrix
  73569. */
  73570. static Identity(): Matrix;
  73571. /**
  73572. * Creates a new identity matrix and stores the result in a given matrix
  73573. * @param result defines the target matrix
  73574. */
  73575. static IdentityToRef(result: Matrix): void;
  73576. /**
  73577. * Creates a new zero matrix
  73578. * @returns a new zero matrix
  73579. */
  73580. static Zero(): Matrix;
  73581. /**
  73582. * Creates a new rotation matrix for "angle" radians around the X axis
  73583. * @param angle defines the angle (in radians) to use
  73584. * @return the new matrix
  73585. */
  73586. static RotationX(angle: number): Matrix;
  73587. /**
  73588. * Creates a new matrix as the invert of a given matrix
  73589. * @param source defines the source matrix
  73590. * @returns the new matrix
  73591. */
  73592. static Invert(source: DeepImmutable<Matrix>): Matrix;
  73593. /**
  73594. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  73595. * @param angle defines the angle (in radians) to use
  73596. * @param result defines the target matrix
  73597. */
  73598. static RotationXToRef(angle: number, result: Matrix): void;
  73599. /**
  73600. * Creates a new rotation matrix for "angle" radians around the Y axis
  73601. * @param angle defines the angle (in radians) to use
  73602. * @return the new matrix
  73603. */
  73604. static RotationY(angle: number): Matrix;
  73605. /**
  73606. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  73607. * @param angle defines the angle (in radians) to use
  73608. * @param result defines the target matrix
  73609. */
  73610. static RotationYToRef(angle: number, result: Matrix): void;
  73611. /**
  73612. * Creates a new rotation matrix for "angle" radians around the Z axis
  73613. * @param angle defines the angle (in radians) to use
  73614. * @return the new matrix
  73615. */
  73616. static RotationZ(angle: number): Matrix;
  73617. /**
  73618. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  73619. * @param angle defines the angle (in radians) to use
  73620. * @param result defines the target matrix
  73621. */
  73622. static RotationZToRef(angle: number, result: Matrix): void;
  73623. /**
  73624. * Creates a new rotation matrix for "angle" radians around the given axis
  73625. * @param axis defines the axis to use
  73626. * @param angle defines the angle (in radians) to use
  73627. * @return the new matrix
  73628. */
  73629. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  73630. /**
  73631. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  73632. * @param axis defines the axis to use
  73633. * @param angle defines the angle (in radians) to use
  73634. * @param result defines the target matrix
  73635. */
  73636. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  73637. /**
  73638. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  73639. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  73640. * @param from defines the vector to align
  73641. * @param to defines the vector to align to
  73642. * @param result defines the target matrix
  73643. */
  73644. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  73645. /**
  73646. * Creates a rotation matrix
  73647. * @param yaw defines the yaw angle in radians (Y axis)
  73648. * @param pitch defines the pitch angle in radians (X axis)
  73649. * @param roll defines the roll angle in radians (X axis)
  73650. * @returns the new rotation matrix
  73651. */
  73652. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  73653. /**
  73654. * Creates a rotation matrix and stores it in a given matrix
  73655. * @param yaw defines the yaw angle in radians (Y axis)
  73656. * @param pitch defines the pitch angle in radians (X axis)
  73657. * @param roll defines the roll angle in radians (X axis)
  73658. * @param result defines the target matrix
  73659. */
  73660. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  73661. /**
  73662. * Creates a scaling matrix
  73663. * @param x defines the scale factor on X axis
  73664. * @param y defines the scale factor on Y axis
  73665. * @param z defines the scale factor on Z axis
  73666. * @returns the new matrix
  73667. */
  73668. static Scaling(x: number, y: number, z: number): Matrix;
  73669. /**
  73670. * Creates a scaling matrix and stores it in a given matrix
  73671. * @param x defines the scale factor on X axis
  73672. * @param y defines the scale factor on Y axis
  73673. * @param z defines the scale factor on Z axis
  73674. * @param result defines the target matrix
  73675. */
  73676. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  73677. /**
  73678. * Creates a translation matrix
  73679. * @param x defines the translation on X axis
  73680. * @param y defines the translation on Y axis
  73681. * @param z defines the translationon Z axis
  73682. * @returns the new matrix
  73683. */
  73684. static Translation(x: number, y: number, z: number): Matrix;
  73685. /**
  73686. * Creates a translation matrix and stores it in a given matrix
  73687. * @param x defines the translation on X axis
  73688. * @param y defines the translation on Y axis
  73689. * @param z defines the translationon Z axis
  73690. * @param result defines the target matrix
  73691. */
  73692. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  73693. /**
  73694. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  73695. * @param startValue defines the start value
  73696. * @param endValue defines the end value
  73697. * @param gradient defines the gradient factor
  73698. * @returns the new matrix
  73699. */
  73700. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  73701. /**
  73702. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  73703. * @param startValue defines the start value
  73704. * @param endValue defines the end value
  73705. * @param gradient defines the gradient factor
  73706. * @param result defines the Matrix object where to store data
  73707. */
  73708. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  73709. /**
  73710. * Builds a new matrix whose values are computed by:
  73711. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  73712. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  73713. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  73714. * @param startValue defines the first matrix
  73715. * @param endValue defines the second matrix
  73716. * @param gradient defines the gradient between the two matrices
  73717. * @returns the new matrix
  73718. */
  73719. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  73720. /**
  73721. * Update a matrix to values which are computed by:
  73722. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  73723. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  73724. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  73725. * @param startValue defines the first matrix
  73726. * @param endValue defines the second matrix
  73727. * @param gradient defines the gradient between the two matrices
  73728. * @param result defines the target matrix
  73729. */
  73730. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  73731. /**
  73732. * 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"
  73733. * This function works in left handed mode
  73734. * @param eye defines the final position of the entity
  73735. * @param target defines where the entity should look at
  73736. * @param up defines the up vector for the entity
  73737. * @returns the new matrix
  73738. */
  73739. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  73740. /**
  73741. * 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".
  73742. * This function works in left handed mode
  73743. * @param eye defines the final position of the entity
  73744. * @param target defines where the entity should look at
  73745. * @param up defines the up vector for the entity
  73746. * @param result defines the target matrix
  73747. */
  73748. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  73749. /**
  73750. * 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"
  73751. * This function works in right handed mode
  73752. * @param eye defines the final position of the entity
  73753. * @param target defines where the entity should look at
  73754. * @param up defines the up vector for the entity
  73755. * @returns the new matrix
  73756. */
  73757. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  73758. /**
  73759. * 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".
  73760. * This function works in right handed mode
  73761. * @param eye defines the final position of the entity
  73762. * @param target defines where the entity should look at
  73763. * @param up defines the up vector for the entity
  73764. * @param result defines the target matrix
  73765. */
  73766. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  73767. /**
  73768. * Create a left-handed orthographic projection matrix
  73769. * @param width defines the viewport width
  73770. * @param height defines the viewport height
  73771. * @param znear defines the near clip plane
  73772. * @param zfar defines the far clip plane
  73773. * @returns a new matrix as a left-handed orthographic projection matrix
  73774. */
  73775. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  73776. /**
  73777. * Store a left-handed orthographic projection to a given matrix
  73778. * @param width defines the viewport width
  73779. * @param height defines the viewport height
  73780. * @param znear defines the near clip plane
  73781. * @param zfar defines the far clip plane
  73782. * @param result defines the target matrix
  73783. */
  73784. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  73785. /**
  73786. * Create a left-handed orthographic projection matrix
  73787. * @param left defines the viewport left coordinate
  73788. * @param right defines the viewport right coordinate
  73789. * @param bottom defines the viewport bottom coordinate
  73790. * @param top defines the viewport top coordinate
  73791. * @param znear defines the near clip plane
  73792. * @param zfar defines the far clip plane
  73793. * @returns a new matrix as a left-handed orthographic projection matrix
  73794. */
  73795. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  73796. /**
  73797. * Stores a left-handed orthographic projection into a given matrix
  73798. * @param left defines the viewport left coordinate
  73799. * @param right defines the viewport right coordinate
  73800. * @param bottom defines the viewport bottom coordinate
  73801. * @param top defines the viewport top coordinate
  73802. * @param znear defines the near clip plane
  73803. * @param zfar defines the far clip plane
  73804. * @param result defines the target matrix
  73805. */
  73806. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  73807. /**
  73808. * Creates a right-handed orthographic projection matrix
  73809. * @param left defines the viewport left coordinate
  73810. * @param right defines the viewport right coordinate
  73811. * @param bottom defines the viewport bottom coordinate
  73812. * @param top defines the viewport top coordinate
  73813. * @param znear defines the near clip plane
  73814. * @param zfar defines the far clip plane
  73815. * @returns a new matrix as a right-handed orthographic projection matrix
  73816. */
  73817. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  73818. /**
  73819. * Stores a right-handed orthographic projection into a given matrix
  73820. * @param left defines the viewport left coordinate
  73821. * @param right defines the viewport right coordinate
  73822. * @param bottom defines the viewport bottom coordinate
  73823. * @param top defines the viewport top coordinate
  73824. * @param znear defines the near clip plane
  73825. * @param zfar defines the far clip plane
  73826. * @param result defines the target matrix
  73827. */
  73828. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  73829. /**
  73830. * Creates a left-handed perspective projection matrix
  73831. * @param width defines the viewport width
  73832. * @param height defines the viewport height
  73833. * @param znear defines the near clip plane
  73834. * @param zfar defines the far clip plane
  73835. * @returns a new matrix as a left-handed perspective projection matrix
  73836. */
  73837. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  73838. /**
  73839. * Creates a left-handed perspective projection matrix
  73840. * @param fov defines the horizontal field of view
  73841. * @param aspect defines the aspect ratio
  73842. * @param znear defines the near clip plane
  73843. * @param zfar defines the far clip plane
  73844. * @returns a new matrix as a left-handed perspective projection matrix
  73845. */
  73846. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  73847. /**
  73848. * Stores a left-handed perspective projection into a given matrix
  73849. * @param fov defines the horizontal field of view
  73850. * @param aspect defines the aspect ratio
  73851. * @param znear defines the near clip plane
  73852. * @param zfar defines the far clip plane
  73853. * @param result defines the target matrix
  73854. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73855. */
  73856. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73857. /**
  73858. * Stores a left-handed perspective projection into a given matrix with depth reversed
  73859. * @param fov defines the horizontal field of view
  73860. * @param aspect defines the aspect ratio
  73861. * @param znear defines the near clip plane
  73862. * @param zfar not used as infinity is used as far clip
  73863. * @param result defines the target matrix
  73864. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73865. */
  73866. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73867. /**
  73868. * Creates a right-handed perspective projection matrix
  73869. * @param fov defines the horizontal field of view
  73870. * @param aspect defines the aspect ratio
  73871. * @param znear defines the near clip plane
  73872. * @param zfar defines the far clip plane
  73873. * @returns a new matrix as a right-handed perspective projection matrix
  73874. */
  73875. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  73876. /**
  73877. * Stores a right-handed perspective projection into a given matrix
  73878. * @param fov defines the horizontal field of view
  73879. * @param aspect defines the aspect ratio
  73880. * @param znear defines the near clip plane
  73881. * @param zfar defines the far clip plane
  73882. * @param result defines the target matrix
  73883. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73884. */
  73885. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73886. /**
  73887. * Stores a right-handed perspective projection into a given matrix
  73888. * @param fov defines the horizontal field of view
  73889. * @param aspect defines the aspect ratio
  73890. * @param znear defines the near clip plane
  73891. * @param zfar not used as infinity is used as far clip
  73892. * @param result defines the target matrix
  73893. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73894. */
  73895. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73896. /**
  73897. * Stores a perspective projection for WebVR info a given matrix
  73898. * @param fov defines the field of view
  73899. * @param znear defines the near clip plane
  73900. * @param zfar defines the far clip plane
  73901. * @param result defines the target matrix
  73902. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  73903. */
  73904. static PerspectiveFovWebVRToRef(fov: {
  73905. upDegrees: number;
  73906. downDegrees: number;
  73907. leftDegrees: number;
  73908. rightDegrees: number;
  73909. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  73910. /**
  73911. * Computes a complete transformation matrix
  73912. * @param viewport defines the viewport to use
  73913. * @param world defines the world matrix
  73914. * @param view defines the view matrix
  73915. * @param projection defines the projection matrix
  73916. * @param zmin defines the near clip plane
  73917. * @param zmax defines the far clip plane
  73918. * @returns the transformation matrix
  73919. */
  73920. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  73921. /**
  73922. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  73923. * @param matrix defines the matrix to use
  73924. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  73925. */
  73926. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  73927. /**
  73928. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  73929. * @param matrix defines the matrix to use
  73930. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  73931. */
  73932. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  73933. /**
  73934. * Compute the transpose of a given matrix
  73935. * @param matrix defines the matrix to transpose
  73936. * @returns the new matrix
  73937. */
  73938. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  73939. /**
  73940. * Compute the transpose of a matrix and store it in a target matrix
  73941. * @param matrix defines the matrix to transpose
  73942. * @param result defines the target matrix
  73943. */
  73944. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  73945. /**
  73946. * Computes a reflection matrix from a plane
  73947. * @param plane defines the reflection plane
  73948. * @returns a new matrix
  73949. */
  73950. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  73951. /**
  73952. * Computes a reflection matrix from a plane
  73953. * @param plane defines the reflection plane
  73954. * @param result defines the target matrix
  73955. */
  73956. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  73957. /**
  73958. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  73959. * @param xaxis defines the value of the 1st axis
  73960. * @param yaxis defines the value of the 2nd axis
  73961. * @param zaxis defines the value of the 3rd axis
  73962. * @param result defines the target matrix
  73963. */
  73964. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  73965. /**
  73966. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  73967. * @param quat defines the quaternion to use
  73968. * @param result defines the target matrix
  73969. */
  73970. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  73971. }
  73972. /**
  73973. * @hidden
  73974. */
  73975. export class TmpVectors {
  73976. static Vector2: Vector2[];
  73977. static Vector3: Vector3[];
  73978. static Vector4: Vector4[];
  73979. static Quaternion: Quaternion[];
  73980. static Matrix: Matrix[];
  73981. }
  73982. }
  73983. declare module BABYLON {
  73984. /**
  73985. * Defines potential orientation for back face culling
  73986. */
  73987. export enum Orientation {
  73988. /**
  73989. * Clockwise
  73990. */
  73991. CW = 0,
  73992. /** Counter clockwise */
  73993. CCW = 1
  73994. }
  73995. /** Class used to represent a Bezier curve */
  73996. export class BezierCurve {
  73997. /**
  73998. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  73999. * @param t defines the time
  74000. * @param x1 defines the left coordinate on X axis
  74001. * @param y1 defines the left coordinate on Y axis
  74002. * @param x2 defines the right coordinate on X axis
  74003. * @param y2 defines the right coordinate on Y axis
  74004. * @returns the interpolated value
  74005. */
  74006. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  74007. }
  74008. /**
  74009. * Defines angle representation
  74010. */
  74011. export class Angle {
  74012. private _radians;
  74013. /**
  74014. * Creates an Angle object of "radians" radians (float).
  74015. * @param radians the angle in radians
  74016. */
  74017. constructor(radians: number);
  74018. /**
  74019. * Get value in degrees
  74020. * @returns the Angle value in degrees (float)
  74021. */
  74022. degrees(): number;
  74023. /**
  74024. * Get value in radians
  74025. * @returns the Angle value in radians (float)
  74026. */
  74027. radians(): number;
  74028. /**
  74029. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  74030. * @param a defines first vector
  74031. * @param b defines second vector
  74032. * @returns a new Angle
  74033. */
  74034. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  74035. /**
  74036. * Gets a new Angle object from the given float in radians
  74037. * @param radians defines the angle value in radians
  74038. * @returns a new Angle
  74039. */
  74040. static FromRadians(radians: number): Angle;
  74041. /**
  74042. * Gets a new Angle object from the given float in degrees
  74043. * @param degrees defines the angle value in degrees
  74044. * @returns a new Angle
  74045. */
  74046. static FromDegrees(degrees: number): Angle;
  74047. }
  74048. /**
  74049. * This represents an arc in a 2d space.
  74050. */
  74051. export class Arc2 {
  74052. /** Defines the start point of the arc */
  74053. startPoint: Vector2;
  74054. /** Defines the mid point of the arc */
  74055. midPoint: Vector2;
  74056. /** Defines the end point of the arc */
  74057. endPoint: Vector2;
  74058. /**
  74059. * Defines the center point of the arc.
  74060. */
  74061. centerPoint: Vector2;
  74062. /**
  74063. * Defines the radius of the arc.
  74064. */
  74065. radius: number;
  74066. /**
  74067. * Defines the angle of the arc (from mid point to end point).
  74068. */
  74069. angle: Angle;
  74070. /**
  74071. * Defines the start angle of the arc (from start point to middle point).
  74072. */
  74073. startAngle: Angle;
  74074. /**
  74075. * Defines the orientation of the arc (clock wise/counter clock wise).
  74076. */
  74077. orientation: Orientation;
  74078. /**
  74079. * Creates an Arc object from the three given points : start, middle and end.
  74080. * @param startPoint Defines the start point of the arc
  74081. * @param midPoint Defines the midlle point of the arc
  74082. * @param endPoint Defines the end point of the arc
  74083. */
  74084. constructor(
  74085. /** Defines the start point of the arc */
  74086. startPoint: Vector2,
  74087. /** Defines the mid point of the arc */
  74088. midPoint: Vector2,
  74089. /** Defines the end point of the arc */
  74090. endPoint: Vector2);
  74091. }
  74092. /**
  74093. * Represents a 2D path made up of multiple 2D points
  74094. */
  74095. export class Path2 {
  74096. private _points;
  74097. private _length;
  74098. /**
  74099. * If the path start and end point are the same
  74100. */
  74101. closed: boolean;
  74102. /**
  74103. * Creates a Path2 object from the starting 2D coordinates x and y.
  74104. * @param x the starting points x value
  74105. * @param y the starting points y value
  74106. */
  74107. constructor(x: number, y: number);
  74108. /**
  74109. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  74110. * @param x the added points x value
  74111. * @param y the added points y value
  74112. * @returns the updated Path2.
  74113. */
  74114. addLineTo(x: number, y: number): Path2;
  74115. /**
  74116. * 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.
  74117. * @param midX middle point x value
  74118. * @param midY middle point y value
  74119. * @param endX end point x value
  74120. * @param endY end point y value
  74121. * @param numberOfSegments (default: 36)
  74122. * @returns the updated Path2.
  74123. */
  74124. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  74125. /**
  74126. * Closes the Path2.
  74127. * @returns the Path2.
  74128. */
  74129. close(): Path2;
  74130. /**
  74131. * Gets the sum of the distance between each sequential point in the path
  74132. * @returns the Path2 total length (float).
  74133. */
  74134. length(): number;
  74135. /**
  74136. * Gets the points which construct the path
  74137. * @returns the Path2 internal array of points.
  74138. */
  74139. getPoints(): Vector2[];
  74140. /**
  74141. * Retreives the point at the distance aways from the starting point
  74142. * @param normalizedLengthPosition the length along the path to retreive the point from
  74143. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  74144. */
  74145. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  74146. /**
  74147. * Creates a new path starting from an x and y position
  74148. * @param x starting x value
  74149. * @param y starting y value
  74150. * @returns a new Path2 starting at the coordinates (x, y).
  74151. */
  74152. static StartingAt(x: number, y: number): Path2;
  74153. }
  74154. /**
  74155. * Represents a 3D path made up of multiple 3D points
  74156. */
  74157. export class Path3D {
  74158. /**
  74159. * an array of Vector3, the curve axis of the Path3D
  74160. */
  74161. path: Vector3[];
  74162. private _curve;
  74163. private _distances;
  74164. private _tangents;
  74165. private _normals;
  74166. private _binormals;
  74167. private _raw;
  74168. private _alignTangentsWithPath;
  74169. private readonly _pointAtData;
  74170. /**
  74171. * new Path3D(path, normal, raw)
  74172. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  74173. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  74174. * @param path an array of Vector3, the curve axis of the Path3D
  74175. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  74176. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  74177. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  74178. */
  74179. constructor(
  74180. /**
  74181. * an array of Vector3, the curve axis of the Path3D
  74182. */
  74183. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  74184. /**
  74185. * Returns the Path3D array of successive Vector3 designing its curve.
  74186. * @returns the Path3D array of successive Vector3 designing its curve.
  74187. */
  74188. getCurve(): Vector3[];
  74189. /**
  74190. * Returns the Path3D array of successive Vector3 designing its curve.
  74191. * @returns the Path3D array of successive Vector3 designing its curve.
  74192. */
  74193. getPoints(): Vector3[];
  74194. /**
  74195. * @returns the computed length (float) of the path.
  74196. */
  74197. length(): number;
  74198. /**
  74199. * Returns an array populated with tangent vectors on each Path3D curve point.
  74200. * @returns an array populated with tangent vectors on each Path3D curve point.
  74201. */
  74202. getTangents(): Vector3[];
  74203. /**
  74204. * Returns an array populated with normal vectors on each Path3D curve point.
  74205. * @returns an array populated with normal vectors on each Path3D curve point.
  74206. */
  74207. getNormals(): Vector3[];
  74208. /**
  74209. * Returns an array populated with binormal vectors on each Path3D curve point.
  74210. * @returns an array populated with binormal vectors on each Path3D curve point.
  74211. */
  74212. getBinormals(): Vector3[];
  74213. /**
  74214. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  74215. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  74216. */
  74217. getDistances(): number[];
  74218. /**
  74219. * Returns an interpolated point along this path
  74220. * @param position the position of the point along this path, from 0.0 to 1.0
  74221. * @returns a new Vector3 as the point
  74222. */
  74223. getPointAt(position: number): Vector3;
  74224. /**
  74225. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  74226. * @param position the position of the point along this path, from 0.0 to 1.0
  74227. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  74228. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  74229. */
  74230. getTangentAt(position: number, interpolated?: boolean): Vector3;
  74231. /**
  74232. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  74233. * @param position the position of the point along this path, from 0.0 to 1.0
  74234. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  74235. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  74236. */
  74237. getNormalAt(position: number, interpolated?: boolean): Vector3;
  74238. /**
  74239. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  74240. * @param position the position of the point along this path, from 0.0 to 1.0
  74241. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  74242. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  74243. */
  74244. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  74245. /**
  74246. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  74247. * @param position the position of the point along this path, from 0.0 to 1.0
  74248. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  74249. */
  74250. getDistanceAt(position: number): number;
  74251. /**
  74252. * Returns the array index of the previous point of an interpolated point along this path
  74253. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  74254. * @returns the array index
  74255. */
  74256. getPreviousPointIndexAt(position: number): number;
  74257. /**
  74258. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  74259. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  74260. * @returns the sub position
  74261. */
  74262. getSubPositionAt(position: number): number;
  74263. /**
  74264. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  74265. * @param target the vector of which to get the closest position to
  74266. * @returns the position of the closest virtual point on this path to the target vector
  74267. */
  74268. getClosestPositionTo(target: Vector3): number;
  74269. /**
  74270. * Returns a sub path (slice) of this path
  74271. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  74272. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  74273. * @returns a sub path (slice) of this path
  74274. */
  74275. slice(start?: number, end?: number): Path3D;
  74276. /**
  74277. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  74278. * @param path path which all values are copied into the curves points
  74279. * @param firstNormal which should be projected onto the curve
  74280. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  74281. * @returns the same object updated.
  74282. */
  74283. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  74284. private _compute;
  74285. private _getFirstNonNullVector;
  74286. private _getLastNonNullVector;
  74287. private _normalVector;
  74288. /**
  74289. * Updates the point at data for an interpolated point along this curve
  74290. * @param position the position of the point along this curve, from 0.0 to 1.0
  74291. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  74292. * @returns the (updated) point at data
  74293. */
  74294. private _updatePointAtData;
  74295. /**
  74296. * Updates the point at data from the specified parameters
  74297. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  74298. * @param point the interpolated point
  74299. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  74300. */
  74301. private _setPointAtData;
  74302. /**
  74303. * Updates the point at interpolation matrix for the tangents, normals and binormals
  74304. */
  74305. private _updateInterpolationMatrix;
  74306. }
  74307. /**
  74308. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  74309. * A Curve3 is designed from a series of successive Vector3.
  74310. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  74311. */
  74312. export class Curve3 {
  74313. private _points;
  74314. private _length;
  74315. /**
  74316. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  74317. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  74318. * @param v1 (Vector3) the control point
  74319. * @param v2 (Vector3) the end point of the Quadratic Bezier
  74320. * @param nbPoints (integer) the wanted number of points in the curve
  74321. * @returns the created Curve3
  74322. */
  74323. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  74324. /**
  74325. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  74326. * @param v0 (Vector3) the origin point of the Cubic Bezier
  74327. * @param v1 (Vector3) the first control point
  74328. * @param v2 (Vector3) the second control point
  74329. * @param v3 (Vector3) the end point of the Cubic Bezier
  74330. * @param nbPoints (integer) the wanted number of points in the curve
  74331. * @returns the created Curve3
  74332. */
  74333. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  74334. /**
  74335. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  74336. * @param p1 (Vector3) the origin point of the Hermite Spline
  74337. * @param t1 (Vector3) the tangent vector at the origin point
  74338. * @param p2 (Vector3) the end point of the Hermite Spline
  74339. * @param t2 (Vector3) the tangent vector at the end point
  74340. * @param nbPoints (integer) the wanted number of points in the curve
  74341. * @returns the created Curve3
  74342. */
  74343. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  74344. /**
  74345. * Returns a Curve3 object along a CatmullRom Spline curve :
  74346. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  74347. * @param nbPoints (integer) the wanted number of points between each curve control points
  74348. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  74349. * @returns the created Curve3
  74350. */
  74351. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  74352. /**
  74353. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  74354. * A Curve3 is designed from a series of successive Vector3.
  74355. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  74356. * @param points points which make up the curve
  74357. */
  74358. constructor(points: Vector3[]);
  74359. /**
  74360. * @returns the Curve3 stored array of successive Vector3
  74361. */
  74362. getPoints(): Vector3[];
  74363. /**
  74364. * @returns the computed length (float) of the curve.
  74365. */
  74366. length(): number;
  74367. /**
  74368. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  74369. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  74370. * curveA and curveB keep unchanged.
  74371. * @param curve the curve to continue from this curve
  74372. * @returns the newly constructed curve
  74373. */
  74374. continue(curve: DeepImmutable<Curve3>): Curve3;
  74375. private _computeLength;
  74376. }
  74377. }
  74378. declare module BABYLON {
  74379. /**
  74380. * This represents the main contract an easing function should follow.
  74381. * Easing functions are used throughout the animation system.
  74382. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74383. */
  74384. export interface IEasingFunction {
  74385. /**
  74386. * Given an input gradient between 0 and 1, this returns the corrseponding value
  74387. * of the easing function.
  74388. * The link below provides some of the most common examples of easing functions.
  74389. * @see https://easings.net/
  74390. * @param gradient Defines the value between 0 and 1 we want the easing value for
  74391. * @returns the corresponding value on the curve defined by the easing function
  74392. */
  74393. ease(gradient: number): number;
  74394. }
  74395. /**
  74396. * Base class used for every default easing function.
  74397. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74398. */
  74399. export class EasingFunction implements IEasingFunction {
  74400. /**
  74401. * Interpolation follows the mathematical formula associated with the easing function.
  74402. */
  74403. static readonly EASINGMODE_EASEIN: number;
  74404. /**
  74405. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  74406. */
  74407. static readonly EASINGMODE_EASEOUT: number;
  74408. /**
  74409. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  74410. */
  74411. static readonly EASINGMODE_EASEINOUT: number;
  74412. private _easingMode;
  74413. /**
  74414. * Sets the easing mode of the current function.
  74415. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  74416. */
  74417. setEasingMode(easingMode: number): void;
  74418. /**
  74419. * Gets the current easing mode.
  74420. * @returns the easing mode
  74421. */
  74422. getEasingMode(): number;
  74423. /**
  74424. * @hidden
  74425. */
  74426. easeInCore(gradient: number): number;
  74427. /**
  74428. * Given an input gradient between 0 and 1, this returns the corresponding value
  74429. * of the easing function.
  74430. * @param gradient Defines the value between 0 and 1 we want the easing value for
  74431. * @returns the corresponding value on the curve defined by the easing function
  74432. */
  74433. ease(gradient: number): number;
  74434. }
  74435. /**
  74436. * Easing function with a circle shape (see link below).
  74437. * @see https://easings.net/#easeInCirc
  74438. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74439. */
  74440. export class CircleEase extends EasingFunction implements IEasingFunction {
  74441. /** @hidden */
  74442. easeInCore(gradient: number): number;
  74443. }
  74444. /**
  74445. * Easing function with a ease back shape (see link below).
  74446. * @see https://easings.net/#easeInBack
  74447. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74448. */
  74449. export class BackEase extends EasingFunction implements IEasingFunction {
  74450. /** Defines the amplitude of the function */
  74451. amplitude: number;
  74452. /**
  74453. * Instantiates a back ease easing
  74454. * @see https://easings.net/#easeInBack
  74455. * @param amplitude Defines the amplitude of the function
  74456. */
  74457. constructor(
  74458. /** Defines the amplitude of the function */
  74459. amplitude?: number);
  74460. /** @hidden */
  74461. easeInCore(gradient: number): number;
  74462. }
  74463. /**
  74464. * Easing function with a bouncing shape (see link below).
  74465. * @see https://easings.net/#easeInBounce
  74466. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74467. */
  74468. export class BounceEase extends EasingFunction implements IEasingFunction {
  74469. /** Defines the number of bounces */
  74470. bounces: number;
  74471. /** Defines the amplitude of the bounce */
  74472. bounciness: number;
  74473. /**
  74474. * Instantiates a bounce easing
  74475. * @see https://easings.net/#easeInBounce
  74476. * @param bounces Defines the number of bounces
  74477. * @param bounciness Defines the amplitude of the bounce
  74478. */
  74479. constructor(
  74480. /** Defines the number of bounces */
  74481. bounces?: number,
  74482. /** Defines the amplitude of the bounce */
  74483. bounciness?: number);
  74484. /** @hidden */
  74485. easeInCore(gradient: number): number;
  74486. }
  74487. /**
  74488. * Easing function with a power of 3 shape (see link below).
  74489. * @see https://easings.net/#easeInCubic
  74490. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74491. */
  74492. export class CubicEase extends EasingFunction implements IEasingFunction {
  74493. /** @hidden */
  74494. easeInCore(gradient: number): number;
  74495. }
  74496. /**
  74497. * Easing function with an elastic shape (see link below).
  74498. * @see https://easings.net/#easeInElastic
  74499. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74500. */
  74501. export class ElasticEase extends EasingFunction implements IEasingFunction {
  74502. /** Defines the number of oscillations*/
  74503. oscillations: number;
  74504. /** Defines the amplitude of the oscillations*/
  74505. springiness: number;
  74506. /**
  74507. * Instantiates an elastic easing function
  74508. * @see https://easings.net/#easeInElastic
  74509. * @param oscillations Defines the number of oscillations
  74510. * @param springiness Defines the amplitude of the oscillations
  74511. */
  74512. constructor(
  74513. /** Defines the number of oscillations*/
  74514. oscillations?: number,
  74515. /** Defines the amplitude of the oscillations*/
  74516. springiness?: number);
  74517. /** @hidden */
  74518. easeInCore(gradient: number): number;
  74519. }
  74520. /**
  74521. * Easing function with an exponential shape (see link below).
  74522. * @see https://easings.net/#easeInExpo
  74523. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74524. */
  74525. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  74526. /** Defines the exponent of the function */
  74527. exponent: number;
  74528. /**
  74529. * Instantiates an exponential easing function
  74530. * @see https://easings.net/#easeInExpo
  74531. * @param exponent Defines the exponent of the function
  74532. */
  74533. constructor(
  74534. /** Defines the exponent of the function */
  74535. exponent?: number);
  74536. /** @hidden */
  74537. easeInCore(gradient: number): number;
  74538. }
  74539. /**
  74540. * Easing function with a power shape (see link below).
  74541. * @see https://easings.net/#easeInQuad
  74542. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74543. */
  74544. export class PowerEase extends EasingFunction implements IEasingFunction {
  74545. /** Defines the power of the function */
  74546. power: number;
  74547. /**
  74548. * Instantiates an power base easing function
  74549. * @see https://easings.net/#easeInQuad
  74550. * @param power Defines the power of the function
  74551. */
  74552. constructor(
  74553. /** Defines the power of the function */
  74554. power?: number);
  74555. /** @hidden */
  74556. easeInCore(gradient: number): number;
  74557. }
  74558. /**
  74559. * Easing function with a power of 2 shape (see link below).
  74560. * @see https://easings.net/#easeInQuad
  74561. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74562. */
  74563. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  74564. /** @hidden */
  74565. easeInCore(gradient: number): number;
  74566. }
  74567. /**
  74568. * Easing function with a power of 4 shape (see link below).
  74569. * @see https://easings.net/#easeInQuart
  74570. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74571. */
  74572. export class QuarticEase extends EasingFunction implements IEasingFunction {
  74573. /** @hidden */
  74574. easeInCore(gradient: number): number;
  74575. }
  74576. /**
  74577. * Easing function with a power of 5 shape (see link below).
  74578. * @see https://easings.net/#easeInQuint
  74579. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74580. */
  74581. export class QuinticEase extends EasingFunction implements IEasingFunction {
  74582. /** @hidden */
  74583. easeInCore(gradient: number): number;
  74584. }
  74585. /**
  74586. * Easing function with a sin shape (see link below).
  74587. * @see https://easings.net/#easeInSine
  74588. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74589. */
  74590. export class SineEase extends EasingFunction implements IEasingFunction {
  74591. /** @hidden */
  74592. easeInCore(gradient: number): number;
  74593. }
  74594. /**
  74595. * Easing function with a bezier shape (see link below).
  74596. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  74597. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74598. */
  74599. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  74600. /** Defines the x component of the start tangent in the bezier curve */
  74601. x1: number;
  74602. /** Defines the y component of the start tangent in the bezier curve */
  74603. y1: number;
  74604. /** Defines the x component of the end tangent in the bezier curve */
  74605. x2: number;
  74606. /** Defines the y component of the end tangent in the bezier curve */
  74607. y2: number;
  74608. /**
  74609. * Instantiates a bezier function
  74610. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  74611. * @param x1 Defines the x component of the start tangent in the bezier curve
  74612. * @param y1 Defines the y component of the start tangent in the bezier curve
  74613. * @param x2 Defines the x component of the end tangent in the bezier curve
  74614. * @param y2 Defines the y component of the end tangent in the bezier curve
  74615. */
  74616. constructor(
  74617. /** Defines the x component of the start tangent in the bezier curve */
  74618. x1?: number,
  74619. /** Defines the y component of the start tangent in the bezier curve */
  74620. y1?: number,
  74621. /** Defines the x component of the end tangent in the bezier curve */
  74622. x2?: number,
  74623. /** Defines the y component of the end tangent in the bezier curve */
  74624. y2?: number);
  74625. /** @hidden */
  74626. easeInCore(gradient: number): number;
  74627. }
  74628. }
  74629. declare module BABYLON {
  74630. /**
  74631. * Class used to hold a RBG color
  74632. */
  74633. export class Color3 {
  74634. /**
  74635. * Defines the red component (between 0 and 1, default is 0)
  74636. */
  74637. r: number;
  74638. /**
  74639. * Defines the green component (between 0 and 1, default is 0)
  74640. */
  74641. g: number;
  74642. /**
  74643. * Defines the blue component (between 0 and 1, default is 0)
  74644. */
  74645. b: number;
  74646. /**
  74647. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  74648. * @param r defines the red component (between 0 and 1, default is 0)
  74649. * @param g defines the green component (between 0 and 1, default is 0)
  74650. * @param b defines the blue component (between 0 and 1, default is 0)
  74651. */
  74652. constructor(
  74653. /**
  74654. * Defines the red component (between 0 and 1, default is 0)
  74655. */
  74656. r?: number,
  74657. /**
  74658. * Defines the green component (between 0 and 1, default is 0)
  74659. */
  74660. g?: number,
  74661. /**
  74662. * Defines the blue component (between 0 and 1, default is 0)
  74663. */
  74664. b?: number);
  74665. /**
  74666. * Creates a string with the Color3 current values
  74667. * @returns the string representation of the Color3 object
  74668. */
  74669. toString(): string;
  74670. /**
  74671. * Returns the string "Color3"
  74672. * @returns "Color3"
  74673. */
  74674. getClassName(): string;
  74675. /**
  74676. * Compute the Color3 hash code
  74677. * @returns an unique number that can be used to hash Color3 objects
  74678. */
  74679. getHashCode(): number;
  74680. /**
  74681. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  74682. * @param array defines the array where to store the r,g,b components
  74683. * @param index defines an optional index in the target array to define where to start storing values
  74684. * @returns the current Color3 object
  74685. */
  74686. toArray(array: FloatArray, index?: number): Color3;
  74687. /**
  74688. * Returns a new Color4 object from the current Color3 and the given alpha
  74689. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  74690. * @returns a new Color4 object
  74691. */
  74692. toColor4(alpha?: number): Color4;
  74693. /**
  74694. * Returns a new array populated with 3 numeric elements : red, green and blue values
  74695. * @returns the new array
  74696. */
  74697. asArray(): number[];
  74698. /**
  74699. * Returns the luminance value
  74700. * @returns a float value
  74701. */
  74702. toLuminance(): number;
  74703. /**
  74704. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  74705. * @param otherColor defines the second operand
  74706. * @returns the new Color3 object
  74707. */
  74708. multiply(otherColor: DeepImmutable<Color3>): Color3;
  74709. /**
  74710. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  74711. * @param otherColor defines the second operand
  74712. * @param result defines the Color3 object where to store the result
  74713. * @returns the current Color3
  74714. */
  74715. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74716. /**
  74717. * Determines equality between Color3 objects
  74718. * @param otherColor defines the second operand
  74719. * @returns true if the rgb values are equal to the given ones
  74720. */
  74721. equals(otherColor: DeepImmutable<Color3>): boolean;
  74722. /**
  74723. * Determines equality between the current Color3 object and a set of r,b,g values
  74724. * @param r defines the red component to check
  74725. * @param g defines the green component to check
  74726. * @param b defines the blue component to check
  74727. * @returns true if the rgb values are equal to the given ones
  74728. */
  74729. equalsFloats(r: number, g: number, b: number): boolean;
  74730. /**
  74731. * Multiplies in place each rgb value by scale
  74732. * @param scale defines the scaling factor
  74733. * @returns the updated Color3
  74734. */
  74735. scale(scale: number): Color3;
  74736. /**
  74737. * Multiplies the rgb values by scale and stores the result into "result"
  74738. * @param scale defines the scaling factor
  74739. * @param result defines the Color3 object where to store the result
  74740. * @returns the unmodified current Color3
  74741. */
  74742. scaleToRef(scale: number, result: Color3): Color3;
  74743. /**
  74744. * Scale the current Color3 values by a factor and add the result to a given Color3
  74745. * @param scale defines the scale factor
  74746. * @param result defines color to store the result into
  74747. * @returns the unmodified current Color3
  74748. */
  74749. scaleAndAddToRef(scale: number, result: Color3): Color3;
  74750. /**
  74751. * Clamps the rgb values by the min and max values and stores the result into "result"
  74752. * @param min defines minimum clamping value (default is 0)
  74753. * @param max defines maximum clamping value (default is 1)
  74754. * @param result defines color to store the result into
  74755. * @returns the original Color3
  74756. */
  74757. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  74758. /**
  74759. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  74760. * @param otherColor defines the second operand
  74761. * @returns the new Color3
  74762. */
  74763. add(otherColor: DeepImmutable<Color3>): Color3;
  74764. /**
  74765. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  74766. * @param otherColor defines the second operand
  74767. * @param result defines Color3 object to store the result into
  74768. * @returns the unmodified current Color3
  74769. */
  74770. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74771. /**
  74772. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  74773. * @param otherColor defines the second operand
  74774. * @returns the new Color3
  74775. */
  74776. subtract(otherColor: DeepImmutable<Color3>): Color3;
  74777. /**
  74778. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  74779. * @param otherColor defines the second operand
  74780. * @param result defines Color3 object to store the result into
  74781. * @returns the unmodified current Color3
  74782. */
  74783. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74784. /**
  74785. * Copy the current object
  74786. * @returns a new Color3 copied the current one
  74787. */
  74788. clone(): Color3;
  74789. /**
  74790. * Copies the rgb values from the source in the current Color3
  74791. * @param source defines the source Color3 object
  74792. * @returns the updated Color3 object
  74793. */
  74794. copyFrom(source: DeepImmutable<Color3>): Color3;
  74795. /**
  74796. * Updates the Color3 rgb values from the given floats
  74797. * @param r defines the red component to read from
  74798. * @param g defines the green component to read from
  74799. * @param b defines the blue component to read from
  74800. * @returns the current Color3 object
  74801. */
  74802. copyFromFloats(r: number, g: number, b: number): Color3;
  74803. /**
  74804. * Updates the Color3 rgb values from the given floats
  74805. * @param r defines the red component to read from
  74806. * @param g defines the green component to read from
  74807. * @param b defines the blue component to read from
  74808. * @returns the current Color3 object
  74809. */
  74810. set(r: number, g: number, b: number): Color3;
  74811. /**
  74812. * Compute the Color3 hexadecimal code as a string
  74813. * @returns a string containing the hexadecimal representation of the Color3 object
  74814. */
  74815. toHexString(): string;
  74816. /**
  74817. * Computes a new Color3 converted from the current one to linear space
  74818. * @returns a new Color3 object
  74819. */
  74820. toLinearSpace(): Color3;
  74821. /**
  74822. * Converts current color in rgb space to HSV values
  74823. * @returns a new color3 representing the HSV values
  74824. */
  74825. toHSV(): Color3;
  74826. /**
  74827. * Converts current color in rgb space to HSV values
  74828. * @param result defines the Color3 where to store the HSV values
  74829. */
  74830. toHSVToRef(result: Color3): void;
  74831. /**
  74832. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  74833. * @param convertedColor defines the Color3 object where to store the linear space version
  74834. * @returns the unmodified Color3
  74835. */
  74836. toLinearSpaceToRef(convertedColor: Color3): Color3;
  74837. /**
  74838. * Computes a new Color3 converted from the current one to gamma space
  74839. * @returns a new Color3 object
  74840. */
  74841. toGammaSpace(): Color3;
  74842. /**
  74843. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  74844. * @param convertedColor defines the Color3 object where to store the gamma space version
  74845. * @returns the unmodified Color3
  74846. */
  74847. toGammaSpaceToRef(convertedColor: Color3): Color3;
  74848. private static _BlackReadOnly;
  74849. /**
  74850. * Convert Hue, saturation and value to a Color3 (RGB)
  74851. * @param hue defines the hue
  74852. * @param saturation defines the saturation
  74853. * @param value defines the value
  74854. * @param result defines the Color3 where to store the RGB values
  74855. */
  74856. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  74857. /**
  74858. * Creates a new Color3 from the string containing valid hexadecimal values
  74859. * @param hex defines a string containing valid hexadecimal values
  74860. * @returns a new Color3 object
  74861. */
  74862. static FromHexString(hex: string): Color3;
  74863. /**
  74864. * Creates a new Color3 from the starting index of the given array
  74865. * @param array defines the source array
  74866. * @param offset defines an offset in the source array
  74867. * @returns a new Color3 object
  74868. */
  74869. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  74870. /**
  74871. * Creates a new Color3 from integer values (< 256)
  74872. * @param r defines the red component to read from (value between 0 and 255)
  74873. * @param g defines the green component to read from (value between 0 and 255)
  74874. * @param b defines the blue component to read from (value between 0 and 255)
  74875. * @returns a new Color3 object
  74876. */
  74877. static FromInts(r: number, g: number, b: number): Color3;
  74878. /**
  74879. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  74880. * @param start defines the start Color3 value
  74881. * @param end defines the end Color3 value
  74882. * @param amount defines the gradient value between start and end
  74883. * @returns a new Color3 object
  74884. */
  74885. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  74886. /**
  74887. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  74888. * @param left defines the start value
  74889. * @param right defines the end value
  74890. * @param amount defines the gradient factor
  74891. * @param result defines the Color3 object where to store the result
  74892. */
  74893. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  74894. /**
  74895. * Returns a Color3 value containing a red color
  74896. * @returns a new Color3 object
  74897. */
  74898. static Red(): Color3;
  74899. /**
  74900. * Returns a Color3 value containing a green color
  74901. * @returns a new Color3 object
  74902. */
  74903. static Green(): Color3;
  74904. /**
  74905. * Returns a Color3 value containing a blue color
  74906. * @returns a new Color3 object
  74907. */
  74908. static Blue(): Color3;
  74909. /**
  74910. * Returns a Color3 value containing a black color
  74911. * @returns a new Color3 object
  74912. */
  74913. static Black(): Color3;
  74914. /**
  74915. * Gets a Color3 value containing a black color that must not be updated
  74916. */
  74917. static readonly BlackReadOnly: DeepImmutable<Color3>;
  74918. /**
  74919. * Returns a Color3 value containing a white color
  74920. * @returns a new Color3 object
  74921. */
  74922. static White(): Color3;
  74923. /**
  74924. * Returns a Color3 value containing a purple color
  74925. * @returns a new Color3 object
  74926. */
  74927. static Purple(): Color3;
  74928. /**
  74929. * Returns a Color3 value containing a magenta color
  74930. * @returns a new Color3 object
  74931. */
  74932. static Magenta(): Color3;
  74933. /**
  74934. * Returns a Color3 value containing a yellow color
  74935. * @returns a new Color3 object
  74936. */
  74937. static Yellow(): Color3;
  74938. /**
  74939. * Returns a Color3 value containing a gray color
  74940. * @returns a new Color3 object
  74941. */
  74942. static Gray(): Color3;
  74943. /**
  74944. * Returns a Color3 value containing a teal color
  74945. * @returns a new Color3 object
  74946. */
  74947. static Teal(): Color3;
  74948. /**
  74949. * Returns a Color3 value containing a random color
  74950. * @returns a new Color3 object
  74951. */
  74952. static Random(): Color3;
  74953. }
  74954. /**
  74955. * Class used to hold a RBGA color
  74956. */
  74957. export class Color4 {
  74958. /**
  74959. * Defines the red component (between 0 and 1, default is 0)
  74960. */
  74961. r: number;
  74962. /**
  74963. * Defines the green component (between 0 and 1, default is 0)
  74964. */
  74965. g: number;
  74966. /**
  74967. * Defines the blue component (between 0 and 1, default is 0)
  74968. */
  74969. b: number;
  74970. /**
  74971. * Defines the alpha component (between 0 and 1, default is 1)
  74972. */
  74973. a: number;
  74974. /**
  74975. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  74976. * @param r defines the red component (between 0 and 1, default is 0)
  74977. * @param g defines the green component (between 0 and 1, default is 0)
  74978. * @param b defines the blue component (between 0 and 1, default is 0)
  74979. * @param a defines the alpha component (between 0 and 1, default is 1)
  74980. */
  74981. constructor(
  74982. /**
  74983. * Defines the red component (between 0 and 1, default is 0)
  74984. */
  74985. r?: number,
  74986. /**
  74987. * Defines the green component (between 0 and 1, default is 0)
  74988. */
  74989. g?: number,
  74990. /**
  74991. * Defines the blue component (between 0 and 1, default is 0)
  74992. */
  74993. b?: number,
  74994. /**
  74995. * Defines the alpha component (between 0 and 1, default is 1)
  74996. */
  74997. a?: number);
  74998. /**
  74999. * Adds in place the given Color4 values to the current Color4 object
  75000. * @param right defines the second operand
  75001. * @returns the current updated Color4 object
  75002. */
  75003. addInPlace(right: DeepImmutable<Color4>): Color4;
  75004. /**
  75005. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  75006. * @returns the new array
  75007. */
  75008. asArray(): number[];
  75009. /**
  75010. * Stores from the starting index in the given array the Color4 successive values
  75011. * @param array defines the array where to store the r,g,b components
  75012. * @param index defines an optional index in the target array to define where to start storing values
  75013. * @returns the current Color4 object
  75014. */
  75015. toArray(array: number[], index?: number): Color4;
  75016. /**
  75017. * Determines equality between Color4 objects
  75018. * @param otherColor defines the second operand
  75019. * @returns true if the rgba values are equal to the given ones
  75020. */
  75021. equals(otherColor: DeepImmutable<Color4>): boolean;
  75022. /**
  75023. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  75024. * @param right defines the second operand
  75025. * @returns a new Color4 object
  75026. */
  75027. add(right: DeepImmutable<Color4>): Color4;
  75028. /**
  75029. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  75030. * @param right defines the second operand
  75031. * @returns a new Color4 object
  75032. */
  75033. subtract(right: DeepImmutable<Color4>): Color4;
  75034. /**
  75035. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  75036. * @param right defines the second operand
  75037. * @param result defines the Color4 object where to store the result
  75038. * @returns the current Color4 object
  75039. */
  75040. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  75041. /**
  75042. * Creates a new Color4 with the current Color4 values multiplied by scale
  75043. * @param scale defines the scaling factor to apply
  75044. * @returns a new Color4 object
  75045. */
  75046. scale(scale: number): Color4;
  75047. /**
  75048. * Multiplies the current Color4 values by scale and stores the result in "result"
  75049. * @param scale defines the scaling factor to apply
  75050. * @param result defines the Color4 object where to store the result
  75051. * @returns the current unmodified Color4
  75052. */
  75053. scaleToRef(scale: number, result: Color4): Color4;
  75054. /**
  75055. * Scale the current Color4 values by a factor and add the result to a given Color4
  75056. * @param scale defines the scale factor
  75057. * @param result defines the Color4 object where to store the result
  75058. * @returns the unmodified current Color4
  75059. */
  75060. scaleAndAddToRef(scale: number, result: Color4): Color4;
  75061. /**
  75062. * Clamps the rgb values by the min and max values and stores the result into "result"
  75063. * @param min defines minimum clamping value (default is 0)
  75064. * @param max defines maximum clamping value (default is 1)
  75065. * @param result defines color to store the result into.
  75066. * @returns the cuurent Color4
  75067. */
  75068. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  75069. /**
  75070. * Multipy an Color4 value by another and return a new Color4 object
  75071. * @param color defines the Color4 value to multiply by
  75072. * @returns a new Color4 object
  75073. */
  75074. multiply(color: Color4): Color4;
  75075. /**
  75076. * Multipy a Color4 value by another and push the result in a reference value
  75077. * @param color defines the Color4 value to multiply by
  75078. * @param result defines the Color4 to fill the result in
  75079. * @returns the result Color4
  75080. */
  75081. multiplyToRef(color: Color4, result: Color4): Color4;
  75082. /**
  75083. * Creates a string with the Color4 current values
  75084. * @returns the string representation of the Color4 object
  75085. */
  75086. toString(): string;
  75087. /**
  75088. * Returns the string "Color4"
  75089. * @returns "Color4"
  75090. */
  75091. getClassName(): string;
  75092. /**
  75093. * Compute the Color4 hash code
  75094. * @returns an unique number that can be used to hash Color4 objects
  75095. */
  75096. getHashCode(): number;
  75097. /**
  75098. * Creates a new Color4 copied from the current one
  75099. * @returns a new Color4 object
  75100. */
  75101. clone(): Color4;
  75102. /**
  75103. * Copies the given Color4 values into the current one
  75104. * @param source defines the source Color4 object
  75105. * @returns the current updated Color4 object
  75106. */
  75107. copyFrom(source: Color4): Color4;
  75108. /**
  75109. * Copies the given float values into the current one
  75110. * @param r defines the red component to read from
  75111. * @param g defines the green component to read from
  75112. * @param b defines the blue component to read from
  75113. * @param a defines the alpha component to read from
  75114. * @returns the current updated Color4 object
  75115. */
  75116. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  75117. /**
  75118. * Copies the given float values into the current one
  75119. * @param r defines the red component to read from
  75120. * @param g defines the green component to read from
  75121. * @param b defines the blue component to read from
  75122. * @param a defines the alpha component to read from
  75123. * @returns the current updated Color4 object
  75124. */
  75125. set(r: number, g: number, b: number, a: number): Color4;
  75126. /**
  75127. * Compute the Color4 hexadecimal code as a string
  75128. * @returns a string containing the hexadecimal representation of the Color4 object
  75129. */
  75130. toHexString(): string;
  75131. /**
  75132. * Computes a new Color4 converted from the current one to linear space
  75133. * @returns a new Color4 object
  75134. */
  75135. toLinearSpace(): Color4;
  75136. /**
  75137. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  75138. * @param convertedColor defines the Color4 object where to store the linear space version
  75139. * @returns the unmodified Color4
  75140. */
  75141. toLinearSpaceToRef(convertedColor: Color4): Color4;
  75142. /**
  75143. * Computes a new Color4 converted from the current one to gamma space
  75144. * @returns a new Color4 object
  75145. */
  75146. toGammaSpace(): Color4;
  75147. /**
  75148. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  75149. * @param convertedColor defines the Color4 object where to store the gamma space version
  75150. * @returns the unmodified Color4
  75151. */
  75152. toGammaSpaceToRef(convertedColor: Color4): Color4;
  75153. /**
  75154. * Creates a new Color4 from the string containing valid hexadecimal values
  75155. * @param hex defines a string containing valid hexadecimal values
  75156. * @returns a new Color4 object
  75157. */
  75158. static FromHexString(hex: string): Color4;
  75159. /**
  75160. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  75161. * @param left defines the start value
  75162. * @param right defines the end value
  75163. * @param amount defines the gradient factor
  75164. * @returns a new Color4 object
  75165. */
  75166. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  75167. /**
  75168. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  75169. * @param left defines the start value
  75170. * @param right defines the end value
  75171. * @param amount defines the gradient factor
  75172. * @param result defines the Color4 object where to store data
  75173. */
  75174. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  75175. /**
  75176. * Creates a new Color4 from a Color3 and an alpha value
  75177. * @param color3 defines the source Color3 to read from
  75178. * @param alpha defines the alpha component (1.0 by default)
  75179. * @returns a new Color4 object
  75180. */
  75181. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  75182. /**
  75183. * Creates a new Color4 from the starting index element of the given array
  75184. * @param array defines the source array to read from
  75185. * @param offset defines the offset in the source array
  75186. * @returns a new Color4 object
  75187. */
  75188. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  75189. /**
  75190. * Creates a new Color3 from integer values (< 256)
  75191. * @param r defines the red component to read from (value between 0 and 255)
  75192. * @param g defines the green component to read from (value between 0 and 255)
  75193. * @param b defines the blue component to read from (value between 0 and 255)
  75194. * @param a defines the alpha component to read from (value between 0 and 255)
  75195. * @returns a new Color3 object
  75196. */
  75197. static FromInts(r: number, g: number, b: number, a: number): Color4;
  75198. /**
  75199. * Check the content of a given array and convert it to an array containing RGBA data
  75200. * If the original array was already containing count * 4 values then it is returned directly
  75201. * @param colors defines the array to check
  75202. * @param count defines the number of RGBA data to expect
  75203. * @returns an array containing count * 4 values (RGBA)
  75204. */
  75205. static CheckColors4(colors: number[], count: number): number[];
  75206. }
  75207. /**
  75208. * @hidden
  75209. */
  75210. export class TmpColors {
  75211. static Color3: Color3[];
  75212. static Color4: Color4[];
  75213. }
  75214. }
  75215. declare module BABYLON {
  75216. /**
  75217. * Defines an interface which represents an animation key frame
  75218. */
  75219. export interface IAnimationKey {
  75220. /**
  75221. * Frame of the key frame
  75222. */
  75223. frame: number;
  75224. /**
  75225. * Value at the specifies key frame
  75226. */
  75227. value: any;
  75228. /**
  75229. * The input tangent for the cubic hermite spline
  75230. */
  75231. inTangent?: any;
  75232. /**
  75233. * The output tangent for the cubic hermite spline
  75234. */
  75235. outTangent?: any;
  75236. /**
  75237. * The animation interpolation type
  75238. */
  75239. interpolation?: AnimationKeyInterpolation;
  75240. }
  75241. /**
  75242. * Enum for the animation key frame interpolation type
  75243. */
  75244. export enum AnimationKeyInterpolation {
  75245. /**
  75246. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  75247. */
  75248. STEP = 1
  75249. }
  75250. }
  75251. declare module BABYLON {
  75252. /**
  75253. * Represents the range of an animation
  75254. */
  75255. export class AnimationRange {
  75256. /**The name of the animation range**/
  75257. name: string;
  75258. /**The starting frame of the animation */
  75259. from: number;
  75260. /**The ending frame of the animation*/
  75261. to: number;
  75262. /**
  75263. * Initializes the range of an animation
  75264. * @param name The name of the animation range
  75265. * @param from The starting frame of the animation
  75266. * @param to The ending frame of the animation
  75267. */
  75268. constructor(
  75269. /**The name of the animation range**/
  75270. name: string,
  75271. /**The starting frame of the animation */
  75272. from: number,
  75273. /**The ending frame of the animation*/
  75274. to: number);
  75275. /**
  75276. * Makes a copy of the animation range
  75277. * @returns A copy of the animation range
  75278. */
  75279. clone(): AnimationRange;
  75280. }
  75281. }
  75282. declare module BABYLON {
  75283. /**
  75284. * Composed of a frame, and an action function
  75285. */
  75286. export class AnimationEvent {
  75287. /** The frame for which the event is triggered **/
  75288. frame: number;
  75289. /** The event to perform when triggered **/
  75290. action: (currentFrame: number) => void;
  75291. /** Specifies if the event should be triggered only once**/
  75292. onlyOnce?: boolean | undefined;
  75293. /**
  75294. * Specifies if the animation event is done
  75295. */
  75296. isDone: boolean;
  75297. /**
  75298. * Initializes the animation event
  75299. * @param frame The frame for which the event is triggered
  75300. * @param action The event to perform when triggered
  75301. * @param onlyOnce Specifies if the event should be triggered only once
  75302. */
  75303. constructor(
  75304. /** The frame for which the event is triggered **/
  75305. frame: number,
  75306. /** The event to perform when triggered **/
  75307. action: (currentFrame: number) => void,
  75308. /** Specifies if the event should be triggered only once**/
  75309. onlyOnce?: boolean | undefined);
  75310. /** @hidden */
  75311. _clone(): AnimationEvent;
  75312. }
  75313. }
  75314. declare module BABYLON {
  75315. /**
  75316. * Interface used to define a behavior
  75317. */
  75318. export interface Behavior<T> {
  75319. /** gets or sets behavior's name */
  75320. name: string;
  75321. /**
  75322. * Function called when the behavior needs to be initialized (after attaching it to a target)
  75323. */
  75324. init(): void;
  75325. /**
  75326. * Called when the behavior is attached to a target
  75327. * @param target defines the target where the behavior is attached to
  75328. */
  75329. attach(target: T): void;
  75330. /**
  75331. * Called when the behavior is detached from its target
  75332. */
  75333. detach(): void;
  75334. }
  75335. /**
  75336. * Interface implemented by classes supporting behaviors
  75337. */
  75338. export interface IBehaviorAware<T> {
  75339. /**
  75340. * Attach a behavior
  75341. * @param behavior defines the behavior to attach
  75342. * @returns the current host
  75343. */
  75344. addBehavior(behavior: Behavior<T>): T;
  75345. /**
  75346. * Remove a behavior from the current object
  75347. * @param behavior defines the behavior to detach
  75348. * @returns the current host
  75349. */
  75350. removeBehavior(behavior: Behavior<T>): T;
  75351. /**
  75352. * Gets a behavior using its name to search
  75353. * @param name defines the name to search
  75354. * @returns the behavior or null if not found
  75355. */
  75356. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  75357. }
  75358. }
  75359. declare module BABYLON {
  75360. /**
  75361. * Defines an array and its length.
  75362. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  75363. */
  75364. export interface ISmartArrayLike<T> {
  75365. /**
  75366. * The data of the array.
  75367. */
  75368. data: Array<T>;
  75369. /**
  75370. * The active length of the array.
  75371. */
  75372. length: number;
  75373. }
  75374. /**
  75375. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  75376. */
  75377. export class SmartArray<T> implements ISmartArrayLike<T> {
  75378. /**
  75379. * The full set of data from the array.
  75380. */
  75381. data: Array<T>;
  75382. /**
  75383. * The active length of the array.
  75384. */
  75385. length: number;
  75386. protected _id: number;
  75387. /**
  75388. * Instantiates a Smart Array.
  75389. * @param capacity defines the default capacity of the array.
  75390. */
  75391. constructor(capacity: number);
  75392. /**
  75393. * Pushes a value at the end of the active data.
  75394. * @param value defines the object to push in the array.
  75395. */
  75396. push(value: T): void;
  75397. /**
  75398. * Iterates over the active data and apply the lambda to them.
  75399. * @param func defines the action to apply on each value.
  75400. */
  75401. forEach(func: (content: T) => void): void;
  75402. /**
  75403. * Sorts the full sets of data.
  75404. * @param compareFn defines the comparison function to apply.
  75405. */
  75406. sort(compareFn: (a: T, b: T) => number): void;
  75407. /**
  75408. * Resets the active data to an empty array.
  75409. */
  75410. reset(): void;
  75411. /**
  75412. * Releases all the data from the array as well as the array.
  75413. */
  75414. dispose(): void;
  75415. /**
  75416. * Concats the active data with a given array.
  75417. * @param array defines the data to concatenate with.
  75418. */
  75419. concat(array: any): void;
  75420. /**
  75421. * Returns the position of a value in the active data.
  75422. * @param value defines the value to find the index for
  75423. * @returns the index if found in the active data otherwise -1
  75424. */
  75425. indexOf(value: T): number;
  75426. /**
  75427. * Returns whether an element is part of the active data.
  75428. * @param value defines the value to look for
  75429. * @returns true if found in the active data otherwise false
  75430. */
  75431. contains(value: T): boolean;
  75432. private static _GlobalId;
  75433. }
  75434. /**
  75435. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  75436. * The data in this array can only be present once
  75437. */
  75438. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  75439. private _duplicateId;
  75440. /**
  75441. * Pushes a value at the end of the active data.
  75442. * THIS DOES NOT PREVENT DUPPLICATE DATA
  75443. * @param value defines the object to push in the array.
  75444. */
  75445. push(value: T): void;
  75446. /**
  75447. * Pushes a value at the end of the active data.
  75448. * If the data is already present, it won t be added again
  75449. * @param value defines the object to push in the array.
  75450. * @returns true if added false if it was already present
  75451. */
  75452. pushNoDuplicate(value: T): boolean;
  75453. /**
  75454. * Resets the active data to an empty array.
  75455. */
  75456. reset(): void;
  75457. /**
  75458. * Concats the active data with a given array.
  75459. * This ensures no dupplicate will be present in the result.
  75460. * @param array defines the data to concatenate with.
  75461. */
  75462. concatWithNoDuplicate(array: any): void;
  75463. }
  75464. }
  75465. declare module BABYLON {
  75466. /**
  75467. * @ignore
  75468. * This is a list of all the different input types that are available in the application.
  75469. * Fo instance: ArcRotateCameraGamepadInput...
  75470. */
  75471. export var CameraInputTypes: {};
  75472. /**
  75473. * This is the contract to implement in order to create a new input class.
  75474. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  75475. */
  75476. export interface ICameraInput<TCamera extends Camera> {
  75477. /**
  75478. * Defines the camera the input is attached to.
  75479. */
  75480. camera: Nullable<TCamera>;
  75481. /**
  75482. * Gets the class name of the current intput.
  75483. * @returns the class name
  75484. */
  75485. getClassName(): string;
  75486. /**
  75487. * Get the friendly name associated with the input class.
  75488. * @returns the input friendly name
  75489. */
  75490. getSimpleName(): string;
  75491. /**
  75492. * Attach the input controls to a specific dom element to get the input from.
  75493. * @param element Defines the element the controls should be listened from
  75494. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75495. */
  75496. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75497. /**
  75498. * Detach the current controls from the specified dom element.
  75499. * @param element Defines the element to stop listening the inputs from
  75500. */
  75501. detachControl(element: Nullable<HTMLElement>): void;
  75502. /**
  75503. * Update the current camera state depending on the inputs that have been used this frame.
  75504. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75505. */
  75506. checkInputs?: () => void;
  75507. }
  75508. /**
  75509. * Represents a map of input types to input instance or input index to input instance.
  75510. */
  75511. export interface CameraInputsMap<TCamera extends Camera> {
  75512. /**
  75513. * Accessor to the input by input type.
  75514. */
  75515. [name: string]: ICameraInput<TCamera>;
  75516. /**
  75517. * Accessor to the input by input index.
  75518. */
  75519. [idx: number]: ICameraInput<TCamera>;
  75520. }
  75521. /**
  75522. * This represents the input manager used within a camera.
  75523. * It helps dealing with all the different kind of input attached to a camera.
  75524. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75525. */
  75526. export class CameraInputsManager<TCamera extends Camera> {
  75527. /**
  75528. * Defines the list of inputs attahed to the camera.
  75529. */
  75530. attached: CameraInputsMap<TCamera>;
  75531. /**
  75532. * Defines the dom element the camera is collecting inputs from.
  75533. * This is null if the controls have not been attached.
  75534. */
  75535. attachedElement: Nullable<HTMLElement>;
  75536. /**
  75537. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75538. */
  75539. noPreventDefault: boolean;
  75540. /**
  75541. * Defined the camera the input manager belongs to.
  75542. */
  75543. camera: TCamera;
  75544. /**
  75545. * Update the current camera state depending on the inputs that have been used this frame.
  75546. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75547. */
  75548. checkInputs: () => void;
  75549. /**
  75550. * Instantiate a new Camera Input Manager.
  75551. * @param camera Defines the camera the input manager blongs to
  75552. */
  75553. constructor(camera: TCamera);
  75554. /**
  75555. * Add an input method to a camera
  75556. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75557. * @param input camera input method
  75558. */
  75559. add(input: ICameraInput<TCamera>): void;
  75560. /**
  75561. * Remove a specific input method from a camera
  75562. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  75563. * @param inputToRemove camera input method
  75564. */
  75565. remove(inputToRemove: ICameraInput<TCamera>): void;
  75566. /**
  75567. * Remove a specific input type from a camera
  75568. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  75569. * @param inputType the type of the input to remove
  75570. */
  75571. removeByType(inputType: string): void;
  75572. private _addCheckInputs;
  75573. /**
  75574. * Attach the input controls to the currently attached dom element to listen the events from.
  75575. * @param input Defines the input to attach
  75576. */
  75577. attachInput(input: ICameraInput<TCamera>): void;
  75578. /**
  75579. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  75580. * @param element Defines the dom element to collect the events from
  75581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75582. */
  75583. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  75584. /**
  75585. * Detach the current manager inputs controls from a specific dom element.
  75586. * @param element Defines the dom element to collect the events from
  75587. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  75588. */
  75589. detachElement(element: HTMLElement, disconnect?: boolean): void;
  75590. /**
  75591. * Rebuild the dynamic inputCheck function from the current list of
  75592. * defined inputs in the manager.
  75593. */
  75594. rebuildInputCheck(): void;
  75595. /**
  75596. * Remove all attached input methods from a camera
  75597. */
  75598. clear(): void;
  75599. /**
  75600. * Serialize the current input manager attached to a camera.
  75601. * This ensures than once parsed,
  75602. * the input associated to the camera will be identical to the current ones
  75603. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  75604. */
  75605. serialize(serializedCamera: any): void;
  75606. /**
  75607. * Parses an input manager serialized JSON to restore the previous list of inputs
  75608. * and states associated to a camera.
  75609. * @param parsedCamera Defines the JSON to parse
  75610. */
  75611. parse(parsedCamera: any): void;
  75612. }
  75613. }
  75614. declare module BABYLON {
  75615. /**
  75616. * Class used to store data that will be store in GPU memory
  75617. */
  75618. export class Buffer {
  75619. private _engine;
  75620. private _buffer;
  75621. /** @hidden */
  75622. _data: Nullable<DataArray>;
  75623. private _updatable;
  75624. private _instanced;
  75625. private _divisor;
  75626. /**
  75627. * Gets the byte stride.
  75628. */
  75629. readonly byteStride: number;
  75630. /**
  75631. * Constructor
  75632. * @param engine the engine
  75633. * @param data the data to use for this buffer
  75634. * @param updatable whether the data is updatable
  75635. * @param stride the stride (optional)
  75636. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  75637. * @param instanced whether the buffer is instanced (optional)
  75638. * @param useBytes set to true if the stride in in bytes (optional)
  75639. * @param divisor sets an optional divisor for instances (1 by default)
  75640. */
  75641. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  75642. /**
  75643. * Create a new VertexBuffer based on the current buffer
  75644. * @param kind defines the vertex buffer kind (position, normal, etc.)
  75645. * @param offset defines offset in the buffer (0 by default)
  75646. * @param size defines the size in floats of attributes (position is 3 for instance)
  75647. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  75648. * @param instanced defines if the vertex buffer contains indexed data
  75649. * @param useBytes defines if the offset and stride are in bytes *
  75650. * @param divisor sets an optional divisor for instances (1 by default)
  75651. * @returns the new vertex buffer
  75652. */
  75653. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  75654. /**
  75655. * Gets a boolean indicating if the Buffer is updatable?
  75656. * @returns true if the buffer is updatable
  75657. */
  75658. isUpdatable(): boolean;
  75659. /**
  75660. * Gets current buffer's data
  75661. * @returns a DataArray or null
  75662. */
  75663. getData(): Nullable<DataArray>;
  75664. /**
  75665. * Gets underlying native buffer
  75666. * @returns underlying native buffer
  75667. */
  75668. getBuffer(): Nullable<DataBuffer>;
  75669. /**
  75670. * Gets the stride in float32 units (i.e. byte stride / 4).
  75671. * May not be an integer if the byte stride is not divisible by 4.
  75672. * @returns the stride in float32 units
  75673. * @deprecated Please use byteStride instead.
  75674. */
  75675. getStrideSize(): number;
  75676. /**
  75677. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  75678. * @param data defines the data to store
  75679. */
  75680. create(data?: Nullable<DataArray>): void;
  75681. /** @hidden */
  75682. _rebuild(): void;
  75683. /**
  75684. * Update current buffer data
  75685. * @param data defines the data to store
  75686. */
  75687. update(data: DataArray): void;
  75688. /**
  75689. * Updates the data directly.
  75690. * @param data the new data
  75691. * @param offset the new offset
  75692. * @param vertexCount the vertex count (optional)
  75693. * @param useBytes set to true if the offset is in bytes
  75694. */
  75695. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  75696. /**
  75697. * Release all resources
  75698. */
  75699. dispose(): void;
  75700. }
  75701. /**
  75702. * Specialized buffer used to store vertex data
  75703. */
  75704. export class VertexBuffer {
  75705. /** @hidden */
  75706. _buffer: Buffer;
  75707. private _kind;
  75708. private _size;
  75709. private _ownsBuffer;
  75710. private _instanced;
  75711. private _instanceDivisor;
  75712. /**
  75713. * The byte type.
  75714. */
  75715. static readonly BYTE: number;
  75716. /**
  75717. * The unsigned byte type.
  75718. */
  75719. static readonly UNSIGNED_BYTE: number;
  75720. /**
  75721. * The short type.
  75722. */
  75723. static readonly SHORT: number;
  75724. /**
  75725. * The unsigned short type.
  75726. */
  75727. static readonly UNSIGNED_SHORT: number;
  75728. /**
  75729. * The integer type.
  75730. */
  75731. static readonly INT: number;
  75732. /**
  75733. * The unsigned integer type.
  75734. */
  75735. static readonly UNSIGNED_INT: number;
  75736. /**
  75737. * The float type.
  75738. */
  75739. static readonly FLOAT: number;
  75740. /**
  75741. * Gets or sets the instance divisor when in instanced mode
  75742. */
  75743. instanceDivisor: number;
  75744. /**
  75745. * Gets the byte stride.
  75746. */
  75747. readonly byteStride: number;
  75748. /**
  75749. * Gets the byte offset.
  75750. */
  75751. readonly byteOffset: number;
  75752. /**
  75753. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  75754. */
  75755. readonly normalized: boolean;
  75756. /**
  75757. * Gets the data type of each component in the array.
  75758. */
  75759. readonly type: number;
  75760. /**
  75761. * Constructor
  75762. * @param engine the engine
  75763. * @param data the data to use for this vertex buffer
  75764. * @param kind the vertex buffer kind
  75765. * @param updatable whether the data is updatable
  75766. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  75767. * @param stride the stride (optional)
  75768. * @param instanced whether the buffer is instanced (optional)
  75769. * @param offset the offset of the data (optional)
  75770. * @param size the number of components (optional)
  75771. * @param type the type of the component (optional)
  75772. * @param normalized whether the data contains normalized data (optional)
  75773. * @param useBytes set to true if stride and offset are in bytes (optional)
  75774. * @param divisor defines the instance divisor to use (1 by default)
  75775. */
  75776. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  75777. /** @hidden */
  75778. _rebuild(): void;
  75779. /**
  75780. * Returns the kind of the VertexBuffer (string)
  75781. * @returns a string
  75782. */
  75783. getKind(): string;
  75784. /**
  75785. * Gets a boolean indicating if the VertexBuffer is updatable?
  75786. * @returns true if the buffer is updatable
  75787. */
  75788. isUpdatable(): boolean;
  75789. /**
  75790. * Gets current buffer's data
  75791. * @returns a DataArray or null
  75792. */
  75793. getData(): Nullable<DataArray>;
  75794. /**
  75795. * Gets underlying native buffer
  75796. * @returns underlying native buffer
  75797. */
  75798. getBuffer(): Nullable<DataBuffer>;
  75799. /**
  75800. * Gets the stride in float32 units (i.e. byte stride / 4).
  75801. * May not be an integer if the byte stride is not divisible by 4.
  75802. * @returns the stride in float32 units
  75803. * @deprecated Please use byteStride instead.
  75804. */
  75805. getStrideSize(): number;
  75806. /**
  75807. * Returns the offset as a multiple of the type byte length.
  75808. * @returns the offset in bytes
  75809. * @deprecated Please use byteOffset instead.
  75810. */
  75811. getOffset(): number;
  75812. /**
  75813. * Returns the number of components per vertex attribute (integer)
  75814. * @returns the size in float
  75815. */
  75816. getSize(): number;
  75817. /**
  75818. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  75819. * @returns true if this buffer is instanced
  75820. */
  75821. getIsInstanced(): boolean;
  75822. /**
  75823. * Returns the instancing divisor, zero for non-instanced (integer).
  75824. * @returns a number
  75825. */
  75826. getInstanceDivisor(): number;
  75827. /**
  75828. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  75829. * @param data defines the data to store
  75830. */
  75831. create(data?: DataArray): void;
  75832. /**
  75833. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  75834. * This function will create a new buffer if the current one is not updatable
  75835. * @param data defines the data to store
  75836. */
  75837. update(data: DataArray): void;
  75838. /**
  75839. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  75840. * Returns the directly updated WebGLBuffer.
  75841. * @param data the new data
  75842. * @param offset the new offset
  75843. * @param useBytes set to true if the offset is in bytes
  75844. */
  75845. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  75846. /**
  75847. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  75848. */
  75849. dispose(): void;
  75850. /**
  75851. * Enumerates each value of this vertex buffer as numbers.
  75852. * @param count the number of values to enumerate
  75853. * @param callback the callback function called for each value
  75854. */
  75855. forEach(count: number, callback: (value: number, index: number) => void): void;
  75856. /**
  75857. * Positions
  75858. */
  75859. static readonly PositionKind: string;
  75860. /**
  75861. * Normals
  75862. */
  75863. static readonly NormalKind: string;
  75864. /**
  75865. * Tangents
  75866. */
  75867. static readonly TangentKind: string;
  75868. /**
  75869. * Texture coordinates
  75870. */
  75871. static readonly UVKind: string;
  75872. /**
  75873. * Texture coordinates 2
  75874. */
  75875. static readonly UV2Kind: string;
  75876. /**
  75877. * Texture coordinates 3
  75878. */
  75879. static readonly UV3Kind: string;
  75880. /**
  75881. * Texture coordinates 4
  75882. */
  75883. static readonly UV4Kind: string;
  75884. /**
  75885. * Texture coordinates 5
  75886. */
  75887. static readonly UV5Kind: string;
  75888. /**
  75889. * Texture coordinates 6
  75890. */
  75891. static readonly UV6Kind: string;
  75892. /**
  75893. * Colors
  75894. */
  75895. static readonly ColorKind: string;
  75896. /**
  75897. * Matrix indices (for bones)
  75898. */
  75899. static readonly MatricesIndicesKind: string;
  75900. /**
  75901. * Matrix weights (for bones)
  75902. */
  75903. static readonly MatricesWeightsKind: string;
  75904. /**
  75905. * Additional matrix indices (for bones)
  75906. */
  75907. static readonly MatricesIndicesExtraKind: string;
  75908. /**
  75909. * Additional matrix weights (for bones)
  75910. */
  75911. static readonly MatricesWeightsExtraKind: string;
  75912. /**
  75913. * Deduces the stride given a kind.
  75914. * @param kind The kind string to deduce
  75915. * @returns The deduced stride
  75916. */
  75917. static DeduceStride(kind: string): number;
  75918. /**
  75919. * Gets the byte length of the given type.
  75920. * @param type the type
  75921. * @returns the number of bytes
  75922. */
  75923. static GetTypeByteLength(type: number): number;
  75924. /**
  75925. * Enumerates each value of the given parameters as numbers.
  75926. * @param data the data to enumerate
  75927. * @param byteOffset the byte offset of the data
  75928. * @param byteStride the byte stride of the data
  75929. * @param componentCount the number of components per element
  75930. * @param componentType the type of the component
  75931. * @param count the number of values to enumerate
  75932. * @param normalized whether the data is normalized
  75933. * @param callback the callback function called for each value
  75934. */
  75935. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  75936. private static _GetFloatValue;
  75937. }
  75938. }
  75939. declare module BABYLON {
  75940. /**
  75941. * @hidden
  75942. */
  75943. export class IntersectionInfo {
  75944. bu: Nullable<number>;
  75945. bv: Nullable<number>;
  75946. distance: number;
  75947. faceId: number;
  75948. subMeshId: number;
  75949. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  75950. }
  75951. }
  75952. declare module BABYLON {
  75953. /**
  75954. * Represens a plane by the equation ax + by + cz + d = 0
  75955. */
  75956. export class Plane {
  75957. private static _TmpMatrix;
  75958. /**
  75959. * Normal of the plane (a,b,c)
  75960. */
  75961. normal: Vector3;
  75962. /**
  75963. * d component of the plane
  75964. */
  75965. d: number;
  75966. /**
  75967. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  75968. * @param a a component of the plane
  75969. * @param b b component of the plane
  75970. * @param c c component of the plane
  75971. * @param d d component of the plane
  75972. */
  75973. constructor(a: number, b: number, c: number, d: number);
  75974. /**
  75975. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  75976. */
  75977. asArray(): number[];
  75978. /**
  75979. * @returns a new plane copied from the current Plane.
  75980. */
  75981. clone(): Plane;
  75982. /**
  75983. * @returns the string "Plane".
  75984. */
  75985. getClassName(): string;
  75986. /**
  75987. * @returns the Plane hash code.
  75988. */
  75989. getHashCode(): number;
  75990. /**
  75991. * Normalize the current Plane in place.
  75992. * @returns the updated Plane.
  75993. */
  75994. normalize(): Plane;
  75995. /**
  75996. * Applies a transformation the plane and returns the result
  75997. * @param transformation the transformation matrix to be applied to the plane
  75998. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  75999. */
  76000. transform(transformation: DeepImmutable<Matrix>): Plane;
  76001. /**
  76002. * Calcualtte the dot product between the point and the plane normal
  76003. * @param point point to calculate the dot product with
  76004. * @returns the dot product (float) of the point coordinates and the plane normal.
  76005. */
  76006. dotCoordinate(point: DeepImmutable<Vector3>): number;
  76007. /**
  76008. * Updates the current Plane from the plane defined by the three given points.
  76009. * @param point1 one of the points used to contruct the plane
  76010. * @param point2 one of the points used to contruct the plane
  76011. * @param point3 one of the points used to contruct the plane
  76012. * @returns the updated Plane.
  76013. */
  76014. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  76015. /**
  76016. * Checks if the plane is facing a given direction
  76017. * @param direction the direction to check if the plane is facing
  76018. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  76019. * @returns True is the vector "direction" is the same side than the plane normal.
  76020. */
  76021. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  76022. /**
  76023. * Calculates the distance to a point
  76024. * @param point point to calculate distance to
  76025. * @returns the signed distance (float) from the given point to the Plane.
  76026. */
  76027. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  76028. /**
  76029. * Creates a plane from an array
  76030. * @param array the array to create a plane from
  76031. * @returns a new Plane from the given array.
  76032. */
  76033. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  76034. /**
  76035. * Creates a plane from three points
  76036. * @param point1 point used to create the plane
  76037. * @param point2 point used to create the plane
  76038. * @param point3 point used to create the plane
  76039. * @returns a new Plane defined by the three given points.
  76040. */
  76041. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  76042. /**
  76043. * Creates a plane from an origin point and a normal
  76044. * @param origin origin of the plane to be constructed
  76045. * @param normal normal of the plane to be constructed
  76046. * @returns a new Plane the normal vector to this plane at the given origin point.
  76047. * Note : the vector "normal" is updated because normalized.
  76048. */
  76049. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  76050. /**
  76051. * Calculates the distance from a plane and a point
  76052. * @param origin origin of the plane to be constructed
  76053. * @param normal normal of the plane to be constructed
  76054. * @param point point to calculate distance to
  76055. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  76056. */
  76057. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  76058. }
  76059. }
  76060. declare module BABYLON {
  76061. /**
  76062. * Class used to store bounding sphere information
  76063. */
  76064. export class BoundingSphere {
  76065. /**
  76066. * Gets the center of the bounding sphere in local space
  76067. */
  76068. readonly center: Vector3;
  76069. /**
  76070. * Radius of the bounding sphere in local space
  76071. */
  76072. radius: number;
  76073. /**
  76074. * Gets the center of the bounding sphere in world space
  76075. */
  76076. readonly centerWorld: Vector3;
  76077. /**
  76078. * Radius of the bounding sphere in world space
  76079. */
  76080. radiusWorld: number;
  76081. /**
  76082. * Gets the minimum vector in local space
  76083. */
  76084. readonly minimum: Vector3;
  76085. /**
  76086. * Gets the maximum vector in local space
  76087. */
  76088. readonly maximum: Vector3;
  76089. private _worldMatrix;
  76090. private static readonly TmpVector3;
  76091. /**
  76092. * Creates a new bounding sphere
  76093. * @param min defines the minimum vector (in local space)
  76094. * @param max defines the maximum vector (in local space)
  76095. * @param worldMatrix defines the new world matrix
  76096. */
  76097. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  76098. /**
  76099. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  76100. * @param min defines the new minimum vector (in local space)
  76101. * @param max defines the new maximum vector (in local space)
  76102. * @param worldMatrix defines the new world matrix
  76103. */
  76104. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  76105. /**
  76106. * Scale the current bounding sphere by applying a scale factor
  76107. * @param factor defines the scale factor to apply
  76108. * @returns the current bounding box
  76109. */
  76110. scale(factor: number): BoundingSphere;
  76111. /**
  76112. * Gets the world matrix of the bounding box
  76113. * @returns a matrix
  76114. */
  76115. getWorldMatrix(): DeepImmutable<Matrix>;
  76116. /** @hidden */
  76117. _update(worldMatrix: DeepImmutable<Matrix>): void;
  76118. /**
  76119. * Tests if the bounding sphere is intersecting the frustum planes
  76120. * @param frustumPlanes defines the frustum planes to test
  76121. * @returns true if there is an intersection
  76122. */
  76123. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76124. /**
  76125. * Tests if the bounding sphere center is in between the frustum planes.
  76126. * Used for optimistic fast inclusion.
  76127. * @param frustumPlanes defines the frustum planes to test
  76128. * @returns true if the sphere center is in between the frustum planes
  76129. */
  76130. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76131. /**
  76132. * Tests if a point is inside the bounding sphere
  76133. * @param point defines the point to test
  76134. * @returns true if the point is inside the bounding sphere
  76135. */
  76136. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  76137. /**
  76138. * Checks if two sphere intersct
  76139. * @param sphere0 sphere 0
  76140. * @param sphere1 sphere 1
  76141. * @returns true if the speres intersect
  76142. */
  76143. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  76144. }
  76145. }
  76146. declare module BABYLON {
  76147. /**
  76148. * Class used to store bounding box information
  76149. */
  76150. export class BoundingBox implements ICullable {
  76151. /**
  76152. * Gets the 8 vectors representing the bounding box in local space
  76153. */
  76154. readonly vectors: Vector3[];
  76155. /**
  76156. * Gets the center of the bounding box in local space
  76157. */
  76158. readonly center: Vector3;
  76159. /**
  76160. * Gets the center of the bounding box in world space
  76161. */
  76162. readonly centerWorld: Vector3;
  76163. /**
  76164. * Gets the extend size in local space
  76165. */
  76166. readonly extendSize: Vector3;
  76167. /**
  76168. * Gets the extend size in world space
  76169. */
  76170. readonly extendSizeWorld: Vector3;
  76171. /**
  76172. * Gets the OBB (object bounding box) directions
  76173. */
  76174. readonly directions: Vector3[];
  76175. /**
  76176. * Gets the 8 vectors representing the bounding box in world space
  76177. */
  76178. readonly vectorsWorld: Vector3[];
  76179. /**
  76180. * Gets the minimum vector in world space
  76181. */
  76182. readonly minimumWorld: Vector3;
  76183. /**
  76184. * Gets the maximum vector in world space
  76185. */
  76186. readonly maximumWorld: Vector3;
  76187. /**
  76188. * Gets the minimum vector in local space
  76189. */
  76190. readonly minimum: Vector3;
  76191. /**
  76192. * Gets the maximum vector in local space
  76193. */
  76194. readonly maximum: Vector3;
  76195. private _worldMatrix;
  76196. private static readonly TmpVector3;
  76197. /**
  76198. * @hidden
  76199. */
  76200. _tag: number;
  76201. /**
  76202. * Creates a new bounding box
  76203. * @param min defines the minimum vector (in local space)
  76204. * @param max defines the maximum vector (in local space)
  76205. * @param worldMatrix defines the new world matrix
  76206. */
  76207. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  76208. /**
  76209. * Recreates the entire bounding box from scratch as if we call the constructor in place
  76210. * @param min defines the new minimum vector (in local space)
  76211. * @param max defines the new maximum vector (in local space)
  76212. * @param worldMatrix defines the new world matrix
  76213. */
  76214. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  76215. /**
  76216. * Scale the current bounding box by applying a scale factor
  76217. * @param factor defines the scale factor to apply
  76218. * @returns the current bounding box
  76219. */
  76220. scale(factor: number): BoundingBox;
  76221. /**
  76222. * Gets the world matrix of the bounding box
  76223. * @returns a matrix
  76224. */
  76225. getWorldMatrix(): DeepImmutable<Matrix>;
  76226. /** @hidden */
  76227. _update(world: DeepImmutable<Matrix>): void;
  76228. /**
  76229. * Tests if the bounding box is intersecting the frustum planes
  76230. * @param frustumPlanes defines the frustum planes to test
  76231. * @returns true if there is an intersection
  76232. */
  76233. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76234. /**
  76235. * Tests if the bounding box is entirely inside the frustum planes
  76236. * @param frustumPlanes defines the frustum planes to test
  76237. * @returns true if there is an inclusion
  76238. */
  76239. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76240. /**
  76241. * Tests if a point is inside the bounding box
  76242. * @param point defines the point to test
  76243. * @returns true if the point is inside the bounding box
  76244. */
  76245. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  76246. /**
  76247. * Tests if the bounding box intersects with a bounding sphere
  76248. * @param sphere defines the sphere to test
  76249. * @returns true if there is an intersection
  76250. */
  76251. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  76252. /**
  76253. * Tests if the bounding box intersects with a box defined by a min and max vectors
  76254. * @param min defines the min vector to use
  76255. * @param max defines the max vector to use
  76256. * @returns true if there is an intersection
  76257. */
  76258. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  76259. /**
  76260. * Tests if two bounding boxes are intersections
  76261. * @param box0 defines the first box to test
  76262. * @param box1 defines the second box to test
  76263. * @returns true if there is an intersection
  76264. */
  76265. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  76266. /**
  76267. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  76268. * @param minPoint defines the minimum vector of the bounding box
  76269. * @param maxPoint defines the maximum vector of the bounding box
  76270. * @param sphereCenter defines the sphere center
  76271. * @param sphereRadius defines the sphere radius
  76272. * @returns true if there is an intersection
  76273. */
  76274. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  76275. /**
  76276. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  76277. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  76278. * @param frustumPlanes defines the frustum planes to test
  76279. * @return true if there is an inclusion
  76280. */
  76281. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76282. /**
  76283. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  76284. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  76285. * @param frustumPlanes defines the frustum planes to test
  76286. * @return true if there is an intersection
  76287. */
  76288. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76289. }
  76290. }
  76291. declare module BABYLON {
  76292. /** @hidden */
  76293. export class Collider {
  76294. /** Define if a collision was found */
  76295. collisionFound: boolean;
  76296. /**
  76297. * Define last intersection point in local space
  76298. */
  76299. intersectionPoint: Vector3;
  76300. /**
  76301. * Define last collided mesh
  76302. */
  76303. collidedMesh: Nullable<AbstractMesh>;
  76304. private _collisionPoint;
  76305. private _planeIntersectionPoint;
  76306. private _tempVector;
  76307. private _tempVector2;
  76308. private _tempVector3;
  76309. private _tempVector4;
  76310. private _edge;
  76311. private _baseToVertex;
  76312. private _destinationPoint;
  76313. private _slidePlaneNormal;
  76314. private _displacementVector;
  76315. /** @hidden */
  76316. _radius: Vector3;
  76317. /** @hidden */
  76318. _retry: number;
  76319. private _velocity;
  76320. private _basePoint;
  76321. private _epsilon;
  76322. /** @hidden */
  76323. _velocityWorldLength: number;
  76324. /** @hidden */
  76325. _basePointWorld: Vector3;
  76326. private _velocityWorld;
  76327. private _normalizedVelocity;
  76328. /** @hidden */
  76329. _initialVelocity: Vector3;
  76330. /** @hidden */
  76331. _initialPosition: Vector3;
  76332. private _nearestDistance;
  76333. private _collisionMask;
  76334. collisionMask: number;
  76335. /**
  76336. * Gets the plane normal used to compute the sliding response (in local space)
  76337. */
  76338. readonly slidePlaneNormal: Vector3;
  76339. /** @hidden */
  76340. _initialize(source: Vector3, dir: Vector3, e: number): void;
  76341. /** @hidden */
  76342. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  76343. /** @hidden */
  76344. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  76345. /** @hidden */
  76346. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  76347. /** @hidden */
  76348. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  76349. /** @hidden */
  76350. _getResponse(pos: Vector3, vel: Vector3): void;
  76351. }
  76352. }
  76353. declare module BABYLON {
  76354. /**
  76355. * Interface for cullable objects
  76356. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  76357. */
  76358. export interface ICullable {
  76359. /**
  76360. * Checks if the object or part of the object is in the frustum
  76361. * @param frustumPlanes Camera near/planes
  76362. * @returns true if the object is in frustum otherwise false
  76363. */
  76364. isInFrustum(frustumPlanes: Plane[]): boolean;
  76365. /**
  76366. * Checks if a cullable object (mesh...) is in the camera frustum
  76367. * Unlike isInFrustum this cheks the full bounding box
  76368. * @param frustumPlanes Camera near/planes
  76369. * @returns true if the object is in frustum otherwise false
  76370. */
  76371. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  76372. }
  76373. /**
  76374. * Info for a bounding data of a mesh
  76375. */
  76376. export class BoundingInfo implements ICullable {
  76377. /**
  76378. * Bounding box for the mesh
  76379. */
  76380. readonly boundingBox: BoundingBox;
  76381. /**
  76382. * Bounding sphere for the mesh
  76383. */
  76384. readonly boundingSphere: BoundingSphere;
  76385. private _isLocked;
  76386. private static readonly TmpVector3;
  76387. /**
  76388. * Constructs bounding info
  76389. * @param minimum min vector of the bounding box/sphere
  76390. * @param maximum max vector of the bounding box/sphere
  76391. * @param worldMatrix defines the new world matrix
  76392. */
  76393. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  76394. /**
  76395. * Recreates the entire bounding info from scratch as if we call the constructor in place
  76396. * @param min defines the new minimum vector (in local space)
  76397. * @param max defines the new maximum vector (in local space)
  76398. * @param worldMatrix defines the new world matrix
  76399. */
  76400. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  76401. /**
  76402. * min vector of the bounding box/sphere
  76403. */
  76404. readonly minimum: Vector3;
  76405. /**
  76406. * max vector of the bounding box/sphere
  76407. */
  76408. readonly maximum: Vector3;
  76409. /**
  76410. * If the info is locked and won't be updated to avoid perf overhead
  76411. */
  76412. isLocked: boolean;
  76413. /**
  76414. * Updates the bounding sphere and box
  76415. * @param world world matrix to be used to update
  76416. */
  76417. update(world: DeepImmutable<Matrix>): void;
  76418. /**
  76419. * Recreate the bounding info to be centered around a specific point given a specific extend.
  76420. * @param center New center of the bounding info
  76421. * @param extend New extend of the bounding info
  76422. * @returns the current bounding info
  76423. */
  76424. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  76425. /**
  76426. * Scale the current bounding info by applying a scale factor
  76427. * @param factor defines the scale factor to apply
  76428. * @returns the current bounding info
  76429. */
  76430. scale(factor: number): BoundingInfo;
  76431. /**
  76432. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  76433. * @param frustumPlanes defines the frustum to test
  76434. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  76435. * @returns true if the bounding info is in the frustum planes
  76436. */
  76437. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  76438. /**
  76439. * Gets the world distance between the min and max points of the bounding box
  76440. */
  76441. readonly diagonalLength: number;
  76442. /**
  76443. * Checks if a cullable object (mesh...) is in the camera frustum
  76444. * Unlike isInFrustum this cheks the full bounding box
  76445. * @param frustumPlanes Camera near/planes
  76446. * @returns true if the object is in frustum otherwise false
  76447. */
  76448. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76449. /** @hidden */
  76450. _checkCollision(collider: Collider): boolean;
  76451. /**
  76452. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  76453. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  76454. * @param point the point to check intersection with
  76455. * @returns if the point intersects
  76456. */
  76457. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  76458. /**
  76459. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  76460. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  76461. * @param boundingInfo the bounding info to check intersection with
  76462. * @param precise if the intersection should be done using OBB
  76463. * @returns if the bounding info intersects
  76464. */
  76465. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  76466. }
  76467. }
  76468. declare module BABYLON {
  76469. /**
  76470. * Extracts minimum and maximum values from a list of indexed positions
  76471. * @param positions defines the positions to use
  76472. * @param indices defines the indices to the positions
  76473. * @param indexStart defines the start index
  76474. * @param indexCount defines the end index
  76475. * @param bias defines bias value to add to the result
  76476. * @return minimum and maximum values
  76477. */
  76478. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  76479. minimum: Vector3;
  76480. maximum: Vector3;
  76481. };
  76482. /**
  76483. * Extracts minimum and maximum values from a list of positions
  76484. * @param positions defines the positions to use
  76485. * @param start defines the start index in the positions array
  76486. * @param count defines the number of positions to handle
  76487. * @param bias defines bias value to add to the result
  76488. * @param stride defines the stride size to use (distance between two positions in the positions array)
  76489. * @return minimum and maximum values
  76490. */
  76491. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  76492. minimum: Vector3;
  76493. maximum: Vector3;
  76494. };
  76495. }
  76496. declare module BABYLON {
  76497. /** @hidden */
  76498. export class WebGLDataBuffer extends DataBuffer {
  76499. private _buffer;
  76500. constructor(resource: WebGLBuffer);
  76501. readonly underlyingResource: any;
  76502. }
  76503. }
  76504. declare module BABYLON {
  76505. /** @hidden */
  76506. export class WebGLPipelineContext implements IPipelineContext {
  76507. engine: ThinEngine;
  76508. program: Nullable<WebGLProgram>;
  76509. context?: WebGLRenderingContext;
  76510. vertexShader?: WebGLShader;
  76511. fragmentShader?: WebGLShader;
  76512. isParallelCompiled: boolean;
  76513. onCompiled?: () => void;
  76514. transformFeedback?: WebGLTransformFeedback | null;
  76515. readonly isAsync: boolean;
  76516. readonly isReady: boolean;
  76517. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  76518. }
  76519. }
  76520. declare module BABYLON {
  76521. interface ThinEngine {
  76522. /**
  76523. * Create an uniform buffer
  76524. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  76525. * @param elements defines the content of the uniform buffer
  76526. * @returns the webGL uniform buffer
  76527. */
  76528. createUniformBuffer(elements: FloatArray): DataBuffer;
  76529. /**
  76530. * Create a dynamic uniform buffer
  76531. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  76532. * @param elements defines the content of the uniform buffer
  76533. * @returns the webGL uniform buffer
  76534. */
  76535. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  76536. /**
  76537. * Update an existing uniform buffer
  76538. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  76539. * @param uniformBuffer defines the target uniform buffer
  76540. * @param elements defines the content to update
  76541. * @param offset defines the offset in the uniform buffer where update should start
  76542. * @param count defines the size of the data to update
  76543. */
  76544. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  76545. /**
  76546. * Bind an uniform buffer to the current webGL context
  76547. * @param buffer defines the buffer to bind
  76548. */
  76549. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  76550. /**
  76551. * Bind a buffer to the current webGL context at a given location
  76552. * @param buffer defines the buffer to bind
  76553. * @param location defines the index where to bind the buffer
  76554. */
  76555. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  76556. /**
  76557. * Bind a specific block at a given index in a specific shader program
  76558. * @param pipelineContext defines the pipeline context to use
  76559. * @param blockName defines the block name
  76560. * @param index defines the index where to bind the block
  76561. */
  76562. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  76563. }
  76564. }
  76565. declare module BABYLON {
  76566. /**
  76567. * Uniform buffer objects.
  76568. *
  76569. * Handles blocks of uniform on the GPU.
  76570. *
  76571. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  76572. *
  76573. * For more information, please refer to :
  76574. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  76575. */
  76576. export class UniformBuffer {
  76577. private _engine;
  76578. private _buffer;
  76579. private _data;
  76580. private _bufferData;
  76581. private _dynamic?;
  76582. private _uniformLocations;
  76583. private _uniformSizes;
  76584. private _uniformLocationPointer;
  76585. private _needSync;
  76586. private _noUBO;
  76587. private _currentEffect;
  76588. /** @hidden */
  76589. _alreadyBound: boolean;
  76590. private static _MAX_UNIFORM_SIZE;
  76591. private static _tempBuffer;
  76592. /**
  76593. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  76594. * This is dynamic to allow compat with webgl 1 and 2.
  76595. * You will need to pass the name of the uniform as well as the value.
  76596. */
  76597. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  76598. /**
  76599. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  76600. * This is dynamic to allow compat with webgl 1 and 2.
  76601. * You will need to pass the name of the uniform as well as the value.
  76602. */
  76603. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  76604. /**
  76605. * Lambda to Update a single float in a uniform buffer.
  76606. * This is dynamic to allow compat with webgl 1 and 2.
  76607. * You will need to pass the name of the uniform as well as the value.
  76608. */
  76609. updateFloat: (name: string, x: number) => void;
  76610. /**
  76611. * Lambda to Update a vec2 of float in a uniform buffer.
  76612. * This is dynamic to allow compat with webgl 1 and 2.
  76613. * You will need to pass the name of the uniform as well as the value.
  76614. */
  76615. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  76616. /**
  76617. * Lambda to Update a vec3 of float in a uniform buffer.
  76618. * This is dynamic to allow compat with webgl 1 and 2.
  76619. * You will need to pass the name of the uniform as well as the value.
  76620. */
  76621. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  76622. /**
  76623. * Lambda to Update a vec4 of float in a uniform buffer.
  76624. * This is dynamic to allow compat with webgl 1 and 2.
  76625. * You will need to pass the name of the uniform as well as the value.
  76626. */
  76627. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  76628. /**
  76629. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  76630. * This is dynamic to allow compat with webgl 1 and 2.
  76631. * You will need to pass the name of the uniform as well as the value.
  76632. */
  76633. updateMatrix: (name: string, mat: Matrix) => void;
  76634. /**
  76635. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  76636. * This is dynamic to allow compat with webgl 1 and 2.
  76637. * You will need to pass the name of the uniform as well as the value.
  76638. */
  76639. updateVector3: (name: string, vector: Vector3) => void;
  76640. /**
  76641. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  76642. * This is dynamic to allow compat with webgl 1 and 2.
  76643. * You will need to pass the name of the uniform as well as the value.
  76644. */
  76645. updateVector4: (name: string, vector: Vector4) => void;
  76646. /**
  76647. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  76648. * This is dynamic to allow compat with webgl 1 and 2.
  76649. * You will need to pass the name of the uniform as well as the value.
  76650. */
  76651. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  76652. /**
  76653. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  76654. * This is dynamic to allow compat with webgl 1 and 2.
  76655. * You will need to pass the name of the uniform as well as the value.
  76656. */
  76657. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  76658. /**
  76659. * Instantiates a new Uniform buffer objects.
  76660. *
  76661. * Handles blocks of uniform on the GPU.
  76662. *
  76663. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  76664. *
  76665. * For more information, please refer to :
  76666. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  76667. * @param engine Define the engine the buffer is associated with
  76668. * @param data Define the data contained in the buffer
  76669. * @param dynamic Define if the buffer is updatable
  76670. */
  76671. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  76672. /**
  76673. * Indicates if the buffer is using the WebGL2 UBO implementation,
  76674. * or just falling back on setUniformXXX calls.
  76675. */
  76676. readonly useUbo: boolean;
  76677. /**
  76678. * Indicates if the WebGL underlying uniform buffer is in sync
  76679. * with the javascript cache data.
  76680. */
  76681. readonly isSync: boolean;
  76682. /**
  76683. * Indicates if the WebGL underlying uniform buffer is dynamic.
  76684. * Also, a dynamic UniformBuffer will disable cache verification and always
  76685. * update the underlying WebGL uniform buffer to the GPU.
  76686. * @returns if Dynamic, otherwise false
  76687. */
  76688. isDynamic(): boolean;
  76689. /**
  76690. * The data cache on JS side.
  76691. * @returns the underlying data as a float array
  76692. */
  76693. getData(): Float32Array;
  76694. /**
  76695. * The underlying WebGL Uniform buffer.
  76696. * @returns the webgl buffer
  76697. */
  76698. getBuffer(): Nullable<DataBuffer>;
  76699. /**
  76700. * std140 layout specifies how to align data within an UBO structure.
  76701. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  76702. * for specs.
  76703. */
  76704. private _fillAlignment;
  76705. /**
  76706. * Adds an uniform in the buffer.
  76707. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  76708. * for the layout to be correct !
  76709. * @param name Name of the uniform, as used in the uniform block in the shader.
  76710. * @param size Data size, or data directly.
  76711. */
  76712. addUniform(name: string, size: number | number[]): void;
  76713. /**
  76714. * Adds a Matrix 4x4 to the uniform buffer.
  76715. * @param name Name of the uniform, as used in the uniform block in the shader.
  76716. * @param mat A 4x4 matrix.
  76717. */
  76718. addMatrix(name: string, mat: Matrix): void;
  76719. /**
  76720. * Adds a vec2 to the uniform buffer.
  76721. * @param name Name of the uniform, as used in the uniform block in the shader.
  76722. * @param x Define the x component value of the vec2
  76723. * @param y Define the y component value of the vec2
  76724. */
  76725. addFloat2(name: string, x: number, y: number): void;
  76726. /**
  76727. * Adds a vec3 to the uniform buffer.
  76728. * @param name Name of the uniform, as used in the uniform block in the shader.
  76729. * @param x Define the x component value of the vec3
  76730. * @param y Define the y component value of the vec3
  76731. * @param z Define the z component value of the vec3
  76732. */
  76733. addFloat3(name: string, x: number, y: number, z: number): void;
  76734. /**
  76735. * Adds a vec3 to the uniform buffer.
  76736. * @param name Name of the uniform, as used in the uniform block in the shader.
  76737. * @param color Define the vec3 from a Color
  76738. */
  76739. addColor3(name: string, color: Color3): void;
  76740. /**
  76741. * Adds a vec4 to the uniform buffer.
  76742. * @param name Name of the uniform, as used in the uniform block in the shader.
  76743. * @param color Define the rgb components from a Color
  76744. * @param alpha Define the a component of the vec4
  76745. */
  76746. addColor4(name: string, color: Color3, alpha: number): void;
  76747. /**
  76748. * Adds a vec3 to the uniform buffer.
  76749. * @param name Name of the uniform, as used in the uniform block in the shader.
  76750. * @param vector Define the vec3 components from a Vector
  76751. */
  76752. addVector3(name: string, vector: Vector3): void;
  76753. /**
  76754. * Adds a Matrix 3x3 to the uniform buffer.
  76755. * @param name Name of the uniform, as used in the uniform block in the shader.
  76756. */
  76757. addMatrix3x3(name: string): void;
  76758. /**
  76759. * Adds a Matrix 2x2 to the uniform buffer.
  76760. * @param name Name of the uniform, as used in the uniform block in the shader.
  76761. */
  76762. addMatrix2x2(name: string): void;
  76763. /**
  76764. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  76765. */
  76766. create(): void;
  76767. /** @hidden */
  76768. _rebuild(): void;
  76769. /**
  76770. * Updates the WebGL Uniform Buffer on the GPU.
  76771. * If the `dynamic` flag is set to true, no cache comparison is done.
  76772. * Otherwise, the buffer will be updated only if the cache differs.
  76773. */
  76774. update(): void;
  76775. /**
  76776. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  76777. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  76778. * @param data Define the flattened data
  76779. * @param size Define the size of the data.
  76780. */
  76781. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  76782. private _valueCache;
  76783. private _cacheMatrix;
  76784. private _updateMatrix3x3ForUniform;
  76785. private _updateMatrix3x3ForEffect;
  76786. private _updateMatrix2x2ForEffect;
  76787. private _updateMatrix2x2ForUniform;
  76788. private _updateFloatForEffect;
  76789. private _updateFloatForUniform;
  76790. private _updateFloat2ForEffect;
  76791. private _updateFloat2ForUniform;
  76792. private _updateFloat3ForEffect;
  76793. private _updateFloat3ForUniform;
  76794. private _updateFloat4ForEffect;
  76795. private _updateFloat4ForUniform;
  76796. private _updateMatrixForEffect;
  76797. private _updateMatrixForUniform;
  76798. private _updateVector3ForEffect;
  76799. private _updateVector3ForUniform;
  76800. private _updateVector4ForEffect;
  76801. private _updateVector4ForUniform;
  76802. private _updateColor3ForEffect;
  76803. private _updateColor3ForUniform;
  76804. private _updateColor4ForEffect;
  76805. private _updateColor4ForUniform;
  76806. /**
  76807. * Sets a sampler uniform on the effect.
  76808. * @param name Define the name of the sampler.
  76809. * @param texture Define the texture to set in the sampler
  76810. */
  76811. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  76812. /**
  76813. * Directly updates the value of the uniform in the cache AND on the GPU.
  76814. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  76815. * @param data Define the flattened data
  76816. */
  76817. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  76818. /**
  76819. * Binds this uniform buffer to an effect.
  76820. * @param effect Define the effect to bind the buffer to
  76821. * @param name Name of the uniform block in the shader.
  76822. */
  76823. bindToEffect(effect: Effect, name: string): void;
  76824. /**
  76825. * Disposes the uniform buffer.
  76826. */
  76827. dispose(): void;
  76828. }
  76829. }
  76830. declare module BABYLON {
  76831. /**
  76832. * Enum that determines the text-wrapping mode to use.
  76833. */
  76834. export enum InspectableType {
  76835. /**
  76836. * Checkbox for booleans
  76837. */
  76838. Checkbox = 0,
  76839. /**
  76840. * Sliders for numbers
  76841. */
  76842. Slider = 1,
  76843. /**
  76844. * Vector3
  76845. */
  76846. Vector3 = 2,
  76847. /**
  76848. * Quaternions
  76849. */
  76850. Quaternion = 3,
  76851. /**
  76852. * Color3
  76853. */
  76854. Color3 = 4,
  76855. /**
  76856. * String
  76857. */
  76858. String = 5
  76859. }
  76860. /**
  76861. * Interface used to define custom inspectable properties.
  76862. * This interface is used by the inspector to display custom property grids
  76863. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76864. */
  76865. export interface IInspectable {
  76866. /**
  76867. * Gets the label to display
  76868. */
  76869. label: string;
  76870. /**
  76871. * Gets the name of the property to edit
  76872. */
  76873. propertyName: string;
  76874. /**
  76875. * Gets the type of the editor to use
  76876. */
  76877. type: InspectableType;
  76878. /**
  76879. * Gets the minimum value of the property when using in "slider" mode
  76880. */
  76881. min?: number;
  76882. /**
  76883. * Gets the maximum value of the property when using in "slider" mode
  76884. */
  76885. max?: number;
  76886. /**
  76887. * Gets the setp to use when using in "slider" mode
  76888. */
  76889. step?: number;
  76890. }
  76891. }
  76892. declare module BABYLON {
  76893. /**
  76894. * Class used to provide helper for timing
  76895. */
  76896. export class TimingTools {
  76897. /**
  76898. * Polyfill for setImmediate
  76899. * @param action defines the action to execute after the current execution block
  76900. */
  76901. static SetImmediate(action: () => void): void;
  76902. }
  76903. }
  76904. declare module BABYLON {
  76905. /**
  76906. * Class used to enable instatition of objects by class name
  76907. */
  76908. export class InstantiationTools {
  76909. /**
  76910. * Use this object to register external classes like custom textures or material
  76911. * to allow the laoders to instantiate them
  76912. */
  76913. static RegisteredExternalClasses: {
  76914. [key: string]: Object;
  76915. };
  76916. /**
  76917. * Tries to instantiate a new object from a given class name
  76918. * @param className defines the class name to instantiate
  76919. * @returns the new object or null if the system was not able to do the instantiation
  76920. */
  76921. static Instantiate(className: string): any;
  76922. }
  76923. }
  76924. declare module BABYLON {
  76925. /**
  76926. * Define options used to create a depth texture
  76927. */
  76928. export class DepthTextureCreationOptions {
  76929. /** Specifies whether or not a stencil should be allocated in the texture */
  76930. generateStencil?: boolean;
  76931. /** Specifies whether or not bilinear filtering is enable on the texture */
  76932. bilinearFiltering?: boolean;
  76933. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  76934. comparisonFunction?: number;
  76935. /** Specifies if the created texture is a cube texture */
  76936. isCube?: boolean;
  76937. }
  76938. }
  76939. declare module BABYLON {
  76940. interface ThinEngine {
  76941. /**
  76942. * Creates a depth stencil cube texture.
  76943. * This is only available in WebGL 2.
  76944. * @param size The size of face edge in the cube texture.
  76945. * @param options The options defining the cube texture.
  76946. * @returns The cube texture
  76947. */
  76948. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  76949. /**
  76950. * Creates a cube texture
  76951. * @param rootUrl defines the url where the files to load is located
  76952. * @param scene defines the current scene
  76953. * @param files defines the list of files to load (1 per face)
  76954. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76955. * @param onLoad defines an optional callback raised when the texture is loaded
  76956. * @param onError defines an optional callback raised if there is an issue to load the texture
  76957. * @param format defines the format of the data
  76958. * @param forcedExtension defines the extension to use to pick the right loader
  76959. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  76960. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76961. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76962. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  76963. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  76964. * @returns the cube texture as an InternalTexture
  76965. */
  76966. 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;
  76967. /**
  76968. * Creates a cube texture
  76969. * @param rootUrl defines the url where the files to load is located
  76970. * @param scene defines the current scene
  76971. * @param files defines the list of files to load (1 per face)
  76972. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76973. * @param onLoad defines an optional callback raised when the texture is loaded
  76974. * @param onError defines an optional callback raised if there is an issue to load the texture
  76975. * @param format defines the format of the data
  76976. * @param forcedExtension defines the extension to use to pick the right loader
  76977. * @returns the cube texture as an InternalTexture
  76978. */
  76979. 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;
  76980. /**
  76981. * Creates a cube texture
  76982. * @param rootUrl defines the url where the files to load is located
  76983. * @param scene defines the current scene
  76984. * @param files defines the list of files to load (1 per face)
  76985. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76986. * @param onLoad defines an optional callback raised when the texture is loaded
  76987. * @param onError defines an optional callback raised if there is an issue to load the texture
  76988. * @param format defines the format of the data
  76989. * @param forcedExtension defines the extension to use to pick the right loader
  76990. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  76991. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76992. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76993. * @returns the cube texture as an InternalTexture
  76994. */
  76995. 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;
  76996. /** @hidden */
  76997. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  76998. /** @hidden */
  76999. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  77000. /** @hidden */
  77001. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  77002. /** @hidden */
  77003. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  77004. /**
  77005. * @hidden
  77006. */
  77007. _setCubeMapTextureParams(loadMipmap: boolean): void;
  77008. }
  77009. }
  77010. declare module BABYLON {
  77011. /**
  77012. * Class for creating a cube texture
  77013. */
  77014. export class CubeTexture extends BaseTexture {
  77015. private _delayedOnLoad;
  77016. /**
  77017. * The url of the texture
  77018. */
  77019. url: string;
  77020. /**
  77021. * Gets or sets the center of the bounding box associated with the cube texture.
  77022. * It must define where the camera used to render the texture was set
  77023. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  77024. */
  77025. boundingBoxPosition: Vector3;
  77026. private _boundingBoxSize;
  77027. /**
  77028. * Gets or sets the size of the bounding box associated with the cube texture
  77029. * When defined, the cubemap will switch to local mode
  77030. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  77031. * @example https://www.babylonjs-playground.com/#RNASML
  77032. */
  77033. /**
  77034. * Returns the bounding box size
  77035. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  77036. */
  77037. boundingBoxSize: Vector3;
  77038. protected _rotationY: number;
  77039. /**
  77040. * Sets texture matrix rotation angle around Y axis in radians.
  77041. */
  77042. /**
  77043. * Gets texture matrix rotation angle around Y axis radians.
  77044. */
  77045. rotationY: number;
  77046. /**
  77047. * Are mip maps generated for this texture or not.
  77048. */
  77049. readonly noMipmap: boolean;
  77050. private _noMipmap;
  77051. private _files;
  77052. protected _forcedExtension: Nullable<string>;
  77053. private _extensions;
  77054. private _textureMatrix;
  77055. private _format;
  77056. private _createPolynomials;
  77057. /** @hidden */
  77058. _prefiltered: boolean;
  77059. /**
  77060. * Creates a cube texture from an array of image urls
  77061. * @param files defines an array of image urls
  77062. * @param scene defines the hosting scene
  77063. * @param noMipmap specifies if mip maps are not used
  77064. * @returns a cube texture
  77065. */
  77066. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  77067. /**
  77068. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  77069. * @param url defines the url of the prefiltered texture
  77070. * @param scene defines the scene the texture is attached to
  77071. * @param forcedExtension defines the extension of the file if different from the url
  77072. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  77073. * @return the prefiltered texture
  77074. */
  77075. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  77076. /**
  77077. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  77078. * as prefiltered data.
  77079. * @param rootUrl defines the url of the texture or the root name of the six images
  77080. * @param scene defines the scene the texture is attached to
  77081. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  77082. * @param noMipmap defines if mipmaps should be created or not
  77083. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  77084. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  77085. * @param onError defines a callback triggered in case of error during load
  77086. * @param format defines the internal format to use for the texture once loaded
  77087. * @param prefiltered defines whether or not the texture is created from prefiltered data
  77088. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  77089. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  77090. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  77091. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  77092. * @return the cube texture
  77093. */
  77094. 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);
  77095. /**
  77096. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  77097. */
  77098. readonly isPrefiltered: boolean;
  77099. /**
  77100. * Get the current class name of the texture useful for serialization or dynamic coding.
  77101. * @returns "CubeTexture"
  77102. */
  77103. getClassName(): string;
  77104. /**
  77105. * Update the url (and optional buffer) of this texture if url was null during construction.
  77106. * @param url the url of the texture
  77107. * @param forcedExtension defines the extension to use
  77108. * @param onLoad callback called when the texture is loaded (defaults to null)
  77109. */
  77110. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  77111. /**
  77112. * Delays loading of the cube texture
  77113. * @param forcedExtension defines the extension to use
  77114. */
  77115. delayLoad(forcedExtension?: string): void;
  77116. /**
  77117. * Returns the reflection texture matrix
  77118. * @returns the reflection texture matrix
  77119. */
  77120. getReflectionTextureMatrix(): Matrix;
  77121. /**
  77122. * Sets the reflection texture matrix
  77123. * @param value Reflection texture matrix
  77124. */
  77125. setReflectionTextureMatrix(value: Matrix): void;
  77126. /**
  77127. * Parses text to create a cube texture
  77128. * @param parsedTexture define the serialized text to read from
  77129. * @param scene defines the hosting scene
  77130. * @param rootUrl defines the root url of the cube texture
  77131. * @returns a cube texture
  77132. */
  77133. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  77134. /**
  77135. * Makes a clone, or deep copy, of the cube texture
  77136. * @returns a new cube texture
  77137. */
  77138. clone(): CubeTexture;
  77139. }
  77140. }
  77141. declare module BABYLON {
  77142. /**
  77143. * Manages the defines for the Material
  77144. */
  77145. export class MaterialDefines {
  77146. /** @hidden */
  77147. protected _keys: string[];
  77148. private _isDirty;
  77149. /** @hidden */
  77150. _renderId: number;
  77151. /** @hidden */
  77152. _areLightsDirty: boolean;
  77153. /** @hidden */
  77154. _areLightsDisposed: boolean;
  77155. /** @hidden */
  77156. _areAttributesDirty: boolean;
  77157. /** @hidden */
  77158. _areTexturesDirty: boolean;
  77159. /** @hidden */
  77160. _areFresnelDirty: boolean;
  77161. /** @hidden */
  77162. _areMiscDirty: boolean;
  77163. /** @hidden */
  77164. _areImageProcessingDirty: boolean;
  77165. /** @hidden */
  77166. _normals: boolean;
  77167. /** @hidden */
  77168. _uvs: boolean;
  77169. /** @hidden */
  77170. _needNormals: boolean;
  77171. /** @hidden */
  77172. _needUVs: boolean;
  77173. [id: string]: any;
  77174. /**
  77175. * Specifies if the material needs to be re-calculated
  77176. */
  77177. readonly isDirty: boolean;
  77178. /**
  77179. * Marks the material to indicate that it has been re-calculated
  77180. */
  77181. markAsProcessed(): void;
  77182. /**
  77183. * Marks the material to indicate that it needs to be re-calculated
  77184. */
  77185. markAsUnprocessed(): void;
  77186. /**
  77187. * Marks the material to indicate all of its defines need to be re-calculated
  77188. */
  77189. markAllAsDirty(): void;
  77190. /**
  77191. * Marks the material to indicate that image processing needs to be re-calculated
  77192. */
  77193. markAsImageProcessingDirty(): void;
  77194. /**
  77195. * Marks the material to indicate the lights need to be re-calculated
  77196. * @param disposed Defines whether the light is dirty due to dispose or not
  77197. */
  77198. markAsLightDirty(disposed?: boolean): void;
  77199. /**
  77200. * Marks the attribute state as changed
  77201. */
  77202. markAsAttributesDirty(): void;
  77203. /**
  77204. * Marks the texture state as changed
  77205. */
  77206. markAsTexturesDirty(): void;
  77207. /**
  77208. * Marks the fresnel state as changed
  77209. */
  77210. markAsFresnelDirty(): void;
  77211. /**
  77212. * Marks the misc state as changed
  77213. */
  77214. markAsMiscDirty(): void;
  77215. /**
  77216. * Rebuilds the material defines
  77217. */
  77218. rebuild(): void;
  77219. /**
  77220. * Specifies if two material defines are equal
  77221. * @param other - A material define instance to compare to
  77222. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  77223. */
  77224. isEqual(other: MaterialDefines): boolean;
  77225. /**
  77226. * Clones this instance's defines to another instance
  77227. * @param other - material defines to clone values to
  77228. */
  77229. cloneTo(other: MaterialDefines): void;
  77230. /**
  77231. * Resets the material define values
  77232. */
  77233. reset(): void;
  77234. /**
  77235. * Converts the material define values to a string
  77236. * @returns - String of material define information
  77237. */
  77238. toString(): string;
  77239. }
  77240. }
  77241. declare module BABYLON {
  77242. /**
  77243. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  77244. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  77245. * 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;
  77246. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  77247. */
  77248. export class ColorCurves {
  77249. private _dirty;
  77250. private _tempColor;
  77251. private _globalCurve;
  77252. private _highlightsCurve;
  77253. private _midtonesCurve;
  77254. private _shadowsCurve;
  77255. private _positiveCurve;
  77256. private _negativeCurve;
  77257. private _globalHue;
  77258. private _globalDensity;
  77259. private _globalSaturation;
  77260. private _globalExposure;
  77261. /**
  77262. * Gets the global Hue value.
  77263. * 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).
  77264. */
  77265. /**
  77266. * Sets the global Hue value.
  77267. * 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).
  77268. */
  77269. globalHue: number;
  77270. /**
  77271. * Gets the global Density value.
  77272. * 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.
  77273. * Values less than zero provide a filter of opposite hue.
  77274. */
  77275. /**
  77276. * Sets the global Density value.
  77277. * 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.
  77278. * Values less than zero provide a filter of opposite hue.
  77279. */
  77280. globalDensity: number;
  77281. /**
  77282. * Gets the global Saturation value.
  77283. * 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.
  77284. */
  77285. /**
  77286. * Sets the global Saturation value.
  77287. * 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.
  77288. */
  77289. globalSaturation: number;
  77290. /**
  77291. * Gets the global Exposure value.
  77292. * 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.
  77293. */
  77294. /**
  77295. * Sets the global Exposure value.
  77296. * 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.
  77297. */
  77298. globalExposure: number;
  77299. private _highlightsHue;
  77300. private _highlightsDensity;
  77301. private _highlightsSaturation;
  77302. private _highlightsExposure;
  77303. /**
  77304. * Gets the highlights Hue value.
  77305. * 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).
  77306. */
  77307. /**
  77308. * Sets the highlights Hue value.
  77309. * 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).
  77310. */
  77311. highlightsHue: number;
  77312. /**
  77313. * Gets the highlights Density value.
  77314. * 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.
  77315. * Values less than zero provide a filter of opposite hue.
  77316. */
  77317. /**
  77318. * Sets the highlights Density value.
  77319. * 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.
  77320. * Values less than zero provide a filter of opposite hue.
  77321. */
  77322. highlightsDensity: number;
  77323. /**
  77324. * Gets the highlights Saturation value.
  77325. * 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.
  77326. */
  77327. /**
  77328. * Sets the highlights Saturation value.
  77329. * 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.
  77330. */
  77331. highlightsSaturation: number;
  77332. /**
  77333. * Gets the highlights Exposure value.
  77334. * 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.
  77335. */
  77336. /**
  77337. * Sets the highlights Exposure value.
  77338. * 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.
  77339. */
  77340. highlightsExposure: number;
  77341. private _midtonesHue;
  77342. private _midtonesDensity;
  77343. private _midtonesSaturation;
  77344. private _midtonesExposure;
  77345. /**
  77346. * Gets the midtones Hue value.
  77347. * 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).
  77348. */
  77349. /**
  77350. * Sets the midtones Hue value.
  77351. * 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).
  77352. */
  77353. midtonesHue: number;
  77354. /**
  77355. * Gets the midtones Density value.
  77356. * 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.
  77357. * Values less than zero provide a filter of opposite hue.
  77358. */
  77359. /**
  77360. * Sets the midtones Density value.
  77361. * 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.
  77362. * Values less than zero provide a filter of opposite hue.
  77363. */
  77364. midtonesDensity: number;
  77365. /**
  77366. * Gets the midtones Saturation value.
  77367. * 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.
  77368. */
  77369. /**
  77370. * Sets the midtones Saturation value.
  77371. * 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.
  77372. */
  77373. midtonesSaturation: number;
  77374. /**
  77375. * Gets the midtones Exposure value.
  77376. * 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.
  77377. */
  77378. /**
  77379. * Sets the midtones Exposure value.
  77380. * 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.
  77381. */
  77382. midtonesExposure: number;
  77383. private _shadowsHue;
  77384. private _shadowsDensity;
  77385. private _shadowsSaturation;
  77386. private _shadowsExposure;
  77387. /**
  77388. * Gets the shadows Hue value.
  77389. * 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).
  77390. */
  77391. /**
  77392. * Sets the shadows Hue value.
  77393. * 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).
  77394. */
  77395. shadowsHue: number;
  77396. /**
  77397. * Gets the shadows Density value.
  77398. * 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.
  77399. * Values less than zero provide a filter of opposite hue.
  77400. */
  77401. /**
  77402. * Sets the shadows Density value.
  77403. * 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.
  77404. * Values less than zero provide a filter of opposite hue.
  77405. */
  77406. shadowsDensity: number;
  77407. /**
  77408. * Gets the shadows Saturation value.
  77409. * 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.
  77410. */
  77411. /**
  77412. * Sets the shadows Saturation value.
  77413. * 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.
  77414. */
  77415. shadowsSaturation: number;
  77416. /**
  77417. * Gets the shadows Exposure value.
  77418. * 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.
  77419. */
  77420. /**
  77421. * Sets the shadows Exposure value.
  77422. * 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.
  77423. */
  77424. shadowsExposure: number;
  77425. /**
  77426. * Returns the class name
  77427. * @returns The class name
  77428. */
  77429. getClassName(): string;
  77430. /**
  77431. * Binds the color curves to the shader.
  77432. * @param colorCurves The color curve to bind
  77433. * @param effect The effect to bind to
  77434. * @param positiveUniform The positive uniform shader parameter
  77435. * @param neutralUniform The neutral uniform shader parameter
  77436. * @param negativeUniform The negative uniform shader parameter
  77437. */
  77438. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  77439. /**
  77440. * Prepare the list of uniforms associated with the ColorCurves effects.
  77441. * @param uniformsList The list of uniforms used in the effect
  77442. */
  77443. static PrepareUniforms(uniformsList: string[]): void;
  77444. /**
  77445. * Returns color grading data based on a hue, density, saturation and exposure value.
  77446. * @param filterHue The hue of the color filter.
  77447. * @param filterDensity The density of the color filter.
  77448. * @param saturation The saturation.
  77449. * @param exposure The exposure.
  77450. * @param result The result data container.
  77451. */
  77452. private getColorGradingDataToRef;
  77453. /**
  77454. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  77455. * @param value The input slider value in range [-100,100].
  77456. * @returns Adjusted value.
  77457. */
  77458. private static applyColorGradingSliderNonlinear;
  77459. /**
  77460. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  77461. * @param hue The hue (H) input.
  77462. * @param saturation The saturation (S) input.
  77463. * @param brightness The brightness (B) input.
  77464. * @result An RGBA color represented as Vector4.
  77465. */
  77466. private static fromHSBToRef;
  77467. /**
  77468. * Returns a value clamped between min and max
  77469. * @param value The value to clamp
  77470. * @param min The minimum of value
  77471. * @param max The maximum of value
  77472. * @returns The clamped value.
  77473. */
  77474. private static clamp;
  77475. /**
  77476. * Clones the current color curve instance.
  77477. * @return The cloned curves
  77478. */
  77479. clone(): ColorCurves;
  77480. /**
  77481. * Serializes the current color curve instance to a json representation.
  77482. * @return a JSON representation
  77483. */
  77484. serialize(): any;
  77485. /**
  77486. * Parses the color curve from a json representation.
  77487. * @param source the JSON source to parse
  77488. * @return The parsed curves
  77489. */
  77490. static Parse(source: any): ColorCurves;
  77491. }
  77492. }
  77493. declare module BABYLON {
  77494. /**
  77495. * Interface to follow in your material defines to integrate easily the
  77496. * Image proccessing functions.
  77497. * @hidden
  77498. */
  77499. export interface IImageProcessingConfigurationDefines {
  77500. IMAGEPROCESSING: boolean;
  77501. VIGNETTE: boolean;
  77502. VIGNETTEBLENDMODEMULTIPLY: boolean;
  77503. VIGNETTEBLENDMODEOPAQUE: boolean;
  77504. TONEMAPPING: boolean;
  77505. TONEMAPPING_ACES: boolean;
  77506. CONTRAST: boolean;
  77507. EXPOSURE: boolean;
  77508. COLORCURVES: boolean;
  77509. COLORGRADING: boolean;
  77510. COLORGRADING3D: boolean;
  77511. SAMPLER3DGREENDEPTH: boolean;
  77512. SAMPLER3DBGRMAP: boolean;
  77513. IMAGEPROCESSINGPOSTPROCESS: boolean;
  77514. }
  77515. /**
  77516. * @hidden
  77517. */
  77518. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  77519. IMAGEPROCESSING: boolean;
  77520. VIGNETTE: boolean;
  77521. VIGNETTEBLENDMODEMULTIPLY: boolean;
  77522. VIGNETTEBLENDMODEOPAQUE: boolean;
  77523. TONEMAPPING: boolean;
  77524. TONEMAPPING_ACES: boolean;
  77525. CONTRAST: boolean;
  77526. COLORCURVES: boolean;
  77527. COLORGRADING: boolean;
  77528. COLORGRADING3D: boolean;
  77529. SAMPLER3DGREENDEPTH: boolean;
  77530. SAMPLER3DBGRMAP: boolean;
  77531. IMAGEPROCESSINGPOSTPROCESS: boolean;
  77532. EXPOSURE: boolean;
  77533. constructor();
  77534. }
  77535. /**
  77536. * This groups together the common properties used for image processing either in direct forward pass
  77537. * or through post processing effect depending on the use of the image processing pipeline in your scene
  77538. * or not.
  77539. */
  77540. export class ImageProcessingConfiguration {
  77541. /**
  77542. * Default tone mapping applied in BabylonJS.
  77543. */
  77544. static readonly TONEMAPPING_STANDARD: number;
  77545. /**
  77546. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  77547. * to other engines rendering to increase portability.
  77548. */
  77549. static readonly TONEMAPPING_ACES: number;
  77550. /**
  77551. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  77552. */
  77553. colorCurves: Nullable<ColorCurves>;
  77554. private _colorCurvesEnabled;
  77555. /**
  77556. * Gets wether the color curves effect is enabled.
  77557. */
  77558. /**
  77559. * Sets wether the color curves effect is enabled.
  77560. */
  77561. colorCurvesEnabled: boolean;
  77562. private _colorGradingTexture;
  77563. /**
  77564. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  77565. */
  77566. /**
  77567. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  77568. */
  77569. colorGradingTexture: Nullable<BaseTexture>;
  77570. private _colorGradingEnabled;
  77571. /**
  77572. * Gets wether the color grading effect is enabled.
  77573. */
  77574. /**
  77575. * Sets wether the color grading effect is enabled.
  77576. */
  77577. colorGradingEnabled: boolean;
  77578. private _colorGradingWithGreenDepth;
  77579. /**
  77580. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  77581. */
  77582. /**
  77583. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  77584. */
  77585. colorGradingWithGreenDepth: boolean;
  77586. private _colorGradingBGR;
  77587. /**
  77588. * Gets wether the color grading texture contains BGR values.
  77589. */
  77590. /**
  77591. * Sets wether the color grading texture contains BGR values.
  77592. */
  77593. colorGradingBGR: boolean;
  77594. /** @hidden */
  77595. _exposure: number;
  77596. /**
  77597. * Gets the Exposure used in the effect.
  77598. */
  77599. /**
  77600. * Sets the Exposure used in the effect.
  77601. */
  77602. exposure: number;
  77603. private _toneMappingEnabled;
  77604. /**
  77605. * Gets wether the tone mapping effect is enabled.
  77606. */
  77607. /**
  77608. * Sets wether the tone mapping effect is enabled.
  77609. */
  77610. toneMappingEnabled: boolean;
  77611. private _toneMappingType;
  77612. /**
  77613. * Gets the type of tone mapping effect.
  77614. */
  77615. /**
  77616. * Sets the type of tone mapping effect used in BabylonJS.
  77617. */
  77618. toneMappingType: number;
  77619. protected _contrast: number;
  77620. /**
  77621. * Gets the contrast used in the effect.
  77622. */
  77623. /**
  77624. * Sets the contrast used in the effect.
  77625. */
  77626. contrast: number;
  77627. /**
  77628. * Vignette stretch size.
  77629. */
  77630. vignetteStretch: number;
  77631. /**
  77632. * Vignette centre X Offset.
  77633. */
  77634. vignetteCentreX: number;
  77635. /**
  77636. * Vignette centre Y Offset.
  77637. */
  77638. vignetteCentreY: number;
  77639. /**
  77640. * Vignette weight or intensity of the vignette effect.
  77641. */
  77642. vignetteWeight: number;
  77643. /**
  77644. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  77645. * if vignetteEnabled is set to true.
  77646. */
  77647. vignetteColor: Color4;
  77648. /**
  77649. * Camera field of view used by the Vignette effect.
  77650. */
  77651. vignetteCameraFov: number;
  77652. private _vignetteBlendMode;
  77653. /**
  77654. * Gets the vignette blend mode allowing different kind of effect.
  77655. */
  77656. /**
  77657. * Sets the vignette blend mode allowing different kind of effect.
  77658. */
  77659. vignetteBlendMode: number;
  77660. private _vignetteEnabled;
  77661. /**
  77662. * Gets wether the vignette effect is enabled.
  77663. */
  77664. /**
  77665. * Sets wether the vignette effect is enabled.
  77666. */
  77667. vignetteEnabled: boolean;
  77668. private _applyByPostProcess;
  77669. /**
  77670. * Gets wether the image processing is applied through a post process or not.
  77671. */
  77672. /**
  77673. * Sets wether the image processing is applied through a post process or not.
  77674. */
  77675. applyByPostProcess: boolean;
  77676. private _isEnabled;
  77677. /**
  77678. * Gets wether the image processing is enabled or not.
  77679. */
  77680. /**
  77681. * Sets wether the image processing is enabled or not.
  77682. */
  77683. isEnabled: boolean;
  77684. /**
  77685. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  77686. */
  77687. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  77688. /**
  77689. * Method called each time the image processing information changes requires to recompile the effect.
  77690. */
  77691. protected _updateParameters(): void;
  77692. /**
  77693. * Gets the current class name.
  77694. * @return "ImageProcessingConfiguration"
  77695. */
  77696. getClassName(): string;
  77697. /**
  77698. * Prepare the list of uniforms associated with the Image Processing effects.
  77699. * @param uniforms The list of uniforms used in the effect
  77700. * @param defines the list of defines currently in use
  77701. */
  77702. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  77703. /**
  77704. * Prepare the list of samplers associated with the Image Processing effects.
  77705. * @param samplersList The list of uniforms used in the effect
  77706. * @param defines the list of defines currently in use
  77707. */
  77708. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  77709. /**
  77710. * Prepare the list of defines associated to the shader.
  77711. * @param defines the list of defines to complete
  77712. * @param forPostProcess Define if we are currently in post process mode or not
  77713. */
  77714. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  77715. /**
  77716. * Returns true if all the image processing information are ready.
  77717. * @returns True if ready, otherwise, false
  77718. */
  77719. isReady(): boolean;
  77720. /**
  77721. * Binds the image processing to the shader.
  77722. * @param effect The effect to bind to
  77723. * @param overrideAspectRatio Override the aspect ratio of the effect
  77724. */
  77725. bind(effect: Effect, overrideAspectRatio?: number): void;
  77726. /**
  77727. * Clones the current image processing instance.
  77728. * @return The cloned image processing
  77729. */
  77730. clone(): ImageProcessingConfiguration;
  77731. /**
  77732. * Serializes the current image processing instance to a json representation.
  77733. * @return a JSON representation
  77734. */
  77735. serialize(): any;
  77736. /**
  77737. * Parses the image processing from a json representation.
  77738. * @param source the JSON source to parse
  77739. * @return The parsed image processing
  77740. */
  77741. static Parse(source: any): ImageProcessingConfiguration;
  77742. private static _VIGNETTEMODE_MULTIPLY;
  77743. private static _VIGNETTEMODE_OPAQUE;
  77744. /**
  77745. * Used to apply the vignette as a mix with the pixel color.
  77746. */
  77747. static readonly VIGNETTEMODE_MULTIPLY: number;
  77748. /**
  77749. * Used to apply the vignette as a replacement of the pixel color.
  77750. */
  77751. static readonly VIGNETTEMODE_OPAQUE: number;
  77752. }
  77753. }
  77754. declare module BABYLON {
  77755. /** @hidden */
  77756. export var postprocessVertexShader: {
  77757. name: string;
  77758. shader: string;
  77759. };
  77760. }
  77761. declare module BABYLON {
  77762. interface ThinEngine {
  77763. /**
  77764. * Creates a new render target texture
  77765. * @param size defines the size of the texture
  77766. * @param options defines the options used to create the texture
  77767. * @returns a new render target texture stored in an InternalTexture
  77768. */
  77769. createRenderTargetTexture(size: number | {
  77770. width: number;
  77771. height: number;
  77772. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  77773. /**
  77774. * Creates a depth stencil texture.
  77775. * This is only available in WebGL 2 or with the depth texture extension available.
  77776. * @param size The size of face edge in the texture.
  77777. * @param options The options defining the texture.
  77778. * @returns The texture
  77779. */
  77780. createDepthStencilTexture(size: number | {
  77781. width: number;
  77782. height: number;
  77783. }, options: DepthTextureCreationOptions): InternalTexture;
  77784. /** @hidden */
  77785. _createDepthStencilTexture(size: number | {
  77786. width: number;
  77787. height: number;
  77788. }, options: DepthTextureCreationOptions): InternalTexture;
  77789. }
  77790. }
  77791. declare module BABYLON {
  77792. /** Defines supported spaces */
  77793. export enum Space {
  77794. /** Local (object) space */
  77795. LOCAL = 0,
  77796. /** World space */
  77797. WORLD = 1,
  77798. /** Bone space */
  77799. BONE = 2
  77800. }
  77801. /** Defines the 3 main axes */
  77802. export class Axis {
  77803. /** X axis */
  77804. static X: Vector3;
  77805. /** Y axis */
  77806. static Y: Vector3;
  77807. /** Z axis */
  77808. static Z: Vector3;
  77809. }
  77810. }
  77811. declare module BABYLON {
  77812. /**
  77813. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  77814. * This is the base of the follow, arc rotate cameras and Free camera
  77815. * @see http://doc.babylonjs.com/features/cameras
  77816. */
  77817. export class TargetCamera extends Camera {
  77818. private static _RigCamTransformMatrix;
  77819. private static _TargetTransformMatrix;
  77820. private static _TargetFocalPoint;
  77821. /**
  77822. * Define the current direction the camera is moving to
  77823. */
  77824. cameraDirection: Vector3;
  77825. /**
  77826. * Define the current rotation the camera is rotating to
  77827. */
  77828. cameraRotation: Vector2;
  77829. /**
  77830. * When set, the up vector of the camera will be updated by the rotation of the camera
  77831. */
  77832. updateUpVectorFromRotation: boolean;
  77833. private _tmpQuaternion;
  77834. /**
  77835. * Define the current rotation of the camera
  77836. */
  77837. rotation: Vector3;
  77838. /**
  77839. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  77840. */
  77841. rotationQuaternion: Quaternion;
  77842. /**
  77843. * Define the current speed of the camera
  77844. */
  77845. speed: number;
  77846. /**
  77847. * Add constraint to the camera to prevent it to move freely in all directions and
  77848. * around all axis.
  77849. */
  77850. noRotationConstraint: boolean;
  77851. /**
  77852. * Define the current target of the camera as an object or a position.
  77853. */
  77854. lockedTarget: any;
  77855. /** @hidden */
  77856. _currentTarget: Vector3;
  77857. /** @hidden */
  77858. _initialFocalDistance: number;
  77859. /** @hidden */
  77860. _viewMatrix: Matrix;
  77861. /** @hidden */
  77862. _camMatrix: Matrix;
  77863. /** @hidden */
  77864. _cameraTransformMatrix: Matrix;
  77865. /** @hidden */
  77866. _cameraRotationMatrix: Matrix;
  77867. /** @hidden */
  77868. _referencePoint: Vector3;
  77869. /** @hidden */
  77870. _transformedReferencePoint: Vector3;
  77871. protected _globalCurrentTarget: Vector3;
  77872. protected _globalCurrentUpVector: Vector3;
  77873. /** @hidden */
  77874. _reset: () => void;
  77875. private _defaultUp;
  77876. /**
  77877. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  77878. * This is the base of the follow, arc rotate cameras and Free camera
  77879. * @see http://doc.babylonjs.com/features/cameras
  77880. * @param name Defines the name of the camera in the scene
  77881. * @param position Defines the start position of the camera in the scene
  77882. * @param scene Defines the scene the camera belongs to
  77883. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  77884. */
  77885. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  77886. /**
  77887. * Gets the position in front of the camera at a given distance.
  77888. * @param distance The distance from the camera we want the position to be
  77889. * @returns the position
  77890. */
  77891. getFrontPosition(distance: number): Vector3;
  77892. /** @hidden */
  77893. _getLockedTargetPosition(): Nullable<Vector3>;
  77894. private _storedPosition;
  77895. private _storedRotation;
  77896. private _storedRotationQuaternion;
  77897. /**
  77898. * Store current camera state of the camera (fov, position, rotation, etc..)
  77899. * @returns the camera
  77900. */
  77901. storeState(): Camera;
  77902. /**
  77903. * Restored camera state. You must call storeState() first
  77904. * @returns whether it was successful or not
  77905. * @hidden
  77906. */
  77907. _restoreStateValues(): boolean;
  77908. /** @hidden */
  77909. _initCache(): void;
  77910. /** @hidden */
  77911. _updateCache(ignoreParentClass?: boolean): void;
  77912. /** @hidden */
  77913. _isSynchronizedViewMatrix(): boolean;
  77914. /** @hidden */
  77915. _computeLocalCameraSpeed(): number;
  77916. /**
  77917. * Defines the target the camera should look at.
  77918. * @param target Defines the new target as a Vector or a mesh
  77919. */
  77920. setTarget(target: Vector3): void;
  77921. /**
  77922. * Return the current target position of the camera. This value is expressed in local space.
  77923. * @returns the target position
  77924. */
  77925. getTarget(): Vector3;
  77926. /** @hidden */
  77927. _decideIfNeedsToMove(): boolean;
  77928. /** @hidden */
  77929. _updatePosition(): void;
  77930. /** @hidden */
  77931. _checkInputs(): void;
  77932. protected _updateCameraRotationMatrix(): void;
  77933. /**
  77934. * 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)
  77935. * @returns the current camera
  77936. */
  77937. private _rotateUpVectorWithCameraRotationMatrix;
  77938. private _cachedRotationZ;
  77939. private _cachedQuaternionRotationZ;
  77940. /** @hidden */
  77941. _getViewMatrix(): Matrix;
  77942. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  77943. /**
  77944. * @hidden
  77945. */
  77946. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  77947. /**
  77948. * @hidden
  77949. */
  77950. _updateRigCameras(): void;
  77951. private _getRigCamPositionAndTarget;
  77952. /**
  77953. * Gets the current object class name.
  77954. * @return the class name
  77955. */
  77956. getClassName(): string;
  77957. }
  77958. }
  77959. declare module BABYLON {
  77960. /**
  77961. * Gather the list of keyboard event types as constants.
  77962. */
  77963. export class KeyboardEventTypes {
  77964. /**
  77965. * The keydown event is fired when a key becomes active (pressed).
  77966. */
  77967. static readonly KEYDOWN: number;
  77968. /**
  77969. * The keyup event is fired when a key has been released.
  77970. */
  77971. static readonly KEYUP: number;
  77972. }
  77973. /**
  77974. * This class is used to store keyboard related info for the onKeyboardObservable event.
  77975. */
  77976. export class KeyboardInfo {
  77977. /**
  77978. * Defines the type of event (KeyboardEventTypes)
  77979. */
  77980. type: number;
  77981. /**
  77982. * Defines the related dom event
  77983. */
  77984. event: KeyboardEvent;
  77985. /**
  77986. * Instantiates a new keyboard info.
  77987. * This class is used to store keyboard related info for the onKeyboardObservable event.
  77988. * @param type Defines the type of event (KeyboardEventTypes)
  77989. * @param event Defines the related dom event
  77990. */
  77991. constructor(
  77992. /**
  77993. * Defines the type of event (KeyboardEventTypes)
  77994. */
  77995. type: number,
  77996. /**
  77997. * Defines the related dom event
  77998. */
  77999. event: KeyboardEvent);
  78000. }
  78001. /**
  78002. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  78003. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  78004. */
  78005. export class KeyboardInfoPre extends KeyboardInfo {
  78006. /**
  78007. * Defines the type of event (KeyboardEventTypes)
  78008. */
  78009. type: number;
  78010. /**
  78011. * Defines the related dom event
  78012. */
  78013. event: KeyboardEvent;
  78014. /**
  78015. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  78016. */
  78017. skipOnPointerObservable: boolean;
  78018. /**
  78019. * Instantiates a new keyboard pre info.
  78020. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  78021. * @param type Defines the type of event (KeyboardEventTypes)
  78022. * @param event Defines the related dom event
  78023. */
  78024. constructor(
  78025. /**
  78026. * Defines the type of event (KeyboardEventTypes)
  78027. */
  78028. type: number,
  78029. /**
  78030. * Defines the related dom event
  78031. */
  78032. event: KeyboardEvent);
  78033. }
  78034. }
  78035. declare module BABYLON {
  78036. /**
  78037. * Manage the keyboard inputs to control the movement of a free camera.
  78038. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78039. */
  78040. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  78041. /**
  78042. * Defines the camera the input is attached to.
  78043. */
  78044. camera: FreeCamera;
  78045. /**
  78046. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  78047. */
  78048. keysUp: number[];
  78049. /**
  78050. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  78051. */
  78052. keysDown: number[];
  78053. /**
  78054. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  78055. */
  78056. keysLeft: number[];
  78057. /**
  78058. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  78059. */
  78060. keysRight: number[];
  78061. private _keys;
  78062. private _onCanvasBlurObserver;
  78063. private _onKeyboardObserver;
  78064. private _engine;
  78065. private _scene;
  78066. /**
  78067. * Attach the input controls to a specific dom element to get the input from.
  78068. * @param element Defines the element the controls should be listened from
  78069. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78070. */
  78071. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78072. /**
  78073. * Detach the current controls from the specified dom element.
  78074. * @param element Defines the element to stop listening the inputs from
  78075. */
  78076. detachControl(element: Nullable<HTMLElement>): void;
  78077. /**
  78078. * Update the current camera state depending on the inputs that have been used this frame.
  78079. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78080. */
  78081. checkInputs(): void;
  78082. /**
  78083. * Gets the class name of the current intput.
  78084. * @returns the class name
  78085. */
  78086. getClassName(): string;
  78087. /** @hidden */
  78088. _onLostFocus(): void;
  78089. /**
  78090. * Get the friendly name associated with the input class.
  78091. * @returns the input friendly name
  78092. */
  78093. getSimpleName(): string;
  78094. }
  78095. }
  78096. declare module BABYLON {
  78097. /**
  78098. * Interface describing all the common properties and methods a shadow light needs to implement.
  78099. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  78100. * as well as binding the different shadow properties to the effects.
  78101. */
  78102. export interface IShadowLight extends Light {
  78103. /**
  78104. * The light id in the scene (used in scene.findLighById for instance)
  78105. */
  78106. id: string;
  78107. /**
  78108. * The position the shdow will be casted from.
  78109. */
  78110. position: Vector3;
  78111. /**
  78112. * In 2d mode (needCube being false), the direction used to cast the shadow.
  78113. */
  78114. direction: Vector3;
  78115. /**
  78116. * The transformed position. Position of the light in world space taking parenting in account.
  78117. */
  78118. transformedPosition: Vector3;
  78119. /**
  78120. * The transformed direction. Direction of the light in world space taking parenting in account.
  78121. */
  78122. transformedDirection: Vector3;
  78123. /**
  78124. * The friendly name of the light in the scene.
  78125. */
  78126. name: string;
  78127. /**
  78128. * Defines the shadow projection clipping minimum z value.
  78129. */
  78130. shadowMinZ: number;
  78131. /**
  78132. * Defines the shadow projection clipping maximum z value.
  78133. */
  78134. shadowMaxZ: number;
  78135. /**
  78136. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  78137. * @returns true if the information has been computed, false if it does not need to (no parenting)
  78138. */
  78139. computeTransformedInformation(): boolean;
  78140. /**
  78141. * Gets the scene the light belongs to.
  78142. * @returns The scene
  78143. */
  78144. getScene(): Scene;
  78145. /**
  78146. * Callback defining a custom Projection Matrix Builder.
  78147. * This can be used to override the default projection matrix computation.
  78148. */
  78149. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  78150. /**
  78151. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  78152. * @param matrix The materix to updated with the projection information
  78153. * @param viewMatrix The transform matrix of the light
  78154. * @param renderList The list of mesh to render in the map
  78155. * @returns The current light
  78156. */
  78157. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  78158. /**
  78159. * Gets the current depth scale used in ESM.
  78160. * @returns The scale
  78161. */
  78162. getDepthScale(): number;
  78163. /**
  78164. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  78165. * @returns true if a cube texture needs to be use
  78166. */
  78167. needCube(): boolean;
  78168. /**
  78169. * Detects if the projection matrix requires to be recomputed this frame.
  78170. * @returns true if it requires to be recomputed otherwise, false.
  78171. */
  78172. needProjectionMatrixCompute(): boolean;
  78173. /**
  78174. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  78175. */
  78176. forceProjectionMatrixCompute(): void;
  78177. /**
  78178. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  78179. * @param faceIndex The index of the face we are computed the direction to generate shadow
  78180. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  78181. */
  78182. getShadowDirection(faceIndex?: number): Vector3;
  78183. /**
  78184. * Gets the minZ used for shadow according to both the scene and the light.
  78185. * @param activeCamera The camera we are returning the min for
  78186. * @returns the depth min z
  78187. */
  78188. getDepthMinZ(activeCamera: Camera): number;
  78189. /**
  78190. * Gets the maxZ used for shadow according to both the scene and the light.
  78191. * @param activeCamera The camera we are returning the max for
  78192. * @returns the depth max z
  78193. */
  78194. getDepthMaxZ(activeCamera: Camera): number;
  78195. }
  78196. /**
  78197. * Base implementation IShadowLight
  78198. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  78199. */
  78200. export abstract class ShadowLight extends Light implements IShadowLight {
  78201. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  78202. protected _position: Vector3;
  78203. protected _setPosition(value: Vector3): void;
  78204. /**
  78205. * Sets the position the shadow will be casted from. Also use as the light position for both
  78206. * point and spot lights.
  78207. */
  78208. /**
  78209. * Sets the position the shadow will be casted from. Also use as the light position for both
  78210. * point and spot lights.
  78211. */
  78212. position: Vector3;
  78213. protected _direction: Vector3;
  78214. protected _setDirection(value: Vector3): void;
  78215. /**
  78216. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  78217. * Also use as the light direction on spot and directional lights.
  78218. */
  78219. /**
  78220. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  78221. * Also use as the light direction on spot and directional lights.
  78222. */
  78223. direction: Vector3;
  78224. private _shadowMinZ;
  78225. /**
  78226. * Gets the shadow projection clipping minimum z value.
  78227. */
  78228. /**
  78229. * Sets the shadow projection clipping minimum z value.
  78230. */
  78231. shadowMinZ: number;
  78232. private _shadowMaxZ;
  78233. /**
  78234. * Sets the shadow projection clipping maximum z value.
  78235. */
  78236. /**
  78237. * Gets the shadow projection clipping maximum z value.
  78238. */
  78239. shadowMaxZ: number;
  78240. /**
  78241. * Callback defining a custom Projection Matrix Builder.
  78242. * This can be used to override the default projection matrix computation.
  78243. */
  78244. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  78245. /**
  78246. * The transformed position. Position of the light in world space taking parenting in account.
  78247. */
  78248. transformedPosition: Vector3;
  78249. /**
  78250. * The transformed direction. Direction of the light in world space taking parenting in account.
  78251. */
  78252. transformedDirection: Vector3;
  78253. private _needProjectionMatrixCompute;
  78254. /**
  78255. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  78256. * @returns true if the information has been computed, false if it does not need to (no parenting)
  78257. */
  78258. computeTransformedInformation(): boolean;
  78259. /**
  78260. * Return the depth scale used for the shadow map.
  78261. * @returns the depth scale.
  78262. */
  78263. getDepthScale(): number;
  78264. /**
  78265. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  78266. * @param faceIndex The index of the face we are computed the direction to generate shadow
  78267. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  78268. */
  78269. getShadowDirection(faceIndex?: number): Vector3;
  78270. /**
  78271. * Returns the ShadowLight absolute position in the World.
  78272. * @returns the position vector in world space
  78273. */
  78274. getAbsolutePosition(): Vector3;
  78275. /**
  78276. * Sets the ShadowLight direction toward the passed target.
  78277. * @param target The point to target in local space
  78278. * @returns the updated ShadowLight direction
  78279. */
  78280. setDirectionToTarget(target: Vector3): Vector3;
  78281. /**
  78282. * Returns the light rotation in euler definition.
  78283. * @returns the x y z rotation in local space.
  78284. */
  78285. getRotation(): Vector3;
  78286. /**
  78287. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  78288. * @returns true if a cube texture needs to be use
  78289. */
  78290. needCube(): boolean;
  78291. /**
  78292. * Detects if the projection matrix requires to be recomputed this frame.
  78293. * @returns true if it requires to be recomputed otherwise, false.
  78294. */
  78295. needProjectionMatrixCompute(): boolean;
  78296. /**
  78297. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  78298. */
  78299. forceProjectionMatrixCompute(): void;
  78300. /** @hidden */
  78301. _initCache(): void;
  78302. /** @hidden */
  78303. _isSynchronized(): boolean;
  78304. /**
  78305. * Computes the world matrix of the node
  78306. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  78307. * @returns the world matrix
  78308. */
  78309. computeWorldMatrix(force?: boolean): Matrix;
  78310. /**
  78311. * Gets the minZ used for shadow according to both the scene and the light.
  78312. * @param activeCamera The camera we are returning the min for
  78313. * @returns the depth min z
  78314. */
  78315. getDepthMinZ(activeCamera: Camera): number;
  78316. /**
  78317. * Gets the maxZ used for shadow according to both the scene and the light.
  78318. * @param activeCamera The camera we are returning the max for
  78319. * @returns the depth max z
  78320. */
  78321. getDepthMaxZ(activeCamera: Camera): number;
  78322. /**
  78323. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  78324. * @param matrix The materix to updated with the projection information
  78325. * @param viewMatrix The transform matrix of the light
  78326. * @param renderList The list of mesh to render in the map
  78327. * @returns The current light
  78328. */
  78329. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  78330. }
  78331. }
  78332. declare module BABYLON {
  78333. /**
  78334. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  78335. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  78336. */
  78337. export class EffectFallbacks implements IEffectFallbacks {
  78338. private _defines;
  78339. private _currentRank;
  78340. private _maxRank;
  78341. private _mesh;
  78342. /**
  78343. * Removes the fallback from the bound mesh.
  78344. */
  78345. unBindMesh(): void;
  78346. /**
  78347. * Adds a fallback on the specified property.
  78348. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  78349. * @param define The name of the define in the shader
  78350. */
  78351. addFallback(rank: number, define: string): void;
  78352. /**
  78353. * Sets the mesh to use CPU skinning when needing to fallback.
  78354. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  78355. * @param mesh The mesh to use the fallbacks.
  78356. */
  78357. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  78358. /**
  78359. * Checks to see if more fallbacks are still availible.
  78360. */
  78361. readonly hasMoreFallbacks: boolean;
  78362. /**
  78363. * Removes the defines that should be removed when falling back.
  78364. * @param currentDefines defines the current define statements for the shader.
  78365. * @param effect defines the current effect we try to compile
  78366. * @returns The resulting defines with defines of the current rank removed.
  78367. */
  78368. reduce(currentDefines: string, effect: Effect): string;
  78369. }
  78370. }
  78371. declare module BABYLON {
  78372. /**
  78373. * "Static Class" containing the most commonly used helper while dealing with material for
  78374. * rendering purpose.
  78375. *
  78376. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  78377. *
  78378. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  78379. */
  78380. export class MaterialHelper {
  78381. /**
  78382. * Bind the current view position to an effect.
  78383. * @param effect The effect to be bound
  78384. * @param scene The scene the eyes position is used from
  78385. */
  78386. static BindEyePosition(effect: Effect, scene: Scene): void;
  78387. /**
  78388. * Helps preparing the defines values about the UVs in used in the effect.
  78389. * UVs are shared as much as we can accross channels in the shaders.
  78390. * @param texture The texture we are preparing the UVs for
  78391. * @param defines The defines to update
  78392. * @param key The channel key "diffuse", "specular"... used in the shader
  78393. */
  78394. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  78395. /**
  78396. * Binds a texture matrix value to its corrsponding uniform
  78397. * @param texture The texture to bind the matrix for
  78398. * @param uniformBuffer The uniform buffer receivin the data
  78399. * @param key The channel key "diffuse", "specular"... used in the shader
  78400. */
  78401. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  78402. /**
  78403. * Gets the current status of the fog (should it be enabled?)
  78404. * @param mesh defines the mesh to evaluate for fog support
  78405. * @param scene defines the hosting scene
  78406. * @returns true if fog must be enabled
  78407. */
  78408. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  78409. /**
  78410. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  78411. * @param mesh defines the current mesh
  78412. * @param scene defines the current scene
  78413. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  78414. * @param pointsCloud defines if point cloud rendering has to be turned on
  78415. * @param fogEnabled defines if fog has to be turned on
  78416. * @param alphaTest defines if alpha testing has to be turned on
  78417. * @param defines defines the current list of defines
  78418. */
  78419. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  78420. /**
  78421. * Helper used to prepare the list of defines associated with frame values for shader compilation
  78422. * @param scene defines the current scene
  78423. * @param engine defines the current engine
  78424. * @param defines specifies the list of active defines
  78425. * @param useInstances defines if instances have to be turned on
  78426. * @param useClipPlane defines if clip plane have to be turned on
  78427. */
  78428. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  78429. /**
  78430. * Prepares the defines for bones
  78431. * @param mesh The mesh containing the geometry data we will draw
  78432. * @param defines The defines to update
  78433. */
  78434. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  78435. /**
  78436. * Prepares the defines for morph targets
  78437. * @param mesh The mesh containing the geometry data we will draw
  78438. * @param defines The defines to update
  78439. */
  78440. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  78441. /**
  78442. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  78443. * @param mesh The mesh containing the geometry data we will draw
  78444. * @param defines The defines to update
  78445. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  78446. * @param useBones Precise whether bones should be used or not (override mesh info)
  78447. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  78448. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  78449. * @returns false if defines are considered not dirty and have not been checked
  78450. */
  78451. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  78452. /**
  78453. * Prepares the defines related to multiview
  78454. * @param scene The scene we are intending to draw
  78455. * @param defines The defines to update
  78456. */
  78457. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  78458. /**
  78459. * Prepares the defines related to the light information passed in parameter
  78460. * @param scene The scene we are intending to draw
  78461. * @param mesh The mesh the effect is compiling for
  78462. * @param light The light the effect is compiling for
  78463. * @param lightIndex The index of the light
  78464. * @param defines The defines to update
  78465. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  78466. * @param state Defines the current state regarding what is needed (normals, etc...)
  78467. */
  78468. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  78469. needNormals: boolean;
  78470. needRebuild: boolean;
  78471. shadowEnabled: boolean;
  78472. specularEnabled: boolean;
  78473. lightmapMode: boolean;
  78474. }): void;
  78475. /**
  78476. * Prepares the defines related to the light information passed in parameter
  78477. * @param scene The scene we are intending to draw
  78478. * @param mesh The mesh the effect is compiling for
  78479. * @param defines The defines to update
  78480. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  78481. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  78482. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  78483. * @returns true if normals will be required for the rest of the effect
  78484. */
  78485. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  78486. /**
  78487. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  78488. * @param lightIndex defines the light index
  78489. * @param uniformsList The uniform list
  78490. * @param samplersList The sampler list
  78491. * @param projectedLightTexture defines if projected texture must be used
  78492. * @param uniformBuffersList defines an optional list of uniform buffers
  78493. */
  78494. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  78495. /**
  78496. * Prepares the uniforms and samplers list to be used in the effect
  78497. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  78498. * @param samplersList The sampler list
  78499. * @param defines The defines helping in the list generation
  78500. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  78501. */
  78502. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  78503. /**
  78504. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  78505. * @param defines The defines to update while falling back
  78506. * @param fallbacks The authorized effect fallbacks
  78507. * @param maxSimultaneousLights The maximum number of lights allowed
  78508. * @param rank the current rank of the Effect
  78509. * @returns The newly affected rank
  78510. */
  78511. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  78512. private static _TmpMorphInfluencers;
  78513. /**
  78514. * Prepares the list of attributes required for morph targets according to the effect defines.
  78515. * @param attribs The current list of supported attribs
  78516. * @param mesh The mesh to prepare the morph targets attributes for
  78517. * @param influencers The number of influencers
  78518. */
  78519. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  78520. /**
  78521. * Prepares the list of attributes required for morph targets according to the effect defines.
  78522. * @param attribs The current list of supported attribs
  78523. * @param mesh The mesh to prepare the morph targets attributes for
  78524. * @param defines The current Defines of the effect
  78525. */
  78526. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  78527. /**
  78528. * Prepares the list of attributes required for bones according to the effect defines.
  78529. * @param attribs The current list of supported attribs
  78530. * @param mesh The mesh to prepare the bones attributes for
  78531. * @param defines The current Defines of the effect
  78532. * @param fallbacks The current efffect fallback strategy
  78533. */
  78534. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  78535. /**
  78536. * Check and prepare the list of attributes required for instances according to the effect defines.
  78537. * @param attribs The current list of supported attribs
  78538. * @param defines The current MaterialDefines of the effect
  78539. */
  78540. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  78541. /**
  78542. * Add the list of attributes required for instances to the attribs array.
  78543. * @param attribs The current list of supported attribs
  78544. */
  78545. static PushAttributesForInstances(attribs: string[]): void;
  78546. /**
  78547. * Binds the light information to the effect.
  78548. * @param light The light containing the generator
  78549. * @param effect The effect we are binding the data to
  78550. * @param lightIndex The light index in the effect used to render
  78551. */
  78552. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  78553. /**
  78554. * Binds the lights information from the scene to the effect for the given mesh.
  78555. * @param light Light to bind
  78556. * @param lightIndex Light index
  78557. * @param scene The scene where the light belongs to
  78558. * @param effect The effect we are binding the data to
  78559. * @param useSpecular Defines if specular is supported
  78560. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  78561. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  78562. */
  78563. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  78564. /**
  78565. * Binds the lights information from the scene to the effect for the given mesh.
  78566. * @param scene The scene the lights belongs to
  78567. * @param mesh The mesh we are binding the information to render
  78568. * @param effect The effect we are binding the data to
  78569. * @param defines The generated defines for the effect
  78570. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  78571. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  78572. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  78573. */
  78574. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  78575. private static _tempFogColor;
  78576. /**
  78577. * Binds the fog information from the scene to the effect for the given mesh.
  78578. * @param scene The scene the lights belongs to
  78579. * @param mesh The mesh we are binding the information to render
  78580. * @param effect The effect we are binding the data to
  78581. * @param linearSpace Defines if the fog effect is applied in linear space
  78582. */
  78583. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  78584. /**
  78585. * Binds the bones information from the mesh to the effect.
  78586. * @param mesh The mesh we are binding the information to render
  78587. * @param effect The effect we are binding the data to
  78588. */
  78589. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  78590. /**
  78591. * Binds the morph targets information from the mesh to the effect.
  78592. * @param abstractMesh The mesh we are binding the information to render
  78593. * @param effect The effect we are binding the data to
  78594. */
  78595. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  78596. /**
  78597. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  78598. * @param defines The generated defines used in the effect
  78599. * @param effect The effect we are binding the data to
  78600. * @param scene The scene we are willing to render with logarithmic scale for
  78601. */
  78602. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  78603. /**
  78604. * Binds the clip plane information from the scene to the effect.
  78605. * @param scene The scene the clip plane information are extracted from
  78606. * @param effect The effect we are binding the data to
  78607. */
  78608. static BindClipPlane(effect: Effect, scene: Scene): void;
  78609. }
  78610. }
  78611. declare module BABYLON {
  78612. /** @hidden */
  78613. export var packingFunctions: {
  78614. name: string;
  78615. shader: string;
  78616. };
  78617. }
  78618. declare module BABYLON {
  78619. /** @hidden */
  78620. export var shadowMapPixelShader: {
  78621. name: string;
  78622. shader: string;
  78623. };
  78624. }
  78625. declare module BABYLON {
  78626. /** @hidden */
  78627. export var bonesDeclaration: {
  78628. name: string;
  78629. shader: string;
  78630. };
  78631. }
  78632. declare module BABYLON {
  78633. /** @hidden */
  78634. export var morphTargetsVertexGlobalDeclaration: {
  78635. name: string;
  78636. shader: string;
  78637. };
  78638. }
  78639. declare module BABYLON {
  78640. /** @hidden */
  78641. export var morphTargetsVertexDeclaration: {
  78642. name: string;
  78643. shader: string;
  78644. };
  78645. }
  78646. declare module BABYLON {
  78647. /** @hidden */
  78648. export var instancesDeclaration: {
  78649. name: string;
  78650. shader: string;
  78651. };
  78652. }
  78653. declare module BABYLON {
  78654. /** @hidden */
  78655. export var helperFunctions: {
  78656. name: string;
  78657. shader: string;
  78658. };
  78659. }
  78660. declare module BABYLON {
  78661. /** @hidden */
  78662. export var morphTargetsVertex: {
  78663. name: string;
  78664. shader: string;
  78665. };
  78666. }
  78667. declare module BABYLON {
  78668. /** @hidden */
  78669. export var instancesVertex: {
  78670. name: string;
  78671. shader: string;
  78672. };
  78673. }
  78674. declare module BABYLON {
  78675. /** @hidden */
  78676. export var bonesVertex: {
  78677. name: string;
  78678. shader: string;
  78679. };
  78680. }
  78681. declare module BABYLON {
  78682. /** @hidden */
  78683. export var shadowMapVertexShader: {
  78684. name: string;
  78685. shader: string;
  78686. };
  78687. }
  78688. declare module BABYLON {
  78689. /** @hidden */
  78690. export var depthBoxBlurPixelShader: {
  78691. name: string;
  78692. shader: string;
  78693. };
  78694. }
  78695. declare module BABYLON {
  78696. /**
  78697. * Defines the options associated with the creation of a custom shader for a shadow generator.
  78698. */
  78699. export interface ICustomShaderOptions {
  78700. /**
  78701. * Gets or sets the custom shader name to use
  78702. */
  78703. shaderName: string;
  78704. /**
  78705. * The list of attribute names used in the shader
  78706. */
  78707. attributes?: string[];
  78708. /**
  78709. * The list of unifrom names used in the shader
  78710. */
  78711. uniforms?: string[];
  78712. /**
  78713. * The list of sampler names used in the shader
  78714. */
  78715. samplers?: string[];
  78716. /**
  78717. * The list of defines used in the shader
  78718. */
  78719. defines?: string[];
  78720. }
  78721. /**
  78722. * Interface to implement to create a shadow generator compatible with BJS.
  78723. */
  78724. export interface IShadowGenerator {
  78725. /**
  78726. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  78727. * @returns The render target texture if present otherwise, null
  78728. */
  78729. getShadowMap(): Nullable<RenderTargetTexture>;
  78730. /**
  78731. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  78732. * @returns The render target texture if the shadow map is present otherwise, null
  78733. */
  78734. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  78735. /**
  78736. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  78737. * @param subMesh The submesh we want to render in the shadow map
  78738. * @param useInstances Defines wether will draw in the map using instances
  78739. * @returns true if ready otherwise, false
  78740. */
  78741. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  78742. /**
  78743. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  78744. * @param defines Defines of the material we want to update
  78745. * @param lightIndex Index of the light in the enabled light list of the material
  78746. */
  78747. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  78748. /**
  78749. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  78750. * defined in the generator but impacting the effect).
  78751. * It implies the unifroms available on the materials are the standard BJS ones.
  78752. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  78753. * @param effect The effect we are binfing the information for
  78754. */
  78755. bindShadowLight(lightIndex: string, effect: Effect): void;
  78756. /**
  78757. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  78758. * (eq to shadow prjection matrix * light transform matrix)
  78759. * @returns The transform matrix used to create the shadow map
  78760. */
  78761. getTransformMatrix(): Matrix;
  78762. /**
  78763. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  78764. * Cube and 2D textures for instance.
  78765. */
  78766. recreateShadowMap(): void;
  78767. /**
  78768. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78769. * @param onCompiled Callback triggered at the and of the effects compilation
  78770. * @param options Sets of optional options forcing the compilation with different modes
  78771. */
  78772. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  78773. useInstances: boolean;
  78774. }>): void;
  78775. /**
  78776. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78777. * @param options Sets of optional options forcing the compilation with different modes
  78778. * @returns A promise that resolves when the compilation completes
  78779. */
  78780. forceCompilationAsync(options?: Partial<{
  78781. useInstances: boolean;
  78782. }>): Promise<void>;
  78783. /**
  78784. * Serializes the shadow generator setup to a json object.
  78785. * @returns The serialized JSON object
  78786. */
  78787. serialize(): any;
  78788. /**
  78789. * Disposes the Shadow map and related Textures and effects.
  78790. */
  78791. dispose(): void;
  78792. }
  78793. /**
  78794. * Default implementation IShadowGenerator.
  78795. * This is the main object responsible of generating shadows in the framework.
  78796. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  78797. */
  78798. export class ShadowGenerator implements IShadowGenerator {
  78799. /**
  78800. * Shadow generator mode None: no filtering applied.
  78801. */
  78802. static readonly FILTER_NONE: number;
  78803. /**
  78804. * Shadow generator mode ESM: Exponential Shadow Mapping.
  78805. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78806. */
  78807. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  78808. /**
  78809. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  78810. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  78811. */
  78812. static readonly FILTER_POISSONSAMPLING: number;
  78813. /**
  78814. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  78815. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78816. */
  78817. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  78818. /**
  78819. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  78820. * edge artifacts on steep falloff.
  78821. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78822. */
  78823. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  78824. /**
  78825. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  78826. * edge artifacts on steep falloff.
  78827. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78828. */
  78829. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  78830. /**
  78831. * Shadow generator mode PCF: Percentage Closer Filtering
  78832. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  78833. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  78834. */
  78835. static readonly FILTER_PCF: number;
  78836. /**
  78837. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  78838. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  78839. * Contact Hardening
  78840. */
  78841. static readonly FILTER_PCSS: number;
  78842. /**
  78843. * Reserved for PCF and PCSS
  78844. * Highest Quality.
  78845. *
  78846. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  78847. *
  78848. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  78849. */
  78850. static readonly QUALITY_HIGH: number;
  78851. /**
  78852. * Reserved for PCF and PCSS
  78853. * Good tradeoff for quality/perf cross devices
  78854. *
  78855. * Execute PCF on a 3*3 kernel.
  78856. *
  78857. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  78858. */
  78859. static readonly QUALITY_MEDIUM: number;
  78860. /**
  78861. * Reserved for PCF and PCSS
  78862. * The lowest quality but the fastest.
  78863. *
  78864. * Execute PCF on a 1*1 kernel.
  78865. *
  78866. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  78867. */
  78868. static readonly QUALITY_LOW: number;
  78869. /** Gets or sets the custom shader name to use */
  78870. customShaderOptions: ICustomShaderOptions;
  78871. /**
  78872. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  78873. */
  78874. onBeforeShadowMapRenderObservable: Observable<Effect>;
  78875. /**
  78876. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  78877. */
  78878. onAfterShadowMapRenderObservable: Observable<Effect>;
  78879. /**
  78880. * Observable triggered before a mesh is rendered in the shadow map.
  78881. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  78882. */
  78883. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  78884. /**
  78885. * Observable triggered after a mesh is rendered in the shadow map.
  78886. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  78887. */
  78888. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  78889. private _bias;
  78890. /**
  78891. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  78892. */
  78893. /**
  78894. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  78895. */
  78896. bias: number;
  78897. private _normalBias;
  78898. /**
  78899. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  78900. */
  78901. /**
  78902. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  78903. */
  78904. normalBias: number;
  78905. private _blurBoxOffset;
  78906. /**
  78907. * Gets the blur box offset: offset applied during the blur pass.
  78908. * Only useful if useKernelBlur = false
  78909. */
  78910. /**
  78911. * Sets the blur box offset: offset applied during the blur pass.
  78912. * Only useful if useKernelBlur = false
  78913. */
  78914. blurBoxOffset: number;
  78915. private _blurScale;
  78916. /**
  78917. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  78918. * 2 means half of the size.
  78919. */
  78920. /**
  78921. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  78922. * 2 means half of the size.
  78923. */
  78924. blurScale: number;
  78925. private _blurKernel;
  78926. /**
  78927. * Gets the blur kernel: kernel size of the blur pass.
  78928. * Only useful if useKernelBlur = true
  78929. */
  78930. /**
  78931. * Sets the blur kernel: kernel size of the blur pass.
  78932. * Only useful if useKernelBlur = true
  78933. */
  78934. blurKernel: number;
  78935. private _useKernelBlur;
  78936. /**
  78937. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  78938. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  78939. */
  78940. /**
  78941. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  78942. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  78943. */
  78944. useKernelBlur: boolean;
  78945. private _depthScale;
  78946. /**
  78947. * Gets the depth scale used in ESM mode.
  78948. */
  78949. /**
  78950. * Sets the depth scale used in ESM mode.
  78951. * This can override the scale stored on the light.
  78952. */
  78953. depthScale: number;
  78954. private _filter;
  78955. /**
  78956. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  78957. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  78958. */
  78959. /**
  78960. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  78961. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  78962. */
  78963. filter: number;
  78964. /**
  78965. * Gets if the current filter is set to Poisson Sampling.
  78966. */
  78967. /**
  78968. * Sets the current filter to Poisson Sampling.
  78969. */
  78970. usePoissonSampling: boolean;
  78971. /**
  78972. * Gets if the current filter is set to ESM.
  78973. */
  78974. /**
  78975. * Sets the current filter is to ESM.
  78976. */
  78977. useExponentialShadowMap: boolean;
  78978. /**
  78979. * Gets if the current filter is set to filtered ESM.
  78980. */
  78981. /**
  78982. * Gets if the current filter is set to filtered ESM.
  78983. */
  78984. useBlurExponentialShadowMap: boolean;
  78985. /**
  78986. * Gets if the current filter is set to "close ESM" (using the inverse of the
  78987. * exponential to prevent steep falloff artifacts).
  78988. */
  78989. /**
  78990. * Sets the current filter to "close ESM" (using the inverse of the
  78991. * exponential to prevent steep falloff artifacts).
  78992. */
  78993. useCloseExponentialShadowMap: boolean;
  78994. /**
  78995. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  78996. * exponential to prevent steep falloff artifacts).
  78997. */
  78998. /**
  78999. * Sets the current filter to filtered "close ESM" (using the inverse of the
  79000. * exponential to prevent steep falloff artifacts).
  79001. */
  79002. useBlurCloseExponentialShadowMap: boolean;
  79003. /**
  79004. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  79005. */
  79006. /**
  79007. * Sets the current filter to "PCF" (percentage closer filtering).
  79008. */
  79009. usePercentageCloserFiltering: boolean;
  79010. private _filteringQuality;
  79011. /**
  79012. * Gets the PCF or PCSS Quality.
  79013. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  79014. */
  79015. /**
  79016. * Sets the PCF or PCSS Quality.
  79017. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  79018. */
  79019. filteringQuality: number;
  79020. /**
  79021. * Gets if the current filter is set to "PCSS" (contact hardening).
  79022. */
  79023. /**
  79024. * Sets the current filter to "PCSS" (contact hardening).
  79025. */
  79026. useContactHardeningShadow: boolean;
  79027. private _contactHardeningLightSizeUVRatio;
  79028. /**
  79029. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  79030. * Using a ratio helps keeping shape stability independently of the map size.
  79031. *
  79032. * It does not account for the light projection as it was having too much
  79033. * instability during the light setup or during light position changes.
  79034. *
  79035. * Only valid if useContactHardeningShadow is true.
  79036. */
  79037. /**
  79038. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  79039. * Using a ratio helps keeping shape stability independently of the map size.
  79040. *
  79041. * It does not account for the light projection as it was having too much
  79042. * instability during the light setup or during light position changes.
  79043. *
  79044. * Only valid if useContactHardeningShadow is true.
  79045. */
  79046. contactHardeningLightSizeUVRatio: number;
  79047. private _darkness;
  79048. /** Gets or sets the actual darkness of a shadow */
  79049. darkness: number;
  79050. /**
  79051. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  79052. * 0 means strongest and 1 would means no shadow.
  79053. * @returns the darkness.
  79054. */
  79055. getDarkness(): number;
  79056. /**
  79057. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  79058. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  79059. * @returns the shadow generator allowing fluent coding.
  79060. */
  79061. setDarkness(darkness: number): ShadowGenerator;
  79062. private _transparencyShadow;
  79063. /** Gets or sets the ability to have transparent shadow */
  79064. transparencyShadow: boolean;
  79065. /**
  79066. * Sets the ability to have transparent shadow (boolean).
  79067. * @param transparent True if transparent else False
  79068. * @returns the shadow generator allowing fluent coding
  79069. */
  79070. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  79071. private _shadowMap;
  79072. private _shadowMap2;
  79073. /**
  79074. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  79075. * @returns The render target texture if present otherwise, null
  79076. */
  79077. getShadowMap(): Nullable<RenderTargetTexture>;
  79078. /**
  79079. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  79080. * @returns The render target texture if the shadow map is present otherwise, null
  79081. */
  79082. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  79083. /**
  79084. * Gets the class name of that object
  79085. * @returns "ShadowGenerator"
  79086. */
  79087. getClassName(): string;
  79088. /**
  79089. * Helper function to add a mesh and its descendants to the list of shadow casters.
  79090. * @param mesh Mesh to add
  79091. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  79092. * @returns the Shadow Generator itself
  79093. */
  79094. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  79095. /**
  79096. * Helper function to remove a mesh and its descendants from the list of shadow casters
  79097. * @param mesh Mesh to remove
  79098. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  79099. * @returns the Shadow Generator itself
  79100. */
  79101. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  79102. /**
  79103. * Controls the extent to which the shadows fade out at the edge of the frustum
  79104. * Used only by directionals and spots
  79105. */
  79106. frustumEdgeFalloff: number;
  79107. private _light;
  79108. /**
  79109. * Returns the associated light object.
  79110. * @returns the light generating the shadow
  79111. */
  79112. getLight(): IShadowLight;
  79113. /**
  79114. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  79115. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  79116. * It might on the other hand introduce peter panning.
  79117. */
  79118. forceBackFacesOnly: boolean;
  79119. private _scene;
  79120. private _lightDirection;
  79121. private _effect;
  79122. private _viewMatrix;
  79123. private _projectionMatrix;
  79124. private _transformMatrix;
  79125. private _cachedPosition;
  79126. private _cachedDirection;
  79127. private _cachedDefines;
  79128. private _currentRenderID;
  79129. private _boxBlurPostprocess;
  79130. private _kernelBlurXPostprocess;
  79131. private _kernelBlurYPostprocess;
  79132. private _blurPostProcesses;
  79133. private _mapSize;
  79134. private _currentFaceIndex;
  79135. private _currentFaceIndexCache;
  79136. private _textureType;
  79137. private _defaultTextureMatrix;
  79138. private _storedUniqueId;
  79139. /** @hidden */
  79140. static _SceneComponentInitialization: (scene: Scene) => void;
  79141. /**
  79142. * Creates a ShadowGenerator object.
  79143. * A ShadowGenerator is the required tool to use the shadows.
  79144. * Each light casting shadows needs to use its own ShadowGenerator.
  79145. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  79146. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  79147. * @param light The light object generating the shadows.
  79148. * @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.
  79149. */
  79150. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  79151. private _initializeGenerator;
  79152. private _initializeShadowMap;
  79153. private _initializeBlurRTTAndPostProcesses;
  79154. private _renderForShadowMap;
  79155. private _renderSubMeshForShadowMap;
  79156. private _applyFilterValues;
  79157. /**
  79158. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  79159. * @param onCompiled Callback triggered at the and of the effects compilation
  79160. * @param options Sets of optional options forcing the compilation with different modes
  79161. */
  79162. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  79163. useInstances: boolean;
  79164. }>): void;
  79165. /**
  79166. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  79167. * @param options Sets of optional options forcing the compilation with different modes
  79168. * @returns A promise that resolves when the compilation completes
  79169. */
  79170. forceCompilationAsync(options?: Partial<{
  79171. useInstances: boolean;
  79172. }>): Promise<void>;
  79173. /**
  79174. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  79175. * @param subMesh The submesh we want to render in the shadow map
  79176. * @param useInstances Defines wether will draw in the map using instances
  79177. * @returns true if ready otherwise, false
  79178. */
  79179. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  79180. /**
  79181. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  79182. * @param defines Defines of the material we want to update
  79183. * @param lightIndex Index of the light in the enabled light list of the material
  79184. */
  79185. prepareDefines(defines: any, lightIndex: number): void;
  79186. /**
  79187. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  79188. * defined in the generator but impacting the effect).
  79189. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  79190. * @param effect The effect we are binfing the information for
  79191. */
  79192. bindShadowLight(lightIndex: string, effect: Effect): void;
  79193. /**
  79194. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  79195. * (eq to shadow prjection matrix * light transform matrix)
  79196. * @returns The transform matrix used to create the shadow map
  79197. */
  79198. getTransformMatrix(): Matrix;
  79199. /**
  79200. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  79201. * Cube and 2D textures for instance.
  79202. */
  79203. recreateShadowMap(): void;
  79204. private _disposeBlurPostProcesses;
  79205. private _disposeRTTandPostProcesses;
  79206. /**
  79207. * Disposes the ShadowGenerator.
  79208. * Returns nothing.
  79209. */
  79210. dispose(): void;
  79211. /**
  79212. * Serializes the shadow generator setup to a json object.
  79213. * @returns The serialized JSON object
  79214. */
  79215. serialize(): any;
  79216. /**
  79217. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  79218. * @param parsedShadowGenerator The JSON object to parse
  79219. * @param scene The scene to create the shadow map for
  79220. * @returns The parsed shadow generator
  79221. */
  79222. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  79223. }
  79224. }
  79225. declare module BABYLON {
  79226. /**
  79227. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  79228. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  79229. * 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.
  79230. */
  79231. export abstract class Light extends Node {
  79232. /**
  79233. * Falloff Default: light is falling off following the material specification:
  79234. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  79235. */
  79236. static readonly FALLOFF_DEFAULT: number;
  79237. /**
  79238. * Falloff Physical: light is falling off following the inverse squared distance law.
  79239. */
  79240. static readonly FALLOFF_PHYSICAL: number;
  79241. /**
  79242. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  79243. * to enhance interoperability with other engines.
  79244. */
  79245. static readonly FALLOFF_GLTF: number;
  79246. /**
  79247. * Falloff Standard: light is falling off like in the standard material
  79248. * to enhance interoperability with other materials.
  79249. */
  79250. static readonly FALLOFF_STANDARD: number;
  79251. /**
  79252. * If every light affecting the material is in this lightmapMode,
  79253. * material.lightmapTexture adds or multiplies
  79254. * (depends on material.useLightmapAsShadowmap)
  79255. * after every other light calculations.
  79256. */
  79257. static readonly LIGHTMAP_DEFAULT: number;
  79258. /**
  79259. * material.lightmapTexture as only diffuse lighting from this light
  79260. * adds only specular lighting from this light
  79261. * adds dynamic shadows
  79262. */
  79263. static readonly LIGHTMAP_SPECULAR: number;
  79264. /**
  79265. * material.lightmapTexture as only lighting
  79266. * no light calculation from this light
  79267. * only adds dynamic shadows from this light
  79268. */
  79269. static readonly LIGHTMAP_SHADOWSONLY: number;
  79270. /**
  79271. * Each light type uses the default quantity according to its type:
  79272. * point/spot lights use luminous intensity
  79273. * directional lights use illuminance
  79274. */
  79275. static readonly INTENSITYMODE_AUTOMATIC: number;
  79276. /**
  79277. * lumen (lm)
  79278. */
  79279. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  79280. /**
  79281. * candela (lm/sr)
  79282. */
  79283. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  79284. /**
  79285. * lux (lm/m^2)
  79286. */
  79287. static readonly INTENSITYMODE_ILLUMINANCE: number;
  79288. /**
  79289. * nit (cd/m^2)
  79290. */
  79291. static readonly INTENSITYMODE_LUMINANCE: number;
  79292. /**
  79293. * Light type const id of the point light.
  79294. */
  79295. static readonly LIGHTTYPEID_POINTLIGHT: number;
  79296. /**
  79297. * Light type const id of the directional light.
  79298. */
  79299. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  79300. /**
  79301. * Light type const id of the spot light.
  79302. */
  79303. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  79304. /**
  79305. * Light type const id of the hemispheric light.
  79306. */
  79307. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  79308. /**
  79309. * Diffuse gives the basic color to an object.
  79310. */
  79311. diffuse: Color3;
  79312. /**
  79313. * Specular produces a highlight color on an object.
  79314. * Note: This is note affecting PBR materials.
  79315. */
  79316. specular: Color3;
  79317. /**
  79318. * Defines the falloff type for this light. This lets overrriding how punctual light are
  79319. * falling off base on range or angle.
  79320. * This can be set to any values in Light.FALLOFF_x.
  79321. *
  79322. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  79323. * other types of materials.
  79324. */
  79325. falloffType: number;
  79326. /**
  79327. * Strength of the light.
  79328. * Note: By default it is define in the framework own unit.
  79329. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  79330. */
  79331. intensity: number;
  79332. private _range;
  79333. protected _inverseSquaredRange: number;
  79334. /**
  79335. * Defines how far from the source the light is impacting in scene units.
  79336. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  79337. */
  79338. /**
  79339. * Defines how far from the source the light is impacting in scene units.
  79340. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  79341. */
  79342. range: number;
  79343. /**
  79344. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  79345. * of light.
  79346. */
  79347. private _photometricScale;
  79348. private _intensityMode;
  79349. /**
  79350. * Gets the photometric scale used to interpret the intensity.
  79351. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  79352. */
  79353. /**
  79354. * Sets the photometric scale used to interpret the intensity.
  79355. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  79356. */
  79357. intensityMode: number;
  79358. private _radius;
  79359. /**
  79360. * Gets the light radius used by PBR Materials to simulate soft area lights.
  79361. */
  79362. /**
  79363. * sets the light radius used by PBR Materials to simulate soft area lights.
  79364. */
  79365. radius: number;
  79366. private _renderPriority;
  79367. /**
  79368. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  79369. * exceeding the number allowed of the materials.
  79370. */
  79371. renderPriority: number;
  79372. private _shadowEnabled;
  79373. /**
  79374. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  79375. * the current shadow generator.
  79376. */
  79377. /**
  79378. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  79379. * the current shadow generator.
  79380. */
  79381. shadowEnabled: boolean;
  79382. private _includedOnlyMeshes;
  79383. /**
  79384. * Gets the only meshes impacted by this light.
  79385. */
  79386. /**
  79387. * Sets the only meshes impacted by this light.
  79388. */
  79389. includedOnlyMeshes: AbstractMesh[];
  79390. private _excludedMeshes;
  79391. /**
  79392. * Gets the meshes not impacted by this light.
  79393. */
  79394. /**
  79395. * Sets the meshes not impacted by this light.
  79396. */
  79397. excludedMeshes: AbstractMesh[];
  79398. private _excludeWithLayerMask;
  79399. /**
  79400. * Gets the layer id use to find what meshes are not impacted by the light.
  79401. * Inactive if 0
  79402. */
  79403. /**
  79404. * Sets the layer id use to find what meshes are not impacted by the light.
  79405. * Inactive if 0
  79406. */
  79407. excludeWithLayerMask: number;
  79408. private _includeOnlyWithLayerMask;
  79409. /**
  79410. * Gets the layer id use to find what meshes are impacted by the light.
  79411. * Inactive if 0
  79412. */
  79413. /**
  79414. * Sets the layer id use to find what meshes are impacted by the light.
  79415. * Inactive if 0
  79416. */
  79417. includeOnlyWithLayerMask: number;
  79418. private _lightmapMode;
  79419. /**
  79420. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  79421. */
  79422. /**
  79423. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  79424. */
  79425. lightmapMode: number;
  79426. /**
  79427. * Shadow generator associted to the light.
  79428. * @hidden Internal use only.
  79429. */
  79430. _shadowGenerator: Nullable<IShadowGenerator>;
  79431. /**
  79432. * @hidden Internal use only.
  79433. */
  79434. _excludedMeshesIds: string[];
  79435. /**
  79436. * @hidden Internal use only.
  79437. */
  79438. _includedOnlyMeshesIds: string[];
  79439. /**
  79440. * The current light unifom buffer.
  79441. * @hidden Internal use only.
  79442. */
  79443. _uniformBuffer: UniformBuffer;
  79444. /** @hidden */
  79445. _renderId: number;
  79446. /**
  79447. * Creates a Light object in the scene.
  79448. * Documentation : https://doc.babylonjs.com/babylon101/lights
  79449. * @param name The firendly name of the light
  79450. * @param scene The scene the light belongs too
  79451. */
  79452. constructor(name: string, scene: Scene);
  79453. protected abstract _buildUniformLayout(): void;
  79454. /**
  79455. * Sets the passed Effect "effect" with the Light information.
  79456. * @param effect The effect to update
  79457. * @param lightIndex The index of the light in the effect to update
  79458. * @returns The light
  79459. */
  79460. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  79461. /**
  79462. * Sets the passed Effect "effect" with the Light textures.
  79463. * @param effect The effect to update
  79464. * @param lightIndex The index of the light in the effect to update
  79465. * @returns The light
  79466. */
  79467. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  79468. /**
  79469. * Binds the lights information from the scene to the effect for the given mesh.
  79470. * @param lightIndex Light index
  79471. * @param scene The scene where the light belongs to
  79472. * @param effect The effect we are binding the data to
  79473. * @param useSpecular Defines if specular is supported
  79474. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  79475. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  79476. */
  79477. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  79478. /**
  79479. * Sets the passed Effect "effect" with the Light information.
  79480. * @param effect The effect to update
  79481. * @param lightDataUniformName The uniform used to store light data (position or direction)
  79482. * @returns The light
  79483. */
  79484. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  79485. /**
  79486. * Returns the string "Light".
  79487. * @returns the class name
  79488. */
  79489. getClassName(): string;
  79490. /** @hidden */
  79491. readonly _isLight: boolean;
  79492. /**
  79493. * Converts the light information to a readable string for debug purpose.
  79494. * @param fullDetails Supports for multiple levels of logging within scene loading
  79495. * @returns the human readable light info
  79496. */
  79497. toString(fullDetails?: boolean): string;
  79498. /** @hidden */
  79499. protected _syncParentEnabledState(): void;
  79500. /**
  79501. * Set the enabled state of this node.
  79502. * @param value - the new enabled state
  79503. */
  79504. setEnabled(value: boolean): void;
  79505. /**
  79506. * Returns the Light associated shadow generator if any.
  79507. * @return the associated shadow generator.
  79508. */
  79509. getShadowGenerator(): Nullable<IShadowGenerator>;
  79510. /**
  79511. * Returns a Vector3, the absolute light position in the World.
  79512. * @returns the world space position of the light
  79513. */
  79514. getAbsolutePosition(): Vector3;
  79515. /**
  79516. * Specifies if the light will affect the passed mesh.
  79517. * @param mesh The mesh to test against the light
  79518. * @return true the mesh is affected otherwise, false.
  79519. */
  79520. canAffectMesh(mesh: AbstractMesh): boolean;
  79521. /**
  79522. * Sort function to order lights for rendering.
  79523. * @param a First Light object to compare to second.
  79524. * @param b Second Light object to compare first.
  79525. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  79526. */
  79527. static CompareLightsPriority(a: Light, b: Light): number;
  79528. /**
  79529. * Releases resources associated with this node.
  79530. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79531. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79532. */
  79533. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79534. /**
  79535. * Returns the light type ID (integer).
  79536. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  79537. */
  79538. getTypeID(): number;
  79539. /**
  79540. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  79541. * @returns the scaled intensity in intensity mode unit
  79542. */
  79543. getScaledIntensity(): number;
  79544. /**
  79545. * Returns a new Light object, named "name", from the current one.
  79546. * @param name The name of the cloned light
  79547. * @returns the new created light
  79548. */
  79549. clone(name: string): Nullable<Light>;
  79550. /**
  79551. * Serializes the current light into a Serialization object.
  79552. * @returns the serialized object.
  79553. */
  79554. serialize(): any;
  79555. /**
  79556. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  79557. * This new light is named "name" and added to the passed scene.
  79558. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  79559. * @param name The friendly name of the light
  79560. * @param scene The scene the new light will belong to
  79561. * @returns the constructor function
  79562. */
  79563. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  79564. /**
  79565. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  79566. * @param parsedLight The JSON representation of the light
  79567. * @param scene The scene to create the parsed light in
  79568. * @returns the created light after parsing
  79569. */
  79570. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  79571. private _hookArrayForExcluded;
  79572. private _hookArrayForIncludedOnly;
  79573. private _resyncMeshes;
  79574. /**
  79575. * Forces the meshes to update their light related information in their rendering used effects
  79576. * @hidden Internal Use Only
  79577. */
  79578. _markMeshesAsLightDirty(): void;
  79579. /**
  79580. * Recomputes the cached photometric scale if needed.
  79581. */
  79582. private _computePhotometricScale;
  79583. /**
  79584. * Returns the Photometric Scale according to the light type and intensity mode.
  79585. */
  79586. private _getPhotometricScale;
  79587. /**
  79588. * Reorder the light in the scene according to their defined priority.
  79589. * @hidden Internal Use Only
  79590. */
  79591. _reorderLightsInScene(): void;
  79592. /**
  79593. * Prepares the list of defines specific to the light type.
  79594. * @param defines the list of defines
  79595. * @param lightIndex defines the index of the light for the effect
  79596. */
  79597. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  79598. }
  79599. }
  79600. declare module BABYLON {
  79601. /**
  79602. * Interface used to define Action
  79603. */
  79604. export interface IAction {
  79605. /**
  79606. * Trigger for the action
  79607. */
  79608. trigger: number;
  79609. /** Options of the trigger */
  79610. triggerOptions: any;
  79611. /**
  79612. * Gets the trigger parameters
  79613. * @returns the trigger parameters
  79614. */
  79615. getTriggerParameter(): any;
  79616. /**
  79617. * Internal only - executes current action event
  79618. * @hidden
  79619. */
  79620. _executeCurrent(evt?: ActionEvent): void;
  79621. /**
  79622. * Serialize placeholder for child classes
  79623. * @param parent of child
  79624. * @returns the serialized object
  79625. */
  79626. serialize(parent: any): any;
  79627. /**
  79628. * Internal only
  79629. * @hidden
  79630. */
  79631. _prepare(): void;
  79632. /**
  79633. * Internal only - manager for action
  79634. * @hidden
  79635. */
  79636. _actionManager: AbstractActionManager;
  79637. /**
  79638. * Adds action to chain of actions, may be a DoNothingAction
  79639. * @param action defines the next action to execute
  79640. * @returns The action passed in
  79641. * @see https://www.babylonjs-playground.com/#1T30HR#0
  79642. */
  79643. then(action: IAction): IAction;
  79644. }
  79645. /**
  79646. * The action to be carried out following a trigger
  79647. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  79648. */
  79649. export class Action implements IAction {
  79650. /** the trigger, with or without parameters, for the action */
  79651. triggerOptions: any;
  79652. /**
  79653. * Trigger for the action
  79654. */
  79655. trigger: number;
  79656. /**
  79657. * Internal only - manager for action
  79658. * @hidden
  79659. */
  79660. _actionManager: ActionManager;
  79661. private _nextActiveAction;
  79662. private _child;
  79663. private _condition?;
  79664. private _triggerParameter;
  79665. /**
  79666. * An event triggered prior to action being executed.
  79667. */
  79668. onBeforeExecuteObservable: Observable<Action>;
  79669. /**
  79670. * Creates a new Action
  79671. * @param triggerOptions the trigger, with or without parameters, for the action
  79672. * @param condition an optional determinant of action
  79673. */
  79674. constructor(
  79675. /** the trigger, with or without parameters, for the action */
  79676. triggerOptions: any, condition?: Condition);
  79677. /**
  79678. * Internal only
  79679. * @hidden
  79680. */
  79681. _prepare(): void;
  79682. /**
  79683. * Gets the trigger parameters
  79684. * @returns the trigger parameters
  79685. */
  79686. getTriggerParameter(): any;
  79687. /**
  79688. * Internal only - executes current action event
  79689. * @hidden
  79690. */
  79691. _executeCurrent(evt?: ActionEvent): void;
  79692. /**
  79693. * Execute placeholder for child classes
  79694. * @param evt optional action event
  79695. */
  79696. execute(evt?: ActionEvent): void;
  79697. /**
  79698. * Skips to next active action
  79699. */
  79700. skipToNextActiveAction(): void;
  79701. /**
  79702. * Adds action to chain of actions, may be a DoNothingAction
  79703. * @param action defines the next action to execute
  79704. * @returns The action passed in
  79705. * @see https://www.babylonjs-playground.com/#1T30HR#0
  79706. */
  79707. then(action: Action): Action;
  79708. /**
  79709. * Internal only
  79710. * @hidden
  79711. */
  79712. _getProperty(propertyPath: string): string;
  79713. /**
  79714. * Internal only
  79715. * @hidden
  79716. */
  79717. _getEffectiveTarget(target: any, propertyPath: string): any;
  79718. /**
  79719. * Serialize placeholder for child classes
  79720. * @param parent of child
  79721. * @returns the serialized object
  79722. */
  79723. serialize(parent: any): any;
  79724. /**
  79725. * Internal only called by serialize
  79726. * @hidden
  79727. */
  79728. protected _serialize(serializedAction: any, parent?: any): any;
  79729. /**
  79730. * Internal only
  79731. * @hidden
  79732. */
  79733. static _SerializeValueAsString: (value: any) => string;
  79734. /**
  79735. * Internal only
  79736. * @hidden
  79737. */
  79738. static _GetTargetProperty: (target: Node | Scene) => {
  79739. name: string;
  79740. targetType: string;
  79741. value: string;
  79742. };
  79743. }
  79744. }
  79745. declare module BABYLON {
  79746. /**
  79747. * A Condition applied to an Action
  79748. */
  79749. export class Condition {
  79750. /**
  79751. * Internal only - manager for action
  79752. * @hidden
  79753. */
  79754. _actionManager: ActionManager;
  79755. /**
  79756. * Internal only
  79757. * @hidden
  79758. */
  79759. _evaluationId: number;
  79760. /**
  79761. * Internal only
  79762. * @hidden
  79763. */
  79764. _currentResult: boolean;
  79765. /**
  79766. * Creates a new Condition
  79767. * @param actionManager the manager of the action the condition is applied to
  79768. */
  79769. constructor(actionManager: ActionManager);
  79770. /**
  79771. * Check if the current condition is valid
  79772. * @returns a boolean
  79773. */
  79774. isValid(): boolean;
  79775. /**
  79776. * Internal only
  79777. * @hidden
  79778. */
  79779. _getProperty(propertyPath: string): string;
  79780. /**
  79781. * Internal only
  79782. * @hidden
  79783. */
  79784. _getEffectiveTarget(target: any, propertyPath: string): any;
  79785. /**
  79786. * Serialize placeholder for child classes
  79787. * @returns the serialized object
  79788. */
  79789. serialize(): any;
  79790. /**
  79791. * Internal only
  79792. * @hidden
  79793. */
  79794. protected _serialize(serializedCondition: any): any;
  79795. }
  79796. /**
  79797. * Defines specific conditional operators as extensions of Condition
  79798. */
  79799. export class ValueCondition extends Condition {
  79800. /** path to specify the property of the target the conditional operator uses */
  79801. propertyPath: string;
  79802. /** the value compared by the conditional operator against the current value of the property */
  79803. value: any;
  79804. /** the conditional operator, default ValueCondition.IsEqual */
  79805. operator: number;
  79806. /**
  79807. * Internal only
  79808. * @hidden
  79809. */
  79810. private static _IsEqual;
  79811. /**
  79812. * Internal only
  79813. * @hidden
  79814. */
  79815. private static _IsDifferent;
  79816. /**
  79817. * Internal only
  79818. * @hidden
  79819. */
  79820. private static _IsGreater;
  79821. /**
  79822. * Internal only
  79823. * @hidden
  79824. */
  79825. private static _IsLesser;
  79826. /**
  79827. * returns the number for IsEqual
  79828. */
  79829. static readonly IsEqual: number;
  79830. /**
  79831. * Returns the number for IsDifferent
  79832. */
  79833. static readonly IsDifferent: number;
  79834. /**
  79835. * Returns the number for IsGreater
  79836. */
  79837. static readonly IsGreater: number;
  79838. /**
  79839. * Returns the number for IsLesser
  79840. */
  79841. static readonly IsLesser: number;
  79842. /**
  79843. * Internal only The action manager for the condition
  79844. * @hidden
  79845. */
  79846. _actionManager: ActionManager;
  79847. /**
  79848. * Internal only
  79849. * @hidden
  79850. */
  79851. private _target;
  79852. /**
  79853. * Internal only
  79854. * @hidden
  79855. */
  79856. private _effectiveTarget;
  79857. /**
  79858. * Internal only
  79859. * @hidden
  79860. */
  79861. private _property;
  79862. /**
  79863. * Creates a new ValueCondition
  79864. * @param actionManager manager for the action the condition applies to
  79865. * @param target for the action
  79866. * @param propertyPath path to specify the property of the target the conditional operator uses
  79867. * @param value the value compared by the conditional operator against the current value of the property
  79868. * @param operator the conditional operator, default ValueCondition.IsEqual
  79869. */
  79870. constructor(actionManager: ActionManager, target: any,
  79871. /** path to specify the property of the target the conditional operator uses */
  79872. propertyPath: string,
  79873. /** the value compared by the conditional operator against the current value of the property */
  79874. value: any,
  79875. /** the conditional operator, default ValueCondition.IsEqual */
  79876. operator?: number);
  79877. /**
  79878. * Compares the given value with the property value for the specified conditional operator
  79879. * @returns the result of the comparison
  79880. */
  79881. isValid(): boolean;
  79882. /**
  79883. * Serialize the ValueCondition into a JSON compatible object
  79884. * @returns serialization object
  79885. */
  79886. serialize(): any;
  79887. /**
  79888. * Gets the name of the conditional operator for the ValueCondition
  79889. * @param operator the conditional operator
  79890. * @returns the name
  79891. */
  79892. static GetOperatorName(operator: number): string;
  79893. }
  79894. /**
  79895. * Defines a predicate condition as an extension of Condition
  79896. */
  79897. export class PredicateCondition extends Condition {
  79898. /** defines the predicate function used to validate the condition */
  79899. predicate: () => boolean;
  79900. /**
  79901. * Internal only - manager for action
  79902. * @hidden
  79903. */
  79904. _actionManager: ActionManager;
  79905. /**
  79906. * Creates a new PredicateCondition
  79907. * @param actionManager manager for the action the condition applies to
  79908. * @param predicate defines the predicate function used to validate the condition
  79909. */
  79910. constructor(actionManager: ActionManager,
  79911. /** defines the predicate function used to validate the condition */
  79912. predicate: () => boolean);
  79913. /**
  79914. * @returns the validity of the predicate condition
  79915. */
  79916. isValid(): boolean;
  79917. }
  79918. /**
  79919. * Defines a state condition as an extension of Condition
  79920. */
  79921. export class StateCondition extends Condition {
  79922. /** Value to compare with target state */
  79923. value: string;
  79924. /**
  79925. * Internal only - manager for action
  79926. * @hidden
  79927. */
  79928. _actionManager: ActionManager;
  79929. /**
  79930. * Internal only
  79931. * @hidden
  79932. */
  79933. private _target;
  79934. /**
  79935. * Creates a new StateCondition
  79936. * @param actionManager manager for the action the condition applies to
  79937. * @param target of the condition
  79938. * @param value to compare with target state
  79939. */
  79940. constructor(actionManager: ActionManager, target: any,
  79941. /** Value to compare with target state */
  79942. value: string);
  79943. /**
  79944. * Gets a boolean indicating if the current condition is met
  79945. * @returns the validity of the state
  79946. */
  79947. isValid(): boolean;
  79948. /**
  79949. * Serialize the StateCondition into a JSON compatible object
  79950. * @returns serialization object
  79951. */
  79952. serialize(): any;
  79953. }
  79954. }
  79955. declare module BABYLON {
  79956. /**
  79957. * This defines an action responsible to toggle a boolean once triggered.
  79958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79959. */
  79960. export class SwitchBooleanAction extends Action {
  79961. /**
  79962. * The path to the boolean property in the target object
  79963. */
  79964. propertyPath: string;
  79965. private _target;
  79966. private _effectiveTarget;
  79967. private _property;
  79968. /**
  79969. * Instantiate the action
  79970. * @param triggerOptions defines the trigger options
  79971. * @param target defines the object containing the boolean
  79972. * @param propertyPath defines the path to the boolean property in the target object
  79973. * @param condition defines the trigger related conditions
  79974. */
  79975. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  79976. /** @hidden */
  79977. _prepare(): void;
  79978. /**
  79979. * Execute the action toggle the boolean value.
  79980. */
  79981. execute(): void;
  79982. /**
  79983. * Serializes the actions and its related information.
  79984. * @param parent defines the object to serialize in
  79985. * @returns the serialized object
  79986. */
  79987. serialize(parent: any): any;
  79988. }
  79989. /**
  79990. * This defines an action responsible to set a the state field of the target
  79991. * to a desired value once triggered.
  79992. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79993. */
  79994. export class SetStateAction extends Action {
  79995. /**
  79996. * The value to store in the state field.
  79997. */
  79998. value: string;
  79999. private _target;
  80000. /**
  80001. * Instantiate the action
  80002. * @param triggerOptions defines the trigger options
  80003. * @param target defines the object containing the state property
  80004. * @param value defines the value to store in the state field
  80005. * @param condition defines the trigger related conditions
  80006. */
  80007. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  80008. /**
  80009. * Execute the action and store the value on the target state property.
  80010. */
  80011. execute(): void;
  80012. /**
  80013. * Serializes the actions and its related information.
  80014. * @param parent defines the object to serialize in
  80015. * @returns the serialized object
  80016. */
  80017. serialize(parent: any): any;
  80018. }
  80019. /**
  80020. * This defines an action responsible to set a property of the target
  80021. * to a desired value once triggered.
  80022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80023. */
  80024. export class SetValueAction extends Action {
  80025. /**
  80026. * The path of the property to set in the target.
  80027. */
  80028. propertyPath: string;
  80029. /**
  80030. * The value to set in the property
  80031. */
  80032. value: any;
  80033. private _target;
  80034. private _effectiveTarget;
  80035. private _property;
  80036. /**
  80037. * Instantiate the action
  80038. * @param triggerOptions defines the trigger options
  80039. * @param target defines the object containing the property
  80040. * @param propertyPath defines the path of the property to set in the target
  80041. * @param value defines the value to set in the property
  80042. * @param condition defines the trigger related conditions
  80043. */
  80044. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  80045. /** @hidden */
  80046. _prepare(): void;
  80047. /**
  80048. * Execute the action and set the targetted property to the desired value.
  80049. */
  80050. execute(): void;
  80051. /**
  80052. * Serializes the actions and its related information.
  80053. * @param parent defines the object to serialize in
  80054. * @returns the serialized object
  80055. */
  80056. serialize(parent: any): any;
  80057. }
  80058. /**
  80059. * This defines an action responsible to increment the target value
  80060. * to a desired value once triggered.
  80061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80062. */
  80063. export class IncrementValueAction extends Action {
  80064. /**
  80065. * The path of the property to increment in the target.
  80066. */
  80067. propertyPath: string;
  80068. /**
  80069. * The value we should increment the property by.
  80070. */
  80071. value: any;
  80072. private _target;
  80073. private _effectiveTarget;
  80074. private _property;
  80075. /**
  80076. * Instantiate the action
  80077. * @param triggerOptions defines the trigger options
  80078. * @param target defines the object containing the property
  80079. * @param propertyPath defines the path of the property to increment in the target
  80080. * @param value defines the value value we should increment the property by
  80081. * @param condition defines the trigger related conditions
  80082. */
  80083. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  80084. /** @hidden */
  80085. _prepare(): void;
  80086. /**
  80087. * Execute the action and increment the target of the value amount.
  80088. */
  80089. execute(): void;
  80090. /**
  80091. * Serializes the actions and its related information.
  80092. * @param parent defines the object to serialize in
  80093. * @returns the serialized object
  80094. */
  80095. serialize(parent: any): any;
  80096. }
  80097. /**
  80098. * This defines an action responsible to start an animation once triggered.
  80099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80100. */
  80101. export class PlayAnimationAction extends Action {
  80102. /**
  80103. * Where the animation should start (animation frame)
  80104. */
  80105. from: number;
  80106. /**
  80107. * Where the animation should stop (animation frame)
  80108. */
  80109. to: number;
  80110. /**
  80111. * Define if the animation should loop or stop after the first play.
  80112. */
  80113. loop?: boolean;
  80114. private _target;
  80115. /**
  80116. * Instantiate the action
  80117. * @param triggerOptions defines the trigger options
  80118. * @param target defines the target animation or animation name
  80119. * @param from defines from where the animation should start (animation frame)
  80120. * @param end defines where the animation should stop (animation frame)
  80121. * @param loop defines if the animation should loop or stop after the first play
  80122. * @param condition defines the trigger related conditions
  80123. */
  80124. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  80125. /** @hidden */
  80126. _prepare(): void;
  80127. /**
  80128. * Execute the action and play the animation.
  80129. */
  80130. execute(): void;
  80131. /**
  80132. * Serializes the actions and its related information.
  80133. * @param parent defines the object to serialize in
  80134. * @returns the serialized object
  80135. */
  80136. serialize(parent: any): any;
  80137. }
  80138. /**
  80139. * This defines an action responsible to stop an animation once triggered.
  80140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80141. */
  80142. export class StopAnimationAction extends Action {
  80143. private _target;
  80144. /**
  80145. * Instantiate the action
  80146. * @param triggerOptions defines the trigger options
  80147. * @param target defines the target animation or animation name
  80148. * @param condition defines the trigger related conditions
  80149. */
  80150. constructor(triggerOptions: any, target: any, condition?: Condition);
  80151. /** @hidden */
  80152. _prepare(): void;
  80153. /**
  80154. * Execute the action and stop the animation.
  80155. */
  80156. execute(): void;
  80157. /**
  80158. * Serializes the actions and its related information.
  80159. * @param parent defines the object to serialize in
  80160. * @returns the serialized object
  80161. */
  80162. serialize(parent: any): any;
  80163. }
  80164. /**
  80165. * This defines an action responsible that does nothing once triggered.
  80166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80167. */
  80168. export class DoNothingAction extends Action {
  80169. /**
  80170. * Instantiate the action
  80171. * @param triggerOptions defines the trigger options
  80172. * @param condition defines the trigger related conditions
  80173. */
  80174. constructor(triggerOptions?: any, condition?: Condition);
  80175. /**
  80176. * Execute the action and do nothing.
  80177. */
  80178. execute(): void;
  80179. /**
  80180. * Serializes the actions and its related information.
  80181. * @param parent defines the object to serialize in
  80182. * @returns the serialized object
  80183. */
  80184. serialize(parent: any): any;
  80185. }
  80186. /**
  80187. * This defines an action responsible to trigger several actions once triggered.
  80188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80189. */
  80190. export class CombineAction extends Action {
  80191. /**
  80192. * The list of aggregated animations to run.
  80193. */
  80194. children: Action[];
  80195. /**
  80196. * Instantiate the action
  80197. * @param triggerOptions defines the trigger options
  80198. * @param children defines the list of aggregated animations to run
  80199. * @param condition defines the trigger related conditions
  80200. */
  80201. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  80202. /** @hidden */
  80203. _prepare(): void;
  80204. /**
  80205. * Execute the action and executes all the aggregated actions.
  80206. */
  80207. execute(evt: ActionEvent): void;
  80208. /**
  80209. * Serializes the actions and its related information.
  80210. * @param parent defines the object to serialize in
  80211. * @returns the serialized object
  80212. */
  80213. serialize(parent: any): any;
  80214. }
  80215. /**
  80216. * This defines an action responsible to run code (external event) once triggered.
  80217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80218. */
  80219. export class ExecuteCodeAction extends Action {
  80220. /**
  80221. * The callback function to run.
  80222. */
  80223. func: (evt: ActionEvent) => void;
  80224. /**
  80225. * Instantiate the action
  80226. * @param triggerOptions defines the trigger options
  80227. * @param func defines the callback function to run
  80228. * @param condition defines the trigger related conditions
  80229. */
  80230. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  80231. /**
  80232. * Execute the action and run the attached code.
  80233. */
  80234. execute(evt: ActionEvent): void;
  80235. }
  80236. /**
  80237. * This defines an action responsible to set the parent property of the target once triggered.
  80238. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80239. */
  80240. export class SetParentAction extends Action {
  80241. private _parent;
  80242. private _target;
  80243. /**
  80244. * Instantiate the action
  80245. * @param triggerOptions defines the trigger options
  80246. * @param target defines the target containing the parent property
  80247. * @param parent defines from where the animation should start (animation frame)
  80248. * @param condition defines the trigger related conditions
  80249. */
  80250. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  80251. /** @hidden */
  80252. _prepare(): void;
  80253. /**
  80254. * Execute the action and set the parent property.
  80255. */
  80256. execute(): void;
  80257. /**
  80258. * Serializes the actions and its related information.
  80259. * @param parent defines the object to serialize in
  80260. * @returns the serialized object
  80261. */
  80262. serialize(parent: any): any;
  80263. }
  80264. }
  80265. declare module BABYLON {
  80266. /**
  80267. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  80268. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  80269. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80270. */
  80271. export class ActionManager extends AbstractActionManager {
  80272. /**
  80273. * Nothing
  80274. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80275. */
  80276. static readonly NothingTrigger: number;
  80277. /**
  80278. * On pick
  80279. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80280. */
  80281. static readonly OnPickTrigger: number;
  80282. /**
  80283. * On left pick
  80284. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80285. */
  80286. static readonly OnLeftPickTrigger: number;
  80287. /**
  80288. * On right pick
  80289. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80290. */
  80291. static readonly OnRightPickTrigger: number;
  80292. /**
  80293. * On center pick
  80294. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80295. */
  80296. static readonly OnCenterPickTrigger: number;
  80297. /**
  80298. * On pick down
  80299. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80300. */
  80301. static readonly OnPickDownTrigger: number;
  80302. /**
  80303. * On double pick
  80304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80305. */
  80306. static readonly OnDoublePickTrigger: number;
  80307. /**
  80308. * On pick up
  80309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80310. */
  80311. static readonly OnPickUpTrigger: number;
  80312. /**
  80313. * On pick out.
  80314. * This trigger will only be raised if you also declared a OnPickDown
  80315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80316. */
  80317. static readonly OnPickOutTrigger: number;
  80318. /**
  80319. * On long press
  80320. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80321. */
  80322. static readonly OnLongPressTrigger: number;
  80323. /**
  80324. * On pointer over
  80325. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80326. */
  80327. static readonly OnPointerOverTrigger: number;
  80328. /**
  80329. * On pointer out
  80330. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80331. */
  80332. static readonly OnPointerOutTrigger: number;
  80333. /**
  80334. * On every frame
  80335. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80336. */
  80337. static readonly OnEveryFrameTrigger: number;
  80338. /**
  80339. * On intersection enter
  80340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80341. */
  80342. static readonly OnIntersectionEnterTrigger: number;
  80343. /**
  80344. * On intersection exit
  80345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80346. */
  80347. static readonly OnIntersectionExitTrigger: number;
  80348. /**
  80349. * On key down
  80350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80351. */
  80352. static readonly OnKeyDownTrigger: number;
  80353. /**
  80354. * On key up
  80355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80356. */
  80357. static readonly OnKeyUpTrigger: number;
  80358. private _scene;
  80359. /**
  80360. * Creates a new action manager
  80361. * @param scene defines the hosting scene
  80362. */
  80363. constructor(scene: Scene);
  80364. /**
  80365. * Releases all associated resources
  80366. */
  80367. dispose(): void;
  80368. /**
  80369. * Gets hosting scene
  80370. * @returns the hosting scene
  80371. */
  80372. getScene(): Scene;
  80373. /**
  80374. * Does this action manager handles actions of any of the given triggers
  80375. * @param triggers defines the triggers to be tested
  80376. * @return a boolean indicating whether one (or more) of the triggers is handled
  80377. */
  80378. hasSpecificTriggers(triggers: number[]): boolean;
  80379. /**
  80380. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  80381. * speed.
  80382. * @param triggerA defines the trigger to be tested
  80383. * @param triggerB defines the trigger to be tested
  80384. * @return a boolean indicating whether one (or more) of the triggers is handled
  80385. */
  80386. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  80387. /**
  80388. * Does this action manager handles actions of a given trigger
  80389. * @param trigger defines the trigger to be tested
  80390. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  80391. * @return whether the trigger is handled
  80392. */
  80393. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  80394. /**
  80395. * Does this action manager has pointer triggers
  80396. */
  80397. readonly hasPointerTriggers: boolean;
  80398. /**
  80399. * Does this action manager has pick triggers
  80400. */
  80401. readonly hasPickTriggers: boolean;
  80402. /**
  80403. * Registers an action to this action manager
  80404. * @param action defines the action to be registered
  80405. * @return the action amended (prepared) after registration
  80406. */
  80407. registerAction(action: IAction): Nullable<IAction>;
  80408. /**
  80409. * Unregisters an action to this action manager
  80410. * @param action defines the action to be unregistered
  80411. * @return a boolean indicating whether the action has been unregistered
  80412. */
  80413. unregisterAction(action: IAction): Boolean;
  80414. /**
  80415. * Process a specific trigger
  80416. * @param trigger defines the trigger to process
  80417. * @param evt defines the event details to be processed
  80418. */
  80419. processTrigger(trigger: number, evt?: IActionEvent): void;
  80420. /** @hidden */
  80421. _getEffectiveTarget(target: any, propertyPath: string): any;
  80422. /** @hidden */
  80423. _getProperty(propertyPath: string): string;
  80424. /**
  80425. * Serialize this manager to a JSON object
  80426. * @param name defines the property name to store this manager
  80427. * @returns a JSON representation of this manager
  80428. */
  80429. serialize(name: string): any;
  80430. /**
  80431. * Creates a new ActionManager from a JSON data
  80432. * @param parsedActions defines the JSON data to read from
  80433. * @param object defines the hosting mesh
  80434. * @param scene defines the hosting scene
  80435. */
  80436. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  80437. /**
  80438. * Get a trigger name by index
  80439. * @param trigger defines the trigger index
  80440. * @returns a trigger name
  80441. */
  80442. static GetTriggerName(trigger: number): string;
  80443. }
  80444. }
  80445. declare module BABYLON {
  80446. /**
  80447. * Class representing a ray with position and direction
  80448. */
  80449. export class Ray {
  80450. /** origin point */
  80451. origin: Vector3;
  80452. /** direction */
  80453. direction: Vector3;
  80454. /** length of the ray */
  80455. length: number;
  80456. private static readonly TmpVector3;
  80457. private _tmpRay;
  80458. /**
  80459. * Creates a new ray
  80460. * @param origin origin point
  80461. * @param direction direction
  80462. * @param length length of the ray
  80463. */
  80464. constructor(
  80465. /** origin point */
  80466. origin: Vector3,
  80467. /** direction */
  80468. direction: Vector3,
  80469. /** length of the ray */
  80470. length?: number);
  80471. /**
  80472. * Checks if the ray intersects a box
  80473. * @param minimum bound of the box
  80474. * @param maximum bound of the box
  80475. * @param intersectionTreshold extra extend to be added to the box in all direction
  80476. * @returns if the box was hit
  80477. */
  80478. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  80479. /**
  80480. * Checks if the ray intersects a box
  80481. * @param box the bounding box to check
  80482. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  80483. * @returns if the box was hit
  80484. */
  80485. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  80486. /**
  80487. * If the ray hits a sphere
  80488. * @param sphere the bounding sphere to check
  80489. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  80490. * @returns true if it hits the sphere
  80491. */
  80492. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  80493. /**
  80494. * If the ray hits a triange
  80495. * @param vertex0 triangle vertex
  80496. * @param vertex1 triangle vertex
  80497. * @param vertex2 triangle vertex
  80498. * @returns intersection information if hit
  80499. */
  80500. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  80501. /**
  80502. * Checks if ray intersects a plane
  80503. * @param plane the plane to check
  80504. * @returns the distance away it was hit
  80505. */
  80506. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  80507. /**
  80508. * Calculate the intercept of a ray on a given axis
  80509. * @param axis to check 'x' | 'y' | 'z'
  80510. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  80511. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  80512. */
  80513. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  80514. /**
  80515. * Checks if ray intersects a mesh
  80516. * @param mesh the mesh to check
  80517. * @param fastCheck if only the bounding box should checked
  80518. * @returns picking info of the intersecton
  80519. */
  80520. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  80521. /**
  80522. * Checks if ray intersects a mesh
  80523. * @param meshes the meshes to check
  80524. * @param fastCheck if only the bounding box should checked
  80525. * @param results array to store result in
  80526. * @returns Array of picking infos
  80527. */
  80528. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  80529. private _comparePickingInfo;
  80530. private static smallnum;
  80531. private static rayl;
  80532. /**
  80533. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  80534. * @param sega the first point of the segment to test the intersection against
  80535. * @param segb the second point of the segment to test the intersection against
  80536. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  80537. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  80538. */
  80539. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  80540. /**
  80541. * Update the ray from viewport position
  80542. * @param x position
  80543. * @param y y position
  80544. * @param viewportWidth viewport width
  80545. * @param viewportHeight viewport height
  80546. * @param world world matrix
  80547. * @param view view matrix
  80548. * @param projection projection matrix
  80549. * @returns this ray updated
  80550. */
  80551. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  80552. /**
  80553. * Creates a ray with origin and direction of 0,0,0
  80554. * @returns the new ray
  80555. */
  80556. static Zero(): Ray;
  80557. /**
  80558. * Creates a new ray from screen space and viewport
  80559. * @param x position
  80560. * @param y y position
  80561. * @param viewportWidth viewport width
  80562. * @param viewportHeight viewport height
  80563. * @param world world matrix
  80564. * @param view view matrix
  80565. * @param projection projection matrix
  80566. * @returns new ray
  80567. */
  80568. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  80569. /**
  80570. * 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
  80571. * transformed to the given world matrix.
  80572. * @param origin The origin point
  80573. * @param end The end point
  80574. * @param world a matrix to transform the ray to. Default is the identity matrix.
  80575. * @returns the new ray
  80576. */
  80577. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  80578. /**
  80579. * Transforms a ray by a matrix
  80580. * @param ray ray to transform
  80581. * @param matrix matrix to apply
  80582. * @returns the resulting new ray
  80583. */
  80584. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  80585. /**
  80586. * Transforms a ray by a matrix
  80587. * @param ray ray to transform
  80588. * @param matrix matrix to apply
  80589. * @param result ray to store result in
  80590. */
  80591. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  80592. /**
  80593. * Unproject a ray from screen space to object space
  80594. * @param sourceX defines the screen space x coordinate to use
  80595. * @param sourceY defines the screen space y coordinate to use
  80596. * @param viewportWidth defines the current width of the viewport
  80597. * @param viewportHeight defines the current height of the viewport
  80598. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80599. * @param view defines the view matrix to use
  80600. * @param projection defines the projection matrix to use
  80601. */
  80602. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  80603. }
  80604. /**
  80605. * Type used to define predicate used to select faces when a mesh intersection is detected
  80606. */
  80607. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  80608. interface Scene {
  80609. /** @hidden */
  80610. _tempPickingRay: Nullable<Ray>;
  80611. /** @hidden */
  80612. _cachedRayForTransform: Ray;
  80613. /** @hidden */
  80614. _pickWithRayInverseMatrix: Matrix;
  80615. /** @hidden */
  80616. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  80617. /** @hidden */
  80618. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  80619. }
  80620. }
  80621. declare module BABYLON {
  80622. /**
  80623. * Groups all the scene component constants in one place to ease maintenance.
  80624. * @hidden
  80625. */
  80626. export class SceneComponentConstants {
  80627. static readonly NAME_EFFECTLAYER: string;
  80628. static readonly NAME_LAYER: string;
  80629. static readonly NAME_LENSFLARESYSTEM: string;
  80630. static readonly NAME_BOUNDINGBOXRENDERER: string;
  80631. static readonly NAME_PARTICLESYSTEM: string;
  80632. static readonly NAME_GAMEPAD: string;
  80633. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  80634. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  80635. static readonly NAME_DEPTHRENDERER: string;
  80636. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  80637. static readonly NAME_SPRITE: string;
  80638. static readonly NAME_OUTLINERENDERER: string;
  80639. static readonly NAME_PROCEDURALTEXTURE: string;
  80640. static readonly NAME_SHADOWGENERATOR: string;
  80641. static readonly NAME_OCTREE: string;
  80642. static readonly NAME_PHYSICSENGINE: string;
  80643. static readonly NAME_AUDIO: string;
  80644. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  80645. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  80646. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  80647. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  80648. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  80649. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  80650. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  80651. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  80652. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  80653. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  80654. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  80655. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  80656. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  80657. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  80658. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  80659. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  80660. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  80661. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  80662. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  80663. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  80664. static readonly STEP_AFTERRENDER_AUDIO: number;
  80665. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  80666. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  80667. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  80668. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  80669. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  80670. static readonly STEP_POINTERMOVE_SPRITE: number;
  80671. static readonly STEP_POINTERDOWN_SPRITE: number;
  80672. static readonly STEP_POINTERUP_SPRITE: number;
  80673. }
  80674. /**
  80675. * This represents a scene component.
  80676. *
  80677. * This is used to decouple the dependency the scene is having on the different workloads like
  80678. * layers, post processes...
  80679. */
  80680. export interface ISceneComponent {
  80681. /**
  80682. * The name of the component. Each component must have a unique name.
  80683. */
  80684. name: string;
  80685. /**
  80686. * The scene the component belongs to.
  80687. */
  80688. scene: Scene;
  80689. /**
  80690. * Register the component to one instance of a scene.
  80691. */
  80692. register(): void;
  80693. /**
  80694. * Rebuilds the elements related to this component in case of
  80695. * context lost for instance.
  80696. */
  80697. rebuild(): void;
  80698. /**
  80699. * Disposes the component and the associated ressources.
  80700. */
  80701. dispose(): void;
  80702. }
  80703. /**
  80704. * This represents a SERIALIZABLE scene component.
  80705. *
  80706. * This extends Scene Component to add Serialization methods on top.
  80707. */
  80708. export interface ISceneSerializableComponent extends ISceneComponent {
  80709. /**
  80710. * Adds all the elements from the container to the scene
  80711. * @param container the container holding the elements
  80712. */
  80713. addFromContainer(container: AbstractScene): void;
  80714. /**
  80715. * Removes all the elements in the container from the scene
  80716. * @param container contains the elements to remove
  80717. * @param dispose if the removed element should be disposed (default: false)
  80718. */
  80719. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  80720. /**
  80721. * Serializes the component data to the specified json object
  80722. * @param serializationObject The object to serialize to
  80723. */
  80724. serialize(serializationObject: any): void;
  80725. }
  80726. /**
  80727. * Strong typing of a Mesh related stage step action
  80728. */
  80729. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  80730. /**
  80731. * Strong typing of a Evaluate Sub Mesh related stage step action
  80732. */
  80733. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  80734. /**
  80735. * Strong typing of a Active Mesh related stage step action
  80736. */
  80737. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  80738. /**
  80739. * Strong typing of a Camera related stage step action
  80740. */
  80741. export type CameraStageAction = (camera: Camera) => void;
  80742. /**
  80743. * Strong typing of a Camera Frame buffer related stage step action
  80744. */
  80745. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  80746. /**
  80747. * Strong typing of a Render Target related stage step action
  80748. */
  80749. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  80750. /**
  80751. * Strong typing of a RenderingGroup related stage step action
  80752. */
  80753. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  80754. /**
  80755. * Strong typing of a Mesh Render related stage step action
  80756. */
  80757. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  80758. /**
  80759. * Strong typing of a simple stage step action
  80760. */
  80761. export type SimpleStageAction = () => void;
  80762. /**
  80763. * Strong typing of a render target action.
  80764. */
  80765. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  80766. /**
  80767. * Strong typing of a pointer move action.
  80768. */
  80769. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  80770. /**
  80771. * Strong typing of a pointer up/down action.
  80772. */
  80773. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  80774. /**
  80775. * Representation of a stage in the scene (Basically a list of ordered steps)
  80776. * @hidden
  80777. */
  80778. export class Stage<T extends Function> extends Array<{
  80779. index: number;
  80780. component: ISceneComponent;
  80781. action: T;
  80782. }> {
  80783. /**
  80784. * Hide ctor from the rest of the world.
  80785. * @param items The items to add.
  80786. */
  80787. private constructor();
  80788. /**
  80789. * Creates a new Stage.
  80790. * @returns A new instance of a Stage
  80791. */
  80792. static Create<T extends Function>(): Stage<T>;
  80793. /**
  80794. * Registers a step in an ordered way in the targeted stage.
  80795. * @param index Defines the position to register the step in
  80796. * @param component Defines the component attached to the step
  80797. * @param action Defines the action to launch during the step
  80798. */
  80799. registerStep(index: number, component: ISceneComponent, action: T): void;
  80800. /**
  80801. * Clears all the steps from the stage.
  80802. */
  80803. clear(): void;
  80804. }
  80805. }
  80806. declare module BABYLON {
  80807. interface Scene {
  80808. /** @hidden */
  80809. _pointerOverSprite: Nullable<Sprite>;
  80810. /** @hidden */
  80811. _pickedDownSprite: Nullable<Sprite>;
  80812. /** @hidden */
  80813. _tempSpritePickingRay: Nullable<Ray>;
  80814. /**
  80815. * All of the sprite managers added to this scene
  80816. * @see http://doc.babylonjs.com/babylon101/sprites
  80817. */
  80818. spriteManagers: Array<ISpriteManager>;
  80819. /**
  80820. * An event triggered when sprites rendering is about to start
  80821. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  80822. */
  80823. onBeforeSpritesRenderingObservable: Observable<Scene>;
  80824. /**
  80825. * An event triggered when sprites rendering is done
  80826. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  80827. */
  80828. onAfterSpritesRenderingObservable: Observable<Scene>;
  80829. /** @hidden */
  80830. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80831. /** Launch a ray to try to pick a sprite in the scene
  80832. * @param x position on screen
  80833. * @param y position on screen
  80834. * @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
  80835. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  80836. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  80837. * @returns a PickingInfo
  80838. */
  80839. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80840. /** Use the given ray to pick a sprite in the scene
  80841. * @param ray The ray (in world space) to use to pick meshes
  80842. * @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
  80843. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  80844. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  80845. * @returns a PickingInfo
  80846. */
  80847. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80848. /** @hidden */
  80849. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80850. /** Launch a ray to try to pick sprites in the scene
  80851. * @param x position on screen
  80852. * @param y position on screen
  80853. * @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
  80854. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  80855. * @returns a PickingInfo array
  80856. */
  80857. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80858. /** Use the given ray to pick sprites in the scene
  80859. * @param ray The ray (in world space) to use to pick meshes
  80860. * @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
  80861. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  80862. * @returns a PickingInfo array
  80863. */
  80864. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80865. /**
  80866. * Force the sprite under the pointer
  80867. * @param sprite defines the sprite to use
  80868. */
  80869. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  80870. /**
  80871. * Gets the sprite under the pointer
  80872. * @returns a Sprite or null if no sprite is under the pointer
  80873. */
  80874. getPointerOverSprite(): Nullable<Sprite>;
  80875. }
  80876. /**
  80877. * Defines the sprite scene component responsible to manage sprites
  80878. * in a given scene.
  80879. */
  80880. export class SpriteSceneComponent implements ISceneComponent {
  80881. /**
  80882. * The component name helpfull to identify the component in the list of scene components.
  80883. */
  80884. readonly name: string;
  80885. /**
  80886. * The scene the component belongs to.
  80887. */
  80888. scene: Scene;
  80889. /** @hidden */
  80890. private _spritePredicate;
  80891. /**
  80892. * Creates a new instance of the component for the given scene
  80893. * @param scene Defines the scene to register the component in
  80894. */
  80895. constructor(scene: Scene);
  80896. /**
  80897. * Registers the component in a given scene
  80898. */
  80899. register(): void;
  80900. /**
  80901. * Rebuilds the elements related to this component in case of
  80902. * context lost for instance.
  80903. */
  80904. rebuild(): void;
  80905. /**
  80906. * Disposes the component and the associated ressources.
  80907. */
  80908. dispose(): void;
  80909. private _pickSpriteButKeepRay;
  80910. private _pointerMove;
  80911. private _pointerDown;
  80912. private _pointerUp;
  80913. }
  80914. }
  80915. declare module BABYLON {
  80916. /** @hidden */
  80917. export var fogFragmentDeclaration: {
  80918. name: string;
  80919. shader: string;
  80920. };
  80921. }
  80922. declare module BABYLON {
  80923. /** @hidden */
  80924. export var fogFragment: {
  80925. name: string;
  80926. shader: string;
  80927. };
  80928. }
  80929. declare module BABYLON {
  80930. /** @hidden */
  80931. export var spritesPixelShader: {
  80932. name: string;
  80933. shader: string;
  80934. };
  80935. }
  80936. declare module BABYLON {
  80937. /** @hidden */
  80938. export var fogVertexDeclaration: {
  80939. name: string;
  80940. shader: string;
  80941. };
  80942. }
  80943. declare module BABYLON {
  80944. /** @hidden */
  80945. export var spritesVertexShader: {
  80946. name: string;
  80947. shader: string;
  80948. };
  80949. }
  80950. declare module BABYLON {
  80951. /**
  80952. * Defines the minimum interface to fullfil in order to be a sprite manager.
  80953. */
  80954. export interface ISpriteManager extends IDisposable {
  80955. /**
  80956. * Restricts the camera to viewing objects with the same layerMask.
  80957. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  80958. */
  80959. layerMask: number;
  80960. /**
  80961. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  80962. */
  80963. isPickable: boolean;
  80964. /**
  80965. * Specifies the rendering group id for this mesh (0 by default)
  80966. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  80967. */
  80968. renderingGroupId: number;
  80969. /**
  80970. * Defines the list of sprites managed by the manager.
  80971. */
  80972. sprites: Array<Sprite>;
  80973. /**
  80974. * Tests the intersection of a sprite with a specific ray.
  80975. * @param ray The ray we are sending to test the collision
  80976. * @param camera The camera space we are sending rays in
  80977. * @param predicate A predicate allowing excluding sprites from the list of object to test
  80978. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  80979. * @returns picking info or null.
  80980. */
  80981. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  80982. /**
  80983. * Intersects the sprites with a ray
  80984. * @param ray defines the ray to intersect with
  80985. * @param camera defines the current active camera
  80986. * @param predicate defines a predicate used to select candidate sprites
  80987. * @returns null if no hit or a PickingInfo array
  80988. */
  80989. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  80990. /**
  80991. * Renders the list of sprites on screen.
  80992. */
  80993. render(): void;
  80994. }
  80995. /**
  80996. * Class used to manage multiple sprites on the same spritesheet
  80997. * @see http://doc.babylonjs.com/babylon101/sprites
  80998. */
  80999. export class SpriteManager implements ISpriteManager {
  81000. /** defines the manager's name */
  81001. name: string;
  81002. /** Gets the list of sprites */
  81003. sprites: Sprite[];
  81004. /** Gets or sets the rendering group id (0 by default) */
  81005. renderingGroupId: number;
  81006. /** Gets or sets camera layer mask */
  81007. layerMask: number;
  81008. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  81009. fogEnabled: boolean;
  81010. /** Gets or sets a boolean indicating if the sprites are pickable */
  81011. isPickable: boolean;
  81012. /** Defines the default width of a cell in the spritesheet */
  81013. cellWidth: number;
  81014. /** Defines the default height of a cell in the spritesheet */
  81015. cellHeight: number;
  81016. /** Associative array from JSON sprite data file */
  81017. private _cellData;
  81018. /** Array of sprite names from JSON sprite data file */
  81019. private _spriteMap;
  81020. /** True when packed cell data from JSON file is ready*/
  81021. private _packedAndReady;
  81022. /**
  81023. * An event triggered when the manager is disposed.
  81024. */
  81025. onDisposeObservable: Observable<SpriteManager>;
  81026. private _onDisposeObserver;
  81027. /**
  81028. * Callback called when the manager is disposed
  81029. */
  81030. onDispose: () => void;
  81031. private _capacity;
  81032. private _fromPacked;
  81033. private _spriteTexture;
  81034. private _epsilon;
  81035. private _scene;
  81036. private _vertexData;
  81037. private _buffer;
  81038. private _vertexBuffers;
  81039. private _indexBuffer;
  81040. private _effectBase;
  81041. private _effectFog;
  81042. /**
  81043. * Gets or sets the spritesheet texture
  81044. */
  81045. texture: Texture;
  81046. /**
  81047. * Creates a new sprite manager
  81048. * @param name defines the manager's name
  81049. * @param imgUrl defines the sprite sheet url
  81050. * @param capacity defines the maximum allowed number of sprites
  81051. * @param cellSize defines the size of a sprite cell
  81052. * @param scene defines the hosting scene
  81053. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  81054. * @param samplingMode defines the smapling mode to use with spritesheet
  81055. * @param fromPacked set to false; do not alter
  81056. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  81057. */
  81058. constructor(
  81059. /** defines the manager's name */
  81060. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  81061. private _makePacked;
  81062. private _appendSpriteVertex;
  81063. /**
  81064. * Intersects the sprites with a ray
  81065. * @param ray defines the ray to intersect with
  81066. * @param camera defines the current active camera
  81067. * @param predicate defines a predicate used to select candidate sprites
  81068. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  81069. * @returns null if no hit or a PickingInfo
  81070. */
  81071. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  81072. /**
  81073. * Intersects the sprites with a ray
  81074. * @param ray defines the ray to intersect with
  81075. * @param camera defines the current active camera
  81076. * @param predicate defines a predicate used to select candidate sprites
  81077. * @returns null if no hit or a PickingInfo array
  81078. */
  81079. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  81080. /**
  81081. * Render all child sprites
  81082. */
  81083. render(): void;
  81084. /**
  81085. * Release associated resources
  81086. */
  81087. dispose(): void;
  81088. }
  81089. }
  81090. declare module BABYLON {
  81091. /**
  81092. * Class used to represent a sprite
  81093. * @see http://doc.babylonjs.com/babylon101/sprites
  81094. */
  81095. export class Sprite {
  81096. /** defines the name */
  81097. name: string;
  81098. /** Gets or sets the current world position */
  81099. position: Vector3;
  81100. /** Gets or sets the main color */
  81101. color: Color4;
  81102. /** Gets or sets the width */
  81103. width: number;
  81104. /** Gets or sets the height */
  81105. height: number;
  81106. /** Gets or sets rotation angle */
  81107. angle: number;
  81108. /** Gets or sets the cell index in the sprite sheet */
  81109. cellIndex: number;
  81110. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  81111. cellRef: string;
  81112. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  81113. invertU: number;
  81114. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  81115. invertV: number;
  81116. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  81117. disposeWhenFinishedAnimating: boolean;
  81118. /** Gets the list of attached animations */
  81119. animations: Animation[];
  81120. /** Gets or sets a boolean indicating if the sprite can be picked */
  81121. isPickable: boolean;
  81122. /**
  81123. * Gets or sets the associated action manager
  81124. */
  81125. actionManager: Nullable<ActionManager>;
  81126. private _animationStarted;
  81127. private _loopAnimation;
  81128. private _fromIndex;
  81129. private _toIndex;
  81130. private _delay;
  81131. private _direction;
  81132. private _manager;
  81133. private _time;
  81134. private _onAnimationEnd;
  81135. /**
  81136. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  81137. */
  81138. isVisible: boolean;
  81139. /**
  81140. * Gets or sets the sprite size
  81141. */
  81142. size: number;
  81143. /**
  81144. * Creates a new Sprite
  81145. * @param name defines the name
  81146. * @param manager defines the manager
  81147. */
  81148. constructor(
  81149. /** defines the name */
  81150. name: string, manager: ISpriteManager);
  81151. /**
  81152. * Starts an animation
  81153. * @param from defines the initial key
  81154. * @param to defines the end key
  81155. * @param loop defines if the animation must loop
  81156. * @param delay defines the start delay (in ms)
  81157. * @param onAnimationEnd defines a callback to call when animation ends
  81158. */
  81159. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  81160. /** Stops current animation (if any) */
  81161. stopAnimation(): void;
  81162. /** @hidden */
  81163. _animate(deltaTime: number): void;
  81164. /** Release associated resources */
  81165. dispose(): void;
  81166. }
  81167. }
  81168. declare module BABYLON {
  81169. /**
  81170. * Information about the result of picking within a scene
  81171. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  81172. */
  81173. export class PickingInfo {
  81174. /** @hidden */
  81175. _pickingUnavailable: boolean;
  81176. /**
  81177. * If the pick collided with an object
  81178. */
  81179. hit: boolean;
  81180. /**
  81181. * Distance away where the pick collided
  81182. */
  81183. distance: number;
  81184. /**
  81185. * The location of pick collision
  81186. */
  81187. pickedPoint: Nullable<Vector3>;
  81188. /**
  81189. * The mesh corresponding the the pick collision
  81190. */
  81191. pickedMesh: Nullable<AbstractMesh>;
  81192. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  81193. bu: number;
  81194. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  81195. bv: number;
  81196. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  81197. faceId: number;
  81198. /** Id of the the submesh that was picked */
  81199. subMeshId: number;
  81200. /** If a sprite was picked, this will be the sprite the pick collided with */
  81201. pickedSprite: Nullable<Sprite>;
  81202. /**
  81203. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  81204. */
  81205. originMesh: Nullable<AbstractMesh>;
  81206. /**
  81207. * The ray that was used to perform the picking.
  81208. */
  81209. ray: Nullable<Ray>;
  81210. /**
  81211. * Gets the normal correspodning to the face the pick collided with
  81212. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  81213. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  81214. * @returns The normal correspodning to the face the pick collided with
  81215. */
  81216. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  81217. /**
  81218. * Gets the texture coordinates of where the pick occured
  81219. * @returns the vector containing the coordnates of the texture
  81220. */
  81221. getTextureCoordinates(): Nullable<Vector2>;
  81222. }
  81223. }
  81224. declare module BABYLON {
  81225. /**
  81226. * Gather the list of pointer event types as constants.
  81227. */
  81228. export class PointerEventTypes {
  81229. /**
  81230. * 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.
  81231. */
  81232. static readonly POINTERDOWN: number;
  81233. /**
  81234. * The pointerup event is fired when a pointer is no longer active.
  81235. */
  81236. static readonly POINTERUP: number;
  81237. /**
  81238. * The pointermove event is fired when a pointer changes coordinates.
  81239. */
  81240. static readonly POINTERMOVE: number;
  81241. /**
  81242. * The pointerwheel event is fired when a mouse wheel has been rotated.
  81243. */
  81244. static readonly POINTERWHEEL: number;
  81245. /**
  81246. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  81247. */
  81248. static readonly POINTERPICK: number;
  81249. /**
  81250. * The pointertap event is fired when a the object has been touched and released without drag.
  81251. */
  81252. static readonly POINTERTAP: number;
  81253. /**
  81254. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  81255. */
  81256. static readonly POINTERDOUBLETAP: number;
  81257. }
  81258. /**
  81259. * Base class of pointer info types.
  81260. */
  81261. export class PointerInfoBase {
  81262. /**
  81263. * Defines the type of event (PointerEventTypes)
  81264. */
  81265. type: number;
  81266. /**
  81267. * Defines the related dom event
  81268. */
  81269. event: PointerEvent | MouseWheelEvent;
  81270. /**
  81271. * Instantiates the base class of pointers info.
  81272. * @param type Defines the type of event (PointerEventTypes)
  81273. * @param event Defines the related dom event
  81274. */
  81275. constructor(
  81276. /**
  81277. * Defines the type of event (PointerEventTypes)
  81278. */
  81279. type: number,
  81280. /**
  81281. * Defines the related dom event
  81282. */
  81283. event: PointerEvent | MouseWheelEvent);
  81284. }
  81285. /**
  81286. * This class is used to store pointer related info for the onPrePointerObservable event.
  81287. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  81288. */
  81289. export class PointerInfoPre extends PointerInfoBase {
  81290. /**
  81291. * Ray from a pointer if availible (eg. 6dof controller)
  81292. */
  81293. ray: Nullable<Ray>;
  81294. /**
  81295. * Defines the local position of the pointer on the canvas.
  81296. */
  81297. localPosition: Vector2;
  81298. /**
  81299. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  81300. */
  81301. skipOnPointerObservable: boolean;
  81302. /**
  81303. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  81304. * @param type Defines the type of event (PointerEventTypes)
  81305. * @param event Defines the related dom event
  81306. * @param localX Defines the local x coordinates of the pointer when the event occured
  81307. * @param localY Defines the local y coordinates of the pointer when the event occured
  81308. */
  81309. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  81310. }
  81311. /**
  81312. * This type contains all the data related to a pointer event in Babylon.js.
  81313. * 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.
  81314. */
  81315. export class PointerInfo extends PointerInfoBase {
  81316. /**
  81317. * Defines the picking info associated to the info (if any)\
  81318. */
  81319. pickInfo: Nullable<PickingInfo>;
  81320. /**
  81321. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  81322. * @param type Defines the type of event (PointerEventTypes)
  81323. * @param event Defines the related dom event
  81324. * @param pickInfo Defines the picking info associated to the info (if any)\
  81325. */
  81326. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  81327. /**
  81328. * Defines the picking info associated to the info (if any)\
  81329. */
  81330. pickInfo: Nullable<PickingInfo>);
  81331. }
  81332. /**
  81333. * Data relating to a touch event on the screen.
  81334. */
  81335. export interface PointerTouch {
  81336. /**
  81337. * X coordinate of touch.
  81338. */
  81339. x: number;
  81340. /**
  81341. * Y coordinate of touch.
  81342. */
  81343. y: number;
  81344. /**
  81345. * Id of touch. Unique for each finger.
  81346. */
  81347. pointerId: number;
  81348. /**
  81349. * Event type passed from DOM.
  81350. */
  81351. type: any;
  81352. }
  81353. }
  81354. declare module BABYLON {
  81355. /**
  81356. * Manage the mouse inputs to control the movement of a free camera.
  81357. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81358. */
  81359. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  81360. /**
  81361. * Define if touch is enabled in the mouse input
  81362. */
  81363. touchEnabled: boolean;
  81364. /**
  81365. * Defines the camera the input is attached to.
  81366. */
  81367. camera: FreeCamera;
  81368. /**
  81369. * Defines the buttons associated with the input to handle camera move.
  81370. */
  81371. buttons: number[];
  81372. /**
  81373. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  81374. */
  81375. angularSensibility: number;
  81376. private _pointerInput;
  81377. private _onMouseMove;
  81378. private _observer;
  81379. private previousPosition;
  81380. /**
  81381. * Observable for when a pointer move event occurs containing the move offset
  81382. */
  81383. onPointerMovedObservable: Observable<{
  81384. offsetX: number;
  81385. offsetY: number;
  81386. }>;
  81387. /**
  81388. * @hidden
  81389. * If the camera should be rotated automatically based on pointer movement
  81390. */
  81391. _allowCameraRotation: boolean;
  81392. /**
  81393. * Manage the mouse inputs to control the movement of a free camera.
  81394. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81395. * @param touchEnabled Defines if touch is enabled or not
  81396. */
  81397. constructor(
  81398. /**
  81399. * Define if touch is enabled in the mouse input
  81400. */
  81401. touchEnabled?: boolean);
  81402. /**
  81403. * Attach the input controls to a specific dom element to get the input from.
  81404. * @param element Defines the element the controls should be listened from
  81405. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81406. */
  81407. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81408. /**
  81409. * Called on JS contextmenu event.
  81410. * Override this method to provide functionality.
  81411. */
  81412. protected onContextMenu(evt: PointerEvent): void;
  81413. /**
  81414. * Detach the current controls from the specified dom element.
  81415. * @param element Defines the element to stop listening the inputs from
  81416. */
  81417. detachControl(element: Nullable<HTMLElement>): void;
  81418. /**
  81419. * Gets the class name of the current intput.
  81420. * @returns the class name
  81421. */
  81422. getClassName(): string;
  81423. /**
  81424. * Get the friendly name associated with the input class.
  81425. * @returns the input friendly name
  81426. */
  81427. getSimpleName(): string;
  81428. }
  81429. }
  81430. declare module BABYLON {
  81431. /**
  81432. * Manage the touch inputs to control the movement of a free camera.
  81433. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81434. */
  81435. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  81436. /**
  81437. * Defines the camera the input is attached to.
  81438. */
  81439. camera: FreeCamera;
  81440. /**
  81441. * Defines the touch sensibility for rotation.
  81442. * The higher the faster.
  81443. */
  81444. touchAngularSensibility: number;
  81445. /**
  81446. * Defines the touch sensibility for move.
  81447. * The higher the faster.
  81448. */
  81449. touchMoveSensibility: number;
  81450. private _offsetX;
  81451. private _offsetY;
  81452. private _pointerPressed;
  81453. private _pointerInput;
  81454. private _observer;
  81455. private _onLostFocus;
  81456. /**
  81457. * Attach the input controls to a specific dom element to get the input from.
  81458. * @param element Defines the element the controls should be listened from
  81459. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81460. */
  81461. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81462. /**
  81463. * Detach the current controls from the specified dom element.
  81464. * @param element Defines the element to stop listening the inputs from
  81465. */
  81466. detachControl(element: Nullable<HTMLElement>): void;
  81467. /**
  81468. * Update the current camera state depending on the inputs that have been used this frame.
  81469. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  81470. */
  81471. checkInputs(): void;
  81472. /**
  81473. * Gets the class name of the current intput.
  81474. * @returns the class name
  81475. */
  81476. getClassName(): string;
  81477. /**
  81478. * Get the friendly name associated with the input class.
  81479. * @returns the input friendly name
  81480. */
  81481. getSimpleName(): string;
  81482. }
  81483. }
  81484. declare module BABYLON {
  81485. /**
  81486. * Default Inputs manager for the FreeCamera.
  81487. * It groups all the default supported inputs for ease of use.
  81488. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81489. */
  81490. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  81491. /**
  81492. * @hidden
  81493. */
  81494. _mouseInput: Nullable<FreeCameraMouseInput>;
  81495. /**
  81496. * Instantiates a new FreeCameraInputsManager.
  81497. * @param camera Defines the camera the inputs belong to
  81498. */
  81499. constructor(camera: FreeCamera);
  81500. /**
  81501. * Add keyboard input support to the input manager.
  81502. * @returns the current input manager
  81503. */
  81504. addKeyboard(): FreeCameraInputsManager;
  81505. /**
  81506. * Add mouse input support to the input manager.
  81507. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  81508. * @returns the current input manager
  81509. */
  81510. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  81511. /**
  81512. * Removes the mouse input support from the manager
  81513. * @returns the current input manager
  81514. */
  81515. removeMouse(): FreeCameraInputsManager;
  81516. /**
  81517. * Add touch input support to the input manager.
  81518. * @returns the current input manager
  81519. */
  81520. addTouch(): FreeCameraInputsManager;
  81521. /**
  81522. * Remove all attached input methods from a camera
  81523. */
  81524. clear(): void;
  81525. }
  81526. }
  81527. declare module BABYLON {
  81528. /**
  81529. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  81530. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  81531. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  81532. */
  81533. export class FreeCamera extends TargetCamera {
  81534. /**
  81535. * Define the collision ellipsoid of the camera.
  81536. * This is helpful to simulate a camera body like the player body around the camera
  81537. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  81538. */
  81539. ellipsoid: Vector3;
  81540. /**
  81541. * Define an offset for the position of the ellipsoid around the camera.
  81542. * This can be helpful to determine the center of the body near the gravity center of the body
  81543. * instead of its head.
  81544. */
  81545. ellipsoidOffset: Vector3;
  81546. /**
  81547. * Enable or disable collisions of the camera with the rest of the scene objects.
  81548. */
  81549. checkCollisions: boolean;
  81550. /**
  81551. * Enable or disable gravity on the camera.
  81552. */
  81553. applyGravity: boolean;
  81554. /**
  81555. * Define the input manager associated to the camera.
  81556. */
  81557. inputs: FreeCameraInputsManager;
  81558. /**
  81559. * Gets the input sensibility for a mouse input. (default is 2000.0)
  81560. * Higher values reduce sensitivity.
  81561. */
  81562. /**
  81563. * Sets the input sensibility for a mouse input. (default is 2000.0)
  81564. * Higher values reduce sensitivity.
  81565. */
  81566. angularSensibility: number;
  81567. /**
  81568. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  81569. */
  81570. keysUp: number[];
  81571. /**
  81572. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  81573. */
  81574. keysDown: number[];
  81575. /**
  81576. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  81577. */
  81578. keysLeft: number[];
  81579. /**
  81580. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  81581. */
  81582. keysRight: number[];
  81583. /**
  81584. * Event raised when the camera collide with a mesh in the scene.
  81585. */
  81586. onCollide: (collidedMesh: AbstractMesh) => void;
  81587. private _collider;
  81588. private _needMoveForGravity;
  81589. private _oldPosition;
  81590. private _diffPosition;
  81591. private _newPosition;
  81592. /** @hidden */
  81593. _localDirection: Vector3;
  81594. /** @hidden */
  81595. _transformedDirection: Vector3;
  81596. /**
  81597. * Instantiates a Free Camera.
  81598. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  81599. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  81600. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  81601. * @param name Define the name of the camera in the scene
  81602. * @param position Define the start position of the camera in the scene
  81603. * @param scene Define the scene the camera belongs to
  81604. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81605. */
  81606. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81607. /**
  81608. * Attached controls to the current camera.
  81609. * @param element Defines the element the controls should be listened from
  81610. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81611. */
  81612. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81613. /**
  81614. * Detach the current controls from the camera.
  81615. * The camera will stop reacting to inputs.
  81616. * @param element Defines the element to stop listening the inputs from
  81617. */
  81618. detachControl(element: HTMLElement): void;
  81619. private _collisionMask;
  81620. /**
  81621. * Define a collision mask to limit the list of object the camera can collide with
  81622. */
  81623. collisionMask: number;
  81624. /** @hidden */
  81625. _collideWithWorld(displacement: Vector3): void;
  81626. private _onCollisionPositionChange;
  81627. /** @hidden */
  81628. _checkInputs(): void;
  81629. /** @hidden */
  81630. _decideIfNeedsToMove(): boolean;
  81631. /** @hidden */
  81632. _updatePosition(): void;
  81633. /**
  81634. * Destroy the camera and release the current resources hold by it.
  81635. */
  81636. dispose(): void;
  81637. /**
  81638. * Gets the current object class name.
  81639. * @return the class name
  81640. */
  81641. getClassName(): string;
  81642. }
  81643. }
  81644. declare module BABYLON {
  81645. /**
  81646. * Represents a gamepad control stick position
  81647. */
  81648. export class StickValues {
  81649. /**
  81650. * The x component of the control stick
  81651. */
  81652. x: number;
  81653. /**
  81654. * The y component of the control stick
  81655. */
  81656. y: number;
  81657. /**
  81658. * Initializes the gamepad x and y control stick values
  81659. * @param x The x component of the gamepad control stick value
  81660. * @param y The y component of the gamepad control stick value
  81661. */
  81662. constructor(
  81663. /**
  81664. * The x component of the control stick
  81665. */
  81666. x: number,
  81667. /**
  81668. * The y component of the control stick
  81669. */
  81670. y: number);
  81671. }
  81672. /**
  81673. * An interface which manages callbacks for gamepad button changes
  81674. */
  81675. export interface GamepadButtonChanges {
  81676. /**
  81677. * Called when a gamepad has been changed
  81678. */
  81679. changed: boolean;
  81680. /**
  81681. * Called when a gamepad press event has been triggered
  81682. */
  81683. pressChanged: boolean;
  81684. /**
  81685. * Called when a touch event has been triggered
  81686. */
  81687. touchChanged: boolean;
  81688. /**
  81689. * Called when a value has changed
  81690. */
  81691. valueChanged: boolean;
  81692. }
  81693. /**
  81694. * Represents a gamepad
  81695. */
  81696. export class Gamepad {
  81697. /**
  81698. * The id of the gamepad
  81699. */
  81700. id: string;
  81701. /**
  81702. * The index of the gamepad
  81703. */
  81704. index: number;
  81705. /**
  81706. * The browser gamepad
  81707. */
  81708. browserGamepad: any;
  81709. /**
  81710. * Specifies what type of gamepad this represents
  81711. */
  81712. type: number;
  81713. private _leftStick;
  81714. private _rightStick;
  81715. /** @hidden */
  81716. _isConnected: boolean;
  81717. private _leftStickAxisX;
  81718. private _leftStickAxisY;
  81719. private _rightStickAxisX;
  81720. private _rightStickAxisY;
  81721. /**
  81722. * Triggered when the left control stick has been changed
  81723. */
  81724. private _onleftstickchanged;
  81725. /**
  81726. * Triggered when the right control stick has been changed
  81727. */
  81728. private _onrightstickchanged;
  81729. /**
  81730. * Represents a gamepad controller
  81731. */
  81732. static GAMEPAD: number;
  81733. /**
  81734. * Represents a generic controller
  81735. */
  81736. static GENERIC: number;
  81737. /**
  81738. * Represents an XBox controller
  81739. */
  81740. static XBOX: number;
  81741. /**
  81742. * Represents a pose-enabled controller
  81743. */
  81744. static POSE_ENABLED: number;
  81745. /**
  81746. * Represents an Dual Shock controller
  81747. */
  81748. static DUALSHOCK: number;
  81749. /**
  81750. * Specifies whether the left control stick should be Y-inverted
  81751. */
  81752. protected _invertLeftStickY: boolean;
  81753. /**
  81754. * Specifies if the gamepad has been connected
  81755. */
  81756. readonly isConnected: boolean;
  81757. /**
  81758. * Initializes the gamepad
  81759. * @param id The id of the gamepad
  81760. * @param index The index of the gamepad
  81761. * @param browserGamepad The browser gamepad
  81762. * @param leftStickX The x component of the left joystick
  81763. * @param leftStickY The y component of the left joystick
  81764. * @param rightStickX The x component of the right joystick
  81765. * @param rightStickY The y component of the right joystick
  81766. */
  81767. constructor(
  81768. /**
  81769. * The id of the gamepad
  81770. */
  81771. id: string,
  81772. /**
  81773. * The index of the gamepad
  81774. */
  81775. index: number,
  81776. /**
  81777. * The browser gamepad
  81778. */
  81779. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  81780. /**
  81781. * Callback triggered when the left joystick has changed
  81782. * @param callback
  81783. */
  81784. onleftstickchanged(callback: (values: StickValues) => void): void;
  81785. /**
  81786. * Callback triggered when the right joystick has changed
  81787. * @param callback
  81788. */
  81789. onrightstickchanged(callback: (values: StickValues) => void): void;
  81790. /**
  81791. * Gets the left joystick
  81792. */
  81793. /**
  81794. * Sets the left joystick values
  81795. */
  81796. leftStick: StickValues;
  81797. /**
  81798. * Gets the right joystick
  81799. */
  81800. /**
  81801. * Sets the right joystick value
  81802. */
  81803. rightStick: StickValues;
  81804. /**
  81805. * Updates the gamepad joystick positions
  81806. */
  81807. update(): void;
  81808. /**
  81809. * Disposes the gamepad
  81810. */
  81811. dispose(): void;
  81812. }
  81813. /**
  81814. * Represents a generic gamepad
  81815. */
  81816. export class GenericPad extends Gamepad {
  81817. private _buttons;
  81818. private _onbuttondown;
  81819. private _onbuttonup;
  81820. /**
  81821. * Observable triggered when a button has been pressed
  81822. */
  81823. onButtonDownObservable: Observable<number>;
  81824. /**
  81825. * Observable triggered when a button has been released
  81826. */
  81827. onButtonUpObservable: Observable<number>;
  81828. /**
  81829. * Callback triggered when a button has been pressed
  81830. * @param callback Called when a button has been pressed
  81831. */
  81832. onbuttondown(callback: (buttonPressed: number) => void): void;
  81833. /**
  81834. * Callback triggered when a button has been released
  81835. * @param callback Called when a button has been released
  81836. */
  81837. onbuttonup(callback: (buttonReleased: number) => void): void;
  81838. /**
  81839. * Initializes the generic gamepad
  81840. * @param id The id of the generic gamepad
  81841. * @param index The index of the generic gamepad
  81842. * @param browserGamepad The browser gamepad
  81843. */
  81844. constructor(id: string, index: number, browserGamepad: any);
  81845. private _setButtonValue;
  81846. /**
  81847. * Updates the generic gamepad
  81848. */
  81849. update(): void;
  81850. /**
  81851. * Disposes the generic gamepad
  81852. */
  81853. dispose(): void;
  81854. }
  81855. }
  81856. declare module BABYLON {
  81857. interface Engine {
  81858. /**
  81859. * Creates a raw texture
  81860. * @param data defines the data to store in the texture
  81861. * @param width defines the width of the texture
  81862. * @param height defines the height of the texture
  81863. * @param format defines the format of the data
  81864. * @param generateMipMaps defines if the engine should generate the mip levels
  81865. * @param invertY defines if data must be stored with Y axis inverted
  81866. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  81867. * @param compression defines the compression used (null by default)
  81868. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81869. * @returns the raw texture inside an InternalTexture
  81870. */
  81871. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  81872. /**
  81873. * Update a raw texture
  81874. * @param texture defines the texture to update
  81875. * @param data defines the data to store in the texture
  81876. * @param format defines the format of the data
  81877. * @param invertY defines if data must be stored with Y axis inverted
  81878. */
  81879. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81880. /**
  81881. * Update a raw texture
  81882. * @param texture defines the texture to update
  81883. * @param data defines the data to store in the texture
  81884. * @param format defines the format of the data
  81885. * @param invertY defines if data must be stored with Y axis inverted
  81886. * @param compression defines the compression used (null by default)
  81887. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81888. */
  81889. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  81890. /**
  81891. * Creates a new raw cube texture
  81892. * @param data defines the array of data to use to create each face
  81893. * @param size defines the size of the textures
  81894. * @param format defines the format of the data
  81895. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81896. * @param generateMipMaps defines if the engine should generate the mip levels
  81897. * @param invertY defines if data must be stored with Y axis inverted
  81898. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81899. * @param compression defines the compression used (null by default)
  81900. * @returns the cube texture as an InternalTexture
  81901. */
  81902. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  81903. /**
  81904. * Update a raw cube texture
  81905. * @param texture defines the texture to udpdate
  81906. * @param data defines the data to store
  81907. * @param format defines the data format
  81908. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81909. * @param invertY defines if data must be stored with Y axis inverted
  81910. */
  81911. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  81912. /**
  81913. * Update a raw cube texture
  81914. * @param texture defines the texture to udpdate
  81915. * @param data defines the data to store
  81916. * @param format defines the data format
  81917. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81918. * @param invertY defines if data must be stored with Y axis inverted
  81919. * @param compression defines the compression used (null by default)
  81920. */
  81921. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  81922. /**
  81923. * Update a raw cube texture
  81924. * @param texture defines the texture to udpdate
  81925. * @param data defines the data to store
  81926. * @param format defines the data format
  81927. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81928. * @param invertY defines if data must be stored with Y axis inverted
  81929. * @param compression defines the compression used (null by default)
  81930. * @param level defines which level of the texture to update
  81931. */
  81932. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  81933. /**
  81934. * Creates a new raw cube texture from a specified url
  81935. * @param url defines the url where the data is located
  81936. * @param scene defines the current scene
  81937. * @param size defines the size of the textures
  81938. * @param format defines the format of the data
  81939. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81940. * @param noMipmap defines if the engine should avoid generating the mip levels
  81941. * @param callback defines a callback used to extract texture data from loaded data
  81942. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  81943. * @param onLoad defines a callback called when texture is loaded
  81944. * @param onError defines a callback called if there is an error
  81945. * @returns the cube texture as an InternalTexture
  81946. */
  81947. 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;
  81948. /**
  81949. * Creates a new raw cube texture from a specified url
  81950. * @param url defines the url where the data is located
  81951. * @param scene defines the current scene
  81952. * @param size defines the size of the textures
  81953. * @param format defines the format of the data
  81954. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81955. * @param noMipmap defines if the engine should avoid generating the mip levels
  81956. * @param callback defines a callback used to extract texture data from loaded data
  81957. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  81958. * @param onLoad defines a callback called when texture is loaded
  81959. * @param onError defines a callback called if there is an error
  81960. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81961. * @param invertY defines if data must be stored with Y axis inverted
  81962. * @returns the cube texture as an InternalTexture
  81963. */
  81964. 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;
  81965. /**
  81966. * Creates a new raw 3D texture
  81967. * @param data defines the data used to create the texture
  81968. * @param width defines the width of the texture
  81969. * @param height defines the height of the texture
  81970. * @param depth defines the depth of the texture
  81971. * @param format defines the format of the texture
  81972. * @param generateMipMaps defines if the engine must generate mip levels
  81973. * @param invertY defines if data must be stored with Y axis inverted
  81974. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81975. * @param compression defines the compressed used (can be null)
  81976. * @param textureType defines the compressed used (can be null)
  81977. * @returns a new raw 3D texture (stored in an InternalTexture)
  81978. */
  81979. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  81980. /**
  81981. * Update a raw 3D texture
  81982. * @param texture defines the texture to update
  81983. * @param data defines the data to store
  81984. * @param format defines the data format
  81985. * @param invertY defines if data must be stored with Y axis inverted
  81986. */
  81987. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81988. /**
  81989. * Update a raw 3D texture
  81990. * @param texture defines the texture to update
  81991. * @param data defines the data to store
  81992. * @param format defines the data format
  81993. * @param invertY defines if data must be stored with Y axis inverted
  81994. * @param compression defines the used compression (can be null)
  81995. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  81996. */
  81997. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  81998. /**
  81999. * Creates a new raw 2D array texture
  82000. * @param data defines the data used to create the texture
  82001. * @param width defines the width of the texture
  82002. * @param height defines the height of the texture
  82003. * @param depth defines the number of layers of the texture
  82004. * @param format defines the format of the texture
  82005. * @param generateMipMaps defines if the engine must generate mip levels
  82006. * @param invertY defines if data must be stored with Y axis inverted
  82007. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  82008. * @param compression defines the compressed used (can be null)
  82009. * @param textureType defines the compressed used (can be null)
  82010. * @returns a new raw 2D array texture (stored in an InternalTexture)
  82011. */
  82012. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  82013. /**
  82014. * Update a raw 2D array texture
  82015. * @param texture defines the texture to update
  82016. * @param data defines the data to store
  82017. * @param format defines the data format
  82018. * @param invertY defines if data must be stored with Y axis inverted
  82019. */
  82020. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  82021. /**
  82022. * Update a raw 2D array texture
  82023. * @param texture defines the texture to update
  82024. * @param data defines the data to store
  82025. * @param format defines the data format
  82026. * @param invertY defines if data must be stored with Y axis inverted
  82027. * @param compression defines the used compression (can be null)
  82028. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  82029. */
  82030. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  82031. }
  82032. }
  82033. declare module BABYLON {
  82034. /**
  82035. * Raw texture can help creating a texture directly from an array of data.
  82036. * This can be super useful if you either get the data from an uncompressed source or
  82037. * if you wish to create your texture pixel by pixel.
  82038. */
  82039. export class RawTexture extends Texture {
  82040. /**
  82041. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  82042. */
  82043. format: number;
  82044. private _engine;
  82045. /**
  82046. * Instantiates a new RawTexture.
  82047. * Raw texture can help creating a texture directly from an array of data.
  82048. * This can be super useful if you either get the data from an uncompressed source or
  82049. * if you wish to create your texture pixel by pixel.
  82050. * @param data define the array of data to use to create the texture
  82051. * @param width define the width of the texture
  82052. * @param height define the height of the texture
  82053. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  82054. * @param scene define the scene the texture belongs to
  82055. * @param generateMipMaps define whether mip maps should be generated or not
  82056. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  82057. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  82058. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  82059. */
  82060. constructor(data: ArrayBufferView, width: number, height: number,
  82061. /**
  82062. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  82063. */
  82064. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  82065. /**
  82066. * Updates the texture underlying data.
  82067. * @param data Define the new data of the texture
  82068. */
  82069. update(data: ArrayBufferView): void;
  82070. /**
  82071. * Creates a luminance texture from some data.
  82072. * @param data Define the texture data
  82073. * @param width Define the width of the texture
  82074. * @param height Define the height of the texture
  82075. * @param scene Define the scene the texture belongs to
  82076. * @param generateMipMaps Define whether or not to create mip maps for the texture
  82077. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  82078. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  82079. * @returns the luminance texture
  82080. */
  82081. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  82082. /**
  82083. * Creates a luminance alpha texture from some data.
  82084. * @param data Define the texture data
  82085. * @param width Define the width of the texture
  82086. * @param height Define the height of the texture
  82087. * @param scene Define the scene the texture belongs to
  82088. * @param generateMipMaps Define whether or not to create mip maps for the texture
  82089. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  82090. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  82091. * @returns the luminance alpha texture
  82092. */
  82093. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  82094. /**
  82095. * Creates an alpha texture from some data.
  82096. * @param data Define the texture data
  82097. * @param width Define the width of the texture
  82098. * @param height Define the height of the texture
  82099. * @param scene Define the scene the texture belongs to
  82100. * @param generateMipMaps Define whether or not to create mip maps for the texture
  82101. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  82102. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  82103. * @returns the alpha texture
  82104. */
  82105. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  82106. /**
  82107. * Creates a RGB texture from some data.
  82108. * @param data Define the texture data
  82109. * @param width Define the width of the texture
  82110. * @param height Define the height of the texture
  82111. * @param scene Define the scene the texture belongs to
  82112. * @param generateMipMaps Define whether or not to create mip maps for the texture
  82113. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  82114. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  82115. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  82116. * @returns the RGB alpha texture
  82117. */
  82118. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  82119. /**
  82120. * Creates a RGBA texture from some data.
  82121. * @param data Define the texture data
  82122. * @param width Define the width of the texture
  82123. * @param height Define the height of the texture
  82124. * @param scene Define the scene the texture belongs to
  82125. * @param generateMipMaps Define whether or not to create mip maps for the texture
  82126. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  82127. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  82128. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  82129. * @returns the RGBA texture
  82130. */
  82131. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  82132. /**
  82133. * Creates a R texture from some data.
  82134. * @param data Define the texture data
  82135. * @param width Define the width of the texture
  82136. * @param height Define the height of the texture
  82137. * @param scene Define the scene the texture belongs to
  82138. * @param generateMipMaps Define whether or not to create mip maps for the texture
  82139. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  82140. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  82141. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  82142. * @returns the R texture
  82143. */
  82144. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  82145. }
  82146. }
  82147. declare module BABYLON {
  82148. /**
  82149. * Interface for the size containing width and height
  82150. */
  82151. export interface ISize {
  82152. /**
  82153. * Width
  82154. */
  82155. width: number;
  82156. /**
  82157. * Heighht
  82158. */
  82159. height: number;
  82160. }
  82161. /**
  82162. * Size containing widht and height
  82163. */
  82164. export class Size implements ISize {
  82165. /**
  82166. * Width
  82167. */
  82168. width: number;
  82169. /**
  82170. * Height
  82171. */
  82172. height: number;
  82173. /**
  82174. * Creates a Size object from the given width and height (floats).
  82175. * @param width width of the new size
  82176. * @param height height of the new size
  82177. */
  82178. constructor(width: number, height: number);
  82179. /**
  82180. * Returns a string with the Size width and height
  82181. * @returns a string with the Size width and height
  82182. */
  82183. toString(): string;
  82184. /**
  82185. * "Size"
  82186. * @returns the string "Size"
  82187. */
  82188. getClassName(): string;
  82189. /**
  82190. * Returns the Size hash code.
  82191. * @returns a hash code for a unique width and height
  82192. */
  82193. getHashCode(): number;
  82194. /**
  82195. * Updates the current size from the given one.
  82196. * @param src the given size
  82197. */
  82198. copyFrom(src: Size): void;
  82199. /**
  82200. * Updates in place the current Size from the given floats.
  82201. * @param width width of the new size
  82202. * @param height height of the new size
  82203. * @returns the updated Size.
  82204. */
  82205. copyFromFloats(width: number, height: number): Size;
  82206. /**
  82207. * Updates in place the current Size from the given floats.
  82208. * @param width width to set
  82209. * @param height height to set
  82210. * @returns the updated Size.
  82211. */
  82212. set(width: number, height: number): Size;
  82213. /**
  82214. * Multiplies the width and height by numbers
  82215. * @param w factor to multiple the width by
  82216. * @param h factor to multiple the height by
  82217. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  82218. */
  82219. multiplyByFloats(w: number, h: number): Size;
  82220. /**
  82221. * Clones the size
  82222. * @returns a new Size copied from the given one.
  82223. */
  82224. clone(): Size;
  82225. /**
  82226. * True if the current Size and the given one width and height are strictly equal.
  82227. * @param other the other size to compare against
  82228. * @returns True if the current Size and the given one width and height are strictly equal.
  82229. */
  82230. equals(other: Size): boolean;
  82231. /**
  82232. * The surface of the Size : width * height (float).
  82233. */
  82234. readonly surface: number;
  82235. /**
  82236. * Create a new size of zero
  82237. * @returns a new Size set to (0.0, 0.0)
  82238. */
  82239. static Zero(): Size;
  82240. /**
  82241. * Sums the width and height of two sizes
  82242. * @param otherSize size to add to this size
  82243. * @returns a new Size set as the addition result of the current Size and the given one.
  82244. */
  82245. add(otherSize: Size): Size;
  82246. /**
  82247. * Subtracts the width and height of two
  82248. * @param otherSize size to subtract to this size
  82249. * @returns a new Size set as the subtraction result of the given one from the current Size.
  82250. */
  82251. subtract(otherSize: Size): Size;
  82252. /**
  82253. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  82254. * @param start starting size to lerp between
  82255. * @param end end size to lerp between
  82256. * @param amount amount to lerp between the start and end values
  82257. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  82258. */
  82259. static Lerp(start: Size, end: Size, amount: number): Size;
  82260. }
  82261. }
  82262. declare module BABYLON {
  82263. /**
  82264. * Defines a runtime animation
  82265. */
  82266. export class RuntimeAnimation {
  82267. private _events;
  82268. /**
  82269. * The current frame of the runtime animation
  82270. */
  82271. private _currentFrame;
  82272. /**
  82273. * The animation used by the runtime animation
  82274. */
  82275. private _animation;
  82276. /**
  82277. * The target of the runtime animation
  82278. */
  82279. private _target;
  82280. /**
  82281. * The initiating animatable
  82282. */
  82283. private _host;
  82284. /**
  82285. * The original value of the runtime animation
  82286. */
  82287. private _originalValue;
  82288. /**
  82289. * The original blend value of the runtime animation
  82290. */
  82291. private _originalBlendValue;
  82292. /**
  82293. * The offsets cache of the runtime animation
  82294. */
  82295. private _offsetsCache;
  82296. /**
  82297. * The high limits cache of the runtime animation
  82298. */
  82299. private _highLimitsCache;
  82300. /**
  82301. * Specifies if the runtime animation has been stopped
  82302. */
  82303. private _stopped;
  82304. /**
  82305. * The blending factor of the runtime animation
  82306. */
  82307. private _blendingFactor;
  82308. /**
  82309. * The BabylonJS scene
  82310. */
  82311. private _scene;
  82312. /**
  82313. * The current value of the runtime animation
  82314. */
  82315. private _currentValue;
  82316. /** @hidden */
  82317. _animationState: _IAnimationState;
  82318. /**
  82319. * The active target of the runtime animation
  82320. */
  82321. private _activeTargets;
  82322. private _currentActiveTarget;
  82323. private _directTarget;
  82324. /**
  82325. * The target path of the runtime animation
  82326. */
  82327. private _targetPath;
  82328. /**
  82329. * The weight of the runtime animation
  82330. */
  82331. private _weight;
  82332. /**
  82333. * The ratio offset of the runtime animation
  82334. */
  82335. private _ratioOffset;
  82336. /**
  82337. * The previous delay of the runtime animation
  82338. */
  82339. private _previousDelay;
  82340. /**
  82341. * The previous ratio of the runtime animation
  82342. */
  82343. private _previousRatio;
  82344. private _enableBlending;
  82345. private _keys;
  82346. private _minFrame;
  82347. private _maxFrame;
  82348. private _minValue;
  82349. private _maxValue;
  82350. private _targetIsArray;
  82351. /**
  82352. * Gets the current frame of the runtime animation
  82353. */
  82354. readonly currentFrame: number;
  82355. /**
  82356. * Gets the weight of the runtime animation
  82357. */
  82358. readonly weight: number;
  82359. /**
  82360. * Gets the current value of the runtime animation
  82361. */
  82362. readonly currentValue: any;
  82363. /**
  82364. * Gets the target path of the runtime animation
  82365. */
  82366. readonly targetPath: string;
  82367. /**
  82368. * Gets the actual target of the runtime animation
  82369. */
  82370. readonly target: any;
  82371. /** @hidden */
  82372. _onLoop: () => void;
  82373. /**
  82374. * Create a new RuntimeAnimation object
  82375. * @param target defines the target of the animation
  82376. * @param animation defines the source animation object
  82377. * @param scene defines the hosting scene
  82378. * @param host defines the initiating Animatable
  82379. */
  82380. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  82381. private _preparePath;
  82382. /**
  82383. * Gets the animation from the runtime animation
  82384. */
  82385. readonly animation: Animation;
  82386. /**
  82387. * Resets the runtime animation to the beginning
  82388. * @param restoreOriginal defines whether to restore the target property to the original value
  82389. */
  82390. reset(restoreOriginal?: boolean): void;
  82391. /**
  82392. * Specifies if the runtime animation is stopped
  82393. * @returns Boolean specifying if the runtime animation is stopped
  82394. */
  82395. isStopped(): boolean;
  82396. /**
  82397. * Disposes of the runtime animation
  82398. */
  82399. dispose(): void;
  82400. /**
  82401. * Apply the interpolated value to the target
  82402. * @param currentValue defines the value computed by the animation
  82403. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  82404. */
  82405. setValue(currentValue: any, weight: number): void;
  82406. private _getOriginalValues;
  82407. private _setValue;
  82408. /**
  82409. * Gets the loop pmode of the runtime animation
  82410. * @returns Loop Mode
  82411. */
  82412. private _getCorrectLoopMode;
  82413. /**
  82414. * Move the current animation to a given frame
  82415. * @param frame defines the frame to move to
  82416. */
  82417. goToFrame(frame: number): void;
  82418. /**
  82419. * @hidden Internal use only
  82420. */
  82421. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  82422. /**
  82423. * Execute the current animation
  82424. * @param delay defines the delay to add to the current frame
  82425. * @param from defines the lower bound of the animation range
  82426. * @param to defines the upper bound of the animation range
  82427. * @param loop defines if the current animation must loop
  82428. * @param speedRatio defines the current speed ratio
  82429. * @param weight defines the weight of the animation (default is -1 so no weight)
  82430. * @param onLoop optional callback called when animation loops
  82431. * @returns a boolean indicating if the animation is running
  82432. */
  82433. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  82434. }
  82435. }
  82436. declare module BABYLON {
  82437. /**
  82438. * Class used to store an actual running animation
  82439. */
  82440. export class Animatable {
  82441. /** defines the target object */
  82442. target: any;
  82443. /** defines the starting frame number (default is 0) */
  82444. fromFrame: number;
  82445. /** defines the ending frame number (default is 100) */
  82446. toFrame: number;
  82447. /** defines if the animation must loop (default is false) */
  82448. loopAnimation: boolean;
  82449. /** defines a callback to call when animation ends if it is not looping */
  82450. onAnimationEnd?: (() => void) | null | undefined;
  82451. /** defines a callback to call when animation loops */
  82452. onAnimationLoop?: (() => void) | null | undefined;
  82453. private _localDelayOffset;
  82454. private _pausedDelay;
  82455. private _runtimeAnimations;
  82456. private _paused;
  82457. private _scene;
  82458. private _speedRatio;
  82459. private _weight;
  82460. private _syncRoot;
  82461. /**
  82462. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  82463. * This will only apply for non looping animation (default is true)
  82464. */
  82465. disposeOnEnd: boolean;
  82466. /**
  82467. * Gets a boolean indicating if the animation has started
  82468. */
  82469. animationStarted: boolean;
  82470. /**
  82471. * Observer raised when the animation ends
  82472. */
  82473. onAnimationEndObservable: Observable<Animatable>;
  82474. /**
  82475. * Observer raised when the animation loops
  82476. */
  82477. onAnimationLoopObservable: Observable<Animatable>;
  82478. /**
  82479. * Gets the root Animatable used to synchronize and normalize animations
  82480. */
  82481. readonly syncRoot: Nullable<Animatable>;
  82482. /**
  82483. * Gets the current frame of the first RuntimeAnimation
  82484. * Used to synchronize Animatables
  82485. */
  82486. readonly masterFrame: number;
  82487. /**
  82488. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  82489. */
  82490. weight: number;
  82491. /**
  82492. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  82493. */
  82494. speedRatio: number;
  82495. /**
  82496. * Creates a new Animatable
  82497. * @param scene defines the hosting scene
  82498. * @param target defines the target object
  82499. * @param fromFrame defines the starting frame number (default is 0)
  82500. * @param toFrame defines the ending frame number (default is 100)
  82501. * @param loopAnimation defines if the animation must loop (default is false)
  82502. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  82503. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  82504. * @param animations defines a group of animation to add to the new Animatable
  82505. * @param onAnimationLoop defines a callback to call when animation loops
  82506. */
  82507. constructor(scene: Scene,
  82508. /** defines the target object */
  82509. target: any,
  82510. /** defines the starting frame number (default is 0) */
  82511. fromFrame?: number,
  82512. /** defines the ending frame number (default is 100) */
  82513. toFrame?: number,
  82514. /** defines if the animation must loop (default is false) */
  82515. loopAnimation?: boolean, speedRatio?: number,
  82516. /** defines a callback to call when animation ends if it is not looping */
  82517. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  82518. /** defines a callback to call when animation loops */
  82519. onAnimationLoop?: (() => void) | null | undefined);
  82520. /**
  82521. * Synchronize and normalize current Animatable with a source Animatable
  82522. * This is useful when using animation weights and when animations are not of the same length
  82523. * @param root defines the root Animatable to synchronize with
  82524. * @returns the current Animatable
  82525. */
  82526. syncWith(root: Animatable): Animatable;
  82527. /**
  82528. * Gets the list of runtime animations
  82529. * @returns an array of RuntimeAnimation
  82530. */
  82531. getAnimations(): RuntimeAnimation[];
  82532. /**
  82533. * Adds more animations to the current animatable
  82534. * @param target defines the target of the animations
  82535. * @param animations defines the new animations to add
  82536. */
  82537. appendAnimations(target: any, animations: Animation[]): void;
  82538. /**
  82539. * Gets the source animation for a specific property
  82540. * @param property defines the propertyu to look for
  82541. * @returns null or the source animation for the given property
  82542. */
  82543. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  82544. /**
  82545. * Gets the runtime animation for a specific property
  82546. * @param property defines the propertyu to look for
  82547. * @returns null or the runtime animation for the given property
  82548. */
  82549. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  82550. /**
  82551. * Resets the animatable to its original state
  82552. */
  82553. reset(): void;
  82554. /**
  82555. * Allows the animatable to blend with current running animations
  82556. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82557. * @param blendingSpeed defines the blending speed to use
  82558. */
  82559. enableBlending(blendingSpeed: number): void;
  82560. /**
  82561. * Disable animation blending
  82562. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82563. */
  82564. disableBlending(): void;
  82565. /**
  82566. * Jump directly to a given frame
  82567. * @param frame defines the frame to jump to
  82568. */
  82569. goToFrame(frame: number): void;
  82570. /**
  82571. * Pause the animation
  82572. */
  82573. pause(): void;
  82574. /**
  82575. * Restart the animation
  82576. */
  82577. restart(): void;
  82578. private _raiseOnAnimationEnd;
  82579. /**
  82580. * Stop and delete the current animation
  82581. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  82582. * @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)
  82583. */
  82584. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  82585. /**
  82586. * Wait asynchronously for the animation to end
  82587. * @returns a promise which will be fullfilled when the animation ends
  82588. */
  82589. waitAsync(): Promise<Animatable>;
  82590. /** @hidden */
  82591. _animate(delay: number): boolean;
  82592. }
  82593. interface Scene {
  82594. /** @hidden */
  82595. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  82596. /** @hidden */
  82597. _processLateAnimationBindingsForMatrices(holder: {
  82598. totalWeight: number;
  82599. animations: RuntimeAnimation[];
  82600. originalValue: Matrix;
  82601. }): any;
  82602. /** @hidden */
  82603. _processLateAnimationBindingsForQuaternions(holder: {
  82604. totalWeight: number;
  82605. animations: RuntimeAnimation[];
  82606. originalValue: Quaternion;
  82607. }, refQuaternion: Quaternion): Quaternion;
  82608. /** @hidden */
  82609. _processLateAnimationBindings(): void;
  82610. /**
  82611. * Will start the animation sequence of a given target
  82612. * @param target defines the target
  82613. * @param from defines from which frame should animation start
  82614. * @param to defines until which frame should animation run.
  82615. * @param weight defines the weight to apply to the animation (1.0 by default)
  82616. * @param loop defines if the animation loops
  82617. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  82618. * @param onAnimationEnd defines the function to be executed when the animation ends
  82619. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  82620. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  82621. * @param onAnimationLoop defines the callback to call when an animation loops
  82622. * @returns the animatable object created for this animation
  82623. */
  82624. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  82625. /**
  82626. * Will start the animation sequence of a given target
  82627. * @param target defines the target
  82628. * @param from defines from which frame should animation start
  82629. * @param to defines until which frame should animation run.
  82630. * @param loop defines if the animation loops
  82631. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  82632. * @param onAnimationEnd defines the function to be executed when the animation ends
  82633. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  82634. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  82635. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  82636. * @param onAnimationLoop defines the callback to call when an animation loops
  82637. * @returns the animatable object created for this animation
  82638. */
  82639. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  82640. /**
  82641. * Will start the animation sequence of a given target and its hierarchy
  82642. * @param target defines the target
  82643. * @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.
  82644. * @param from defines from which frame should animation start
  82645. * @param to defines until which frame should animation run.
  82646. * @param loop defines if the animation loops
  82647. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  82648. * @param onAnimationEnd defines the function to be executed when the animation ends
  82649. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  82650. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  82651. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  82652. * @param onAnimationLoop defines the callback to call when an animation loops
  82653. * @returns the list of created animatables
  82654. */
  82655. 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[];
  82656. /**
  82657. * Begin a new animation on a given node
  82658. * @param target defines the target where the animation will take place
  82659. * @param animations defines the list of animations to start
  82660. * @param from defines the initial value
  82661. * @param to defines the final value
  82662. * @param loop defines if you want animation to loop (off by default)
  82663. * @param speedRatio defines the speed ratio to apply to all animations
  82664. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82665. * @param onAnimationLoop defines the callback to call when an animation loops
  82666. * @returns the list of created animatables
  82667. */
  82668. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  82669. /**
  82670. * Begin a new animation on a given node and its hierarchy
  82671. * @param target defines the root node where the animation will take place
  82672. * @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.
  82673. * @param animations defines the list of animations to start
  82674. * @param from defines the initial value
  82675. * @param to defines the final value
  82676. * @param loop defines if you want animation to loop (off by default)
  82677. * @param speedRatio defines the speed ratio to apply to all animations
  82678. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82679. * @param onAnimationLoop defines the callback to call when an animation loops
  82680. * @returns the list of animatables created for all nodes
  82681. */
  82682. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  82683. /**
  82684. * Gets the animatable associated with a specific target
  82685. * @param target defines the target of the animatable
  82686. * @returns the required animatable if found
  82687. */
  82688. getAnimatableByTarget(target: any): Nullable<Animatable>;
  82689. /**
  82690. * Gets all animatables associated with a given target
  82691. * @param target defines the target to look animatables for
  82692. * @returns an array of Animatables
  82693. */
  82694. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  82695. /**
  82696. * Stops and removes all animations that have been applied to the scene
  82697. */
  82698. stopAllAnimations(): void;
  82699. /**
  82700. * Gets the current delta time used by animation engine
  82701. */
  82702. deltaTime: number;
  82703. }
  82704. interface Bone {
  82705. /**
  82706. * Copy an animation range from another bone
  82707. * @param source defines the source bone
  82708. * @param rangeName defines the range name to copy
  82709. * @param frameOffset defines the frame offset
  82710. * @param rescaleAsRequired defines if rescaling must be applied if required
  82711. * @param skelDimensionsRatio defines the scaling ratio
  82712. * @returns true if operation was successful
  82713. */
  82714. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  82715. }
  82716. }
  82717. declare module BABYLON {
  82718. /**
  82719. * Class used to override all child animations of a given target
  82720. */
  82721. export class AnimationPropertiesOverride {
  82722. /**
  82723. * Gets or sets a value indicating if animation blending must be used
  82724. */
  82725. enableBlending: boolean;
  82726. /**
  82727. * Gets or sets the blending speed to use when enableBlending is true
  82728. */
  82729. blendingSpeed: number;
  82730. /**
  82731. * Gets or sets the default loop mode to use
  82732. */
  82733. loopMode: number;
  82734. }
  82735. }
  82736. declare module BABYLON {
  82737. /**
  82738. * Class used to handle skinning animations
  82739. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82740. */
  82741. export class Skeleton implements IAnimatable {
  82742. /** defines the skeleton name */
  82743. name: string;
  82744. /** defines the skeleton Id */
  82745. id: string;
  82746. /**
  82747. * Defines the list of child bones
  82748. */
  82749. bones: Bone[];
  82750. /**
  82751. * Defines an estimate of the dimension of the skeleton at rest
  82752. */
  82753. dimensionsAtRest: Vector3;
  82754. /**
  82755. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  82756. */
  82757. needInitialSkinMatrix: boolean;
  82758. /**
  82759. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  82760. */
  82761. overrideMesh: Nullable<AbstractMesh>;
  82762. /**
  82763. * Gets the list of animations attached to this skeleton
  82764. */
  82765. animations: Array<Animation>;
  82766. private _scene;
  82767. private _isDirty;
  82768. private _transformMatrices;
  82769. private _transformMatrixTexture;
  82770. private _meshesWithPoseMatrix;
  82771. private _animatables;
  82772. private _identity;
  82773. private _synchronizedWithMesh;
  82774. private _ranges;
  82775. private _lastAbsoluteTransformsUpdateId;
  82776. private _canUseTextureForBones;
  82777. private _uniqueId;
  82778. /** @hidden */
  82779. _numBonesWithLinkedTransformNode: number;
  82780. /** @hidden */
  82781. _hasWaitingData: Nullable<boolean>;
  82782. /**
  82783. * Specifies if the skeleton should be serialized
  82784. */
  82785. doNotSerialize: boolean;
  82786. private _useTextureToStoreBoneMatrices;
  82787. /**
  82788. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  82789. * Please note that this option is not available if the hardware does not support it
  82790. */
  82791. useTextureToStoreBoneMatrices: boolean;
  82792. private _animationPropertiesOverride;
  82793. /**
  82794. * Gets or sets the animation properties override
  82795. */
  82796. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82797. /**
  82798. * List of inspectable custom properties (used by the Inspector)
  82799. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82800. */
  82801. inspectableCustomProperties: IInspectable[];
  82802. /**
  82803. * An observable triggered before computing the skeleton's matrices
  82804. */
  82805. onBeforeComputeObservable: Observable<Skeleton>;
  82806. /**
  82807. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  82808. */
  82809. readonly isUsingTextureForMatrices: boolean;
  82810. /**
  82811. * Gets the unique ID of this skeleton
  82812. */
  82813. readonly uniqueId: number;
  82814. /**
  82815. * Creates a new skeleton
  82816. * @param name defines the skeleton name
  82817. * @param id defines the skeleton Id
  82818. * @param scene defines the hosting scene
  82819. */
  82820. constructor(
  82821. /** defines the skeleton name */
  82822. name: string,
  82823. /** defines the skeleton Id */
  82824. id: string, scene: Scene);
  82825. /**
  82826. * Gets the current object class name.
  82827. * @return the class name
  82828. */
  82829. getClassName(): string;
  82830. /**
  82831. * Returns an array containing the root bones
  82832. * @returns an array containing the root bones
  82833. */
  82834. getChildren(): Array<Bone>;
  82835. /**
  82836. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  82837. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  82838. * @returns a Float32Array containing matrices data
  82839. */
  82840. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  82841. /**
  82842. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  82843. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  82844. * @returns a raw texture containing the data
  82845. */
  82846. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  82847. /**
  82848. * Gets the current hosting scene
  82849. * @returns a scene object
  82850. */
  82851. getScene(): Scene;
  82852. /**
  82853. * Gets a string representing the current skeleton data
  82854. * @param fullDetails defines a boolean indicating if we want a verbose version
  82855. * @returns a string representing the current skeleton data
  82856. */
  82857. toString(fullDetails?: boolean): string;
  82858. /**
  82859. * Get bone's index searching by name
  82860. * @param name defines bone's name to search for
  82861. * @return the indice of the bone. Returns -1 if not found
  82862. */
  82863. getBoneIndexByName(name: string): number;
  82864. /**
  82865. * Creater a new animation range
  82866. * @param name defines the name of the range
  82867. * @param from defines the start key
  82868. * @param to defines the end key
  82869. */
  82870. createAnimationRange(name: string, from: number, to: number): void;
  82871. /**
  82872. * Delete a specific animation range
  82873. * @param name defines the name of the range
  82874. * @param deleteFrames defines if frames must be removed as well
  82875. */
  82876. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  82877. /**
  82878. * Gets a specific animation range
  82879. * @param name defines the name of the range to look for
  82880. * @returns the requested animation range or null if not found
  82881. */
  82882. getAnimationRange(name: string): Nullable<AnimationRange>;
  82883. /**
  82884. * Gets the list of all animation ranges defined on this skeleton
  82885. * @returns an array
  82886. */
  82887. getAnimationRanges(): Nullable<AnimationRange>[];
  82888. /**
  82889. * Copy animation range from a source skeleton.
  82890. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  82891. * @param source defines the source skeleton
  82892. * @param name defines the name of the range to copy
  82893. * @param rescaleAsRequired defines if rescaling must be applied if required
  82894. * @returns true if operation was successful
  82895. */
  82896. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  82897. /**
  82898. * Forces the skeleton to go to rest pose
  82899. */
  82900. returnToRest(): void;
  82901. private _getHighestAnimationFrame;
  82902. /**
  82903. * Begin a specific animation range
  82904. * @param name defines the name of the range to start
  82905. * @param loop defines if looping must be turned on (false by default)
  82906. * @param speedRatio defines the speed ratio to apply (1 by default)
  82907. * @param onAnimationEnd defines a callback which will be called when animation will end
  82908. * @returns a new animatable
  82909. */
  82910. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  82911. /** @hidden */
  82912. _markAsDirty(): void;
  82913. /** @hidden */
  82914. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  82915. /** @hidden */
  82916. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  82917. private _computeTransformMatrices;
  82918. /**
  82919. * Build all resources required to render a skeleton
  82920. */
  82921. prepare(): void;
  82922. /**
  82923. * Gets the list of animatables currently running for this skeleton
  82924. * @returns an array of animatables
  82925. */
  82926. getAnimatables(): IAnimatable[];
  82927. /**
  82928. * Clone the current skeleton
  82929. * @param name defines the name of the new skeleton
  82930. * @param id defines the id of the new skeleton
  82931. * @returns the new skeleton
  82932. */
  82933. clone(name: string, id?: string): Skeleton;
  82934. /**
  82935. * Enable animation blending for this skeleton
  82936. * @param blendingSpeed defines the blending speed to apply
  82937. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82938. */
  82939. enableBlending(blendingSpeed?: number): void;
  82940. /**
  82941. * Releases all resources associated with the current skeleton
  82942. */
  82943. dispose(): void;
  82944. /**
  82945. * Serialize the skeleton in a JSON object
  82946. * @returns a JSON object
  82947. */
  82948. serialize(): any;
  82949. /**
  82950. * Creates a new skeleton from serialized data
  82951. * @param parsedSkeleton defines the serialized data
  82952. * @param scene defines the hosting scene
  82953. * @returns a new skeleton
  82954. */
  82955. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  82956. /**
  82957. * Compute all node absolute transforms
  82958. * @param forceUpdate defines if computation must be done even if cache is up to date
  82959. */
  82960. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  82961. /**
  82962. * Gets the root pose matrix
  82963. * @returns a matrix
  82964. */
  82965. getPoseMatrix(): Nullable<Matrix>;
  82966. /**
  82967. * Sorts bones per internal index
  82968. */
  82969. sortBones(): void;
  82970. private _sortBones;
  82971. }
  82972. }
  82973. declare module BABYLON {
  82974. /**
  82975. * Class used to store bone information
  82976. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82977. */
  82978. export class Bone extends Node {
  82979. /**
  82980. * defines the bone name
  82981. */
  82982. name: string;
  82983. private static _tmpVecs;
  82984. private static _tmpQuat;
  82985. private static _tmpMats;
  82986. /**
  82987. * Gets the list of child bones
  82988. */
  82989. children: Bone[];
  82990. /** Gets the animations associated with this bone */
  82991. animations: Animation[];
  82992. /**
  82993. * Gets or sets bone length
  82994. */
  82995. length: number;
  82996. /**
  82997. * @hidden Internal only
  82998. * Set this value to map this bone to a different index in the transform matrices
  82999. * Set this value to -1 to exclude the bone from the transform matrices
  83000. */
  83001. _index: Nullable<number>;
  83002. private _skeleton;
  83003. private _localMatrix;
  83004. private _restPose;
  83005. private _baseMatrix;
  83006. private _absoluteTransform;
  83007. private _invertedAbsoluteTransform;
  83008. private _parent;
  83009. private _scalingDeterminant;
  83010. private _worldTransform;
  83011. private _localScaling;
  83012. private _localRotation;
  83013. private _localPosition;
  83014. private _needToDecompose;
  83015. private _needToCompose;
  83016. /** @hidden */
  83017. _linkedTransformNode: Nullable<TransformNode>;
  83018. /** @hidden */
  83019. _waitingTransformNodeId: Nullable<string>;
  83020. /** @hidden */
  83021. /** @hidden */
  83022. _matrix: Matrix;
  83023. /**
  83024. * Create a new bone
  83025. * @param name defines the bone name
  83026. * @param skeleton defines the parent skeleton
  83027. * @param parentBone defines the parent (can be null if the bone is the root)
  83028. * @param localMatrix defines the local matrix
  83029. * @param restPose defines the rest pose matrix
  83030. * @param baseMatrix defines the base matrix
  83031. * @param index defines index of the bone in the hiearchy
  83032. */
  83033. constructor(
  83034. /**
  83035. * defines the bone name
  83036. */
  83037. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  83038. /**
  83039. * Gets the current object class name.
  83040. * @return the class name
  83041. */
  83042. getClassName(): string;
  83043. /**
  83044. * Gets the parent skeleton
  83045. * @returns a skeleton
  83046. */
  83047. getSkeleton(): Skeleton;
  83048. /**
  83049. * Gets parent bone
  83050. * @returns a bone or null if the bone is the root of the bone hierarchy
  83051. */
  83052. getParent(): Nullable<Bone>;
  83053. /**
  83054. * Returns an array containing the root bones
  83055. * @returns an array containing the root bones
  83056. */
  83057. getChildren(): Array<Bone>;
  83058. /**
  83059. * Gets the node index in matrix array generated for rendering
  83060. * @returns the node index
  83061. */
  83062. getIndex(): number;
  83063. /**
  83064. * Sets the parent bone
  83065. * @param parent defines the parent (can be null if the bone is the root)
  83066. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  83067. */
  83068. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  83069. /**
  83070. * Gets the local matrix
  83071. * @returns a matrix
  83072. */
  83073. getLocalMatrix(): Matrix;
  83074. /**
  83075. * Gets the base matrix (initial matrix which remains unchanged)
  83076. * @returns a matrix
  83077. */
  83078. getBaseMatrix(): Matrix;
  83079. /**
  83080. * Gets the rest pose matrix
  83081. * @returns a matrix
  83082. */
  83083. getRestPose(): Matrix;
  83084. /**
  83085. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  83086. */
  83087. getWorldMatrix(): Matrix;
  83088. /**
  83089. * Sets the local matrix to rest pose matrix
  83090. */
  83091. returnToRest(): void;
  83092. /**
  83093. * Gets the inverse of the absolute transform matrix.
  83094. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  83095. * @returns a matrix
  83096. */
  83097. getInvertedAbsoluteTransform(): Matrix;
  83098. /**
  83099. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  83100. * @returns a matrix
  83101. */
  83102. getAbsoluteTransform(): Matrix;
  83103. /**
  83104. * Links with the given transform node.
  83105. * The local matrix of this bone is copied from the transform node every frame.
  83106. * @param transformNode defines the transform node to link to
  83107. */
  83108. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  83109. /**
  83110. * Gets the node used to drive the bone's transformation
  83111. * @returns a transform node or null
  83112. */
  83113. getTransformNode(): Nullable<TransformNode>;
  83114. /** Gets or sets current position (in local space) */
  83115. position: Vector3;
  83116. /** Gets or sets current rotation (in local space) */
  83117. rotation: Vector3;
  83118. /** Gets or sets current rotation quaternion (in local space) */
  83119. rotationQuaternion: Quaternion;
  83120. /** Gets or sets current scaling (in local space) */
  83121. scaling: Vector3;
  83122. /**
  83123. * Gets the animation properties override
  83124. */
  83125. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  83126. private _decompose;
  83127. private _compose;
  83128. /**
  83129. * Update the base and local matrices
  83130. * @param matrix defines the new base or local matrix
  83131. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  83132. * @param updateLocalMatrix defines if the local matrix should be updated
  83133. */
  83134. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  83135. /** @hidden */
  83136. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  83137. /**
  83138. * Flag the bone as dirty (Forcing it to update everything)
  83139. */
  83140. markAsDirty(): void;
  83141. /** @hidden */
  83142. _markAsDirtyAndCompose(): void;
  83143. private _markAsDirtyAndDecompose;
  83144. /**
  83145. * Translate the bone in local or world space
  83146. * @param vec The amount to translate the bone
  83147. * @param space The space that the translation is in
  83148. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83149. */
  83150. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  83151. /**
  83152. * Set the postion of the bone in local or world space
  83153. * @param position The position to set the bone
  83154. * @param space The space that the position is in
  83155. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83156. */
  83157. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  83158. /**
  83159. * Set the absolute position of the bone (world space)
  83160. * @param position The position to set the bone
  83161. * @param mesh The mesh that this bone is attached to
  83162. */
  83163. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  83164. /**
  83165. * Scale the bone on the x, y and z axes (in local space)
  83166. * @param x The amount to scale the bone on the x axis
  83167. * @param y The amount to scale the bone on the y axis
  83168. * @param z The amount to scale the bone on the z axis
  83169. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  83170. */
  83171. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  83172. /**
  83173. * Set the bone scaling in local space
  83174. * @param scale defines the scaling vector
  83175. */
  83176. setScale(scale: Vector3): void;
  83177. /**
  83178. * Gets the current scaling in local space
  83179. * @returns the current scaling vector
  83180. */
  83181. getScale(): Vector3;
  83182. /**
  83183. * Gets the current scaling in local space and stores it in a target vector
  83184. * @param result defines the target vector
  83185. */
  83186. getScaleToRef(result: Vector3): void;
  83187. /**
  83188. * Set the yaw, pitch, and roll of the bone in local or world space
  83189. * @param yaw The rotation of the bone on the y axis
  83190. * @param pitch The rotation of the bone on the x axis
  83191. * @param roll The rotation of the bone on the z axis
  83192. * @param space The space that the axes of rotation are in
  83193. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83194. */
  83195. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  83196. /**
  83197. * Add a rotation to the bone on an axis in local or world space
  83198. * @param axis The axis to rotate the bone on
  83199. * @param amount The amount to rotate the bone
  83200. * @param space The space that the axis is in
  83201. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83202. */
  83203. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  83204. /**
  83205. * Set the rotation of the bone to a particular axis angle in local or world space
  83206. * @param axis The axis to rotate the bone on
  83207. * @param angle The angle that the bone should be rotated to
  83208. * @param space The space that the axis is in
  83209. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83210. */
  83211. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  83212. /**
  83213. * Set the euler rotation of the bone in local of world space
  83214. * @param rotation The euler rotation that the bone should be set to
  83215. * @param space The space that the rotation is in
  83216. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83217. */
  83218. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  83219. /**
  83220. * Set the quaternion rotation of the bone in local of world space
  83221. * @param quat The quaternion rotation that the bone should be set to
  83222. * @param space The space that the rotation is in
  83223. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83224. */
  83225. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  83226. /**
  83227. * Set the rotation matrix of the bone in local of world space
  83228. * @param rotMat The rotation matrix that the bone should be set to
  83229. * @param space The space that the rotation is in
  83230. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83231. */
  83232. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  83233. private _rotateWithMatrix;
  83234. private _getNegativeRotationToRef;
  83235. /**
  83236. * Get the position of the bone in local or world space
  83237. * @param space The space that the returned position is in
  83238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83239. * @returns The position of the bone
  83240. */
  83241. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  83242. /**
  83243. * Copy the position of the bone to a vector3 in local or world space
  83244. * @param space The space that the returned position is in
  83245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83246. * @param result The vector3 to copy the position to
  83247. */
  83248. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  83249. /**
  83250. * Get the absolute position of the bone (world space)
  83251. * @param mesh The mesh that this bone is attached to
  83252. * @returns The absolute position of the bone
  83253. */
  83254. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  83255. /**
  83256. * Copy the absolute position of the bone (world space) to the result param
  83257. * @param mesh The mesh that this bone is attached to
  83258. * @param result The vector3 to copy the absolute position to
  83259. */
  83260. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  83261. /**
  83262. * Compute the absolute transforms of this bone and its children
  83263. */
  83264. computeAbsoluteTransforms(): void;
  83265. /**
  83266. * Get the world direction from an axis that is in the local space of the bone
  83267. * @param localAxis The local direction that is used to compute the world direction
  83268. * @param mesh The mesh that this bone is attached to
  83269. * @returns The world direction
  83270. */
  83271. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  83272. /**
  83273. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  83274. * @param localAxis The local direction that is used to compute the world direction
  83275. * @param mesh The mesh that this bone is attached to
  83276. * @param result The vector3 that the world direction will be copied to
  83277. */
  83278. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  83279. /**
  83280. * Get the euler rotation of the bone in local or world space
  83281. * @param space The space that the rotation should be in
  83282. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83283. * @returns The euler rotation
  83284. */
  83285. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  83286. /**
  83287. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  83288. * @param space The space that the rotation should be in
  83289. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83290. * @param result The vector3 that the rotation should be copied to
  83291. */
  83292. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  83293. /**
  83294. * Get the quaternion rotation of the bone in either local or world space
  83295. * @param space The space that the rotation should be in
  83296. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83297. * @returns The quaternion rotation
  83298. */
  83299. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  83300. /**
  83301. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  83302. * @param space The space that the rotation should be in
  83303. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83304. * @param result The quaternion that the rotation should be copied to
  83305. */
  83306. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  83307. /**
  83308. * Get the rotation matrix of the bone in local or world space
  83309. * @param space The space that the rotation should be in
  83310. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83311. * @returns The rotation matrix
  83312. */
  83313. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  83314. /**
  83315. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  83316. * @param space The space that the rotation should be in
  83317. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83318. * @param result The quaternion that the rotation should be copied to
  83319. */
  83320. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  83321. /**
  83322. * Get the world position of a point that is in the local space of the bone
  83323. * @param position The local position
  83324. * @param mesh The mesh that this bone is attached to
  83325. * @returns The world position
  83326. */
  83327. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  83328. /**
  83329. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  83330. * @param position The local position
  83331. * @param mesh The mesh that this bone is attached to
  83332. * @param result The vector3 that the world position should be copied to
  83333. */
  83334. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  83335. /**
  83336. * Get the local position of a point that is in world space
  83337. * @param position The world position
  83338. * @param mesh The mesh that this bone is attached to
  83339. * @returns The local position
  83340. */
  83341. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  83342. /**
  83343. * Get the local position of a point that is in world space and copy it to the result param
  83344. * @param position The world position
  83345. * @param mesh The mesh that this bone is attached to
  83346. * @param result The vector3 that the local position should be copied to
  83347. */
  83348. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  83349. }
  83350. }
  83351. declare module BABYLON {
  83352. /**
  83353. * 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.
  83354. * @see https://doc.babylonjs.com/how_to/transformnode
  83355. */
  83356. export class TransformNode extends Node {
  83357. /**
  83358. * Object will not rotate to face the camera
  83359. */
  83360. static BILLBOARDMODE_NONE: number;
  83361. /**
  83362. * Object will rotate to face the camera but only on the x axis
  83363. */
  83364. static BILLBOARDMODE_X: number;
  83365. /**
  83366. * Object will rotate to face the camera but only on the y axis
  83367. */
  83368. static BILLBOARDMODE_Y: number;
  83369. /**
  83370. * Object will rotate to face the camera but only on the z axis
  83371. */
  83372. static BILLBOARDMODE_Z: number;
  83373. /**
  83374. * Object will rotate to face the camera
  83375. */
  83376. static BILLBOARDMODE_ALL: number;
  83377. /**
  83378. * Object will rotate to face the camera's position instead of orientation
  83379. */
  83380. static BILLBOARDMODE_USE_POSITION: number;
  83381. private _forward;
  83382. private _forwardInverted;
  83383. private _up;
  83384. private _right;
  83385. private _rightInverted;
  83386. private _position;
  83387. private _rotation;
  83388. private _rotationQuaternion;
  83389. protected _scaling: Vector3;
  83390. protected _isDirty: boolean;
  83391. private _transformToBoneReferal;
  83392. private _isAbsoluteSynced;
  83393. private _billboardMode;
  83394. /**
  83395. * Gets or sets the billboard mode. Default is 0.
  83396. *
  83397. * | Value | Type | Description |
  83398. * | --- | --- | --- |
  83399. * | 0 | BILLBOARDMODE_NONE | |
  83400. * | 1 | BILLBOARDMODE_X | |
  83401. * | 2 | BILLBOARDMODE_Y | |
  83402. * | 4 | BILLBOARDMODE_Z | |
  83403. * | 7 | BILLBOARDMODE_ALL | |
  83404. *
  83405. */
  83406. billboardMode: number;
  83407. private _preserveParentRotationForBillboard;
  83408. /**
  83409. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  83410. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  83411. */
  83412. preserveParentRotationForBillboard: boolean;
  83413. /**
  83414. * 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
  83415. */
  83416. scalingDeterminant: number;
  83417. private _infiniteDistance;
  83418. /**
  83419. * Gets or sets the distance of the object to max, often used by skybox
  83420. */
  83421. infiniteDistance: boolean;
  83422. /**
  83423. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  83424. * By default the system will update normals to compensate
  83425. */
  83426. ignoreNonUniformScaling: boolean;
  83427. /**
  83428. * 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
  83429. */
  83430. reIntegrateRotationIntoRotationQuaternion: boolean;
  83431. /** @hidden */
  83432. _poseMatrix: Nullable<Matrix>;
  83433. /** @hidden */
  83434. _localMatrix: Matrix;
  83435. private _usePivotMatrix;
  83436. private _absolutePosition;
  83437. private _absoluteScaling;
  83438. private _absoluteRotationQuaternion;
  83439. private _pivotMatrix;
  83440. private _pivotMatrixInverse;
  83441. protected _postMultiplyPivotMatrix: boolean;
  83442. protected _isWorldMatrixFrozen: boolean;
  83443. /** @hidden */
  83444. _indexInSceneTransformNodesArray: number;
  83445. /**
  83446. * An event triggered after the world matrix is updated
  83447. */
  83448. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  83449. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  83450. /**
  83451. * Gets a string identifying the name of the class
  83452. * @returns "TransformNode" string
  83453. */
  83454. getClassName(): string;
  83455. /**
  83456. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  83457. */
  83458. position: Vector3;
  83459. /**
  83460. * 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)).
  83461. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  83462. */
  83463. rotation: Vector3;
  83464. /**
  83465. * 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)).
  83466. */
  83467. scaling: Vector3;
  83468. /**
  83469. * 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).
  83470. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  83471. */
  83472. rotationQuaternion: Nullable<Quaternion>;
  83473. /**
  83474. * The forward direction of that transform in world space.
  83475. */
  83476. readonly forward: Vector3;
  83477. /**
  83478. * The up direction of that transform in world space.
  83479. */
  83480. readonly up: Vector3;
  83481. /**
  83482. * The right direction of that transform in world space.
  83483. */
  83484. readonly right: Vector3;
  83485. /**
  83486. * Copies the parameter passed Matrix into the mesh Pose matrix.
  83487. * @param matrix the matrix to copy the pose from
  83488. * @returns this TransformNode.
  83489. */
  83490. updatePoseMatrix(matrix: Matrix): TransformNode;
  83491. /**
  83492. * Returns the mesh Pose matrix.
  83493. * @returns the pose matrix
  83494. */
  83495. getPoseMatrix(): Matrix;
  83496. /** @hidden */
  83497. _isSynchronized(): boolean;
  83498. /** @hidden */
  83499. _initCache(): void;
  83500. /**
  83501. * Flag the transform node as dirty (Forcing it to update everything)
  83502. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  83503. * @returns this transform node
  83504. */
  83505. markAsDirty(property: string): TransformNode;
  83506. /**
  83507. * Returns the current mesh absolute position.
  83508. * Returns a Vector3.
  83509. */
  83510. readonly absolutePosition: Vector3;
  83511. /**
  83512. * Returns the current mesh absolute scaling.
  83513. * Returns a Vector3.
  83514. */
  83515. readonly absoluteScaling: Vector3;
  83516. /**
  83517. * Returns the current mesh absolute rotation.
  83518. * Returns a Quaternion.
  83519. */
  83520. readonly absoluteRotationQuaternion: Quaternion;
  83521. /**
  83522. * Sets a new matrix to apply before all other transformation
  83523. * @param matrix defines the transform matrix
  83524. * @returns the current TransformNode
  83525. */
  83526. setPreTransformMatrix(matrix: Matrix): TransformNode;
  83527. /**
  83528. * Sets a new pivot matrix to the current node
  83529. * @param matrix defines the new pivot matrix to use
  83530. * @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
  83531. * @returns the current TransformNode
  83532. */
  83533. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  83534. /**
  83535. * Returns the mesh pivot matrix.
  83536. * Default : Identity.
  83537. * @returns the matrix
  83538. */
  83539. getPivotMatrix(): Matrix;
  83540. /**
  83541. * Instantiate (when possible) or clone that node with its hierarchy
  83542. * @param newParent defines the new parent to use for the instance (or clone)
  83543. * @param options defines options to configure how copy is done
  83544. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  83545. * @returns an instance (or a clone) of the current node with its hiearchy
  83546. */
  83547. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  83548. doNotInstantiate: boolean;
  83549. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  83550. /**
  83551. * Prevents the World matrix to be computed any longer
  83552. * @param newWorldMatrix defines an optional matrix to use as world matrix
  83553. * @returns the TransformNode.
  83554. */
  83555. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  83556. /**
  83557. * Allows back the World matrix computation.
  83558. * @returns the TransformNode.
  83559. */
  83560. unfreezeWorldMatrix(): this;
  83561. /**
  83562. * True if the World matrix has been frozen.
  83563. */
  83564. readonly isWorldMatrixFrozen: boolean;
  83565. /**
  83566. * Retuns the mesh absolute position in the World.
  83567. * @returns a Vector3.
  83568. */
  83569. getAbsolutePosition(): Vector3;
  83570. /**
  83571. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  83572. * @param absolutePosition the absolute position to set
  83573. * @returns the TransformNode.
  83574. */
  83575. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  83576. /**
  83577. * Sets the mesh position in its local space.
  83578. * @param vector3 the position to set in localspace
  83579. * @returns the TransformNode.
  83580. */
  83581. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  83582. /**
  83583. * Returns the mesh position in the local space from the current World matrix values.
  83584. * @returns a new Vector3.
  83585. */
  83586. getPositionExpressedInLocalSpace(): Vector3;
  83587. /**
  83588. * Translates the mesh along the passed Vector3 in its local space.
  83589. * @param vector3 the distance to translate in localspace
  83590. * @returns the TransformNode.
  83591. */
  83592. locallyTranslate(vector3: Vector3): TransformNode;
  83593. private static _lookAtVectorCache;
  83594. /**
  83595. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  83596. * @param targetPoint the position (must be in same space as current mesh) to look at
  83597. * @param yawCor optional yaw (y-axis) correction in radians
  83598. * @param pitchCor optional pitch (x-axis) correction in radians
  83599. * @param rollCor optional roll (z-axis) correction in radians
  83600. * @param space the choosen space of the target
  83601. * @returns the TransformNode.
  83602. */
  83603. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  83604. /**
  83605. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  83606. * This Vector3 is expressed in the World space.
  83607. * @param localAxis axis to rotate
  83608. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  83609. */
  83610. getDirection(localAxis: Vector3): Vector3;
  83611. /**
  83612. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  83613. * localAxis is expressed in the mesh local space.
  83614. * result is computed in the Wordl space from the mesh World matrix.
  83615. * @param localAxis axis to rotate
  83616. * @param result the resulting transformnode
  83617. * @returns this TransformNode.
  83618. */
  83619. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  83620. /**
  83621. * Sets this transform node rotation to the given local axis.
  83622. * @param localAxis the axis in local space
  83623. * @param yawCor optional yaw (y-axis) correction in radians
  83624. * @param pitchCor optional pitch (x-axis) correction in radians
  83625. * @param rollCor optional roll (z-axis) correction in radians
  83626. * @returns this TransformNode
  83627. */
  83628. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  83629. /**
  83630. * Sets a new pivot point to the current node
  83631. * @param point defines the new pivot point to use
  83632. * @param space defines if the point is in world or local space (local by default)
  83633. * @returns the current TransformNode
  83634. */
  83635. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  83636. /**
  83637. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  83638. * @returns the pivot point
  83639. */
  83640. getPivotPoint(): Vector3;
  83641. /**
  83642. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  83643. * @param result the vector3 to store the result
  83644. * @returns this TransformNode.
  83645. */
  83646. getPivotPointToRef(result: Vector3): TransformNode;
  83647. /**
  83648. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  83649. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  83650. */
  83651. getAbsolutePivotPoint(): Vector3;
  83652. /**
  83653. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  83654. * @param result vector3 to store the result
  83655. * @returns this TransformNode.
  83656. */
  83657. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  83658. /**
  83659. * Defines the passed node as the parent of the current node.
  83660. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  83661. * @see https://doc.babylonjs.com/how_to/parenting
  83662. * @param node the node ot set as the parent
  83663. * @returns this TransformNode.
  83664. */
  83665. setParent(node: Nullable<Node>): TransformNode;
  83666. private _nonUniformScaling;
  83667. /**
  83668. * True if the scaling property of this object is non uniform eg. (1,2,1)
  83669. */
  83670. readonly nonUniformScaling: boolean;
  83671. /** @hidden */
  83672. _updateNonUniformScalingState(value: boolean): boolean;
  83673. /**
  83674. * Attach the current TransformNode to another TransformNode associated with a bone
  83675. * @param bone Bone affecting the TransformNode
  83676. * @param affectedTransformNode TransformNode associated with the bone
  83677. * @returns this object
  83678. */
  83679. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  83680. /**
  83681. * Detach the transform node if its associated with a bone
  83682. * @returns this object
  83683. */
  83684. detachFromBone(): TransformNode;
  83685. private static _rotationAxisCache;
  83686. /**
  83687. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  83688. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  83689. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  83690. * The passed axis is also normalized.
  83691. * @param axis the axis to rotate around
  83692. * @param amount the amount to rotate in radians
  83693. * @param space Space to rotate in (Default: local)
  83694. * @returns the TransformNode.
  83695. */
  83696. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  83697. /**
  83698. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  83699. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  83700. * The passed axis is also normalized. .
  83701. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  83702. * @param point the point to rotate around
  83703. * @param axis the axis to rotate around
  83704. * @param amount the amount to rotate in radians
  83705. * @returns the TransformNode
  83706. */
  83707. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  83708. /**
  83709. * Translates the mesh along the axis vector for the passed distance in the given space.
  83710. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  83711. * @param axis the axis to translate in
  83712. * @param distance the distance to translate
  83713. * @param space Space to rotate in (Default: local)
  83714. * @returns the TransformNode.
  83715. */
  83716. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  83717. /**
  83718. * Adds a rotation step to the mesh current rotation.
  83719. * x, y, z are Euler angles expressed in radians.
  83720. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  83721. * This means this rotation is made in the mesh local space only.
  83722. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  83723. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  83724. * ```javascript
  83725. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  83726. * ```
  83727. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  83728. * 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.
  83729. * @param x Rotation to add
  83730. * @param y Rotation to add
  83731. * @param z Rotation to add
  83732. * @returns the TransformNode.
  83733. */
  83734. addRotation(x: number, y: number, z: number): TransformNode;
  83735. /**
  83736. * @hidden
  83737. */
  83738. protected _getEffectiveParent(): Nullable<Node>;
  83739. /**
  83740. * Computes the world matrix of the node
  83741. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83742. * @returns the world matrix
  83743. */
  83744. computeWorldMatrix(force?: boolean): Matrix;
  83745. protected _afterComputeWorldMatrix(): void;
  83746. /**
  83747. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  83748. * @param func callback function to add
  83749. *
  83750. * @returns the TransformNode.
  83751. */
  83752. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  83753. /**
  83754. * Removes a registered callback function.
  83755. * @param func callback function to remove
  83756. * @returns the TransformNode.
  83757. */
  83758. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  83759. /**
  83760. * Gets the position of the current mesh in camera space
  83761. * @param camera defines the camera to use
  83762. * @returns a position
  83763. */
  83764. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  83765. /**
  83766. * Returns the distance from the mesh to the active camera
  83767. * @param camera defines the camera to use
  83768. * @returns the distance
  83769. */
  83770. getDistanceToCamera(camera?: Nullable<Camera>): number;
  83771. /**
  83772. * Clone the current transform node
  83773. * @param name Name of the new clone
  83774. * @param newParent New parent for the clone
  83775. * @param doNotCloneChildren Do not clone children hierarchy
  83776. * @returns the new transform node
  83777. */
  83778. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  83779. /**
  83780. * Serializes the objects information.
  83781. * @param currentSerializationObject defines the object to serialize in
  83782. * @returns the serialized object
  83783. */
  83784. serialize(currentSerializationObject?: any): any;
  83785. /**
  83786. * Returns a new TransformNode object parsed from the source provided.
  83787. * @param parsedTransformNode is the source.
  83788. * @param scene the scne the object belongs to
  83789. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  83790. * @returns a new TransformNode object parsed from the source provided.
  83791. */
  83792. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  83793. /**
  83794. * Get all child-transformNodes of this node
  83795. * @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
  83796. * @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
  83797. * @returns an array of TransformNode
  83798. */
  83799. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  83800. /**
  83801. * Releases resources associated with this transform node.
  83802. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83803. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83804. */
  83805. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83806. /**
  83807. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  83808. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  83809. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  83810. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  83811. * @returns the current mesh
  83812. */
  83813. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  83814. private _syncAbsoluteScalingAndRotation;
  83815. }
  83816. }
  83817. declare module BABYLON {
  83818. /**
  83819. * Defines the types of pose enabled controllers that are supported
  83820. */
  83821. export enum PoseEnabledControllerType {
  83822. /**
  83823. * HTC Vive
  83824. */
  83825. VIVE = 0,
  83826. /**
  83827. * Oculus Rift
  83828. */
  83829. OCULUS = 1,
  83830. /**
  83831. * Windows mixed reality
  83832. */
  83833. WINDOWS = 2,
  83834. /**
  83835. * Samsung gear VR
  83836. */
  83837. GEAR_VR = 3,
  83838. /**
  83839. * Google Daydream
  83840. */
  83841. DAYDREAM = 4,
  83842. /**
  83843. * Generic
  83844. */
  83845. GENERIC = 5
  83846. }
  83847. /**
  83848. * Defines the MutableGamepadButton interface for the state of a gamepad button
  83849. */
  83850. export interface MutableGamepadButton {
  83851. /**
  83852. * Value of the button/trigger
  83853. */
  83854. value: number;
  83855. /**
  83856. * If the button/trigger is currently touched
  83857. */
  83858. touched: boolean;
  83859. /**
  83860. * If the button/trigger is currently pressed
  83861. */
  83862. pressed: boolean;
  83863. }
  83864. /**
  83865. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  83866. * @hidden
  83867. */
  83868. export interface ExtendedGamepadButton extends GamepadButton {
  83869. /**
  83870. * If the button/trigger is currently pressed
  83871. */
  83872. readonly pressed: boolean;
  83873. /**
  83874. * If the button/trigger is currently touched
  83875. */
  83876. readonly touched: boolean;
  83877. /**
  83878. * Value of the button/trigger
  83879. */
  83880. readonly value: number;
  83881. }
  83882. /** @hidden */
  83883. export interface _GamePadFactory {
  83884. /**
  83885. * Returns wether or not the current gamepad can be created for this type of controller.
  83886. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  83887. * @returns true if it can be created, otherwise false
  83888. */
  83889. canCreate(gamepadInfo: any): boolean;
  83890. /**
  83891. * Creates a new instance of the Gamepad.
  83892. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  83893. * @returns the new gamepad instance
  83894. */
  83895. create(gamepadInfo: any): Gamepad;
  83896. }
  83897. /**
  83898. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  83899. */
  83900. export class PoseEnabledControllerHelper {
  83901. /** @hidden */
  83902. static _ControllerFactories: _GamePadFactory[];
  83903. /** @hidden */
  83904. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  83905. /**
  83906. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  83907. * @param vrGamepad the gamepad to initialized
  83908. * @returns a vr controller of the type the gamepad identified as
  83909. */
  83910. static InitiateController(vrGamepad: any): Gamepad;
  83911. }
  83912. /**
  83913. * Defines the PoseEnabledController object that contains state of a vr capable controller
  83914. */
  83915. export class PoseEnabledController extends Gamepad implements PoseControlled {
  83916. /**
  83917. * If the controller is used in a webXR session
  83918. */
  83919. isXR: boolean;
  83920. private _deviceRoomPosition;
  83921. private _deviceRoomRotationQuaternion;
  83922. /**
  83923. * The device position in babylon space
  83924. */
  83925. devicePosition: Vector3;
  83926. /**
  83927. * The device rotation in babylon space
  83928. */
  83929. deviceRotationQuaternion: Quaternion;
  83930. /**
  83931. * The scale factor of the device in babylon space
  83932. */
  83933. deviceScaleFactor: number;
  83934. /**
  83935. * (Likely devicePosition should be used instead) The device position in its room space
  83936. */
  83937. position: Vector3;
  83938. /**
  83939. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  83940. */
  83941. rotationQuaternion: Quaternion;
  83942. /**
  83943. * The type of controller (Eg. Windows mixed reality)
  83944. */
  83945. controllerType: PoseEnabledControllerType;
  83946. protected _calculatedPosition: Vector3;
  83947. private _calculatedRotation;
  83948. /**
  83949. * The raw pose from the device
  83950. */
  83951. rawPose: DevicePose;
  83952. private _trackPosition;
  83953. private _maxRotationDistFromHeadset;
  83954. private _draggedRoomRotation;
  83955. /**
  83956. * @hidden
  83957. */
  83958. _disableTrackPosition(fixedPosition: Vector3): void;
  83959. /**
  83960. * Internal, the mesh attached to the controller
  83961. * @hidden
  83962. */
  83963. _mesh: Nullable<AbstractMesh>;
  83964. private _poseControlledCamera;
  83965. private _leftHandSystemQuaternion;
  83966. /**
  83967. * Internal, matrix used to convert room space to babylon space
  83968. * @hidden
  83969. */
  83970. _deviceToWorld: Matrix;
  83971. /**
  83972. * Node to be used when casting a ray from the controller
  83973. * @hidden
  83974. */
  83975. _pointingPoseNode: Nullable<TransformNode>;
  83976. /**
  83977. * Name of the child mesh that can be used to cast a ray from the controller
  83978. */
  83979. static readonly POINTING_POSE: string;
  83980. /**
  83981. * Creates a new PoseEnabledController from a gamepad
  83982. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  83983. */
  83984. constructor(browserGamepad: any);
  83985. private _workingMatrix;
  83986. /**
  83987. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  83988. */
  83989. update(): void;
  83990. /**
  83991. * Updates only the pose device and mesh without doing any button event checking
  83992. */
  83993. protected _updatePoseAndMesh(): void;
  83994. /**
  83995. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  83996. * @param poseData raw pose fromthe device
  83997. */
  83998. updateFromDevice(poseData: DevicePose): void;
  83999. /**
  84000. * @hidden
  84001. */
  84002. _meshAttachedObservable: Observable<AbstractMesh>;
  84003. /**
  84004. * Attaches a mesh to the controller
  84005. * @param mesh the mesh to be attached
  84006. */
  84007. attachToMesh(mesh: AbstractMesh): void;
  84008. /**
  84009. * Attaches the controllers mesh to a camera
  84010. * @param camera the camera the mesh should be attached to
  84011. */
  84012. attachToPoseControlledCamera(camera: TargetCamera): void;
  84013. /**
  84014. * Disposes of the controller
  84015. */
  84016. dispose(): void;
  84017. /**
  84018. * The mesh that is attached to the controller
  84019. */
  84020. readonly mesh: Nullable<AbstractMesh>;
  84021. /**
  84022. * Gets the ray of the controller in the direction the controller is pointing
  84023. * @param length the length the resulting ray should be
  84024. * @returns a ray in the direction the controller is pointing
  84025. */
  84026. getForwardRay(length?: number): Ray;
  84027. }
  84028. }
  84029. declare module BABYLON {
  84030. /**
  84031. * Defines the WebVRController object that represents controllers tracked in 3D space
  84032. */
  84033. export abstract class WebVRController extends PoseEnabledController {
  84034. /**
  84035. * Internal, the default controller model for the controller
  84036. */
  84037. protected _defaultModel: Nullable<AbstractMesh>;
  84038. /**
  84039. * Fired when the trigger state has changed
  84040. */
  84041. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  84042. /**
  84043. * Fired when the main button state has changed
  84044. */
  84045. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  84046. /**
  84047. * Fired when the secondary button state has changed
  84048. */
  84049. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  84050. /**
  84051. * Fired when the pad state has changed
  84052. */
  84053. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  84054. /**
  84055. * Fired when controllers stick values have changed
  84056. */
  84057. onPadValuesChangedObservable: Observable<StickValues>;
  84058. /**
  84059. * Array of button availible on the controller
  84060. */
  84061. protected _buttons: Array<MutableGamepadButton>;
  84062. private _onButtonStateChange;
  84063. /**
  84064. * Fired when a controller button's state has changed
  84065. * @param callback the callback containing the button that was modified
  84066. */
  84067. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  84068. /**
  84069. * X and Y axis corresponding to the controllers joystick
  84070. */
  84071. pad: StickValues;
  84072. /**
  84073. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  84074. */
  84075. hand: string;
  84076. /**
  84077. * The default controller model for the controller
  84078. */
  84079. readonly defaultModel: Nullable<AbstractMesh>;
  84080. /**
  84081. * Creates a new WebVRController from a gamepad
  84082. * @param vrGamepad the gamepad that the WebVRController should be created from
  84083. */
  84084. constructor(vrGamepad: any);
  84085. /**
  84086. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  84087. */
  84088. update(): void;
  84089. /**
  84090. * Function to be called when a button is modified
  84091. */
  84092. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  84093. /**
  84094. * Loads a mesh and attaches it to the controller
  84095. * @param scene the scene the mesh should be added to
  84096. * @param meshLoaded callback for when the mesh has been loaded
  84097. */
  84098. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  84099. private _setButtonValue;
  84100. private _changes;
  84101. private _checkChanges;
  84102. /**
  84103. * Disposes of th webVRCOntroller
  84104. */
  84105. dispose(): void;
  84106. }
  84107. }
  84108. declare module BABYLON {
  84109. /**
  84110. * The HemisphericLight simulates the ambient environment light,
  84111. * so the passed direction is the light reflection direction, not the incoming direction.
  84112. */
  84113. export class HemisphericLight extends Light {
  84114. /**
  84115. * The groundColor is the light in the opposite direction to the one specified during creation.
  84116. * 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.
  84117. */
  84118. groundColor: Color3;
  84119. /**
  84120. * The light reflection direction, not the incoming direction.
  84121. */
  84122. direction: Vector3;
  84123. /**
  84124. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  84125. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  84126. * The HemisphericLight can't cast shadows.
  84127. * Documentation : https://doc.babylonjs.com/babylon101/lights
  84128. * @param name The friendly name of the light
  84129. * @param direction The direction of the light reflection
  84130. * @param scene The scene the light belongs to
  84131. */
  84132. constructor(name: string, direction: Vector3, scene: Scene);
  84133. protected _buildUniformLayout(): void;
  84134. /**
  84135. * Returns the string "HemisphericLight".
  84136. * @return The class name
  84137. */
  84138. getClassName(): string;
  84139. /**
  84140. * Sets the HemisphericLight direction towards the passed target (Vector3).
  84141. * Returns the updated direction.
  84142. * @param target The target the direction should point to
  84143. * @return The computed direction
  84144. */
  84145. setDirectionToTarget(target: Vector3): Vector3;
  84146. /**
  84147. * Returns the shadow generator associated to the light.
  84148. * @returns Always null for hemispheric lights because it does not support shadows.
  84149. */
  84150. getShadowGenerator(): Nullable<IShadowGenerator>;
  84151. /**
  84152. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  84153. * @param effect The effect to update
  84154. * @param lightIndex The index of the light in the effect to update
  84155. * @returns The hemispheric light
  84156. */
  84157. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  84158. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  84159. /**
  84160. * Computes the world matrix of the node
  84161. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  84162. * @param useWasUpdatedFlag defines a reserved property
  84163. * @returns the world matrix
  84164. */
  84165. computeWorldMatrix(): Matrix;
  84166. /**
  84167. * Returns the integer 3.
  84168. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  84169. */
  84170. getTypeID(): number;
  84171. /**
  84172. * Prepares the list of defines specific to the light type.
  84173. * @param defines the list of defines
  84174. * @param lightIndex defines the index of the light for the effect
  84175. */
  84176. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  84177. }
  84178. }
  84179. declare module BABYLON {
  84180. /** @hidden */
  84181. export var vrMultiviewToSingleviewPixelShader: {
  84182. name: string;
  84183. shader: string;
  84184. };
  84185. }
  84186. declare module BABYLON {
  84187. /**
  84188. * Renders to multiple views with a single draw call
  84189. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  84190. */
  84191. export class MultiviewRenderTarget extends RenderTargetTexture {
  84192. /**
  84193. * Creates a multiview render target
  84194. * @param scene scene used with the render target
  84195. * @param size the size of the render target (used for each view)
  84196. */
  84197. constructor(scene: Scene, size?: number | {
  84198. width: number;
  84199. height: number;
  84200. } | {
  84201. ratio: number;
  84202. });
  84203. /**
  84204. * @hidden
  84205. * @param faceIndex the face index, if its a cube texture
  84206. */
  84207. _bindFrameBuffer(faceIndex?: number): void;
  84208. /**
  84209. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  84210. * @returns the view count
  84211. */
  84212. getViewCount(): number;
  84213. }
  84214. }
  84215. declare module BABYLON {
  84216. /**
  84217. * Represents a camera frustum
  84218. */
  84219. export class Frustum {
  84220. /**
  84221. * Gets the planes representing the frustum
  84222. * @param transform matrix to be applied to the returned planes
  84223. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  84224. */
  84225. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  84226. /**
  84227. * Gets the near frustum plane transformed by the transform matrix
  84228. * @param transform transformation matrix to be applied to the resulting frustum plane
  84229. * @param frustumPlane the resuling frustum plane
  84230. */
  84231. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  84232. /**
  84233. * Gets the far frustum plane transformed by the transform matrix
  84234. * @param transform transformation matrix to be applied to the resulting frustum plane
  84235. * @param frustumPlane the resuling frustum plane
  84236. */
  84237. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  84238. /**
  84239. * Gets the left frustum plane transformed by the transform matrix
  84240. * @param transform transformation matrix to be applied to the resulting frustum plane
  84241. * @param frustumPlane the resuling frustum plane
  84242. */
  84243. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  84244. /**
  84245. * Gets the right frustum plane transformed by the transform matrix
  84246. * @param transform transformation matrix to be applied to the resulting frustum plane
  84247. * @param frustumPlane the resuling frustum plane
  84248. */
  84249. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  84250. /**
  84251. * Gets the top frustum plane transformed by the transform matrix
  84252. * @param transform transformation matrix to be applied to the resulting frustum plane
  84253. * @param frustumPlane the resuling frustum plane
  84254. */
  84255. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  84256. /**
  84257. * Gets the bottom frustum plane transformed by the transform matrix
  84258. * @param transform transformation matrix to be applied to the resulting frustum plane
  84259. * @param frustumPlane the resuling frustum plane
  84260. */
  84261. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  84262. /**
  84263. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  84264. * @param transform transformation matrix to be applied to the resulting frustum planes
  84265. * @param frustumPlanes the resuling frustum planes
  84266. */
  84267. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  84268. }
  84269. }
  84270. declare module BABYLON {
  84271. interface Engine {
  84272. /**
  84273. * Creates a new multiview render target
  84274. * @param width defines the width of the texture
  84275. * @param height defines the height of the texture
  84276. * @returns the created multiview texture
  84277. */
  84278. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  84279. /**
  84280. * Binds a multiview framebuffer to be drawn to
  84281. * @param multiviewTexture texture to bind
  84282. */
  84283. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  84284. }
  84285. interface Camera {
  84286. /**
  84287. * @hidden
  84288. * 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)
  84289. */
  84290. _useMultiviewToSingleView: boolean;
  84291. /**
  84292. * @hidden
  84293. * 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)
  84294. */
  84295. _multiviewTexture: Nullable<RenderTargetTexture>;
  84296. /**
  84297. * @hidden
  84298. * ensures the multiview texture of the camera exists and has the specified width/height
  84299. * @param width height to set on the multiview texture
  84300. * @param height width to set on the multiview texture
  84301. */
  84302. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  84303. }
  84304. interface Scene {
  84305. /** @hidden */
  84306. _transformMatrixR: Matrix;
  84307. /** @hidden */
  84308. _multiviewSceneUbo: Nullable<UniformBuffer>;
  84309. /** @hidden */
  84310. _createMultiviewUbo(): void;
  84311. /** @hidden */
  84312. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  84313. /** @hidden */
  84314. _renderMultiviewToSingleView(camera: Camera): void;
  84315. }
  84316. }
  84317. declare module BABYLON {
  84318. /**
  84319. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  84320. * This will not be used for webXR as it supports displaying texture arrays directly
  84321. */
  84322. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  84323. /**
  84324. * Initializes a VRMultiviewToSingleview
  84325. * @param name name of the post process
  84326. * @param camera camera to be applied to
  84327. * @param scaleFactor scaling factor to the size of the output texture
  84328. */
  84329. constructor(name: string, camera: Camera, scaleFactor: number);
  84330. }
  84331. }
  84332. declare module BABYLON {
  84333. /**
  84334. * Interface used to define additional presentation attributes
  84335. */
  84336. export interface IVRPresentationAttributes {
  84337. /**
  84338. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  84339. */
  84340. highRefreshRate: boolean;
  84341. /**
  84342. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  84343. */
  84344. foveationLevel: number;
  84345. }
  84346. interface Engine {
  84347. /** @hidden */
  84348. _vrDisplay: any;
  84349. /** @hidden */
  84350. _vrSupported: boolean;
  84351. /** @hidden */
  84352. _oldSize: Size;
  84353. /** @hidden */
  84354. _oldHardwareScaleFactor: number;
  84355. /** @hidden */
  84356. _vrExclusivePointerMode: boolean;
  84357. /** @hidden */
  84358. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  84359. /** @hidden */
  84360. _onVRDisplayPointerRestricted: () => void;
  84361. /** @hidden */
  84362. _onVRDisplayPointerUnrestricted: () => void;
  84363. /** @hidden */
  84364. _onVrDisplayConnect: Nullable<(display: any) => void>;
  84365. /** @hidden */
  84366. _onVrDisplayDisconnect: Nullable<() => void>;
  84367. /** @hidden */
  84368. _onVrDisplayPresentChange: Nullable<() => void>;
  84369. /**
  84370. * Observable signaled when VR display mode changes
  84371. */
  84372. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  84373. /**
  84374. * Observable signaled when VR request present is complete
  84375. */
  84376. onVRRequestPresentComplete: Observable<boolean>;
  84377. /**
  84378. * Observable signaled when VR request present starts
  84379. */
  84380. onVRRequestPresentStart: Observable<Engine>;
  84381. /**
  84382. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  84383. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  84384. */
  84385. isInVRExclusivePointerMode: boolean;
  84386. /**
  84387. * Gets a boolean indicating if a webVR device was detected
  84388. * @returns true if a webVR device was detected
  84389. */
  84390. isVRDevicePresent(): boolean;
  84391. /**
  84392. * Gets the current webVR device
  84393. * @returns the current webVR device (or null)
  84394. */
  84395. getVRDevice(): any;
  84396. /**
  84397. * Initializes a webVR display and starts listening to display change events
  84398. * The onVRDisplayChangedObservable will be notified upon these changes
  84399. * @returns A promise containing a VRDisplay and if vr is supported
  84400. */
  84401. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  84402. /** @hidden */
  84403. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  84404. /**
  84405. * Gets or sets the presentation attributes used to configure VR rendering
  84406. */
  84407. vrPresentationAttributes?: IVRPresentationAttributes;
  84408. /**
  84409. * Call this function to switch to webVR mode
  84410. * Will do nothing if webVR is not supported or if there is no webVR device
  84411. * @param options the webvr options provided to the camera. mainly used for multiview
  84412. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84413. */
  84414. enableVR(options: WebVROptions): void;
  84415. /** @hidden */
  84416. _onVRFullScreenTriggered(): void;
  84417. }
  84418. }
  84419. declare module BABYLON {
  84420. /**
  84421. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  84422. * IMPORTANT!! The data is right-hand data.
  84423. * @export
  84424. * @interface DevicePose
  84425. */
  84426. export interface DevicePose {
  84427. /**
  84428. * The position of the device, values in array are [x,y,z].
  84429. */
  84430. readonly position: Nullable<Float32Array>;
  84431. /**
  84432. * The linearVelocity of the device, values in array are [x,y,z].
  84433. */
  84434. readonly linearVelocity: Nullable<Float32Array>;
  84435. /**
  84436. * The linearAcceleration of the device, values in array are [x,y,z].
  84437. */
  84438. readonly linearAcceleration: Nullable<Float32Array>;
  84439. /**
  84440. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  84441. */
  84442. readonly orientation: Nullable<Float32Array>;
  84443. /**
  84444. * The angularVelocity of the device, values in array are [x,y,z].
  84445. */
  84446. readonly angularVelocity: Nullable<Float32Array>;
  84447. /**
  84448. * The angularAcceleration of the device, values in array are [x,y,z].
  84449. */
  84450. readonly angularAcceleration: Nullable<Float32Array>;
  84451. }
  84452. /**
  84453. * Interface representing a pose controlled object in Babylon.
  84454. * A pose controlled object has both regular pose values as well as pose values
  84455. * from an external device such as a VR head mounted display
  84456. */
  84457. export interface PoseControlled {
  84458. /**
  84459. * The position of the object in babylon space.
  84460. */
  84461. position: Vector3;
  84462. /**
  84463. * The rotation quaternion of the object in babylon space.
  84464. */
  84465. rotationQuaternion: Quaternion;
  84466. /**
  84467. * The position of the device in babylon space.
  84468. */
  84469. devicePosition?: Vector3;
  84470. /**
  84471. * The rotation quaternion of the device in babylon space.
  84472. */
  84473. deviceRotationQuaternion: Quaternion;
  84474. /**
  84475. * The raw pose coming from the device.
  84476. */
  84477. rawPose: Nullable<DevicePose>;
  84478. /**
  84479. * The scale of the device to be used when translating from device space to babylon space.
  84480. */
  84481. deviceScaleFactor: number;
  84482. /**
  84483. * Updates the poseControlled values based on the input device pose.
  84484. * @param poseData the pose data to update the object with
  84485. */
  84486. updateFromDevice(poseData: DevicePose): void;
  84487. }
  84488. /**
  84489. * Set of options to customize the webVRCamera
  84490. */
  84491. export interface WebVROptions {
  84492. /**
  84493. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  84494. */
  84495. trackPosition?: boolean;
  84496. /**
  84497. * Sets the scale of the vrDevice in babylon space. (default: 1)
  84498. */
  84499. positionScale?: number;
  84500. /**
  84501. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  84502. */
  84503. displayName?: string;
  84504. /**
  84505. * Should the native controller meshes be initialized. (default: true)
  84506. */
  84507. controllerMeshes?: boolean;
  84508. /**
  84509. * Creating a default HemiLight only on controllers. (default: true)
  84510. */
  84511. defaultLightingOnControllers?: boolean;
  84512. /**
  84513. * If you don't want to use the default VR button of the helper. (default: false)
  84514. */
  84515. useCustomVRButton?: boolean;
  84516. /**
  84517. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  84518. */
  84519. customVRButton?: HTMLButtonElement;
  84520. /**
  84521. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  84522. */
  84523. rayLength?: number;
  84524. /**
  84525. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  84526. */
  84527. defaultHeight?: number;
  84528. /**
  84529. * If multiview should be used if availible (default: false)
  84530. */
  84531. useMultiview?: boolean;
  84532. }
  84533. /**
  84534. * This represents a WebVR camera.
  84535. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  84536. * @example http://doc.babylonjs.com/how_to/webvr_camera
  84537. */
  84538. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  84539. private webVROptions;
  84540. /**
  84541. * @hidden
  84542. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  84543. */
  84544. _vrDevice: any;
  84545. /**
  84546. * The rawPose of the vrDevice.
  84547. */
  84548. rawPose: Nullable<DevicePose>;
  84549. private _onVREnabled;
  84550. private _specsVersion;
  84551. private _attached;
  84552. private _frameData;
  84553. protected _descendants: Array<Node>;
  84554. private _deviceRoomPosition;
  84555. /** @hidden */
  84556. _deviceRoomRotationQuaternion: Quaternion;
  84557. private _standingMatrix;
  84558. /**
  84559. * Represents device position in babylon space.
  84560. */
  84561. devicePosition: Vector3;
  84562. /**
  84563. * Represents device rotation in babylon space.
  84564. */
  84565. deviceRotationQuaternion: Quaternion;
  84566. /**
  84567. * The scale of the device to be used when translating from device space to babylon space.
  84568. */
  84569. deviceScaleFactor: number;
  84570. private _deviceToWorld;
  84571. private _worldToDevice;
  84572. /**
  84573. * References to the webVR controllers for the vrDevice.
  84574. */
  84575. controllers: Array<WebVRController>;
  84576. /**
  84577. * Emits an event when a controller is attached.
  84578. */
  84579. onControllersAttachedObservable: Observable<WebVRController[]>;
  84580. /**
  84581. * Emits an event when a controller's mesh has been loaded;
  84582. */
  84583. onControllerMeshLoadedObservable: Observable<WebVRController>;
  84584. /**
  84585. * Emits an event when the HMD's pose has been updated.
  84586. */
  84587. onPoseUpdatedFromDeviceObservable: Observable<any>;
  84588. private _poseSet;
  84589. /**
  84590. * If the rig cameras be used as parent instead of this camera.
  84591. */
  84592. rigParenting: boolean;
  84593. private _lightOnControllers;
  84594. private _defaultHeight?;
  84595. /**
  84596. * Instantiates a WebVRFreeCamera.
  84597. * @param name The name of the WebVRFreeCamera
  84598. * @param position The starting anchor position for the camera
  84599. * @param scene The scene the camera belongs to
  84600. * @param webVROptions a set of customizable options for the webVRCamera
  84601. */
  84602. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  84603. /**
  84604. * Gets the device distance from the ground in meters.
  84605. * @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.
  84606. */
  84607. deviceDistanceToRoomGround(): number;
  84608. /**
  84609. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  84610. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  84611. */
  84612. useStandingMatrix(callback?: (bool: boolean) => void): void;
  84613. /**
  84614. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  84615. * @returns A promise with a boolean set to if the standing matrix is supported.
  84616. */
  84617. useStandingMatrixAsync(): Promise<boolean>;
  84618. /**
  84619. * Disposes the camera
  84620. */
  84621. dispose(): void;
  84622. /**
  84623. * Gets a vrController by name.
  84624. * @param name The name of the controller to retreive
  84625. * @returns the controller matching the name specified or null if not found
  84626. */
  84627. getControllerByName(name: string): Nullable<WebVRController>;
  84628. private _leftController;
  84629. /**
  84630. * The controller corresponding to the users left hand.
  84631. */
  84632. readonly leftController: Nullable<WebVRController>;
  84633. private _rightController;
  84634. /**
  84635. * The controller corresponding to the users right hand.
  84636. */
  84637. readonly rightController: Nullable<WebVRController>;
  84638. /**
  84639. * Casts a ray forward from the vrCamera's gaze.
  84640. * @param length Length of the ray (default: 100)
  84641. * @returns the ray corresponding to the gaze
  84642. */
  84643. getForwardRay(length?: number): Ray;
  84644. /**
  84645. * @hidden
  84646. * Updates the camera based on device's frame data
  84647. */
  84648. _checkInputs(): void;
  84649. /**
  84650. * Updates the poseControlled values based on the input device pose.
  84651. * @param poseData Pose coming from the device
  84652. */
  84653. updateFromDevice(poseData: DevicePose): void;
  84654. private _htmlElementAttached;
  84655. private _detachIfAttached;
  84656. /**
  84657. * WebVR's attach control will start broadcasting frames to the device.
  84658. * Note that in certain browsers (chrome for example) this function must be called
  84659. * within a user-interaction callback. Example:
  84660. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  84661. *
  84662. * @param element html element to attach the vrDevice to
  84663. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  84664. */
  84665. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84666. /**
  84667. * Detaches the camera from the html element and disables VR
  84668. *
  84669. * @param element html element to detach from
  84670. */
  84671. detachControl(element: HTMLElement): void;
  84672. /**
  84673. * @returns the name of this class
  84674. */
  84675. getClassName(): string;
  84676. /**
  84677. * Calls resetPose on the vrDisplay
  84678. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  84679. */
  84680. resetToCurrentRotation(): void;
  84681. /**
  84682. * @hidden
  84683. * Updates the rig cameras (left and right eye)
  84684. */
  84685. _updateRigCameras(): void;
  84686. private _workingVector;
  84687. private _oneVector;
  84688. private _workingMatrix;
  84689. private updateCacheCalled;
  84690. private _correctPositionIfNotTrackPosition;
  84691. /**
  84692. * @hidden
  84693. * Updates the cached values of the camera
  84694. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  84695. */
  84696. _updateCache(ignoreParentClass?: boolean): void;
  84697. /**
  84698. * @hidden
  84699. * Get current device position in babylon world
  84700. */
  84701. _computeDevicePosition(): void;
  84702. /**
  84703. * Updates the current device position and rotation in the babylon world
  84704. */
  84705. update(): void;
  84706. /**
  84707. * @hidden
  84708. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  84709. * @returns an identity matrix
  84710. */
  84711. _getViewMatrix(): Matrix;
  84712. private _tmpMatrix;
  84713. /**
  84714. * This function is called by the two RIG cameras.
  84715. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  84716. * @hidden
  84717. */
  84718. _getWebVRViewMatrix(): Matrix;
  84719. /** @hidden */
  84720. _getWebVRProjectionMatrix(): Matrix;
  84721. private _onGamepadConnectedObserver;
  84722. private _onGamepadDisconnectedObserver;
  84723. private _updateCacheWhenTrackingDisabledObserver;
  84724. /**
  84725. * Initializes the controllers and their meshes
  84726. */
  84727. initControllers(): void;
  84728. }
  84729. }
  84730. declare module BABYLON {
  84731. /**
  84732. * Size options for a post process
  84733. */
  84734. export type PostProcessOptions = {
  84735. width: number;
  84736. height: number;
  84737. };
  84738. /**
  84739. * PostProcess can be used to apply a shader to a texture after it has been rendered
  84740. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  84741. */
  84742. export class PostProcess {
  84743. /** Name of the PostProcess. */
  84744. name: string;
  84745. /**
  84746. * Gets or sets the unique id of the post process
  84747. */
  84748. uniqueId: number;
  84749. /**
  84750. * Width of the texture to apply the post process on
  84751. */
  84752. width: number;
  84753. /**
  84754. * Height of the texture to apply the post process on
  84755. */
  84756. height: number;
  84757. /**
  84758. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  84759. * @hidden
  84760. */
  84761. _outputTexture: Nullable<InternalTexture>;
  84762. /**
  84763. * Sampling mode used by the shader
  84764. * See https://doc.babylonjs.com/classes/3.1/texture
  84765. */
  84766. renderTargetSamplingMode: number;
  84767. /**
  84768. * Clear color to use when screen clearing
  84769. */
  84770. clearColor: Color4;
  84771. /**
  84772. * If the buffer needs to be cleared before applying the post process. (default: true)
  84773. * Should be set to false if shader will overwrite all previous pixels.
  84774. */
  84775. autoClear: boolean;
  84776. /**
  84777. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  84778. */
  84779. alphaMode: number;
  84780. /**
  84781. * Sets the setAlphaBlendConstants of the babylon engine
  84782. */
  84783. alphaConstants: Color4;
  84784. /**
  84785. * Animations to be used for the post processing
  84786. */
  84787. animations: Animation[];
  84788. /**
  84789. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  84790. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  84791. */
  84792. enablePixelPerfectMode: boolean;
  84793. /**
  84794. * Force the postprocess to be applied without taking in account viewport
  84795. */
  84796. forceFullscreenViewport: boolean;
  84797. /**
  84798. * List of inspectable custom properties (used by the Inspector)
  84799. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84800. */
  84801. inspectableCustomProperties: IInspectable[];
  84802. /**
  84803. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  84804. *
  84805. * | Value | Type | Description |
  84806. * | ----- | ----------------------------------- | ----------- |
  84807. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  84808. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  84809. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  84810. *
  84811. */
  84812. scaleMode: number;
  84813. /**
  84814. * Force textures to be a power of two (default: false)
  84815. */
  84816. alwaysForcePOT: boolean;
  84817. private _samples;
  84818. /**
  84819. * Number of sample textures (default: 1)
  84820. */
  84821. samples: number;
  84822. /**
  84823. * Modify the scale of the post process to be the same as the viewport (default: false)
  84824. */
  84825. adaptScaleToCurrentViewport: boolean;
  84826. private _camera;
  84827. private _scene;
  84828. private _engine;
  84829. private _options;
  84830. private _reusable;
  84831. private _textureType;
  84832. /**
  84833. * Smart array of input and output textures for the post process.
  84834. * @hidden
  84835. */
  84836. _textures: SmartArray<InternalTexture>;
  84837. /**
  84838. * The index in _textures that corresponds to the output texture.
  84839. * @hidden
  84840. */
  84841. _currentRenderTextureInd: number;
  84842. private _effect;
  84843. private _samplers;
  84844. private _fragmentUrl;
  84845. private _vertexUrl;
  84846. private _parameters;
  84847. private _scaleRatio;
  84848. protected _indexParameters: any;
  84849. private _shareOutputWithPostProcess;
  84850. private _texelSize;
  84851. private _forcedOutputTexture;
  84852. /**
  84853. * Returns the fragment url or shader name used in the post process.
  84854. * @returns the fragment url or name in the shader store.
  84855. */
  84856. getEffectName(): string;
  84857. /**
  84858. * An event triggered when the postprocess is activated.
  84859. */
  84860. onActivateObservable: Observable<Camera>;
  84861. private _onActivateObserver;
  84862. /**
  84863. * A function that is added to the onActivateObservable
  84864. */
  84865. onActivate: Nullable<(camera: Camera) => void>;
  84866. /**
  84867. * An event triggered when the postprocess changes its size.
  84868. */
  84869. onSizeChangedObservable: Observable<PostProcess>;
  84870. private _onSizeChangedObserver;
  84871. /**
  84872. * A function that is added to the onSizeChangedObservable
  84873. */
  84874. onSizeChanged: (postProcess: PostProcess) => void;
  84875. /**
  84876. * An event triggered when the postprocess applies its effect.
  84877. */
  84878. onApplyObservable: Observable<Effect>;
  84879. private _onApplyObserver;
  84880. /**
  84881. * A function that is added to the onApplyObservable
  84882. */
  84883. onApply: (effect: Effect) => void;
  84884. /**
  84885. * An event triggered before rendering the postprocess
  84886. */
  84887. onBeforeRenderObservable: Observable<Effect>;
  84888. private _onBeforeRenderObserver;
  84889. /**
  84890. * A function that is added to the onBeforeRenderObservable
  84891. */
  84892. onBeforeRender: (effect: Effect) => void;
  84893. /**
  84894. * An event triggered after rendering the postprocess
  84895. */
  84896. onAfterRenderObservable: Observable<Effect>;
  84897. private _onAfterRenderObserver;
  84898. /**
  84899. * A function that is added to the onAfterRenderObservable
  84900. */
  84901. onAfterRender: (efect: Effect) => void;
  84902. /**
  84903. * 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
  84904. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  84905. */
  84906. inputTexture: InternalTexture;
  84907. /**
  84908. * Gets the camera which post process is applied to.
  84909. * @returns The camera the post process is applied to.
  84910. */
  84911. getCamera(): Camera;
  84912. /**
  84913. * Gets the texel size of the postprocess.
  84914. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  84915. */
  84916. readonly texelSize: Vector2;
  84917. /**
  84918. * Creates a new instance PostProcess
  84919. * @param name The name of the PostProcess.
  84920. * @param fragmentUrl The url of the fragment shader to be used.
  84921. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  84922. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  84923. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  84924. * @param camera The camera to apply the render pass to.
  84925. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  84926. * @param engine The engine which the post process will be applied. (default: current engine)
  84927. * @param reusable If the post process can be reused on the same frame. (default: false)
  84928. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  84929. * @param textureType Type of textures used when performing the post process. (default: 0)
  84930. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  84931. * @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
  84932. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  84933. */
  84934. constructor(
  84935. /** Name of the PostProcess. */
  84936. 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);
  84937. /**
  84938. * Gets a string idenfifying the name of the class
  84939. * @returns "PostProcess" string
  84940. */
  84941. getClassName(): string;
  84942. /**
  84943. * Gets the engine which this post process belongs to.
  84944. * @returns The engine the post process was enabled with.
  84945. */
  84946. getEngine(): Engine;
  84947. /**
  84948. * The effect that is created when initializing the post process.
  84949. * @returns The created effect corresponding the the postprocess.
  84950. */
  84951. getEffect(): Effect;
  84952. /**
  84953. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  84954. * @param postProcess The post process to share the output with.
  84955. * @returns This post process.
  84956. */
  84957. shareOutputWith(postProcess: PostProcess): PostProcess;
  84958. /**
  84959. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  84960. * This should be called if the post process that shares output with this post process is disabled/disposed.
  84961. */
  84962. useOwnOutput(): void;
  84963. /**
  84964. * Updates the effect with the current post process compile time values and recompiles the shader.
  84965. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  84966. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  84967. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  84968. * @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
  84969. * @param onCompiled Called when the shader has been compiled.
  84970. * @param onError Called if there is an error when compiling a shader.
  84971. */
  84972. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84973. /**
  84974. * The post process is reusable if it can be used multiple times within one frame.
  84975. * @returns If the post process is reusable
  84976. */
  84977. isReusable(): boolean;
  84978. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  84979. markTextureDirty(): void;
  84980. /**
  84981. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  84982. * 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.
  84983. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  84984. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  84985. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  84986. * @returns The target texture that was bound to be written to.
  84987. */
  84988. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  84989. /**
  84990. * If the post process is supported.
  84991. */
  84992. readonly isSupported: boolean;
  84993. /**
  84994. * The aspect ratio of the output texture.
  84995. */
  84996. readonly aspectRatio: number;
  84997. /**
  84998. * Get a value indicating if the post-process is ready to be used
  84999. * @returns true if the post-process is ready (shader is compiled)
  85000. */
  85001. isReady(): boolean;
  85002. /**
  85003. * Binds all textures and uniforms to the shader, this will be run on every pass.
  85004. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  85005. */
  85006. apply(): Nullable<Effect>;
  85007. private _disposeTextures;
  85008. /**
  85009. * Disposes the post process.
  85010. * @param camera The camera to dispose the post process on.
  85011. */
  85012. dispose(camera?: Camera): void;
  85013. }
  85014. }
  85015. declare module BABYLON {
  85016. /** @hidden */
  85017. export var kernelBlurVaryingDeclaration: {
  85018. name: string;
  85019. shader: string;
  85020. };
  85021. }
  85022. declare module BABYLON {
  85023. /** @hidden */
  85024. export var kernelBlurFragment: {
  85025. name: string;
  85026. shader: string;
  85027. };
  85028. }
  85029. declare module BABYLON {
  85030. /** @hidden */
  85031. export var kernelBlurFragment2: {
  85032. name: string;
  85033. shader: string;
  85034. };
  85035. }
  85036. declare module BABYLON {
  85037. /** @hidden */
  85038. export var kernelBlurPixelShader: {
  85039. name: string;
  85040. shader: string;
  85041. };
  85042. }
  85043. declare module BABYLON {
  85044. /** @hidden */
  85045. export var kernelBlurVertex: {
  85046. name: string;
  85047. shader: string;
  85048. };
  85049. }
  85050. declare module BABYLON {
  85051. /** @hidden */
  85052. export var kernelBlurVertexShader: {
  85053. name: string;
  85054. shader: string;
  85055. };
  85056. }
  85057. declare module BABYLON {
  85058. /**
  85059. * The Blur Post Process which blurs an image based on a kernel and direction.
  85060. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  85061. */
  85062. export class BlurPostProcess extends PostProcess {
  85063. /** The direction in which to blur the image. */
  85064. direction: Vector2;
  85065. private blockCompilation;
  85066. protected _kernel: number;
  85067. protected _idealKernel: number;
  85068. protected _packedFloat: boolean;
  85069. private _staticDefines;
  85070. /**
  85071. * Sets the length in pixels of the blur sample region
  85072. */
  85073. /**
  85074. * Gets the length in pixels of the blur sample region
  85075. */
  85076. kernel: number;
  85077. /**
  85078. * Sets wether or not the blur needs to unpack/repack floats
  85079. */
  85080. /**
  85081. * Gets wether or not the blur is unpacking/repacking floats
  85082. */
  85083. packedFloat: boolean;
  85084. /**
  85085. * Creates a new instance BlurPostProcess
  85086. * @param name The name of the effect.
  85087. * @param direction The direction in which to blur the image.
  85088. * @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.
  85089. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  85090. * @param camera The camera to apply the render pass to.
  85091. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  85092. * @param engine The engine which the post process will be applied. (default: current engine)
  85093. * @param reusable If the post process can be reused on the same frame. (default: false)
  85094. * @param textureType Type of textures used when performing the post process. (default: 0)
  85095. * @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)
  85096. */
  85097. constructor(name: string,
  85098. /** The direction in which to blur the image. */
  85099. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  85100. /**
  85101. * Updates the effect with the current post process compile time values and recompiles the shader.
  85102. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  85103. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  85104. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  85105. * @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
  85106. * @param onCompiled Called when the shader has been compiled.
  85107. * @param onError Called if there is an error when compiling a shader.
  85108. */
  85109. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  85110. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  85111. /**
  85112. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  85113. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  85114. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  85115. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  85116. * The gaps between physical kernels are compensated for in the weighting of the samples
  85117. * @param idealKernel Ideal blur kernel.
  85118. * @return Nearest best kernel.
  85119. */
  85120. protected _nearestBestKernel(idealKernel: number): number;
  85121. /**
  85122. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  85123. * @param x The point on the Gaussian distribution to sample.
  85124. * @return the value of the Gaussian function at x.
  85125. */
  85126. protected _gaussianWeight(x: number): number;
  85127. /**
  85128. * Generates a string that can be used as a floating point number in GLSL.
  85129. * @param x Value to print.
  85130. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  85131. * @return GLSL float string.
  85132. */
  85133. protected _glslFloat(x: number, decimalFigures?: number): string;
  85134. }
  85135. }
  85136. declare module BABYLON {
  85137. /**
  85138. * Mirror texture can be used to simulate the view from a mirror in a scene.
  85139. * It will dynamically be rendered every frame to adapt to the camera point of view.
  85140. * You can then easily use it as a reflectionTexture on a flat surface.
  85141. * In case the surface is not a plane, please consider relying on reflection probes.
  85142. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  85143. */
  85144. export class MirrorTexture extends RenderTargetTexture {
  85145. private scene;
  85146. /**
  85147. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  85148. * 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.
  85149. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  85150. */
  85151. mirrorPlane: Plane;
  85152. /**
  85153. * Define the blur ratio used to blur the reflection if needed.
  85154. */
  85155. blurRatio: number;
  85156. /**
  85157. * Define the adaptive blur kernel used to blur the reflection if needed.
  85158. * This will autocompute the closest best match for the `blurKernel`
  85159. */
  85160. adaptiveBlurKernel: number;
  85161. /**
  85162. * Define the blur kernel used to blur the reflection if needed.
  85163. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  85164. */
  85165. blurKernel: number;
  85166. /**
  85167. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  85168. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  85169. */
  85170. blurKernelX: number;
  85171. /**
  85172. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  85173. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  85174. */
  85175. blurKernelY: number;
  85176. private _autoComputeBlurKernel;
  85177. protected _onRatioRescale(): void;
  85178. private _updateGammaSpace;
  85179. private _imageProcessingConfigChangeObserver;
  85180. private _transformMatrix;
  85181. private _mirrorMatrix;
  85182. private _savedViewMatrix;
  85183. private _blurX;
  85184. private _blurY;
  85185. private _adaptiveBlurKernel;
  85186. private _blurKernelX;
  85187. private _blurKernelY;
  85188. private _blurRatio;
  85189. /**
  85190. * Instantiates a Mirror Texture.
  85191. * Mirror texture can be used to simulate the view from a mirror in a scene.
  85192. * It will dynamically be rendered every frame to adapt to the camera point of view.
  85193. * You can then easily use it as a reflectionTexture on a flat surface.
  85194. * In case the surface is not a plane, please consider relying on reflection probes.
  85195. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  85196. * @param name
  85197. * @param size
  85198. * @param scene
  85199. * @param generateMipMaps
  85200. * @param type
  85201. * @param samplingMode
  85202. * @param generateDepthBuffer
  85203. */
  85204. constructor(name: string, size: number | {
  85205. width: number;
  85206. height: number;
  85207. } | {
  85208. ratio: number;
  85209. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  85210. private _preparePostProcesses;
  85211. /**
  85212. * Clone the mirror texture.
  85213. * @returns the cloned texture
  85214. */
  85215. clone(): MirrorTexture;
  85216. /**
  85217. * Serialize the texture to a JSON representation you could use in Parse later on
  85218. * @returns the serialized JSON representation
  85219. */
  85220. serialize(): any;
  85221. /**
  85222. * Dispose the texture and release its associated resources.
  85223. */
  85224. dispose(): void;
  85225. }
  85226. }
  85227. declare module BABYLON {
  85228. /**
  85229. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  85230. * @see http://doc.babylonjs.com/babylon101/materials#texture
  85231. */
  85232. export class Texture extends BaseTexture {
  85233. /**
  85234. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  85235. */
  85236. static SerializeBuffers: boolean;
  85237. /** @hidden */
  85238. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  85239. /** @hidden */
  85240. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  85241. /** @hidden */
  85242. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  85243. /** nearest is mag = nearest and min = nearest and mip = linear */
  85244. static readonly NEAREST_SAMPLINGMODE: number;
  85245. /** nearest is mag = nearest and min = nearest and mip = linear */
  85246. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  85247. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85248. static readonly BILINEAR_SAMPLINGMODE: number;
  85249. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85250. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  85251. /** Trilinear is mag = linear and min = linear and mip = linear */
  85252. static readonly TRILINEAR_SAMPLINGMODE: number;
  85253. /** Trilinear is mag = linear and min = linear and mip = linear */
  85254. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  85255. /** mag = nearest and min = nearest and mip = nearest */
  85256. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  85257. /** mag = nearest and min = linear and mip = nearest */
  85258. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  85259. /** mag = nearest and min = linear and mip = linear */
  85260. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  85261. /** mag = nearest and min = linear and mip = none */
  85262. static readonly NEAREST_LINEAR: number;
  85263. /** mag = nearest and min = nearest and mip = none */
  85264. static readonly NEAREST_NEAREST: number;
  85265. /** mag = linear and min = nearest and mip = nearest */
  85266. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  85267. /** mag = linear and min = nearest and mip = linear */
  85268. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  85269. /** mag = linear and min = linear and mip = none */
  85270. static readonly LINEAR_LINEAR: number;
  85271. /** mag = linear and min = nearest and mip = none */
  85272. static readonly LINEAR_NEAREST: number;
  85273. /** Explicit coordinates mode */
  85274. static readonly EXPLICIT_MODE: number;
  85275. /** Spherical coordinates mode */
  85276. static readonly SPHERICAL_MODE: number;
  85277. /** Planar coordinates mode */
  85278. static readonly PLANAR_MODE: number;
  85279. /** Cubic coordinates mode */
  85280. static readonly CUBIC_MODE: number;
  85281. /** Projection coordinates mode */
  85282. static readonly PROJECTION_MODE: number;
  85283. /** Inverse Cubic coordinates mode */
  85284. static readonly SKYBOX_MODE: number;
  85285. /** Inverse Cubic coordinates mode */
  85286. static readonly INVCUBIC_MODE: number;
  85287. /** Equirectangular coordinates mode */
  85288. static readonly EQUIRECTANGULAR_MODE: number;
  85289. /** Equirectangular Fixed coordinates mode */
  85290. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  85291. /** Equirectangular Fixed Mirrored coordinates mode */
  85292. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  85293. /** Texture is not repeating outside of 0..1 UVs */
  85294. static readonly CLAMP_ADDRESSMODE: number;
  85295. /** Texture is repeating outside of 0..1 UVs */
  85296. static readonly WRAP_ADDRESSMODE: number;
  85297. /** Texture is repeating and mirrored */
  85298. static readonly MIRROR_ADDRESSMODE: number;
  85299. /**
  85300. * 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
  85301. */
  85302. static UseSerializedUrlIfAny: boolean;
  85303. /**
  85304. * Define the url of the texture.
  85305. */
  85306. url: Nullable<string>;
  85307. /**
  85308. * Define an offset on the texture to offset the u coordinates of the UVs
  85309. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  85310. */
  85311. uOffset: number;
  85312. /**
  85313. * Define an offset on the texture to offset the v coordinates of the UVs
  85314. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  85315. */
  85316. vOffset: number;
  85317. /**
  85318. * Define an offset on the texture to scale the u coordinates of the UVs
  85319. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  85320. */
  85321. uScale: number;
  85322. /**
  85323. * Define an offset on the texture to scale the v coordinates of the UVs
  85324. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  85325. */
  85326. vScale: number;
  85327. /**
  85328. * Define an offset on the texture to rotate around the u coordinates of the UVs
  85329. * @see http://doc.babylonjs.com/how_to/more_materials
  85330. */
  85331. uAng: number;
  85332. /**
  85333. * Define an offset on the texture to rotate around the v coordinates of the UVs
  85334. * @see http://doc.babylonjs.com/how_to/more_materials
  85335. */
  85336. vAng: number;
  85337. /**
  85338. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  85339. * @see http://doc.babylonjs.com/how_to/more_materials
  85340. */
  85341. wAng: number;
  85342. /**
  85343. * Defines the center of rotation (U)
  85344. */
  85345. uRotationCenter: number;
  85346. /**
  85347. * Defines the center of rotation (V)
  85348. */
  85349. vRotationCenter: number;
  85350. /**
  85351. * Defines the center of rotation (W)
  85352. */
  85353. wRotationCenter: number;
  85354. /**
  85355. * Are mip maps generated for this texture or not.
  85356. */
  85357. readonly noMipmap: boolean;
  85358. /**
  85359. * List of inspectable custom properties (used by the Inspector)
  85360. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85361. */
  85362. inspectableCustomProperties: Nullable<IInspectable[]>;
  85363. private _noMipmap;
  85364. /** @hidden */
  85365. _invertY: boolean;
  85366. private _rowGenerationMatrix;
  85367. private _cachedTextureMatrix;
  85368. private _projectionModeMatrix;
  85369. private _t0;
  85370. private _t1;
  85371. private _t2;
  85372. private _cachedUOffset;
  85373. private _cachedVOffset;
  85374. private _cachedUScale;
  85375. private _cachedVScale;
  85376. private _cachedUAng;
  85377. private _cachedVAng;
  85378. private _cachedWAng;
  85379. private _cachedProjectionMatrixId;
  85380. private _cachedCoordinatesMode;
  85381. /** @hidden */
  85382. protected _initialSamplingMode: number;
  85383. /** @hidden */
  85384. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  85385. private _deleteBuffer;
  85386. protected _format: Nullable<number>;
  85387. private _delayedOnLoad;
  85388. private _delayedOnError;
  85389. private _mimeType?;
  85390. /**
  85391. * Observable triggered once the texture has been loaded.
  85392. */
  85393. onLoadObservable: Observable<Texture>;
  85394. protected _isBlocking: boolean;
  85395. /**
  85396. * Is the texture preventing material to render while loading.
  85397. * If false, a default texture will be used instead of the loading one during the preparation step.
  85398. */
  85399. isBlocking: boolean;
  85400. /**
  85401. * Get the current sampling mode associated with the texture.
  85402. */
  85403. readonly samplingMode: number;
  85404. /**
  85405. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  85406. */
  85407. readonly invertY: boolean;
  85408. /**
  85409. * Instantiates a new texture.
  85410. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  85411. * @see http://doc.babylonjs.com/babylon101/materials#texture
  85412. * @param url defines the url of the picture to load as a texture
  85413. * @param scene defines the scene or engine the texture will belong to
  85414. * @param noMipmap defines if the texture will require mip maps or not
  85415. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  85416. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  85417. * @param onLoad defines a callback triggered when the texture has been loaded
  85418. * @param onError defines a callback triggered when an error occurred during the loading session
  85419. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  85420. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  85421. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  85422. * @param mimeType defines an optional mime type information
  85423. */
  85424. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  85425. /**
  85426. * Update the url (and optional buffer) of this texture if url was null during construction.
  85427. * @param url the url of the texture
  85428. * @param buffer the buffer of the texture (defaults to null)
  85429. * @param onLoad callback called when the texture is loaded (defaults to null)
  85430. */
  85431. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  85432. /**
  85433. * Finish the loading sequence of a texture flagged as delayed load.
  85434. * @hidden
  85435. */
  85436. delayLoad(): void;
  85437. private _prepareRowForTextureGeneration;
  85438. /**
  85439. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  85440. * @returns the transform matrix of the texture.
  85441. */
  85442. getTextureMatrix(uBase?: number): Matrix;
  85443. /**
  85444. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  85445. * @returns The reflection texture transform
  85446. */
  85447. getReflectionTextureMatrix(): Matrix;
  85448. /**
  85449. * Clones the texture.
  85450. * @returns the cloned texture
  85451. */
  85452. clone(): Texture;
  85453. /**
  85454. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  85455. * @returns The JSON representation of the texture
  85456. */
  85457. serialize(): any;
  85458. /**
  85459. * Get the current class name of the texture useful for serialization or dynamic coding.
  85460. * @returns "Texture"
  85461. */
  85462. getClassName(): string;
  85463. /**
  85464. * Dispose the texture and release its associated resources.
  85465. */
  85466. dispose(): void;
  85467. /**
  85468. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  85469. * @param parsedTexture Define the JSON representation of the texture
  85470. * @param scene Define the scene the parsed texture should be instantiated in
  85471. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  85472. * @returns The parsed texture if successful
  85473. */
  85474. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  85475. /**
  85476. * Creates a texture from its base 64 representation.
  85477. * @param data Define the base64 payload without the data: prefix
  85478. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  85479. * @param scene Define the scene the texture should belong to
  85480. * @param noMipmap Forces the texture to not create mip map information if true
  85481. * @param invertY define if the texture needs to be inverted on the y axis during loading
  85482. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  85483. * @param onLoad define a callback triggered when the texture has been loaded
  85484. * @param onError define a callback triggered when an error occurred during the loading session
  85485. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  85486. * @returns the created texture
  85487. */
  85488. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  85489. /**
  85490. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  85491. * @param data Define the base64 payload without the data: prefix
  85492. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  85493. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  85494. * @param scene Define the scene the texture should belong to
  85495. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  85496. * @param noMipmap Forces the texture to not create mip map information if true
  85497. * @param invertY define if the texture needs to be inverted on the y axis during loading
  85498. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  85499. * @param onLoad define a callback triggered when the texture has been loaded
  85500. * @param onError define a callback triggered when an error occurred during the loading session
  85501. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  85502. * @returns the created texture
  85503. */
  85504. 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;
  85505. }
  85506. }
  85507. declare module BABYLON {
  85508. /**
  85509. * PostProcessManager is used to manage one or more post processes or post process pipelines
  85510. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  85511. */
  85512. export class PostProcessManager {
  85513. private _scene;
  85514. private _indexBuffer;
  85515. private _vertexBuffers;
  85516. /**
  85517. * Creates a new instance PostProcess
  85518. * @param scene The scene that the post process is associated with.
  85519. */
  85520. constructor(scene: Scene);
  85521. private _prepareBuffers;
  85522. private _buildIndexBuffer;
  85523. /**
  85524. * Rebuilds the vertex buffers of the manager.
  85525. * @hidden
  85526. */
  85527. _rebuild(): void;
  85528. /**
  85529. * Prepares a frame to be run through a post process.
  85530. * @param sourceTexture The input texture to the post procesess. (default: null)
  85531. * @param postProcesses An array of post processes to be run. (default: null)
  85532. * @returns True if the post processes were able to be run.
  85533. * @hidden
  85534. */
  85535. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  85536. /**
  85537. * Manually render a set of post processes to a texture.
  85538. * @param postProcesses An array of post processes to be run.
  85539. * @param targetTexture The target texture to render to.
  85540. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  85541. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  85542. * @param lodLevel defines which lod of the texture to render to
  85543. */
  85544. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  85545. /**
  85546. * Finalize the result of the output of the postprocesses.
  85547. * @param doNotPresent If true the result will not be displayed to the screen.
  85548. * @param targetTexture The target texture to render to.
  85549. * @param faceIndex The index of the face to bind the target texture to.
  85550. * @param postProcesses The array of post processes to render.
  85551. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  85552. * @hidden
  85553. */
  85554. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  85555. /**
  85556. * Disposes of the post process manager.
  85557. */
  85558. dispose(): void;
  85559. }
  85560. }
  85561. declare module BABYLON {
  85562. /** Interface used by value gradients (color, factor, ...) */
  85563. export interface IValueGradient {
  85564. /**
  85565. * Gets or sets the gradient value (between 0 and 1)
  85566. */
  85567. gradient: number;
  85568. }
  85569. /** Class used to store color4 gradient */
  85570. export class ColorGradient implements IValueGradient {
  85571. /**
  85572. * Gets or sets the gradient value (between 0 and 1)
  85573. */
  85574. gradient: number;
  85575. /**
  85576. * Gets or sets first associated color
  85577. */
  85578. color1: Color4;
  85579. /**
  85580. * Gets or sets second associated color
  85581. */
  85582. color2?: Color4;
  85583. /**
  85584. * Will get a color picked randomly between color1 and color2.
  85585. * If color2 is undefined then color1 will be used
  85586. * @param result defines the target Color4 to store the result in
  85587. */
  85588. getColorToRef(result: Color4): void;
  85589. }
  85590. /** Class used to store color 3 gradient */
  85591. export class Color3Gradient implements IValueGradient {
  85592. /**
  85593. * Gets or sets the gradient value (between 0 and 1)
  85594. */
  85595. gradient: number;
  85596. /**
  85597. * Gets or sets the associated color
  85598. */
  85599. color: Color3;
  85600. }
  85601. /** Class used to store factor gradient */
  85602. export class FactorGradient implements IValueGradient {
  85603. /**
  85604. * Gets or sets the gradient value (between 0 and 1)
  85605. */
  85606. gradient: number;
  85607. /**
  85608. * Gets or sets first associated factor
  85609. */
  85610. factor1: number;
  85611. /**
  85612. * Gets or sets second associated factor
  85613. */
  85614. factor2?: number;
  85615. /**
  85616. * Will get a number picked randomly between factor1 and factor2.
  85617. * If factor2 is undefined then factor1 will be used
  85618. * @returns the picked number
  85619. */
  85620. getFactor(): number;
  85621. }
  85622. /**
  85623. * Helper used to simplify some generic gradient tasks
  85624. */
  85625. export class GradientHelper {
  85626. /**
  85627. * Gets the current gradient from an array of IValueGradient
  85628. * @param ratio defines the current ratio to get
  85629. * @param gradients defines the array of IValueGradient
  85630. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  85631. */
  85632. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  85633. }
  85634. }
  85635. declare module BABYLON {
  85636. interface ThinEngine {
  85637. /**
  85638. * Creates a dynamic texture
  85639. * @param width defines the width of the texture
  85640. * @param height defines the height of the texture
  85641. * @param generateMipMaps defines if the engine should generate the mip levels
  85642. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85643. * @returns the dynamic texture inside an InternalTexture
  85644. */
  85645. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  85646. /**
  85647. * Update the content of a dynamic texture
  85648. * @param texture defines the texture to update
  85649. * @param canvas defines the canvas containing the source
  85650. * @param invertY defines if data must be stored with Y axis inverted
  85651. * @param premulAlpha defines if alpha is stored as premultiplied
  85652. * @param format defines the format of the data
  85653. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  85654. */
  85655. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  85656. }
  85657. }
  85658. declare module BABYLON {
  85659. /**
  85660. * Helper class used to generate a canvas to manipulate images
  85661. */
  85662. export class CanvasGenerator {
  85663. /**
  85664. * Create a new canvas (or offscreen canvas depending on the context)
  85665. * @param width defines the expected width
  85666. * @param height defines the expected height
  85667. * @return a new canvas or offscreen canvas
  85668. */
  85669. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  85670. }
  85671. }
  85672. declare module BABYLON {
  85673. /**
  85674. * A class extending Texture allowing drawing on a texture
  85675. * @see http://doc.babylonjs.com/how_to/dynamictexture
  85676. */
  85677. export class DynamicTexture extends Texture {
  85678. private _generateMipMaps;
  85679. private _canvas;
  85680. private _context;
  85681. private _engine;
  85682. /**
  85683. * Creates a DynamicTexture
  85684. * @param name defines the name of the texture
  85685. * @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
  85686. * @param scene defines the scene where you want the texture
  85687. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  85688. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  85689. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  85690. */
  85691. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  85692. /**
  85693. * Get the current class name of the texture useful for serialization or dynamic coding.
  85694. * @returns "DynamicTexture"
  85695. */
  85696. getClassName(): string;
  85697. /**
  85698. * Gets the current state of canRescale
  85699. */
  85700. readonly canRescale: boolean;
  85701. private _recreate;
  85702. /**
  85703. * Scales the texture
  85704. * @param ratio the scale factor to apply to both width and height
  85705. */
  85706. scale(ratio: number): void;
  85707. /**
  85708. * Resizes the texture
  85709. * @param width the new width
  85710. * @param height the new height
  85711. */
  85712. scaleTo(width: number, height: number): void;
  85713. /**
  85714. * Gets the context of the canvas used by the texture
  85715. * @returns the canvas context of the dynamic texture
  85716. */
  85717. getContext(): CanvasRenderingContext2D;
  85718. /**
  85719. * Clears the texture
  85720. */
  85721. clear(): void;
  85722. /**
  85723. * Updates the texture
  85724. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  85725. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  85726. */
  85727. update(invertY?: boolean, premulAlpha?: boolean): void;
  85728. /**
  85729. * Draws text onto the texture
  85730. * @param text defines the text to be drawn
  85731. * @param x defines the placement of the text from the left
  85732. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  85733. * @param font defines the font to be used with font-style, font-size, font-name
  85734. * @param color defines the color used for the text
  85735. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  85736. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  85737. * @param update defines whether texture is immediately update (default is true)
  85738. */
  85739. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  85740. /**
  85741. * Clones the texture
  85742. * @returns the clone of the texture.
  85743. */
  85744. clone(): DynamicTexture;
  85745. /**
  85746. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  85747. * @returns a serialized dynamic texture object
  85748. */
  85749. serialize(): any;
  85750. /** @hidden */
  85751. _rebuild(): void;
  85752. }
  85753. }
  85754. declare module BABYLON {
  85755. interface AbstractScene {
  85756. /**
  85757. * The list of procedural textures added to the scene
  85758. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85759. */
  85760. proceduralTextures: Array<ProceduralTexture>;
  85761. }
  85762. /**
  85763. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  85764. * in a given scene.
  85765. */
  85766. export class ProceduralTextureSceneComponent implements ISceneComponent {
  85767. /**
  85768. * The component name helpfull to identify the component in the list of scene components.
  85769. */
  85770. readonly name: string;
  85771. /**
  85772. * The scene the component belongs to.
  85773. */
  85774. scene: Scene;
  85775. /**
  85776. * Creates a new instance of the component for the given scene
  85777. * @param scene Defines the scene to register the component in
  85778. */
  85779. constructor(scene: Scene);
  85780. /**
  85781. * Registers the component in a given scene
  85782. */
  85783. register(): void;
  85784. /**
  85785. * Rebuilds the elements related to this component in case of
  85786. * context lost for instance.
  85787. */
  85788. rebuild(): void;
  85789. /**
  85790. * Disposes the component and the associated ressources.
  85791. */
  85792. dispose(): void;
  85793. private _beforeClear;
  85794. }
  85795. }
  85796. declare module BABYLON {
  85797. interface ThinEngine {
  85798. /**
  85799. * Creates a new render target cube texture
  85800. * @param size defines the size of the texture
  85801. * @param options defines the options used to create the texture
  85802. * @returns a new render target cube texture stored in an InternalTexture
  85803. */
  85804. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85805. }
  85806. }
  85807. declare module BABYLON {
  85808. /** @hidden */
  85809. export var proceduralVertexShader: {
  85810. name: string;
  85811. shader: string;
  85812. };
  85813. }
  85814. declare module BABYLON {
  85815. /**
  85816. * 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.
  85817. * This is the base class of any Procedural texture and contains most of the shareable code.
  85818. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85819. */
  85820. export class ProceduralTexture extends Texture {
  85821. isCube: boolean;
  85822. /**
  85823. * Define if the texture is enabled or not (disabled texture will not render)
  85824. */
  85825. isEnabled: boolean;
  85826. /**
  85827. * Define if the texture must be cleared before rendering (default is true)
  85828. */
  85829. autoClear: boolean;
  85830. /**
  85831. * Callback called when the texture is generated
  85832. */
  85833. onGenerated: () => void;
  85834. /**
  85835. * Event raised when the texture is generated
  85836. */
  85837. onGeneratedObservable: Observable<ProceduralTexture>;
  85838. /** @hidden */
  85839. _generateMipMaps: boolean;
  85840. /** @hidden **/
  85841. _effect: Effect;
  85842. /** @hidden */
  85843. _textures: {
  85844. [key: string]: Texture;
  85845. };
  85846. private _size;
  85847. private _currentRefreshId;
  85848. private _refreshRate;
  85849. private _vertexBuffers;
  85850. private _indexBuffer;
  85851. private _uniforms;
  85852. private _samplers;
  85853. private _fragment;
  85854. private _floats;
  85855. private _ints;
  85856. private _floatsArrays;
  85857. private _colors3;
  85858. private _colors4;
  85859. private _vectors2;
  85860. private _vectors3;
  85861. private _matrices;
  85862. private _fallbackTexture;
  85863. private _fallbackTextureUsed;
  85864. private _engine;
  85865. private _cachedDefines;
  85866. private _contentUpdateId;
  85867. private _contentData;
  85868. /**
  85869. * Instantiates a new procedural texture.
  85870. * 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.
  85871. * This is the base class of any Procedural texture and contains most of the shareable code.
  85872. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85873. * @param name Define the name of the texture
  85874. * @param size Define the size of the texture to create
  85875. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  85876. * @param scene Define the scene the texture belongs to
  85877. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  85878. * @param generateMipMaps Define if the texture should creates mip maps or not
  85879. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  85880. */
  85881. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  85882. /**
  85883. * The effect that is created when initializing the post process.
  85884. * @returns The created effect corresponding the the postprocess.
  85885. */
  85886. getEffect(): Effect;
  85887. /**
  85888. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  85889. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  85890. */
  85891. getContent(): Nullable<ArrayBufferView>;
  85892. private _createIndexBuffer;
  85893. /** @hidden */
  85894. _rebuild(): void;
  85895. /**
  85896. * Resets the texture in order to recreate its associated resources.
  85897. * This can be called in case of context loss
  85898. */
  85899. reset(): void;
  85900. protected _getDefines(): string;
  85901. /**
  85902. * Is the texture ready to be used ? (rendered at least once)
  85903. * @returns true if ready, otherwise, false.
  85904. */
  85905. isReady(): boolean;
  85906. /**
  85907. * Resets the refresh counter of the texture and start bak from scratch.
  85908. * Could be useful to regenerate the texture if it is setup to render only once.
  85909. */
  85910. resetRefreshCounter(): void;
  85911. /**
  85912. * Set the fragment shader to use in order to render the texture.
  85913. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  85914. */
  85915. setFragment(fragment: any): void;
  85916. /**
  85917. * Define the refresh rate of the texture or the rendering frequency.
  85918. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85919. */
  85920. refreshRate: number;
  85921. /** @hidden */
  85922. _shouldRender(): boolean;
  85923. /**
  85924. * Get the size the texture is rendering at.
  85925. * @returns the size (texture is always squared)
  85926. */
  85927. getRenderSize(): number;
  85928. /**
  85929. * Resize the texture to new value.
  85930. * @param size Define the new size the texture should have
  85931. * @param generateMipMaps Define whether the new texture should create mip maps
  85932. */
  85933. resize(size: number, generateMipMaps: boolean): void;
  85934. private _checkUniform;
  85935. /**
  85936. * Set a texture in the shader program used to render.
  85937. * @param name Define the name of the uniform samplers as defined in the shader
  85938. * @param texture Define the texture to bind to this sampler
  85939. * @return the texture itself allowing "fluent" like uniform updates
  85940. */
  85941. setTexture(name: string, texture: Texture): ProceduralTexture;
  85942. /**
  85943. * Set a float in the shader.
  85944. * @param name Define the name of the uniform as defined in the shader
  85945. * @param value Define the value to give to the uniform
  85946. * @return the texture itself allowing "fluent" like uniform updates
  85947. */
  85948. setFloat(name: string, value: number): ProceduralTexture;
  85949. /**
  85950. * Set a int in the shader.
  85951. * @param name Define the name of the uniform as defined in the shader
  85952. * @param value Define the value to give to the uniform
  85953. * @return the texture itself allowing "fluent" like uniform updates
  85954. */
  85955. setInt(name: string, value: number): ProceduralTexture;
  85956. /**
  85957. * Set an array of floats in the shader.
  85958. * @param name Define the name of the uniform as defined in the shader
  85959. * @param value Define the value to give to the uniform
  85960. * @return the texture itself allowing "fluent" like uniform updates
  85961. */
  85962. setFloats(name: string, value: number[]): ProceduralTexture;
  85963. /**
  85964. * Set a vec3 in the shader from a Color3.
  85965. * @param name Define the name of the uniform as defined in the shader
  85966. * @param value Define the value to give to the uniform
  85967. * @return the texture itself allowing "fluent" like uniform updates
  85968. */
  85969. setColor3(name: string, value: Color3): ProceduralTexture;
  85970. /**
  85971. * Set a vec4 in the shader from a Color4.
  85972. * @param name Define the name of the uniform as defined in the shader
  85973. * @param value Define the value to give to the uniform
  85974. * @return the texture itself allowing "fluent" like uniform updates
  85975. */
  85976. setColor4(name: string, value: Color4): ProceduralTexture;
  85977. /**
  85978. * Set a vec2 in the shader from a Vector2.
  85979. * @param name Define the name of the uniform as defined in the shader
  85980. * @param value Define the value to give to the uniform
  85981. * @return the texture itself allowing "fluent" like uniform updates
  85982. */
  85983. setVector2(name: string, value: Vector2): ProceduralTexture;
  85984. /**
  85985. * Set a vec3 in the shader from a Vector3.
  85986. * @param name Define the name of the uniform as defined in the shader
  85987. * @param value Define the value to give to the uniform
  85988. * @return the texture itself allowing "fluent" like uniform updates
  85989. */
  85990. setVector3(name: string, value: Vector3): ProceduralTexture;
  85991. /**
  85992. * Set a mat4 in the shader from a MAtrix.
  85993. * @param name Define the name of the uniform as defined in the shader
  85994. * @param value Define the value to give to the uniform
  85995. * @return the texture itself allowing "fluent" like uniform updates
  85996. */
  85997. setMatrix(name: string, value: Matrix): ProceduralTexture;
  85998. /**
  85999. * Render the texture to its associated render target.
  86000. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  86001. */
  86002. render(useCameraPostProcess?: boolean): void;
  86003. /**
  86004. * Clone the texture.
  86005. * @returns the cloned texture
  86006. */
  86007. clone(): ProceduralTexture;
  86008. /**
  86009. * Dispose the texture and release its asoociated resources.
  86010. */
  86011. dispose(): void;
  86012. }
  86013. }
  86014. declare module BABYLON {
  86015. /**
  86016. * This represents the base class for particle system in Babylon.
  86017. * 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.
  86018. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  86019. * @example https://doc.babylonjs.com/babylon101/particles
  86020. */
  86021. export class BaseParticleSystem {
  86022. /**
  86023. * Source color is added to the destination color without alpha affecting the result
  86024. */
  86025. static BLENDMODE_ONEONE: number;
  86026. /**
  86027. * Blend current color and particle color using particle’s alpha
  86028. */
  86029. static BLENDMODE_STANDARD: number;
  86030. /**
  86031. * Add current color and particle color multiplied by particle’s alpha
  86032. */
  86033. static BLENDMODE_ADD: number;
  86034. /**
  86035. * Multiply current color with particle color
  86036. */
  86037. static BLENDMODE_MULTIPLY: number;
  86038. /**
  86039. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  86040. */
  86041. static BLENDMODE_MULTIPLYADD: number;
  86042. /**
  86043. * List of animations used by the particle system.
  86044. */
  86045. animations: Animation[];
  86046. /**
  86047. * The id of the Particle system.
  86048. */
  86049. id: string;
  86050. /**
  86051. * The friendly name of the Particle system.
  86052. */
  86053. name: string;
  86054. /**
  86055. * The rendering group used by the Particle system to chose when to render.
  86056. */
  86057. renderingGroupId: number;
  86058. /**
  86059. * The emitter represents the Mesh or position we are attaching the particle system to.
  86060. */
  86061. emitter: Nullable<AbstractMesh | Vector3>;
  86062. /**
  86063. * The maximum number of particles to emit per frame
  86064. */
  86065. emitRate: number;
  86066. /**
  86067. * If you want to launch only a few particles at once, that can be done, as well.
  86068. */
  86069. manualEmitCount: number;
  86070. /**
  86071. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86072. */
  86073. updateSpeed: number;
  86074. /**
  86075. * The amount of time the particle system is running (depends of the overall update speed).
  86076. */
  86077. targetStopDuration: number;
  86078. /**
  86079. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86080. */
  86081. disposeOnStop: boolean;
  86082. /**
  86083. * Minimum power of emitting particles.
  86084. */
  86085. minEmitPower: number;
  86086. /**
  86087. * Maximum power of emitting particles.
  86088. */
  86089. maxEmitPower: number;
  86090. /**
  86091. * Minimum life time of emitting particles.
  86092. */
  86093. minLifeTime: number;
  86094. /**
  86095. * Maximum life time of emitting particles.
  86096. */
  86097. maxLifeTime: number;
  86098. /**
  86099. * Minimum Size of emitting particles.
  86100. */
  86101. minSize: number;
  86102. /**
  86103. * Maximum Size of emitting particles.
  86104. */
  86105. maxSize: number;
  86106. /**
  86107. * Minimum scale of emitting particles on X axis.
  86108. */
  86109. minScaleX: number;
  86110. /**
  86111. * Maximum scale of emitting particles on X axis.
  86112. */
  86113. maxScaleX: number;
  86114. /**
  86115. * Minimum scale of emitting particles on Y axis.
  86116. */
  86117. minScaleY: number;
  86118. /**
  86119. * Maximum scale of emitting particles on Y axis.
  86120. */
  86121. maxScaleY: number;
  86122. /**
  86123. * Gets or sets the minimal initial rotation in radians.
  86124. */
  86125. minInitialRotation: number;
  86126. /**
  86127. * Gets or sets the maximal initial rotation in radians.
  86128. */
  86129. maxInitialRotation: number;
  86130. /**
  86131. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86132. */
  86133. minAngularSpeed: number;
  86134. /**
  86135. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86136. */
  86137. maxAngularSpeed: number;
  86138. /**
  86139. * The texture used to render each particle. (this can be a spritesheet)
  86140. */
  86141. particleTexture: Nullable<Texture>;
  86142. /**
  86143. * The layer mask we are rendering the particles through.
  86144. */
  86145. layerMask: number;
  86146. /**
  86147. * This can help using your own shader to render the particle system.
  86148. * The according effect will be created
  86149. */
  86150. customShader: any;
  86151. /**
  86152. * By default particle system starts as soon as they are created. This prevents the
  86153. * automatic start to happen and let you decide when to start emitting particles.
  86154. */
  86155. preventAutoStart: boolean;
  86156. private _noiseTexture;
  86157. /**
  86158. * Gets or sets a texture used to add random noise to particle positions
  86159. */
  86160. noiseTexture: Nullable<ProceduralTexture>;
  86161. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86162. noiseStrength: Vector3;
  86163. /**
  86164. * Callback triggered when the particle animation is ending.
  86165. */
  86166. onAnimationEnd: Nullable<() => void>;
  86167. /**
  86168. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  86169. */
  86170. blendMode: number;
  86171. /**
  86172. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  86173. * to override the particles.
  86174. */
  86175. forceDepthWrite: boolean;
  86176. /** 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 */
  86177. preWarmCycles: number;
  86178. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  86179. preWarmStepOffset: number;
  86180. /**
  86181. * 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)
  86182. */
  86183. spriteCellChangeSpeed: number;
  86184. /**
  86185. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86186. */
  86187. startSpriteCellID: number;
  86188. /**
  86189. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86190. */
  86191. endSpriteCellID: number;
  86192. /**
  86193. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86194. */
  86195. spriteCellWidth: number;
  86196. /**
  86197. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86198. */
  86199. spriteCellHeight: number;
  86200. /**
  86201. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86202. */
  86203. spriteRandomStartCell: boolean;
  86204. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86205. translationPivot: Vector2;
  86206. /** @hidden */
  86207. protected _isAnimationSheetEnabled: boolean;
  86208. /**
  86209. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86210. */
  86211. beginAnimationOnStart: boolean;
  86212. /**
  86213. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86214. */
  86215. beginAnimationFrom: number;
  86216. /**
  86217. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86218. */
  86219. beginAnimationTo: number;
  86220. /**
  86221. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86222. */
  86223. beginAnimationLoop: boolean;
  86224. /**
  86225. * Gets or sets a world offset applied to all particles
  86226. */
  86227. worldOffset: Vector3;
  86228. /**
  86229. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  86230. */
  86231. isAnimationSheetEnabled: boolean;
  86232. /**
  86233. * Get hosting scene
  86234. * @returns the scene
  86235. */
  86236. getScene(): Scene;
  86237. /**
  86238. * You can use gravity if you want to give an orientation to your particles.
  86239. */
  86240. gravity: Vector3;
  86241. protected _colorGradients: Nullable<Array<ColorGradient>>;
  86242. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  86243. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  86244. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  86245. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  86246. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  86247. protected _dragGradients: Nullable<Array<FactorGradient>>;
  86248. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  86249. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  86250. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  86251. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  86252. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  86253. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  86254. /**
  86255. * Defines the delay in milliseconds before starting the system (0 by default)
  86256. */
  86257. startDelay: number;
  86258. /**
  86259. * Gets the current list of drag gradients.
  86260. * You must use addDragGradient and removeDragGradient to udpate this list
  86261. * @returns the list of drag gradients
  86262. */
  86263. getDragGradients(): Nullable<Array<FactorGradient>>;
  86264. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86265. limitVelocityDamping: number;
  86266. /**
  86267. * Gets the current list of limit velocity gradients.
  86268. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86269. * @returns the list of limit velocity gradients
  86270. */
  86271. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86272. /**
  86273. * Gets the current list of color gradients.
  86274. * You must use addColorGradient and removeColorGradient to udpate this list
  86275. * @returns the list of color gradients
  86276. */
  86277. getColorGradients(): Nullable<Array<ColorGradient>>;
  86278. /**
  86279. * Gets the current list of size gradients.
  86280. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86281. * @returns the list of size gradients
  86282. */
  86283. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86284. /**
  86285. * Gets the current list of color remap gradients.
  86286. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86287. * @returns the list of color remap gradients
  86288. */
  86289. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86290. /**
  86291. * Gets the current list of alpha remap gradients.
  86292. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86293. * @returns the list of alpha remap gradients
  86294. */
  86295. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86296. /**
  86297. * Gets the current list of life time gradients.
  86298. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86299. * @returns the list of life time gradients
  86300. */
  86301. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86302. /**
  86303. * Gets the current list of angular speed gradients.
  86304. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86305. * @returns the list of angular speed gradients
  86306. */
  86307. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86308. /**
  86309. * Gets the current list of velocity gradients.
  86310. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86311. * @returns the list of velocity gradients
  86312. */
  86313. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86314. /**
  86315. * Gets the current list of start size gradients.
  86316. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86317. * @returns the list of start size gradients
  86318. */
  86319. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86320. /**
  86321. * Gets the current list of emit rate gradients.
  86322. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86323. * @returns the list of emit rate gradients
  86324. */
  86325. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86326. /**
  86327. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86328. * This only works when particleEmitterTyps is a BoxParticleEmitter
  86329. */
  86330. direction1: Vector3;
  86331. /**
  86332. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86333. * This only works when particleEmitterTyps is a BoxParticleEmitter
  86334. */
  86335. direction2: Vector3;
  86336. /**
  86337. * 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.
  86338. * This only works when particleEmitterTyps is a BoxParticleEmitter
  86339. */
  86340. minEmitBox: Vector3;
  86341. /**
  86342. * 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.
  86343. * This only works when particleEmitterTyps is a BoxParticleEmitter
  86344. */
  86345. maxEmitBox: Vector3;
  86346. /**
  86347. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  86348. */
  86349. color1: Color4;
  86350. /**
  86351. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  86352. */
  86353. color2: Color4;
  86354. /**
  86355. * Color the particle will have at the end of its lifetime
  86356. */
  86357. colorDead: Color4;
  86358. /**
  86359. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  86360. */
  86361. textureMask: Color4;
  86362. /**
  86363. * The particle emitter type defines the emitter used by the particle system.
  86364. * It can be for example box, sphere, or cone...
  86365. */
  86366. particleEmitterType: IParticleEmitterType;
  86367. /** @hidden */
  86368. _isSubEmitter: boolean;
  86369. /**
  86370. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86371. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86372. */
  86373. billboardMode: number;
  86374. protected _isBillboardBased: boolean;
  86375. /**
  86376. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86377. */
  86378. isBillboardBased: boolean;
  86379. /**
  86380. * The scene the particle system belongs to.
  86381. */
  86382. protected _scene: Scene;
  86383. /**
  86384. * Local cache of defines for image processing.
  86385. */
  86386. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  86387. /**
  86388. * Default configuration related to image processing available in the standard Material.
  86389. */
  86390. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  86391. /**
  86392. * Gets the image processing configuration used either in this material.
  86393. */
  86394. /**
  86395. * Sets the Default image processing configuration used either in the this material.
  86396. *
  86397. * If sets to null, the scene one is in use.
  86398. */
  86399. imageProcessingConfiguration: ImageProcessingConfiguration;
  86400. /**
  86401. * Attaches a new image processing configuration to the Standard Material.
  86402. * @param configuration
  86403. */
  86404. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  86405. /** @hidden */
  86406. protected _reset(): void;
  86407. /** @hidden */
  86408. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  86409. /**
  86410. * Instantiates a particle system.
  86411. * 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.
  86412. * @param name The name of the particle system
  86413. */
  86414. constructor(name: string);
  86415. /**
  86416. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86417. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86418. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86419. * @returns the emitter
  86420. */
  86421. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86422. /**
  86423. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86424. * @param radius The radius of the hemisphere to emit from
  86425. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86426. * @returns the emitter
  86427. */
  86428. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  86429. /**
  86430. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86431. * @param radius The radius of the sphere to emit from
  86432. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86433. * @returns the emitter
  86434. */
  86435. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  86436. /**
  86437. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86438. * @param radius The radius of the sphere to emit from
  86439. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86440. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86441. * @returns the emitter
  86442. */
  86443. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  86444. /**
  86445. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86446. * @param radius The radius of the emission cylinder
  86447. * @param height The height of the emission cylinder
  86448. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86449. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86450. * @returns the emitter
  86451. */
  86452. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  86453. /**
  86454. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86455. * @param radius The radius of the cylinder to emit from
  86456. * @param height The height of the emission cylinder
  86457. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86458. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86459. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86460. * @returns the emitter
  86461. */
  86462. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  86463. /**
  86464. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86465. * @param radius The radius of the cone to emit from
  86466. * @param angle The base angle of the cone
  86467. * @returns the emitter
  86468. */
  86469. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  86470. /**
  86471. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86472. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86473. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86474. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86475. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86476. * @returns the emitter
  86477. */
  86478. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86479. }
  86480. }
  86481. declare module BABYLON {
  86482. /**
  86483. * Type of sub emitter
  86484. */
  86485. export enum SubEmitterType {
  86486. /**
  86487. * Attached to the particle over it's lifetime
  86488. */
  86489. ATTACHED = 0,
  86490. /**
  86491. * Created when the particle dies
  86492. */
  86493. END = 1
  86494. }
  86495. /**
  86496. * Sub emitter class used to emit particles from an existing particle
  86497. */
  86498. export class SubEmitter {
  86499. /**
  86500. * the particle system to be used by the sub emitter
  86501. */
  86502. particleSystem: ParticleSystem;
  86503. /**
  86504. * Type of the submitter (Default: END)
  86505. */
  86506. type: SubEmitterType;
  86507. /**
  86508. * 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)
  86509. * Note: This only is supported when using an emitter of type Mesh
  86510. */
  86511. inheritDirection: boolean;
  86512. /**
  86513. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  86514. */
  86515. inheritedVelocityAmount: number;
  86516. /**
  86517. * Creates a sub emitter
  86518. * @param particleSystem the particle system to be used by the sub emitter
  86519. */
  86520. constructor(
  86521. /**
  86522. * the particle system to be used by the sub emitter
  86523. */
  86524. particleSystem: ParticleSystem);
  86525. /**
  86526. * Clones the sub emitter
  86527. * @returns the cloned sub emitter
  86528. */
  86529. clone(): SubEmitter;
  86530. /**
  86531. * Serialize current object to a JSON object
  86532. * @returns the serialized object
  86533. */
  86534. serialize(): any;
  86535. /** @hidden */
  86536. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  86537. /**
  86538. * Creates a new SubEmitter from a serialized JSON version
  86539. * @param serializationObject defines the JSON object to read from
  86540. * @param scene defines the hosting scene
  86541. * @param rootUrl defines the rootUrl for data loading
  86542. * @returns a new SubEmitter
  86543. */
  86544. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  86545. /** Release associated resources */
  86546. dispose(): void;
  86547. }
  86548. }
  86549. declare module BABYLON {
  86550. /** @hidden */
  86551. export var clipPlaneFragmentDeclaration: {
  86552. name: string;
  86553. shader: string;
  86554. };
  86555. }
  86556. declare module BABYLON {
  86557. /** @hidden */
  86558. export var imageProcessingDeclaration: {
  86559. name: string;
  86560. shader: string;
  86561. };
  86562. }
  86563. declare module BABYLON {
  86564. /** @hidden */
  86565. export var imageProcessingFunctions: {
  86566. name: string;
  86567. shader: string;
  86568. };
  86569. }
  86570. declare module BABYLON {
  86571. /** @hidden */
  86572. export var clipPlaneFragment: {
  86573. name: string;
  86574. shader: string;
  86575. };
  86576. }
  86577. declare module BABYLON {
  86578. /** @hidden */
  86579. export var particlesPixelShader: {
  86580. name: string;
  86581. shader: string;
  86582. };
  86583. }
  86584. declare module BABYLON {
  86585. /** @hidden */
  86586. export var clipPlaneVertexDeclaration: {
  86587. name: string;
  86588. shader: string;
  86589. };
  86590. }
  86591. declare module BABYLON {
  86592. /** @hidden */
  86593. export var clipPlaneVertex: {
  86594. name: string;
  86595. shader: string;
  86596. };
  86597. }
  86598. declare module BABYLON {
  86599. /** @hidden */
  86600. export var particlesVertexShader: {
  86601. name: string;
  86602. shader: string;
  86603. };
  86604. }
  86605. declare module BABYLON {
  86606. /**
  86607. * This represents a particle system in Babylon.
  86608. * 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.
  86609. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  86610. * @example https://doc.babylonjs.com/babylon101/particles
  86611. */
  86612. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  86613. /**
  86614. * Billboard mode will only apply to Y axis
  86615. */
  86616. static readonly BILLBOARDMODE_Y: number;
  86617. /**
  86618. * Billboard mode will apply to all axes
  86619. */
  86620. static readonly BILLBOARDMODE_ALL: number;
  86621. /**
  86622. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  86623. */
  86624. static readonly BILLBOARDMODE_STRETCHED: number;
  86625. /**
  86626. * This function can be defined to provide custom update for active particles.
  86627. * This function will be called instead of regular update (age, position, color, etc.).
  86628. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  86629. */
  86630. updateFunction: (particles: Particle[]) => void;
  86631. private _emitterWorldMatrix;
  86632. /**
  86633. * This function can be defined to specify initial direction for every new particle.
  86634. * It by default use the emitterType defined function
  86635. */
  86636. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  86637. /**
  86638. * This function can be defined to specify initial position for every new particle.
  86639. * It by default use the emitterType defined function
  86640. */
  86641. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  86642. /**
  86643. * @hidden
  86644. */
  86645. _inheritedVelocityOffset: Vector3;
  86646. /**
  86647. * An event triggered when the system is disposed
  86648. */
  86649. onDisposeObservable: Observable<ParticleSystem>;
  86650. private _onDisposeObserver;
  86651. /**
  86652. * Sets a callback that will be triggered when the system is disposed
  86653. */
  86654. onDispose: () => void;
  86655. private _particles;
  86656. private _epsilon;
  86657. private _capacity;
  86658. private _stockParticles;
  86659. private _newPartsExcess;
  86660. private _vertexData;
  86661. private _vertexBuffer;
  86662. private _vertexBuffers;
  86663. private _spriteBuffer;
  86664. private _indexBuffer;
  86665. private _effect;
  86666. private _customEffect;
  86667. private _cachedDefines;
  86668. private _scaledColorStep;
  86669. private _colorDiff;
  86670. private _scaledDirection;
  86671. private _scaledGravity;
  86672. private _currentRenderId;
  86673. private _alive;
  86674. private _useInstancing;
  86675. private _started;
  86676. private _stopped;
  86677. private _actualFrame;
  86678. private _scaledUpdateSpeed;
  86679. private _vertexBufferSize;
  86680. /** @hidden */
  86681. _currentEmitRateGradient: Nullable<FactorGradient>;
  86682. /** @hidden */
  86683. _currentEmitRate1: number;
  86684. /** @hidden */
  86685. _currentEmitRate2: number;
  86686. /** @hidden */
  86687. _currentStartSizeGradient: Nullable<FactorGradient>;
  86688. /** @hidden */
  86689. _currentStartSize1: number;
  86690. /** @hidden */
  86691. _currentStartSize2: number;
  86692. private readonly _rawTextureWidth;
  86693. private _rampGradientsTexture;
  86694. private _useRampGradients;
  86695. /** Gets or sets a boolean indicating that ramp gradients must be used
  86696. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86697. */
  86698. useRampGradients: boolean;
  86699. /**
  86700. * 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.
  86701. * 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: [])
  86702. */
  86703. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  86704. private _subEmitters;
  86705. /**
  86706. * @hidden
  86707. * If the particle systems emitter should be disposed when the particle system is disposed
  86708. */
  86709. _disposeEmitterOnDispose: boolean;
  86710. /**
  86711. * The current active Sub-systems, this property is used by the root particle system only.
  86712. */
  86713. activeSubSystems: Array<ParticleSystem>;
  86714. private _rootParticleSystem;
  86715. /**
  86716. * Gets the current list of active particles
  86717. */
  86718. readonly particles: Particle[];
  86719. /**
  86720. * Returns the string "ParticleSystem"
  86721. * @returns a string containing the class name
  86722. */
  86723. getClassName(): string;
  86724. /**
  86725. * Instantiates a particle system.
  86726. * 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.
  86727. * @param name The name of the particle system
  86728. * @param capacity The max number of particles alive at the same time
  86729. * @param scene The scene the particle system belongs to
  86730. * @param customEffect a custom effect used to change the way particles are rendered by default
  86731. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  86732. * @param epsilon Offset used to render the particles
  86733. */
  86734. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  86735. private _addFactorGradient;
  86736. private _removeFactorGradient;
  86737. /**
  86738. * Adds a new life time gradient
  86739. * @param gradient defines the gradient to use (between 0 and 1)
  86740. * @param factor defines the life time factor to affect to the specified gradient
  86741. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86742. * @returns the current particle system
  86743. */
  86744. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86745. /**
  86746. * Remove a specific life time gradient
  86747. * @param gradient defines the gradient to remove
  86748. * @returns the current particle system
  86749. */
  86750. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86751. /**
  86752. * Adds a new size gradient
  86753. * @param gradient defines the gradient to use (between 0 and 1)
  86754. * @param factor defines the size factor to affect to the specified gradient
  86755. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86756. * @returns the current particle system
  86757. */
  86758. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86759. /**
  86760. * Remove a specific size gradient
  86761. * @param gradient defines the gradient to remove
  86762. * @returns the current particle system
  86763. */
  86764. removeSizeGradient(gradient: number): IParticleSystem;
  86765. /**
  86766. * Adds a new color remap gradient
  86767. * @param gradient defines the gradient to use (between 0 and 1)
  86768. * @param min defines the color remap minimal range
  86769. * @param max defines the color remap maximal range
  86770. * @returns the current particle system
  86771. */
  86772. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86773. /**
  86774. * Remove a specific color remap gradient
  86775. * @param gradient defines the gradient to remove
  86776. * @returns the current particle system
  86777. */
  86778. removeColorRemapGradient(gradient: number): IParticleSystem;
  86779. /**
  86780. * Adds a new alpha remap gradient
  86781. * @param gradient defines the gradient to use (between 0 and 1)
  86782. * @param min defines the alpha remap minimal range
  86783. * @param max defines the alpha remap maximal range
  86784. * @returns the current particle system
  86785. */
  86786. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86787. /**
  86788. * Remove a specific alpha remap gradient
  86789. * @param gradient defines the gradient to remove
  86790. * @returns the current particle system
  86791. */
  86792. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  86793. /**
  86794. * Adds a new angular speed gradient
  86795. * @param gradient defines the gradient to use (between 0 and 1)
  86796. * @param factor defines the angular speed to affect to the specified gradient
  86797. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86798. * @returns the current particle system
  86799. */
  86800. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86801. /**
  86802. * Remove a specific angular speed gradient
  86803. * @param gradient defines the gradient to remove
  86804. * @returns the current particle system
  86805. */
  86806. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86807. /**
  86808. * Adds a new velocity gradient
  86809. * @param gradient defines the gradient to use (between 0 and 1)
  86810. * @param factor defines the velocity to affect to the specified gradient
  86811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86812. * @returns the current particle system
  86813. */
  86814. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86815. /**
  86816. * Remove a specific velocity gradient
  86817. * @param gradient defines the gradient to remove
  86818. * @returns the current particle system
  86819. */
  86820. removeVelocityGradient(gradient: number): IParticleSystem;
  86821. /**
  86822. * Adds a new limit velocity gradient
  86823. * @param gradient defines the gradient to use (between 0 and 1)
  86824. * @param factor defines the limit velocity value to affect to the specified gradient
  86825. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86826. * @returns the current particle system
  86827. */
  86828. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86829. /**
  86830. * Remove a specific limit velocity gradient
  86831. * @param gradient defines the gradient to remove
  86832. * @returns the current particle system
  86833. */
  86834. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86835. /**
  86836. * Adds a new drag gradient
  86837. * @param gradient defines the gradient to use (between 0 and 1)
  86838. * @param factor defines the drag value to affect to the specified gradient
  86839. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86840. * @returns the current particle system
  86841. */
  86842. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86843. /**
  86844. * Remove a specific drag gradient
  86845. * @param gradient defines the gradient to remove
  86846. * @returns the current particle system
  86847. */
  86848. removeDragGradient(gradient: number): IParticleSystem;
  86849. /**
  86850. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86851. * @param gradient defines the gradient to use (between 0 and 1)
  86852. * @param factor defines the emit rate value to affect to the specified gradient
  86853. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86854. * @returns the current particle system
  86855. */
  86856. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86857. /**
  86858. * Remove a specific emit rate gradient
  86859. * @param gradient defines the gradient to remove
  86860. * @returns the current particle system
  86861. */
  86862. removeEmitRateGradient(gradient: number): IParticleSystem;
  86863. /**
  86864. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86865. * @param gradient defines the gradient to use (between 0 and 1)
  86866. * @param factor defines the start size value to affect to the specified gradient
  86867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86868. * @returns the current particle system
  86869. */
  86870. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86871. /**
  86872. * Remove a specific start size gradient
  86873. * @param gradient defines the gradient to remove
  86874. * @returns the current particle system
  86875. */
  86876. removeStartSizeGradient(gradient: number): IParticleSystem;
  86877. private _createRampGradientTexture;
  86878. /**
  86879. * Gets the current list of ramp gradients.
  86880. * You must use addRampGradient and removeRampGradient to udpate this list
  86881. * @returns the list of ramp gradients
  86882. */
  86883. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86884. /**
  86885. * Adds a new ramp gradient used to remap particle colors
  86886. * @param gradient defines the gradient to use (between 0 and 1)
  86887. * @param color defines the color to affect to the specified gradient
  86888. * @returns the current particle system
  86889. */
  86890. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  86891. /**
  86892. * Remove a specific ramp gradient
  86893. * @param gradient defines the gradient to remove
  86894. * @returns the current particle system
  86895. */
  86896. removeRampGradient(gradient: number): ParticleSystem;
  86897. /**
  86898. * Adds a new color gradient
  86899. * @param gradient defines the gradient to use (between 0 and 1)
  86900. * @param color1 defines the color to affect to the specified gradient
  86901. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86902. * @returns this particle system
  86903. */
  86904. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86905. /**
  86906. * Remove a specific color gradient
  86907. * @param gradient defines the gradient to remove
  86908. * @returns this particle system
  86909. */
  86910. removeColorGradient(gradient: number): IParticleSystem;
  86911. private _fetchR;
  86912. protected _reset(): void;
  86913. private _resetEffect;
  86914. private _createVertexBuffers;
  86915. private _createIndexBuffer;
  86916. /**
  86917. * Gets the maximum number of particles active at the same time.
  86918. * @returns The max number of active particles.
  86919. */
  86920. getCapacity(): number;
  86921. /**
  86922. * Gets whether there are still active particles in the system.
  86923. * @returns True if it is alive, otherwise false.
  86924. */
  86925. isAlive(): boolean;
  86926. /**
  86927. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86928. * @returns True if it has been started, otherwise false.
  86929. */
  86930. isStarted(): boolean;
  86931. private _prepareSubEmitterInternalArray;
  86932. /**
  86933. * Starts the particle system and begins to emit
  86934. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  86935. */
  86936. start(delay?: number): void;
  86937. /**
  86938. * Stops the particle system.
  86939. * @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.
  86940. */
  86941. stop(stopSubEmitters?: boolean): void;
  86942. /**
  86943. * Remove all active particles
  86944. */
  86945. reset(): void;
  86946. /**
  86947. * @hidden (for internal use only)
  86948. */
  86949. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  86950. /**
  86951. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  86952. * Its lifetime will start back at 0.
  86953. */
  86954. recycleParticle: (particle: Particle) => void;
  86955. private _stopSubEmitters;
  86956. private _createParticle;
  86957. private _removeFromRoot;
  86958. private _emitFromParticle;
  86959. private _update;
  86960. /** @hidden */
  86961. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  86962. /** @hidden */
  86963. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  86964. /** @hidden */
  86965. private _getEffect;
  86966. /**
  86967. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  86968. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  86969. */
  86970. animate(preWarmOnly?: boolean): void;
  86971. private _appendParticleVertices;
  86972. /**
  86973. * Rebuilds the particle system.
  86974. */
  86975. rebuild(): void;
  86976. /**
  86977. * Is this system ready to be used/rendered
  86978. * @return true if the system is ready
  86979. */
  86980. isReady(): boolean;
  86981. private _render;
  86982. /**
  86983. * Renders the particle system in its current state.
  86984. * @returns the current number of particles
  86985. */
  86986. render(): number;
  86987. /**
  86988. * Disposes the particle system and free the associated resources
  86989. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86990. */
  86991. dispose(disposeTexture?: boolean): void;
  86992. /**
  86993. * Clones the particle system.
  86994. * @param name The name of the cloned object
  86995. * @param newEmitter The new emitter to use
  86996. * @returns the cloned particle system
  86997. */
  86998. clone(name: string, newEmitter: any): ParticleSystem;
  86999. /**
  87000. * Serializes the particle system to a JSON object.
  87001. * @returns the JSON object
  87002. */
  87003. serialize(): any;
  87004. /** @hidden */
  87005. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  87006. /** @hidden */
  87007. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  87008. /**
  87009. * Parses a JSON object to create a particle system.
  87010. * @param parsedParticleSystem The JSON object to parse
  87011. * @param scene The scene to create the particle system in
  87012. * @param rootUrl The root url to use to load external dependencies like texture
  87013. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  87014. * @returns the Parsed particle system
  87015. */
  87016. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  87017. }
  87018. }
  87019. declare module BABYLON {
  87020. /**
  87021. * A particle represents one of the element emitted by a particle system.
  87022. * This is mainly define by its coordinates, direction, velocity and age.
  87023. */
  87024. export class Particle {
  87025. /**
  87026. * The particle system the particle belongs to.
  87027. */
  87028. particleSystem: ParticleSystem;
  87029. private static _Count;
  87030. /**
  87031. * Unique ID of the particle
  87032. */
  87033. id: number;
  87034. /**
  87035. * The world position of the particle in the scene.
  87036. */
  87037. position: Vector3;
  87038. /**
  87039. * The world direction of the particle in the scene.
  87040. */
  87041. direction: Vector3;
  87042. /**
  87043. * The color of the particle.
  87044. */
  87045. color: Color4;
  87046. /**
  87047. * The color change of the particle per step.
  87048. */
  87049. colorStep: Color4;
  87050. /**
  87051. * Defines how long will the life of the particle be.
  87052. */
  87053. lifeTime: number;
  87054. /**
  87055. * The current age of the particle.
  87056. */
  87057. age: number;
  87058. /**
  87059. * The current size of the particle.
  87060. */
  87061. size: number;
  87062. /**
  87063. * The current scale of the particle.
  87064. */
  87065. scale: Vector2;
  87066. /**
  87067. * The current angle of the particle.
  87068. */
  87069. angle: number;
  87070. /**
  87071. * Defines how fast is the angle changing.
  87072. */
  87073. angularSpeed: number;
  87074. /**
  87075. * Defines the cell index used by the particle to be rendered from a sprite.
  87076. */
  87077. cellIndex: number;
  87078. /**
  87079. * The information required to support color remapping
  87080. */
  87081. remapData: Vector4;
  87082. /** @hidden */
  87083. _randomCellOffset?: number;
  87084. /** @hidden */
  87085. _initialDirection: Nullable<Vector3>;
  87086. /** @hidden */
  87087. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  87088. /** @hidden */
  87089. _initialStartSpriteCellID: number;
  87090. /** @hidden */
  87091. _initialEndSpriteCellID: number;
  87092. /** @hidden */
  87093. _currentColorGradient: Nullable<ColorGradient>;
  87094. /** @hidden */
  87095. _currentColor1: Color4;
  87096. /** @hidden */
  87097. _currentColor2: Color4;
  87098. /** @hidden */
  87099. _currentSizeGradient: Nullable<FactorGradient>;
  87100. /** @hidden */
  87101. _currentSize1: number;
  87102. /** @hidden */
  87103. _currentSize2: number;
  87104. /** @hidden */
  87105. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  87106. /** @hidden */
  87107. _currentAngularSpeed1: number;
  87108. /** @hidden */
  87109. _currentAngularSpeed2: number;
  87110. /** @hidden */
  87111. _currentVelocityGradient: Nullable<FactorGradient>;
  87112. /** @hidden */
  87113. _currentVelocity1: number;
  87114. /** @hidden */
  87115. _currentVelocity2: number;
  87116. /** @hidden */
  87117. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  87118. /** @hidden */
  87119. _currentLimitVelocity1: number;
  87120. /** @hidden */
  87121. _currentLimitVelocity2: number;
  87122. /** @hidden */
  87123. _currentDragGradient: Nullable<FactorGradient>;
  87124. /** @hidden */
  87125. _currentDrag1: number;
  87126. /** @hidden */
  87127. _currentDrag2: number;
  87128. /** @hidden */
  87129. _randomNoiseCoordinates1: Vector3;
  87130. /** @hidden */
  87131. _randomNoiseCoordinates2: Vector3;
  87132. /**
  87133. * Creates a new instance Particle
  87134. * @param particleSystem the particle system the particle belongs to
  87135. */
  87136. constructor(
  87137. /**
  87138. * The particle system the particle belongs to.
  87139. */
  87140. particleSystem: ParticleSystem);
  87141. private updateCellInfoFromSystem;
  87142. /**
  87143. * Defines how the sprite cell index is updated for the particle
  87144. */
  87145. updateCellIndex(): void;
  87146. /** @hidden */
  87147. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  87148. /** @hidden */
  87149. _inheritParticleInfoToSubEmitters(): void;
  87150. /** @hidden */
  87151. _reset(): void;
  87152. /**
  87153. * Copy the properties of particle to another one.
  87154. * @param other the particle to copy the information to.
  87155. */
  87156. copyTo(other: Particle): void;
  87157. }
  87158. }
  87159. declare module BABYLON {
  87160. /**
  87161. * Particle emitter represents a volume emitting particles.
  87162. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  87163. */
  87164. export interface IParticleEmitterType {
  87165. /**
  87166. * Called by the particle System when the direction is computed for the created particle.
  87167. * @param worldMatrix is the world matrix of the particle system
  87168. * @param directionToUpdate is the direction vector to update with the result
  87169. * @param particle is the particle we are computed the direction for
  87170. */
  87171. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87172. /**
  87173. * Called by the particle System when the position is computed for the created particle.
  87174. * @param worldMatrix is the world matrix of the particle system
  87175. * @param positionToUpdate is the position vector to update with the result
  87176. * @param particle is the particle we are computed the position for
  87177. */
  87178. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87179. /**
  87180. * Clones the current emitter and returns a copy of it
  87181. * @returns the new emitter
  87182. */
  87183. clone(): IParticleEmitterType;
  87184. /**
  87185. * Called by the GPUParticleSystem to setup the update shader
  87186. * @param effect defines the update shader
  87187. */
  87188. applyToShader(effect: Effect): void;
  87189. /**
  87190. * Returns a string to use to update the GPU particles update shader
  87191. * @returns the effect defines string
  87192. */
  87193. getEffectDefines(): string;
  87194. /**
  87195. * Returns a string representing the class name
  87196. * @returns a string containing the class name
  87197. */
  87198. getClassName(): string;
  87199. /**
  87200. * Serializes the particle system to a JSON object.
  87201. * @returns the JSON object
  87202. */
  87203. serialize(): any;
  87204. /**
  87205. * Parse properties from a JSON object
  87206. * @param serializationObject defines the JSON object
  87207. */
  87208. parse(serializationObject: any): void;
  87209. }
  87210. }
  87211. declare module BABYLON {
  87212. /**
  87213. * Particle emitter emitting particles from the inside of a box.
  87214. * It emits the particles randomly between 2 given directions.
  87215. */
  87216. export class BoxParticleEmitter implements IParticleEmitterType {
  87217. /**
  87218. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87219. */
  87220. direction1: Vector3;
  87221. /**
  87222. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87223. */
  87224. direction2: Vector3;
  87225. /**
  87226. * 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.
  87227. */
  87228. minEmitBox: Vector3;
  87229. /**
  87230. * 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.
  87231. */
  87232. maxEmitBox: Vector3;
  87233. /**
  87234. * Creates a new instance BoxParticleEmitter
  87235. */
  87236. constructor();
  87237. /**
  87238. * Called by the particle System when the direction is computed for the created particle.
  87239. * @param worldMatrix is the world matrix of the particle system
  87240. * @param directionToUpdate is the direction vector to update with the result
  87241. * @param particle is the particle we are computed the direction for
  87242. */
  87243. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87244. /**
  87245. * Called by the particle System when the position is computed for the created particle.
  87246. * @param worldMatrix is the world matrix of the particle system
  87247. * @param positionToUpdate is the position vector to update with the result
  87248. * @param particle is the particle we are computed the position for
  87249. */
  87250. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87251. /**
  87252. * Clones the current emitter and returns a copy of it
  87253. * @returns the new emitter
  87254. */
  87255. clone(): BoxParticleEmitter;
  87256. /**
  87257. * Called by the GPUParticleSystem to setup the update shader
  87258. * @param effect defines the update shader
  87259. */
  87260. applyToShader(effect: Effect): void;
  87261. /**
  87262. * Returns a string to use to update the GPU particles update shader
  87263. * @returns a string containng the defines string
  87264. */
  87265. getEffectDefines(): string;
  87266. /**
  87267. * Returns the string "BoxParticleEmitter"
  87268. * @returns a string containing the class name
  87269. */
  87270. getClassName(): string;
  87271. /**
  87272. * Serializes the particle system to a JSON object.
  87273. * @returns the JSON object
  87274. */
  87275. serialize(): any;
  87276. /**
  87277. * Parse properties from a JSON object
  87278. * @param serializationObject defines the JSON object
  87279. */
  87280. parse(serializationObject: any): void;
  87281. }
  87282. }
  87283. declare module BABYLON {
  87284. /**
  87285. * Particle emitter emitting particles from the inside of a cone.
  87286. * It emits the particles alongside the cone volume from the base to the particle.
  87287. * The emission direction might be randomized.
  87288. */
  87289. export class ConeParticleEmitter implements IParticleEmitterType {
  87290. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  87291. directionRandomizer: number;
  87292. private _radius;
  87293. private _angle;
  87294. private _height;
  87295. /**
  87296. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  87297. */
  87298. radiusRange: number;
  87299. /**
  87300. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  87301. */
  87302. heightRange: number;
  87303. /**
  87304. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  87305. */
  87306. emitFromSpawnPointOnly: boolean;
  87307. /**
  87308. * Gets or sets the radius of the emission cone
  87309. */
  87310. radius: number;
  87311. /**
  87312. * Gets or sets the angle of the emission cone
  87313. */
  87314. angle: number;
  87315. private _buildHeight;
  87316. /**
  87317. * Creates a new instance ConeParticleEmitter
  87318. * @param radius the radius of the emission cone (1 by default)
  87319. * @param angle the cone base angle (PI by default)
  87320. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  87321. */
  87322. constructor(radius?: number, angle?: number,
  87323. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  87324. directionRandomizer?: number);
  87325. /**
  87326. * Called by the particle System when the direction is computed for the created particle.
  87327. * @param worldMatrix is the world matrix of the particle system
  87328. * @param directionToUpdate is the direction vector to update with the result
  87329. * @param particle is the particle we are computed the direction for
  87330. */
  87331. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87332. /**
  87333. * Called by the particle System when the position is computed for the created particle.
  87334. * @param worldMatrix is the world matrix of the particle system
  87335. * @param positionToUpdate is the position vector to update with the result
  87336. * @param particle is the particle we are computed the position for
  87337. */
  87338. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87339. /**
  87340. * Clones the current emitter and returns a copy of it
  87341. * @returns the new emitter
  87342. */
  87343. clone(): ConeParticleEmitter;
  87344. /**
  87345. * Called by the GPUParticleSystem to setup the update shader
  87346. * @param effect defines the update shader
  87347. */
  87348. applyToShader(effect: Effect): void;
  87349. /**
  87350. * Returns a string to use to update the GPU particles update shader
  87351. * @returns a string containng the defines string
  87352. */
  87353. getEffectDefines(): string;
  87354. /**
  87355. * Returns the string "ConeParticleEmitter"
  87356. * @returns a string containing the class name
  87357. */
  87358. getClassName(): string;
  87359. /**
  87360. * Serializes the particle system to a JSON object.
  87361. * @returns the JSON object
  87362. */
  87363. serialize(): any;
  87364. /**
  87365. * Parse properties from a JSON object
  87366. * @param serializationObject defines the JSON object
  87367. */
  87368. parse(serializationObject: any): void;
  87369. }
  87370. }
  87371. declare module BABYLON {
  87372. /**
  87373. * Particle emitter emitting particles from the inside of a cylinder.
  87374. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  87375. */
  87376. export class CylinderParticleEmitter implements IParticleEmitterType {
  87377. /**
  87378. * The radius of the emission cylinder.
  87379. */
  87380. radius: number;
  87381. /**
  87382. * The height of the emission cylinder.
  87383. */
  87384. height: number;
  87385. /**
  87386. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87387. */
  87388. radiusRange: number;
  87389. /**
  87390. * How much to randomize the particle direction [0-1].
  87391. */
  87392. directionRandomizer: number;
  87393. /**
  87394. * Creates a new instance CylinderParticleEmitter
  87395. * @param radius the radius of the emission cylinder (1 by default)
  87396. * @param height the height of the emission cylinder (1 by default)
  87397. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87398. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87399. */
  87400. constructor(
  87401. /**
  87402. * The radius of the emission cylinder.
  87403. */
  87404. radius?: number,
  87405. /**
  87406. * The height of the emission cylinder.
  87407. */
  87408. height?: number,
  87409. /**
  87410. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87411. */
  87412. radiusRange?: number,
  87413. /**
  87414. * How much to randomize the particle direction [0-1].
  87415. */
  87416. directionRandomizer?: number);
  87417. /**
  87418. * Called by the particle System when the direction is computed for the created particle.
  87419. * @param worldMatrix is the world matrix of the particle system
  87420. * @param directionToUpdate is the direction vector to update with the result
  87421. * @param particle is the particle we are computed the direction for
  87422. */
  87423. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87424. /**
  87425. * Called by the particle System when the position is computed for the created particle.
  87426. * @param worldMatrix is the world matrix of the particle system
  87427. * @param positionToUpdate is the position vector to update with the result
  87428. * @param particle is the particle we are computed the position for
  87429. */
  87430. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87431. /**
  87432. * Clones the current emitter and returns a copy of it
  87433. * @returns the new emitter
  87434. */
  87435. clone(): CylinderParticleEmitter;
  87436. /**
  87437. * Called by the GPUParticleSystem to setup the update shader
  87438. * @param effect defines the update shader
  87439. */
  87440. applyToShader(effect: Effect): void;
  87441. /**
  87442. * Returns a string to use to update the GPU particles update shader
  87443. * @returns a string containng the defines string
  87444. */
  87445. getEffectDefines(): string;
  87446. /**
  87447. * Returns the string "CylinderParticleEmitter"
  87448. * @returns a string containing the class name
  87449. */
  87450. getClassName(): string;
  87451. /**
  87452. * Serializes the particle system to a JSON object.
  87453. * @returns the JSON object
  87454. */
  87455. serialize(): any;
  87456. /**
  87457. * Parse properties from a JSON object
  87458. * @param serializationObject defines the JSON object
  87459. */
  87460. parse(serializationObject: any): void;
  87461. }
  87462. /**
  87463. * Particle emitter emitting particles from the inside of a cylinder.
  87464. * It emits the particles randomly between two vectors.
  87465. */
  87466. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  87467. /**
  87468. * The min limit of the emission direction.
  87469. */
  87470. direction1: Vector3;
  87471. /**
  87472. * The max limit of the emission direction.
  87473. */
  87474. direction2: Vector3;
  87475. /**
  87476. * Creates a new instance CylinderDirectedParticleEmitter
  87477. * @param radius the radius of the emission cylinder (1 by default)
  87478. * @param height the height of the emission cylinder (1 by default)
  87479. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87480. * @param direction1 the min limit of the emission direction (up vector by default)
  87481. * @param direction2 the max limit of the emission direction (up vector by default)
  87482. */
  87483. constructor(radius?: number, height?: number, radiusRange?: number,
  87484. /**
  87485. * The min limit of the emission direction.
  87486. */
  87487. direction1?: Vector3,
  87488. /**
  87489. * The max limit of the emission direction.
  87490. */
  87491. direction2?: Vector3);
  87492. /**
  87493. * Called by the particle System when the direction is computed for the created particle.
  87494. * @param worldMatrix is the world matrix of the particle system
  87495. * @param directionToUpdate is the direction vector to update with the result
  87496. * @param particle is the particle we are computed the direction for
  87497. */
  87498. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87499. /**
  87500. * Clones the current emitter and returns a copy of it
  87501. * @returns the new emitter
  87502. */
  87503. clone(): CylinderDirectedParticleEmitter;
  87504. /**
  87505. * Called by the GPUParticleSystem to setup the update shader
  87506. * @param effect defines the update shader
  87507. */
  87508. applyToShader(effect: Effect): void;
  87509. /**
  87510. * Returns a string to use to update the GPU particles update shader
  87511. * @returns a string containng the defines string
  87512. */
  87513. getEffectDefines(): string;
  87514. /**
  87515. * Returns the string "CylinderDirectedParticleEmitter"
  87516. * @returns a string containing the class name
  87517. */
  87518. getClassName(): string;
  87519. /**
  87520. * Serializes the particle system to a JSON object.
  87521. * @returns the JSON object
  87522. */
  87523. serialize(): any;
  87524. /**
  87525. * Parse properties from a JSON object
  87526. * @param serializationObject defines the JSON object
  87527. */
  87528. parse(serializationObject: any): void;
  87529. }
  87530. }
  87531. declare module BABYLON {
  87532. /**
  87533. * Particle emitter emitting particles from the inside of a hemisphere.
  87534. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  87535. */
  87536. export class HemisphericParticleEmitter implements IParticleEmitterType {
  87537. /**
  87538. * The radius of the emission hemisphere.
  87539. */
  87540. radius: number;
  87541. /**
  87542. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87543. */
  87544. radiusRange: number;
  87545. /**
  87546. * How much to randomize the particle direction [0-1].
  87547. */
  87548. directionRandomizer: number;
  87549. /**
  87550. * Creates a new instance HemisphericParticleEmitter
  87551. * @param radius the radius of the emission hemisphere (1 by default)
  87552. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87553. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87554. */
  87555. constructor(
  87556. /**
  87557. * The radius of the emission hemisphere.
  87558. */
  87559. radius?: number,
  87560. /**
  87561. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87562. */
  87563. radiusRange?: number,
  87564. /**
  87565. * How much to randomize the particle direction [0-1].
  87566. */
  87567. directionRandomizer?: number);
  87568. /**
  87569. * Called by the particle System when the direction is computed for the created particle.
  87570. * @param worldMatrix is the world matrix of the particle system
  87571. * @param directionToUpdate is the direction vector to update with the result
  87572. * @param particle is the particle we are computed the direction for
  87573. */
  87574. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87575. /**
  87576. * Called by the particle System when the position is computed for the created particle.
  87577. * @param worldMatrix is the world matrix of the particle system
  87578. * @param positionToUpdate is the position vector to update with the result
  87579. * @param particle is the particle we are computed the position for
  87580. */
  87581. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87582. /**
  87583. * Clones the current emitter and returns a copy of it
  87584. * @returns the new emitter
  87585. */
  87586. clone(): HemisphericParticleEmitter;
  87587. /**
  87588. * Called by the GPUParticleSystem to setup the update shader
  87589. * @param effect defines the update shader
  87590. */
  87591. applyToShader(effect: Effect): void;
  87592. /**
  87593. * Returns a string to use to update the GPU particles update shader
  87594. * @returns a string containng the defines string
  87595. */
  87596. getEffectDefines(): string;
  87597. /**
  87598. * Returns the string "HemisphericParticleEmitter"
  87599. * @returns a string containing the class name
  87600. */
  87601. getClassName(): string;
  87602. /**
  87603. * Serializes the particle system to a JSON object.
  87604. * @returns the JSON object
  87605. */
  87606. serialize(): any;
  87607. /**
  87608. * Parse properties from a JSON object
  87609. * @param serializationObject defines the JSON object
  87610. */
  87611. parse(serializationObject: any): void;
  87612. }
  87613. }
  87614. declare module BABYLON {
  87615. /**
  87616. * Particle emitter emitting particles from a point.
  87617. * It emits the particles randomly between 2 given directions.
  87618. */
  87619. export class PointParticleEmitter implements IParticleEmitterType {
  87620. /**
  87621. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87622. */
  87623. direction1: Vector3;
  87624. /**
  87625. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87626. */
  87627. direction2: Vector3;
  87628. /**
  87629. * Creates a new instance PointParticleEmitter
  87630. */
  87631. constructor();
  87632. /**
  87633. * Called by the particle System when the direction is computed for the created particle.
  87634. * @param worldMatrix is the world matrix of the particle system
  87635. * @param directionToUpdate is the direction vector to update with the result
  87636. * @param particle is the particle we are computed the direction for
  87637. */
  87638. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87639. /**
  87640. * Called by the particle System when the position is computed for the created particle.
  87641. * @param worldMatrix is the world matrix of the particle system
  87642. * @param positionToUpdate is the position vector to update with the result
  87643. * @param particle is the particle we are computed the position for
  87644. */
  87645. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87646. /**
  87647. * Clones the current emitter and returns a copy of it
  87648. * @returns the new emitter
  87649. */
  87650. clone(): PointParticleEmitter;
  87651. /**
  87652. * Called by the GPUParticleSystem to setup the update shader
  87653. * @param effect defines the update shader
  87654. */
  87655. applyToShader(effect: Effect): void;
  87656. /**
  87657. * Returns a string to use to update the GPU particles update shader
  87658. * @returns a string containng the defines string
  87659. */
  87660. getEffectDefines(): string;
  87661. /**
  87662. * Returns the string "PointParticleEmitter"
  87663. * @returns a string containing the class name
  87664. */
  87665. getClassName(): string;
  87666. /**
  87667. * Serializes the particle system to a JSON object.
  87668. * @returns the JSON object
  87669. */
  87670. serialize(): any;
  87671. /**
  87672. * Parse properties from a JSON object
  87673. * @param serializationObject defines the JSON object
  87674. */
  87675. parse(serializationObject: any): void;
  87676. }
  87677. }
  87678. declare module BABYLON {
  87679. /**
  87680. * Particle emitter emitting particles from the inside of a sphere.
  87681. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  87682. */
  87683. export class SphereParticleEmitter implements IParticleEmitterType {
  87684. /**
  87685. * The radius of the emission sphere.
  87686. */
  87687. radius: number;
  87688. /**
  87689. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87690. */
  87691. radiusRange: number;
  87692. /**
  87693. * How much to randomize the particle direction [0-1].
  87694. */
  87695. directionRandomizer: number;
  87696. /**
  87697. * Creates a new instance SphereParticleEmitter
  87698. * @param radius the radius of the emission sphere (1 by default)
  87699. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87700. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87701. */
  87702. constructor(
  87703. /**
  87704. * The radius of the emission sphere.
  87705. */
  87706. radius?: number,
  87707. /**
  87708. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87709. */
  87710. radiusRange?: number,
  87711. /**
  87712. * How much to randomize the particle direction [0-1].
  87713. */
  87714. directionRandomizer?: number);
  87715. /**
  87716. * Called by the particle System when the direction is computed for the created particle.
  87717. * @param worldMatrix is the world matrix of the particle system
  87718. * @param directionToUpdate is the direction vector to update with the result
  87719. * @param particle is the particle we are computed the direction for
  87720. */
  87721. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87722. /**
  87723. * Called by the particle System when the position is computed for the created particle.
  87724. * @param worldMatrix is the world matrix of the particle system
  87725. * @param positionToUpdate is the position vector to update with the result
  87726. * @param particle is the particle we are computed the position for
  87727. */
  87728. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87729. /**
  87730. * Clones the current emitter and returns a copy of it
  87731. * @returns the new emitter
  87732. */
  87733. clone(): SphereParticleEmitter;
  87734. /**
  87735. * Called by the GPUParticleSystem to setup the update shader
  87736. * @param effect defines the update shader
  87737. */
  87738. applyToShader(effect: Effect): void;
  87739. /**
  87740. * Returns a string to use to update the GPU particles update shader
  87741. * @returns a string containng the defines string
  87742. */
  87743. getEffectDefines(): string;
  87744. /**
  87745. * Returns the string "SphereParticleEmitter"
  87746. * @returns a string containing the class name
  87747. */
  87748. getClassName(): string;
  87749. /**
  87750. * Serializes the particle system to a JSON object.
  87751. * @returns the JSON object
  87752. */
  87753. serialize(): any;
  87754. /**
  87755. * Parse properties from a JSON object
  87756. * @param serializationObject defines the JSON object
  87757. */
  87758. parse(serializationObject: any): void;
  87759. }
  87760. /**
  87761. * Particle emitter emitting particles from the inside of a sphere.
  87762. * It emits the particles randomly between two vectors.
  87763. */
  87764. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  87765. /**
  87766. * The min limit of the emission direction.
  87767. */
  87768. direction1: Vector3;
  87769. /**
  87770. * The max limit of the emission direction.
  87771. */
  87772. direction2: Vector3;
  87773. /**
  87774. * Creates a new instance SphereDirectedParticleEmitter
  87775. * @param radius the radius of the emission sphere (1 by default)
  87776. * @param direction1 the min limit of the emission direction (up vector by default)
  87777. * @param direction2 the max limit of the emission direction (up vector by default)
  87778. */
  87779. constructor(radius?: number,
  87780. /**
  87781. * The min limit of the emission direction.
  87782. */
  87783. direction1?: Vector3,
  87784. /**
  87785. * The max limit of the emission direction.
  87786. */
  87787. direction2?: Vector3);
  87788. /**
  87789. * Called by the particle System when the direction is computed for the created particle.
  87790. * @param worldMatrix is the world matrix of the particle system
  87791. * @param directionToUpdate is the direction vector to update with the result
  87792. * @param particle is the particle we are computed the direction for
  87793. */
  87794. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87795. /**
  87796. * Clones the current emitter and returns a copy of it
  87797. * @returns the new emitter
  87798. */
  87799. clone(): SphereDirectedParticleEmitter;
  87800. /**
  87801. * Called by the GPUParticleSystem to setup the update shader
  87802. * @param effect defines the update shader
  87803. */
  87804. applyToShader(effect: Effect): void;
  87805. /**
  87806. * Returns a string to use to update the GPU particles update shader
  87807. * @returns a string containng the defines string
  87808. */
  87809. getEffectDefines(): string;
  87810. /**
  87811. * Returns the string "SphereDirectedParticleEmitter"
  87812. * @returns a string containing the class name
  87813. */
  87814. getClassName(): string;
  87815. /**
  87816. * Serializes the particle system to a JSON object.
  87817. * @returns the JSON object
  87818. */
  87819. serialize(): any;
  87820. /**
  87821. * Parse properties from a JSON object
  87822. * @param serializationObject defines the JSON object
  87823. */
  87824. parse(serializationObject: any): void;
  87825. }
  87826. }
  87827. declare module BABYLON {
  87828. /**
  87829. * Interface representing a particle system in Babylon.js.
  87830. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  87831. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  87832. */
  87833. export interface IParticleSystem {
  87834. /**
  87835. * List of animations used by the particle system.
  87836. */
  87837. animations: Animation[];
  87838. /**
  87839. * The id of the Particle system.
  87840. */
  87841. id: string;
  87842. /**
  87843. * The name of the Particle system.
  87844. */
  87845. name: string;
  87846. /**
  87847. * The emitter represents the Mesh or position we are attaching the particle system to.
  87848. */
  87849. emitter: Nullable<AbstractMesh | Vector3>;
  87850. /**
  87851. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87852. */
  87853. isBillboardBased: boolean;
  87854. /**
  87855. * The rendering group used by the Particle system to chose when to render.
  87856. */
  87857. renderingGroupId: number;
  87858. /**
  87859. * The layer mask we are rendering the particles through.
  87860. */
  87861. layerMask: number;
  87862. /**
  87863. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87864. */
  87865. updateSpeed: number;
  87866. /**
  87867. * The amount of time the particle system is running (depends of the overall update speed).
  87868. */
  87869. targetStopDuration: number;
  87870. /**
  87871. * The texture used to render each particle. (this can be a spritesheet)
  87872. */
  87873. particleTexture: Nullable<Texture>;
  87874. /**
  87875. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  87876. */
  87877. blendMode: number;
  87878. /**
  87879. * Minimum life time of emitting particles.
  87880. */
  87881. minLifeTime: number;
  87882. /**
  87883. * Maximum life time of emitting particles.
  87884. */
  87885. maxLifeTime: number;
  87886. /**
  87887. * Minimum Size of emitting particles.
  87888. */
  87889. minSize: number;
  87890. /**
  87891. * Maximum Size of emitting particles.
  87892. */
  87893. maxSize: number;
  87894. /**
  87895. * Minimum scale of emitting particles on X axis.
  87896. */
  87897. minScaleX: number;
  87898. /**
  87899. * Maximum scale of emitting particles on X axis.
  87900. */
  87901. maxScaleX: number;
  87902. /**
  87903. * Minimum scale of emitting particles on Y axis.
  87904. */
  87905. minScaleY: number;
  87906. /**
  87907. * Maximum scale of emitting particles on Y axis.
  87908. */
  87909. maxScaleY: number;
  87910. /**
  87911. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87912. */
  87913. color1: Color4;
  87914. /**
  87915. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87916. */
  87917. color2: Color4;
  87918. /**
  87919. * Color the particle will have at the end of its lifetime.
  87920. */
  87921. colorDead: Color4;
  87922. /**
  87923. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  87924. */
  87925. emitRate: number;
  87926. /**
  87927. * You can use gravity if you want to give an orientation to your particles.
  87928. */
  87929. gravity: Vector3;
  87930. /**
  87931. * Minimum power of emitting particles.
  87932. */
  87933. minEmitPower: number;
  87934. /**
  87935. * Maximum power of emitting particles.
  87936. */
  87937. maxEmitPower: number;
  87938. /**
  87939. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87940. */
  87941. minAngularSpeed: number;
  87942. /**
  87943. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87944. */
  87945. maxAngularSpeed: number;
  87946. /**
  87947. * Gets or sets the minimal initial rotation in radians.
  87948. */
  87949. minInitialRotation: number;
  87950. /**
  87951. * Gets or sets the maximal initial rotation in radians.
  87952. */
  87953. maxInitialRotation: number;
  87954. /**
  87955. * The particle emitter type defines the emitter used by the particle system.
  87956. * It can be for example box, sphere, or cone...
  87957. */
  87958. particleEmitterType: Nullable<IParticleEmitterType>;
  87959. /**
  87960. * Defines the delay in milliseconds before starting the system (0 by default)
  87961. */
  87962. startDelay: number;
  87963. /**
  87964. * 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
  87965. */
  87966. preWarmCycles: number;
  87967. /**
  87968. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  87969. */
  87970. preWarmStepOffset: number;
  87971. /**
  87972. * 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)
  87973. */
  87974. spriteCellChangeSpeed: number;
  87975. /**
  87976. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87977. */
  87978. startSpriteCellID: number;
  87979. /**
  87980. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87981. */
  87982. endSpriteCellID: number;
  87983. /**
  87984. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87985. */
  87986. spriteCellWidth: number;
  87987. /**
  87988. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87989. */
  87990. spriteCellHeight: number;
  87991. /**
  87992. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87993. */
  87994. spriteRandomStartCell: boolean;
  87995. /**
  87996. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  87997. */
  87998. isAnimationSheetEnabled: boolean;
  87999. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  88000. translationPivot: Vector2;
  88001. /**
  88002. * Gets or sets a texture used to add random noise to particle positions
  88003. */
  88004. noiseTexture: Nullable<BaseTexture>;
  88005. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  88006. noiseStrength: Vector3;
  88007. /**
  88008. * Gets or sets the billboard mode to use when isBillboardBased = true.
  88009. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  88010. */
  88011. billboardMode: number;
  88012. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  88013. limitVelocityDamping: number;
  88014. /**
  88015. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  88016. */
  88017. beginAnimationOnStart: boolean;
  88018. /**
  88019. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  88020. */
  88021. beginAnimationFrom: number;
  88022. /**
  88023. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  88024. */
  88025. beginAnimationTo: number;
  88026. /**
  88027. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  88028. */
  88029. beginAnimationLoop: boolean;
  88030. /**
  88031. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  88032. */
  88033. disposeOnStop: boolean;
  88034. /**
  88035. * Gets the maximum number of particles active at the same time.
  88036. * @returns The max number of active particles.
  88037. */
  88038. getCapacity(): number;
  88039. /**
  88040. * Gets if the system has been started. (Note: this will still be true after stop is called)
  88041. * @returns True if it has been started, otherwise false.
  88042. */
  88043. isStarted(): boolean;
  88044. /**
  88045. * Animates the particle system for this frame.
  88046. */
  88047. animate(): void;
  88048. /**
  88049. * Renders the particle system in its current state.
  88050. * @returns the current number of particles
  88051. */
  88052. render(): number;
  88053. /**
  88054. * Dispose the particle system and frees its associated resources.
  88055. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  88056. */
  88057. dispose(disposeTexture?: boolean): void;
  88058. /**
  88059. * Clones the particle system.
  88060. * @param name The name of the cloned object
  88061. * @param newEmitter The new emitter to use
  88062. * @returns the cloned particle system
  88063. */
  88064. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  88065. /**
  88066. * Serializes the particle system to a JSON object.
  88067. * @returns the JSON object
  88068. */
  88069. serialize(): any;
  88070. /**
  88071. * Rebuild the particle system
  88072. */
  88073. rebuild(): void;
  88074. /**
  88075. * Starts the particle system and begins to emit
  88076. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  88077. */
  88078. start(delay?: number): void;
  88079. /**
  88080. * Stops the particle system.
  88081. */
  88082. stop(): void;
  88083. /**
  88084. * Remove all active particles
  88085. */
  88086. reset(): void;
  88087. /**
  88088. * Is this system ready to be used/rendered
  88089. * @return true if the system is ready
  88090. */
  88091. isReady(): boolean;
  88092. /**
  88093. * Adds a new color gradient
  88094. * @param gradient defines the gradient to use (between 0 and 1)
  88095. * @param color1 defines the color to affect to the specified gradient
  88096. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  88097. * @returns the current particle system
  88098. */
  88099. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  88100. /**
  88101. * Remove a specific color gradient
  88102. * @param gradient defines the gradient to remove
  88103. * @returns the current particle system
  88104. */
  88105. removeColorGradient(gradient: number): IParticleSystem;
  88106. /**
  88107. * Adds a new size gradient
  88108. * @param gradient defines the gradient to use (between 0 and 1)
  88109. * @param factor defines the size factor to affect to the specified gradient
  88110. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88111. * @returns the current particle system
  88112. */
  88113. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88114. /**
  88115. * Remove a specific size gradient
  88116. * @param gradient defines the gradient to remove
  88117. * @returns the current particle system
  88118. */
  88119. removeSizeGradient(gradient: number): IParticleSystem;
  88120. /**
  88121. * Gets the current list of color gradients.
  88122. * You must use addColorGradient and removeColorGradient to udpate this list
  88123. * @returns the list of color gradients
  88124. */
  88125. getColorGradients(): Nullable<Array<ColorGradient>>;
  88126. /**
  88127. * Gets the current list of size gradients.
  88128. * You must use addSizeGradient and removeSizeGradient to udpate this list
  88129. * @returns the list of size gradients
  88130. */
  88131. getSizeGradients(): Nullable<Array<FactorGradient>>;
  88132. /**
  88133. * Gets the current list of angular speed gradients.
  88134. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  88135. * @returns the list of angular speed gradients
  88136. */
  88137. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  88138. /**
  88139. * Adds a new angular speed gradient
  88140. * @param gradient defines the gradient to use (between 0 and 1)
  88141. * @param factor defines the angular speed to affect to the specified gradient
  88142. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88143. * @returns the current particle system
  88144. */
  88145. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88146. /**
  88147. * Remove a specific angular speed gradient
  88148. * @param gradient defines the gradient to remove
  88149. * @returns the current particle system
  88150. */
  88151. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  88152. /**
  88153. * Gets the current list of velocity gradients.
  88154. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  88155. * @returns the list of velocity gradients
  88156. */
  88157. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  88158. /**
  88159. * Adds a new velocity gradient
  88160. * @param gradient defines the gradient to use (between 0 and 1)
  88161. * @param factor defines the velocity to affect to the specified gradient
  88162. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88163. * @returns the current particle system
  88164. */
  88165. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88166. /**
  88167. * Remove a specific velocity gradient
  88168. * @param gradient defines the gradient to remove
  88169. * @returns the current particle system
  88170. */
  88171. removeVelocityGradient(gradient: number): IParticleSystem;
  88172. /**
  88173. * Gets the current list of limit velocity gradients.
  88174. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  88175. * @returns the list of limit velocity gradients
  88176. */
  88177. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  88178. /**
  88179. * Adds a new limit velocity gradient
  88180. * @param gradient defines the gradient to use (between 0 and 1)
  88181. * @param factor defines the limit velocity to affect to the specified gradient
  88182. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88183. * @returns the current particle system
  88184. */
  88185. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88186. /**
  88187. * Remove a specific limit velocity gradient
  88188. * @param gradient defines the gradient to remove
  88189. * @returns the current particle system
  88190. */
  88191. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  88192. /**
  88193. * Adds a new drag gradient
  88194. * @param gradient defines the gradient to use (between 0 and 1)
  88195. * @param factor defines the drag to affect to the specified gradient
  88196. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88197. * @returns the current particle system
  88198. */
  88199. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88200. /**
  88201. * Remove a specific drag gradient
  88202. * @param gradient defines the gradient to remove
  88203. * @returns the current particle system
  88204. */
  88205. removeDragGradient(gradient: number): IParticleSystem;
  88206. /**
  88207. * Gets the current list of drag gradients.
  88208. * You must use addDragGradient and removeDragGradient to udpate this list
  88209. * @returns the list of drag gradients
  88210. */
  88211. getDragGradients(): Nullable<Array<FactorGradient>>;
  88212. /**
  88213. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  88214. * @param gradient defines the gradient to use (between 0 and 1)
  88215. * @param factor defines the emit rate to affect to the specified gradient
  88216. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88217. * @returns the current particle system
  88218. */
  88219. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88220. /**
  88221. * Remove a specific emit rate gradient
  88222. * @param gradient defines the gradient to remove
  88223. * @returns the current particle system
  88224. */
  88225. removeEmitRateGradient(gradient: number): IParticleSystem;
  88226. /**
  88227. * Gets the current list of emit rate gradients.
  88228. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  88229. * @returns the list of emit rate gradients
  88230. */
  88231. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  88232. /**
  88233. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  88234. * @param gradient defines the gradient to use (between 0 and 1)
  88235. * @param factor defines the start size to affect to the specified gradient
  88236. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88237. * @returns the current particle system
  88238. */
  88239. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88240. /**
  88241. * Remove a specific start size gradient
  88242. * @param gradient defines the gradient to remove
  88243. * @returns the current particle system
  88244. */
  88245. removeStartSizeGradient(gradient: number): IParticleSystem;
  88246. /**
  88247. * Gets the current list of start size gradients.
  88248. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  88249. * @returns the list of start size gradients
  88250. */
  88251. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  88252. /**
  88253. * Adds a new life time gradient
  88254. * @param gradient defines the gradient to use (between 0 and 1)
  88255. * @param factor defines the life time factor to affect to the specified gradient
  88256. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88257. * @returns the current particle system
  88258. */
  88259. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88260. /**
  88261. * Remove a specific life time gradient
  88262. * @param gradient defines the gradient to remove
  88263. * @returns the current particle system
  88264. */
  88265. removeLifeTimeGradient(gradient: number): IParticleSystem;
  88266. /**
  88267. * Gets the current list of life time gradients.
  88268. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  88269. * @returns the list of life time gradients
  88270. */
  88271. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  88272. /**
  88273. * Gets the current list of color gradients.
  88274. * You must use addColorGradient and removeColorGradient to udpate this list
  88275. * @returns the list of color gradients
  88276. */
  88277. getColorGradients(): Nullable<Array<ColorGradient>>;
  88278. /**
  88279. * Adds a new ramp gradient used to remap particle colors
  88280. * @param gradient defines the gradient to use (between 0 and 1)
  88281. * @param color defines the color to affect to the specified gradient
  88282. * @returns the current particle system
  88283. */
  88284. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  88285. /**
  88286. * Gets the current list of ramp gradients.
  88287. * You must use addRampGradient and removeRampGradient to udpate this list
  88288. * @returns the list of ramp gradients
  88289. */
  88290. getRampGradients(): Nullable<Array<Color3Gradient>>;
  88291. /** Gets or sets a boolean indicating that ramp gradients must be used
  88292. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  88293. */
  88294. useRampGradients: boolean;
  88295. /**
  88296. * Adds a new color remap gradient
  88297. * @param gradient defines the gradient to use (between 0 and 1)
  88298. * @param min defines the color remap minimal range
  88299. * @param max defines the color remap maximal range
  88300. * @returns the current particle system
  88301. */
  88302. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88303. /**
  88304. * Gets the current list of color remap gradients.
  88305. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  88306. * @returns the list of color remap gradients
  88307. */
  88308. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  88309. /**
  88310. * Adds a new alpha remap gradient
  88311. * @param gradient defines the gradient to use (between 0 and 1)
  88312. * @param min defines the alpha remap minimal range
  88313. * @param max defines the alpha remap maximal range
  88314. * @returns the current particle system
  88315. */
  88316. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88317. /**
  88318. * Gets the current list of alpha remap gradients.
  88319. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  88320. * @returns the list of alpha remap gradients
  88321. */
  88322. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  88323. /**
  88324. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  88325. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  88326. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  88327. * @returns the emitter
  88328. */
  88329. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  88330. /**
  88331. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  88332. * @param radius The radius of the hemisphere to emit from
  88333. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  88334. * @returns the emitter
  88335. */
  88336. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  88337. /**
  88338. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  88339. * @param radius The radius of the sphere to emit from
  88340. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  88341. * @returns the emitter
  88342. */
  88343. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  88344. /**
  88345. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  88346. * @param radius The radius of the sphere to emit from
  88347. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  88348. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  88349. * @returns the emitter
  88350. */
  88351. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  88352. /**
  88353. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  88354. * @param radius The radius of the emission cylinder
  88355. * @param height The height of the emission cylinder
  88356. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  88357. * @param directionRandomizer How much to randomize the particle direction [0-1]
  88358. * @returns the emitter
  88359. */
  88360. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  88361. /**
  88362. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  88363. * @param radius The radius of the cylinder to emit from
  88364. * @param height The height of the emission cylinder
  88365. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88366. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  88367. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  88368. * @returns the emitter
  88369. */
  88370. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  88371. /**
  88372. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  88373. * @param radius The radius of the cone to emit from
  88374. * @param angle The base angle of the cone
  88375. * @returns the emitter
  88376. */
  88377. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  88378. /**
  88379. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  88380. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  88381. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  88382. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  88383. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  88384. * @returns the emitter
  88385. */
  88386. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  88387. /**
  88388. * Get hosting scene
  88389. * @returns the scene
  88390. */
  88391. getScene(): Scene;
  88392. }
  88393. }
  88394. declare module BABYLON {
  88395. /**
  88396. * Creates an instance based on a source mesh.
  88397. */
  88398. export class InstancedMesh extends AbstractMesh {
  88399. private _sourceMesh;
  88400. private _currentLOD;
  88401. /** @hidden */
  88402. _indexInSourceMeshInstanceArray: number;
  88403. constructor(name: string, source: Mesh);
  88404. /**
  88405. * Returns the string "InstancedMesh".
  88406. */
  88407. getClassName(): string;
  88408. /** Gets the list of lights affecting that mesh */
  88409. readonly lightSources: Light[];
  88410. _resyncLightSources(): void;
  88411. _resyncLightSource(light: Light): void;
  88412. _removeLightSource(light: Light, dispose: boolean): void;
  88413. /**
  88414. * If the source mesh receives shadows
  88415. */
  88416. readonly receiveShadows: boolean;
  88417. /**
  88418. * The material of the source mesh
  88419. */
  88420. readonly material: Nullable<Material>;
  88421. /**
  88422. * Visibility of the source mesh
  88423. */
  88424. readonly visibility: number;
  88425. /**
  88426. * Skeleton of the source mesh
  88427. */
  88428. readonly skeleton: Nullable<Skeleton>;
  88429. /**
  88430. * Rendering ground id of the source mesh
  88431. */
  88432. renderingGroupId: number;
  88433. /**
  88434. * Returns the total number of vertices (integer).
  88435. */
  88436. getTotalVertices(): number;
  88437. /**
  88438. * Returns a positive integer : the total number of indices in this mesh geometry.
  88439. * @returns the numner of indices or zero if the mesh has no geometry.
  88440. */
  88441. getTotalIndices(): number;
  88442. /**
  88443. * The source mesh of the instance
  88444. */
  88445. readonly sourceMesh: Mesh;
  88446. /**
  88447. * Is this node ready to be used/rendered
  88448. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88449. * @return {boolean} is it ready
  88450. */
  88451. isReady(completeCheck?: boolean): boolean;
  88452. /**
  88453. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88454. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88455. * @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.
  88456. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88457. */
  88458. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88459. /**
  88460. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88461. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88462. * The `data` are either a numeric array either a Float32Array.
  88463. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88464. * 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).
  88465. * Note that a new underlying VertexBuffer object is created each call.
  88466. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88467. *
  88468. * Possible `kind` values :
  88469. * - VertexBuffer.PositionKind
  88470. * - VertexBuffer.UVKind
  88471. * - VertexBuffer.UV2Kind
  88472. * - VertexBuffer.UV3Kind
  88473. * - VertexBuffer.UV4Kind
  88474. * - VertexBuffer.UV5Kind
  88475. * - VertexBuffer.UV6Kind
  88476. * - VertexBuffer.ColorKind
  88477. * - VertexBuffer.MatricesIndicesKind
  88478. * - VertexBuffer.MatricesIndicesExtraKind
  88479. * - VertexBuffer.MatricesWeightsKind
  88480. * - VertexBuffer.MatricesWeightsExtraKind
  88481. *
  88482. * Returns the Mesh.
  88483. */
  88484. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88485. /**
  88486. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88487. * If the mesh has no geometry, it is simply returned as it is.
  88488. * The `data` are either a numeric array either a Float32Array.
  88489. * No new underlying VertexBuffer object is created.
  88490. * 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.
  88491. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88492. *
  88493. * Possible `kind` values :
  88494. * - VertexBuffer.PositionKind
  88495. * - VertexBuffer.UVKind
  88496. * - VertexBuffer.UV2Kind
  88497. * - VertexBuffer.UV3Kind
  88498. * - VertexBuffer.UV4Kind
  88499. * - VertexBuffer.UV5Kind
  88500. * - VertexBuffer.UV6Kind
  88501. * - VertexBuffer.ColorKind
  88502. * - VertexBuffer.MatricesIndicesKind
  88503. * - VertexBuffer.MatricesIndicesExtraKind
  88504. * - VertexBuffer.MatricesWeightsKind
  88505. * - VertexBuffer.MatricesWeightsExtraKind
  88506. *
  88507. * Returns the Mesh.
  88508. */
  88509. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88510. /**
  88511. * Sets the mesh indices.
  88512. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88513. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88514. * This method creates a new index buffer each call.
  88515. * Returns the Mesh.
  88516. */
  88517. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88518. /**
  88519. * Boolean : True if the mesh owns the requested kind of data.
  88520. */
  88521. isVerticesDataPresent(kind: string): boolean;
  88522. /**
  88523. * Returns an array of indices (IndicesArray).
  88524. */
  88525. getIndices(): Nullable<IndicesArray>;
  88526. readonly _positions: Nullable<Vector3[]>;
  88527. /**
  88528. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88529. * This means the mesh underlying bounding box and sphere are recomputed.
  88530. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88531. * @returns the current mesh
  88532. */
  88533. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88534. /** @hidden */
  88535. _preActivate(): InstancedMesh;
  88536. /** @hidden */
  88537. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88538. /** @hidden */
  88539. _postActivate(): void;
  88540. getWorldMatrix(): Matrix;
  88541. readonly isAnInstance: boolean;
  88542. /**
  88543. * Returns the current associated LOD AbstractMesh.
  88544. */
  88545. getLOD(camera: Camera): AbstractMesh;
  88546. /** @hidden */
  88547. _syncSubMeshes(): InstancedMesh;
  88548. /** @hidden */
  88549. _generatePointsArray(): boolean;
  88550. /**
  88551. * Creates a new InstancedMesh from the current mesh.
  88552. * - name (string) : the cloned mesh name
  88553. * - newParent (optional Node) : the optional Node to parent the clone to.
  88554. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88555. *
  88556. * Returns the clone.
  88557. */
  88558. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  88559. /**
  88560. * Disposes the InstancedMesh.
  88561. * Returns nothing.
  88562. */
  88563. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88564. }
  88565. interface Mesh {
  88566. /**
  88567. * Register a custom buffer that will be instanced
  88568. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88569. * @param kind defines the buffer kind
  88570. * @param stride defines the stride in floats
  88571. */
  88572. registerInstancedBuffer(kind: string, stride: number): void;
  88573. /** @hidden */
  88574. _userInstancedBuffersStorage: {
  88575. data: {
  88576. [key: string]: Float32Array;
  88577. };
  88578. sizes: {
  88579. [key: string]: number;
  88580. };
  88581. vertexBuffers: {
  88582. [key: string]: Nullable<VertexBuffer>;
  88583. };
  88584. strides: {
  88585. [key: string]: number;
  88586. };
  88587. };
  88588. }
  88589. interface AbstractMesh {
  88590. /**
  88591. * Object used to store instanced buffers defined by user
  88592. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88593. */
  88594. instancedBuffers: {
  88595. [key: string]: any;
  88596. };
  88597. }
  88598. }
  88599. declare module BABYLON {
  88600. /**
  88601. * Defines the options associated with the creation of a shader material.
  88602. */
  88603. export interface IShaderMaterialOptions {
  88604. /**
  88605. * Does the material work in alpha blend mode
  88606. */
  88607. needAlphaBlending: boolean;
  88608. /**
  88609. * Does the material work in alpha test mode
  88610. */
  88611. needAlphaTesting: boolean;
  88612. /**
  88613. * The list of attribute names used in the shader
  88614. */
  88615. attributes: string[];
  88616. /**
  88617. * The list of unifrom names used in the shader
  88618. */
  88619. uniforms: string[];
  88620. /**
  88621. * The list of UBO names used in the shader
  88622. */
  88623. uniformBuffers: string[];
  88624. /**
  88625. * The list of sampler names used in the shader
  88626. */
  88627. samplers: string[];
  88628. /**
  88629. * The list of defines used in the shader
  88630. */
  88631. defines: string[];
  88632. }
  88633. /**
  88634. * 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.
  88635. *
  88636. * This returned material effects how the mesh will look based on the code in the shaders.
  88637. *
  88638. * @see http://doc.babylonjs.com/how_to/shader_material
  88639. */
  88640. export class ShaderMaterial extends Material {
  88641. private _shaderPath;
  88642. private _options;
  88643. private _textures;
  88644. private _textureArrays;
  88645. private _floats;
  88646. private _ints;
  88647. private _floatsArrays;
  88648. private _colors3;
  88649. private _colors3Arrays;
  88650. private _colors4;
  88651. private _colors4Arrays;
  88652. private _vectors2;
  88653. private _vectors3;
  88654. private _vectors4;
  88655. private _matrices;
  88656. private _matrixArrays;
  88657. private _matrices3x3;
  88658. private _matrices2x2;
  88659. private _vectors2Arrays;
  88660. private _vectors3Arrays;
  88661. private _vectors4Arrays;
  88662. private _cachedWorldViewMatrix;
  88663. private _cachedWorldViewProjectionMatrix;
  88664. private _renderId;
  88665. private _multiview;
  88666. /**
  88667. * Instantiate a new shader material.
  88668. * 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.
  88669. * This returned material effects how the mesh will look based on the code in the shaders.
  88670. * @see http://doc.babylonjs.com/how_to/shader_material
  88671. * @param name Define the name of the material in the scene
  88672. * @param scene Define the scene the material belongs to
  88673. * @param shaderPath Defines the route to the shader code in one of three ways:
  88674. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88675. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88676. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88677. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88678. * @param options Define the options used to create the shader
  88679. */
  88680. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88681. /**
  88682. * Gets the shader path used to define the shader code
  88683. * It can be modified to trigger a new compilation
  88684. */
  88685. /**
  88686. * Sets the shader path used to define the shader code
  88687. * It can be modified to trigger a new compilation
  88688. */
  88689. shaderPath: any;
  88690. /**
  88691. * Gets the options used to compile the shader.
  88692. * They can be modified to trigger a new compilation
  88693. */
  88694. readonly options: IShaderMaterialOptions;
  88695. /**
  88696. * Gets the current class name of the material e.g. "ShaderMaterial"
  88697. * Mainly use in serialization.
  88698. * @returns the class name
  88699. */
  88700. getClassName(): string;
  88701. /**
  88702. * Specifies if the material will require alpha blending
  88703. * @returns a boolean specifying if alpha blending is needed
  88704. */
  88705. needAlphaBlending(): boolean;
  88706. /**
  88707. * Specifies if this material should be rendered in alpha test mode
  88708. * @returns a boolean specifying if an alpha test is needed.
  88709. */
  88710. needAlphaTesting(): boolean;
  88711. private _checkUniform;
  88712. /**
  88713. * Set a texture in the shader.
  88714. * @param name Define the name of the uniform samplers as defined in the shader
  88715. * @param texture Define the texture to bind to this sampler
  88716. * @return the material itself allowing "fluent" like uniform updates
  88717. */
  88718. setTexture(name: string, texture: Texture): ShaderMaterial;
  88719. /**
  88720. * Set a texture array in the shader.
  88721. * @param name Define the name of the uniform sampler array as defined in the shader
  88722. * @param textures Define the list of textures to bind to this sampler
  88723. * @return the material itself allowing "fluent" like uniform updates
  88724. */
  88725. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88726. /**
  88727. * Set a float in the shader.
  88728. * @param name Define the name of the uniform as defined in the shader
  88729. * @param value Define the value to give to the uniform
  88730. * @return the material itself allowing "fluent" like uniform updates
  88731. */
  88732. setFloat(name: string, value: number): ShaderMaterial;
  88733. /**
  88734. * Set a int in the shader.
  88735. * @param name Define the name of the uniform as defined in the shader
  88736. * @param value Define the value to give to the uniform
  88737. * @return the material itself allowing "fluent" like uniform updates
  88738. */
  88739. setInt(name: string, value: number): ShaderMaterial;
  88740. /**
  88741. * Set an array of floats in the shader.
  88742. * @param name Define the name of the uniform as defined in the shader
  88743. * @param value Define the value to give to the uniform
  88744. * @return the material itself allowing "fluent" like uniform updates
  88745. */
  88746. setFloats(name: string, value: number[]): ShaderMaterial;
  88747. /**
  88748. * Set a vec3 in the shader from a Color3.
  88749. * @param name Define the name of the uniform as defined in the shader
  88750. * @param value Define the value to give to the uniform
  88751. * @return the material itself allowing "fluent" like uniform updates
  88752. */
  88753. setColor3(name: string, value: Color3): ShaderMaterial;
  88754. /**
  88755. * Set a vec3 array in the shader from a Color3 array.
  88756. * @param name Define the name of the uniform as defined in the shader
  88757. * @param value Define the value to give to the uniform
  88758. * @return the material itself allowing "fluent" like uniform updates
  88759. */
  88760. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88761. /**
  88762. * Set a vec4 in the shader from a Color4.
  88763. * @param name Define the name of the uniform as defined in the shader
  88764. * @param value Define the value to give to the uniform
  88765. * @return the material itself allowing "fluent" like uniform updates
  88766. */
  88767. setColor4(name: string, value: Color4): ShaderMaterial;
  88768. /**
  88769. * Set a vec4 array in the shader from a Color4 array.
  88770. * @param name Define the name of the uniform as defined in the shader
  88771. * @param value Define the value to give to the uniform
  88772. * @return the material itself allowing "fluent" like uniform updates
  88773. */
  88774. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88775. /**
  88776. * Set a vec2 in the shader from a Vector2.
  88777. * @param name Define the name of the uniform as defined in the shader
  88778. * @param value Define the value to give to the uniform
  88779. * @return the material itself allowing "fluent" like uniform updates
  88780. */
  88781. setVector2(name: string, value: Vector2): ShaderMaterial;
  88782. /**
  88783. * Set a vec3 in the shader from a Vector3.
  88784. * @param name Define the name of the uniform as defined in the shader
  88785. * @param value Define the value to give to the uniform
  88786. * @return the material itself allowing "fluent" like uniform updates
  88787. */
  88788. setVector3(name: string, value: Vector3): ShaderMaterial;
  88789. /**
  88790. * Set a vec4 in the shader from a Vector4.
  88791. * @param name Define the name of the uniform as defined in the shader
  88792. * @param value Define the value to give to the uniform
  88793. * @return the material itself allowing "fluent" like uniform updates
  88794. */
  88795. setVector4(name: string, value: Vector4): ShaderMaterial;
  88796. /**
  88797. * Set a mat4 in the shader from a Matrix.
  88798. * @param name Define the name of the uniform as defined in the shader
  88799. * @param value Define the value to give to the uniform
  88800. * @return the material itself allowing "fluent" like uniform updates
  88801. */
  88802. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88803. /**
  88804. * Set a float32Array in the shader from a matrix array.
  88805. * @param name Define the name of the uniform as defined in the shader
  88806. * @param value Define the value to give to the uniform
  88807. * @return the material itself allowing "fluent" like uniform updates
  88808. */
  88809. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88810. /**
  88811. * Set a mat3 in the shader from a Float32Array.
  88812. * @param name Define the name of the uniform as defined in the shader
  88813. * @param value Define the value to give to the uniform
  88814. * @return the material itself allowing "fluent" like uniform updates
  88815. */
  88816. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88817. /**
  88818. * Set a mat2 in the shader from a Float32Array.
  88819. * @param name Define the name of the uniform as defined in the shader
  88820. * @param value Define the value to give to the uniform
  88821. * @return the material itself allowing "fluent" like uniform updates
  88822. */
  88823. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88824. /**
  88825. * Set a vec2 array in the shader from a number array.
  88826. * @param name Define the name of the uniform as defined in the shader
  88827. * @param value Define the value to give to the uniform
  88828. * @return the material itself allowing "fluent" like uniform updates
  88829. */
  88830. setArray2(name: string, value: number[]): ShaderMaterial;
  88831. /**
  88832. * Set a vec3 array in the shader from a number array.
  88833. * @param name Define the name of the uniform as defined in the shader
  88834. * @param value Define the value to give to the uniform
  88835. * @return the material itself allowing "fluent" like uniform updates
  88836. */
  88837. setArray3(name: string, value: number[]): ShaderMaterial;
  88838. /**
  88839. * Set a vec4 array in the shader from a number array.
  88840. * @param name Define the name of the uniform as defined in the shader
  88841. * @param value Define the value to give to the uniform
  88842. * @return the material itself allowing "fluent" like uniform updates
  88843. */
  88844. setArray4(name: string, value: number[]): ShaderMaterial;
  88845. private _checkCache;
  88846. /**
  88847. * Specifies that the submesh is ready to be used
  88848. * @param mesh defines the mesh to check
  88849. * @param subMesh defines which submesh to check
  88850. * @param useInstances specifies that instances should be used
  88851. * @returns a boolean indicating that the submesh is ready or not
  88852. */
  88853. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88854. /**
  88855. * Checks if the material is ready to render the requested mesh
  88856. * @param mesh Define the mesh to render
  88857. * @param useInstances Define whether or not the material is used with instances
  88858. * @returns true if ready, otherwise false
  88859. */
  88860. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88861. /**
  88862. * Binds the world matrix to the material
  88863. * @param world defines the world transformation matrix
  88864. */
  88865. bindOnlyWorldMatrix(world: Matrix): void;
  88866. /**
  88867. * Binds the material to the mesh
  88868. * @param world defines the world transformation matrix
  88869. * @param mesh defines the mesh to bind the material to
  88870. */
  88871. bind(world: Matrix, mesh?: Mesh): void;
  88872. /**
  88873. * Gets the active textures from the material
  88874. * @returns an array of textures
  88875. */
  88876. getActiveTextures(): BaseTexture[];
  88877. /**
  88878. * Specifies if the material uses a texture
  88879. * @param texture defines the texture to check against the material
  88880. * @returns a boolean specifying if the material uses the texture
  88881. */
  88882. hasTexture(texture: BaseTexture): boolean;
  88883. /**
  88884. * Makes a duplicate of the material, and gives it a new name
  88885. * @param name defines the new name for the duplicated material
  88886. * @returns the cloned material
  88887. */
  88888. clone(name: string): ShaderMaterial;
  88889. /**
  88890. * Disposes the material
  88891. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88892. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88893. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88894. */
  88895. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88896. /**
  88897. * Serializes this material in a JSON representation
  88898. * @returns the serialized material object
  88899. */
  88900. serialize(): any;
  88901. /**
  88902. * Creates a shader material from parsed shader material data
  88903. * @param source defines the JSON represnetation of the material
  88904. * @param scene defines the hosting scene
  88905. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88906. * @returns a new material
  88907. */
  88908. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  88909. }
  88910. }
  88911. declare module BABYLON {
  88912. /** @hidden */
  88913. export var colorPixelShader: {
  88914. name: string;
  88915. shader: string;
  88916. };
  88917. }
  88918. declare module BABYLON {
  88919. /** @hidden */
  88920. export var colorVertexShader: {
  88921. name: string;
  88922. shader: string;
  88923. };
  88924. }
  88925. declare module BABYLON {
  88926. /**
  88927. * Line mesh
  88928. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88929. */
  88930. export class LinesMesh extends Mesh {
  88931. /**
  88932. * If vertex color should be applied to the mesh
  88933. */
  88934. readonly useVertexColor?: boolean | undefined;
  88935. /**
  88936. * If vertex alpha should be applied to the mesh
  88937. */
  88938. readonly useVertexAlpha?: boolean | undefined;
  88939. /**
  88940. * Color of the line (Default: White)
  88941. */
  88942. color: Color3;
  88943. /**
  88944. * Alpha of the line (Default: 1)
  88945. */
  88946. alpha: number;
  88947. /**
  88948. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88949. * This margin is expressed in world space coordinates, so its value may vary.
  88950. * Default value is 0.1
  88951. */
  88952. intersectionThreshold: number;
  88953. private _colorShader;
  88954. private color4;
  88955. /**
  88956. * Creates a new LinesMesh
  88957. * @param name defines the name
  88958. * @param scene defines the hosting scene
  88959. * @param parent defines the parent mesh if any
  88960. * @param source defines the optional source LinesMesh used to clone data from
  88961. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88962. * When false, achieved by calling a clone(), also passing False.
  88963. * This will make creation of children, recursive.
  88964. * @param useVertexColor defines if this LinesMesh supports vertex color
  88965. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  88966. */
  88967. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  88968. /**
  88969. * If vertex color should be applied to the mesh
  88970. */
  88971. useVertexColor?: boolean | undefined,
  88972. /**
  88973. * If vertex alpha should be applied to the mesh
  88974. */
  88975. useVertexAlpha?: boolean | undefined);
  88976. private _addClipPlaneDefine;
  88977. private _removeClipPlaneDefine;
  88978. isReady(): boolean;
  88979. /**
  88980. * Returns the string "LineMesh"
  88981. */
  88982. getClassName(): string;
  88983. /**
  88984. * @hidden
  88985. */
  88986. /**
  88987. * @hidden
  88988. */
  88989. material: Material;
  88990. /**
  88991. * @hidden
  88992. */
  88993. readonly checkCollisions: boolean;
  88994. /** @hidden */
  88995. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88996. /** @hidden */
  88997. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88998. /**
  88999. * Disposes of the line mesh
  89000. * @param doNotRecurse If children should be disposed
  89001. */
  89002. dispose(doNotRecurse?: boolean): void;
  89003. /**
  89004. * Returns a new LineMesh object cloned from the current one.
  89005. */
  89006. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  89007. /**
  89008. * Creates a new InstancedLinesMesh object from the mesh model.
  89009. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89010. * @param name defines the name of the new instance
  89011. * @returns a new InstancedLinesMesh
  89012. */
  89013. createInstance(name: string): InstancedLinesMesh;
  89014. }
  89015. /**
  89016. * Creates an instance based on a source LinesMesh
  89017. */
  89018. export class InstancedLinesMesh extends InstancedMesh {
  89019. /**
  89020. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  89021. * This margin is expressed in world space coordinates, so its value may vary.
  89022. * Initilized with the intersectionThreshold value of the source LinesMesh
  89023. */
  89024. intersectionThreshold: number;
  89025. constructor(name: string, source: LinesMesh);
  89026. /**
  89027. * Returns the string "InstancedLinesMesh".
  89028. */
  89029. getClassName(): string;
  89030. }
  89031. }
  89032. declare module BABYLON {
  89033. /** @hidden */
  89034. export var linePixelShader: {
  89035. name: string;
  89036. shader: string;
  89037. };
  89038. }
  89039. declare module BABYLON {
  89040. /** @hidden */
  89041. export var lineVertexShader: {
  89042. name: string;
  89043. shader: string;
  89044. };
  89045. }
  89046. declare module BABYLON {
  89047. interface AbstractMesh {
  89048. /**
  89049. * Gets the edgesRenderer associated with the mesh
  89050. */
  89051. edgesRenderer: Nullable<EdgesRenderer>;
  89052. }
  89053. interface LinesMesh {
  89054. /**
  89055. * Enables the edge rendering mode on the mesh.
  89056. * This mode makes the mesh edges visible
  89057. * @param epsilon defines the maximal distance between two angles to detect a face
  89058. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89059. * @returns the currentAbstractMesh
  89060. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89061. */
  89062. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  89063. }
  89064. interface InstancedLinesMesh {
  89065. /**
  89066. * Enables the edge rendering mode on the mesh.
  89067. * This mode makes the mesh edges visible
  89068. * @param epsilon defines the maximal distance between two angles to detect a face
  89069. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89070. * @returns the current InstancedLinesMesh
  89071. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89072. */
  89073. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  89074. }
  89075. /**
  89076. * Defines the minimum contract an Edges renderer should follow.
  89077. */
  89078. export interface IEdgesRenderer extends IDisposable {
  89079. /**
  89080. * Gets or sets a boolean indicating if the edgesRenderer is active
  89081. */
  89082. isEnabled: boolean;
  89083. /**
  89084. * Renders the edges of the attached mesh,
  89085. */
  89086. render(): void;
  89087. /**
  89088. * Checks wether or not the edges renderer is ready to render.
  89089. * @return true if ready, otherwise false.
  89090. */
  89091. isReady(): boolean;
  89092. }
  89093. /**
  89094. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  89095. */
  89096. export class EdgesRenderer implements IEdgesRenderer {
  89097. /**
  89098. * Define the size of the edges with an orthographic camera
  89099. */
  89100. edgesWidthScalerForOrthographic: number;
  89101. /**
  89102. * Define the size of the edges with a perspective camera
  89103. */
  89104. edgesWidthScalerForPerspective: number;
  89105. protected _source: AbstractMesh;
  89106. protected _linesPositions: number[];
  89107. protected _linesNormals: number[];
  89108. protected _linesIndices: number[];
  89109. protected _epsilon: number;
  89110. protected _indicesCount: number;
  89111. protected _lineShader: ShaderMaterial;
  89112. protected _ib: DataBuffer;
  89113. protected _buffers: {
  89114. [key: string]: Nullable<VertexBuffer>;
  89115. };
  89116. protected _checkVerticesInsteadOfIndices: boolean;
  89117. private _meshRebuildObserver;
  89118. private _meshDisposeObserver;
  89119. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  89120. isEnabled: boolean;
  89121. /**
  89122. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  89123. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  89124. * @param source Mesh used to create edges
  89125. * @param epsilon sum of angles in adjacency to check for edge
  89126. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  89127. * @param generateEdgesLines - should generate Lines or only prepare resources.
  89128. */
  89129. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  89130. protected _prepareRessources(): void;
  89131. /** @hidden */
  89132. _rebuild(): void;
  89133. /**
  89134. * Releases the required resources for the edges renderer
  89135. */
  89136. dispose(): void;
  89137. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  89138. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  89139. /**
  89140. * Checks if the pair of p0 and p1 is en edge
  89141. * @param faceIndex
  89142. * @param edge
  89143. * @param faceNormals
  89144. * @param p0
  89145. * @param p1
  89146. * @private
  89147. */
  89148. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  89149. /**
  89150. * push line into the position, normal and index buffer
  89151. * @protected
  89152. */
  89153. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  89154. /**
  89155. * Generates lines edges from adjacencjes
  89156. * @private
  89157. */
  89158. _generateEdgesLines(): void;
  89159. /**
  89160. * Checks wether or not the edges renderer is ready to render.
  89161. * @return true if ready, otherwise false.
  89162. */
  89163. isReady(): boolean;
  89164. /**
  89165. * Renders the edges of the attached mesh,
  89166. */
  89167. render(): void;
  89168. }
  89169. /**
  89170. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  89171. */
  89172. export class LineEdgesRenderer extends EdgesRenderer {
  89173. /**
  89174. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  89175. * @param source LineMesh used to generate edges
  89176. * @param epsilon not important (specified angle for edge detection)
  89177. * @param checkVerticesInsteadOfIndices not important for LineMesh
  89178. */
  89179. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  89180. /**
  89181. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  89182. */
  89183. _generateEdgesLines(): void;
  89184. }
  89185. }
  89186. declare module BABYLON {
  89187. /**
  89188. * This represents the object necessary to create a rendering group.
  89189. * This is exclusively used and created by the rendering manager.
  89190. * To modify the behavior, you use the available helpers in your scene or meshes.
  89191. * @hidden
  89192. */
  89193. export class RenderingGroup {
  89194. index: number;
  89195. private static _zeroVector;
  89196. private _scene;
  89197. private _opaqueSubMeshes;
  89198. private _transparentSubMeshes;
  89199. private _alphaTestSubMeshes;
  89200. private _depthOnlySubMeshes;
  89201. private _particleSystems;
  89202. private _spriteManagers;
  89203. private _opaqueSortCompareFn;
  89204. private _alphaTestSortCompareFn;
  89205. private _transparentSortCompareFn;
  89206. private _renderOpaque;
  89207. private _renderAlphaTest;
  89208. private _renderTransparent;
  89209. /** @hidden */
  89210. _edgesRenderers: SmartArray<IEdgesRenderer>;
  89211. onBeforeTransparentRendering: () => void;
  89212. /**
  89213. * Set the opaque sort comparison function.
  89214. * If null the sub meshes will be render in the order they were created
  89215. */
  89216. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  89217. /**
  89218. * Set the alpha test sort comparison function.
  89219. * If null the sub meshes will be render in the order they were created
  89220. */
  89221. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  89222. /**
  89223. * Set the transparent sort comparison function.
  89224. * If null the sub meshes will be render in the order they were created
  89225. */
  89226. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  89227. /**
  89228. * Creates a new rendering group.
  89229. * @param index The rendering group index
  89230. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  89231. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  89232. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  89233. */
  89234. 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>);
  89235. /**
  89236. * Render all the sub meshes contained in the group.
  89237. * @param customRenderFunction Used to override the default render behaviour of the group.
  89238. * @returns true if rendered some submeshes.
  89239. */
  89240. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  89241. /**
  89242. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  89243. * @param subMeshes The submeshes to render
  89244. */
  89245. private renderOpaqueSorted;
  89246. /**
  89247. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  89248. * @param subMeshes The submeshes to render
  89249. */
  89250. private renderAlphaTestSorted;
  89251. /**
  89252. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  89253. * @param subMeshes The submeshes to render
  89254. */
  89255. private renderTransparentSorted;
  89256. /**
  89257. * Renders the submeshes in a specified order.
  89258. * @param subMeshes The submeshes to sort before render
  89259. * @param sortCompareFn The comparison function use to sort
  89260. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  89261. * @param transparent Specifies to activate blending if true
  89262. */
  89263. private static renderSorted;
  89264. /**
  89265. * Renders the submeshes in the order they were dispatched (no sort applied).
  89266. * @param subMeshes The submeshes to render
  89267. */
  89268. private static renderUnsorted;
  89269. /**
  89270. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89271. * are rendered back to front if in the same alpha index.
  89272. *
  89273. * @param a The first submesh
  89274. * @param b The second submesh
  89275. * @returns The result of the comparison
  89276. */
  89277. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  89278. /**
  89279. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89280. * are rendered back to front.
  89281. *
  89282. * @param a The first submesh
  89283. * @param b The second submesh
  89284. * @returns The result of the comparison
  89285. */
  89286. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  89287. /**
  89288. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89289. * are rendered front to back (prevent overdraw).
  89290. *
  89291. * @param a The first submesh
  89292. * @param b The second submesh
  89293. * @returns The result of the comparison
  89294. */
  89295. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  89296. /**
  89297. * Resets the different lists of submeshes to prepare a new frame.
  89298. */
  89299. prepare(): void;
  89300. dispose(): void;
  89301. /**
  89302. * Inserts the submesh in its correct queue depending on its material.
  89303. * @param subMesh The submesh to dispatch
  89304. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89305. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89306. */
  89307. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89308. dispatchSprites(spriteManager: ISpriteManager): void;
  89309. dispatchParticles(particleSystem: IParticleSystem): void;
  89310. private _renderParticles;
  89311. private _renderSprites;
  89312. }
  89313. }
  89314. declare module BABYLON {
  89315. /**
  89316. * Interface describing the different options available in the rendering manager
  89317. * regarding Auto Clear between groups.
  89318. */
  89319. export interface IRenderingManagerAutoClearSetup {
  89320. /**
  89321. * Defines whether or not autoclear is enable.
  89322. */
  89323. autoClear: boolean;
  89324. /**
  89325. * Defines whether or not to autoclear the depth buffer.
  89326. */
  89327. depth: boolean;
  89328. /**
  89329. * Defines whether or not to autoclear the stencil buffer.
  89330. */
  89331. stencil: boolean;
  89332. }
  89333. /**
  89334. * This class is used by the onRenderingGroupObservable
  89335. */
  89336. export class RenderingGroupInfo {
  89337. /**
  89338. * The Scene that being rendered
  89339. */
  89340. scene: Scene;
  89341. /**
  89342. * The camera currently used for the rendering pass
  89343. */
  89344. camera: Nullable<Camera>;
  89345. /**
  89346. * The ID of the renderingGroup being processed
  89347. */
  89348. renderingGroupId: number;
  89349. }
  89350. /**
  89351. * This is the manager responsible of all the rendering for meshes sprites and particles.
  89352. * It is enable to manage the different groups as well as the different necessary sort functions.
  89353. * This should not be used directly aside of the few static configurations
  89354. */
  89355. export class RenderingManager {
  89356. /**
  89357. * The max id used for rendering groups (not included)
  89358. */
  89359. static MAX_RENDERINGGROUPS: number;
  89360. /**
  89361. * The min id used for rendering groups (included)
  89362. */
  89363. static MIN_RENDERINGGROUPS: number;
  89364. /**
  89365. * Used to globally prevent autoclearing scenes.
  89366. */
  89367. static AUTOCLEAR: boolean;
  89368. /**
  89369. * @hidden
  89370. */
  89371. _useSceneAutoClearSetup: boolean;
  89372. private _scene;
  89373. private _renderingGroups;
  89374. private _depthStencilBufferAlreadyCleaned;
  89375. private _autoClearDepthStencil;
  89376. private _customOpaqueSortCompareFn;
  89377. private _customAlphaTestSortCompareFn;
  89378. private _customTransparentSortCompareFn;
  89379. private _renderingGroupInfo;
  89380. /**
  89381. * Instantiates a new rendering group for a particular scene
  89382. * @param scene Defines the scene the groups belongs to
  89383. */
  89384. constructor(scene: Scene);
  89385. private _clearDepthStencilBuffer;
  89386. /**
  89387. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  89388. * @hidden
  89389. */
  89390. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  89391. /**
  89392. * Resets the different information of the group to prepare a new frame
  89393. * @hidden
  89394. */
  89395. reset(): void;
  89396. /**
  89397. * Dispose and release the group and its associated resources.
  89398. * @hidden
  89399. */
  89400. dispose(): void;
  89401. /**
  89402. * Clear the info related to rendering groups preventing retention points during dispose.
  89403. */
  89404. freeRenderingGroups(): void;
  89405. private _prepareRenderingGroup;
  89406. /**
  89407. * Add a sprite manager to the rendering manager in order to render it this frame.
  89408. * @param spriteManager Define the sprite manager to render
  89409. */
  89410. dispatchSprites(spriteManager: ISpriteManager): void;
  89411. /**
  89412. * Add a particle system to the rendering manager in order to render it this frame.
  89413. * @param particleSystem Define the particle system to render
  89414. */
  89415. dispatchParticles(particleSystem: IParticleSystem): void;
  89416. /**
  89417. * Add a submesh to the manager in order to render it this frame
  89418. * @param subMesh The submesh to dispatch
  89419. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89420. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89421. */
  89422. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89423. /**
  89424. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89425. * This allowed control for front to back rendering or reversly depending of the special needs.
  89426. *
  89427. * @param renderingGroupId The rendering group id corresponding to its index
  89428. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89429. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89430. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89431. */
  89432. 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;
  89433. /**
  89434. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89435. *
  89436. * @param renderingGroupId The rendering group id corresponding to its index
  89437. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89438. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89439. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89440. */
  89441. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89442. /**
  89443. * Gets the current auto clear configuration for one rendering group of the rendering
  89444. * manager.
  89445. * @param index the rendering group index to get the information for
  89446. * @returns The auto clear setup for the requested rendering group
  89447. */
  89448. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89449. }
  89450. }
  89451. declare module BABYLON {
  89452. /**
  89453. * This Helps creating a texture that will be created from a camera in your scene.
  89454. * It is basically a dynamic texture that could be used to create special effects for instance.
  89455. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  89456. */
  89457. export class RenderTargetTexture extends Texture {
  89458. isCube: boolean;
  89459. /**
  89460. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  89461. */
  89462. static readonly REFRESHRATE_RENDER_ONCE: number;
  89463. /**
  89464. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  89465. */
  89466. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  89467. /**
  89468. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  89469. * the central point of your effect and can save a lot of performances.
  89470. */
  89471. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  89472. /**
  89473. * Use this predicate to dynamically define the list of mesh you want to render.
  89474. * If set, the renderList property will be overwritten.
  89475. */
  89476. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  89477. private _renderList;
  89478. /**
  89479. * Use this list to define the list of mesh you want to render.
  89480. */
  89481. renderList: Nullable<Array<AbstractMesh>>;
  89482. private _hookArray;
  89483. /**
  89484. * Define if particles should be rendered in your texture.
  89485. */
  89486. renderParticles: boolean;
  89487. /**
  89488. * Define if sprites should be rendered in your texture.
  89489. */
  89490. renderSprites: boolean;
  89491. /**
  89492. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  89493. */
  89494. coordinatesMode: number;
  89495. /**
  89496. * Define the camera used to render the texture.
  89497. */
  89498. activeCamera: Nullable<Camera>;
  89499. /**
  89500. * Override the render function of the texture with your own one.
  89501. */
  89502. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  89503. /**
  89504. * Define if camera post processes should be use while rendering the texture.
  89505. */
  89506. useCameraPostProcesses: boolean;
  89507. /**
  89508. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  89509. */
  89510. ignoreCameraViewport: boolean;
  89511. private _postProcessManager;
  89512. private _postProcesses;
  89513. private _resizeObserver;
  89514. /**
  89515. * An event triggered when the texture is unbind.
  89516. */
  89517. onBeforeBindObservable: Observable<RenderTargetTexture>;
  89518. /**
  89519. * An event triggered when the texture is unbind.
  89520. */
  89521. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  89522. private _onAfterUnbindObserver;
  89523. /**
  89524. * Set a after unbind callback in the texture.
  89525. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  89526. */
  89527. onAfterUnbind: () => void;
  89528. /**
  89529. * An event triggered before rendering the texture
  89530. */
  89531. onBeforeRenderObservable: Observable<number>;
  89532. private _onBeforeRenderObserver;
  89533. /**
  89534. * Set a before render callback in the texture.
  89535. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  89536. */
  89537. onBeforeRender: (faceIndex: number) => void;
  89538. /**
  89539. * An event triggered after rendering the texture
  89540. */
  89541. onAfterRenderObservable: Observable<number>;
  89542. private _onAfterRenderObserver;
  89543. /**
  89544. * Set a after render callback in the texture.
  89545. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  89546. */
  89547. onAfterRender: (faceIndex: number) => void;
  89548. /**
  89549. * An event triggered after the texture clear
  89550. */
  89551. onClearObservable: Observable<Engine>;
  89552. private _onClearObserver;
  89553. /**
  89554. * Set a clear callback in the texture.
  89555. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  89556. */
  89557. onClear: (Engine: Engine) => void;
  89558. /**
  89559. * An event triggered when the texture is resized.
  89560. */
  89561. onResizeObservable: Observable<RenderTargetTexture>;
  89562. /**
  89563. * Define the clear color of the Render Target if it should be different from the scene.
  89564. */
  89565. clearColor: Color4;
  89566. protected _size: number | {
  89567. width: number;
  89568. height: number;
  89569. };
  89570. protected _initialSizeParameter: number | {
  89571. width: number;
  89572. height: number;
  89573. } | {
  89574. ratio: number;
  89575. };
  89576. protected _sizeRatio: Nullable<number>;
  89577. /** @hidden */
  89578. _generateMipMaps: boolean;
  89579. protected _renderingManager: RenderingManager;
  89580. /** @hidden */
  89581. _waitingRenderList: string[];
  89582. protected _doNotChangeAspectRatio: boolean;
  89583. protected _currentRefreshId: number;
  89584. protected _refreshRate: number;
  89585. protected _textureMatrix: Matrix;
  89586. protected _samples: number;
  89587. protected _renderTargetOptions: RenderTargetCreationOptions;
  89588. /**
  89589. * Gets render target creation options that were used.
  89590. */
  89591. readonly renderTargetOptions: RenderTargetCreationOptions;
  89592. protected _engine: Engine;
  89593. protected _onRatioRescale(): void;
  89594. /**
  89595. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  89596. * It must define where the camera used to render the texture is set
  89597. */
  89598. boundingBoxPosition: Vector3;
  89599. private _boundingBoxSize;
  89600. /**
  89601. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  89602. * When defined, the cubemap will switch to local mode
  89603. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  89604. * @example https://www.babylonjs-playground.com/#RNASML
  89605. */
  89606. boundingBoxSize: Vector3;
  89607. /**
  89608. * In case the RTT has been created with a depth texture, get the associated
  89609. * depth texture.
  89610. * Otherwise, return null.
  89611. */
  89612. depthStencilTexture: Nullable<InternalTexture>;
  89613. /**
  89614. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  89615. * or used a shadow, depth texture...
  89616. * @param name The friendly name of the texture
  89617. * @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)
  89618. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  89619. * @param generateMipMaps True if mip maps need to be generated after render.
  89620. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  89621. * @param type The type of the buffer in the RTT (int, half float, float...)
  89622. * @param isCube True if a cube texture needs to be created
  89623. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  89624. * @param generateDepthBuffer True to generate a depth buffer
  89625. * @param generateStencilBuffer True to generate a stencil buffer
  89626. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  89627. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  89628. * @param delayAllocation if the texture allocation should be delayed (default: false)
  89629. */
  89630. constructor(name: string, size: number | {
  89631. width: number;
  89632. height: number;
  89633. } | {
  89634. ratio: number;
  89635. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  89636. /**
  89637. * Creates a depth stencil texture.
  89638. * This is only available in WebGL 2 or with the depth texture extension available.
  89639. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  89640. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  89641. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  89642. */
  89643. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  89644. private _processSizeParameter;
  89645. /**
  89646. * Define the number of samples to use in case of MSAA.
  89647. * It defaults to one meaning no MSAA has been enabled.
  89648. */
  89649. samples: number;
  89650. /**
  89651. * Resets the refresh counter of the texture and start bak from scratch.
  89652. * Could be useful to regenerate the texture if it is setup to render only once.
  89653. */
  89654. resetRefreshCounter(): void;
  89655. /**
  89656. * Define the refresh rate of the texture or the rendering frequency.
  89657. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89658. */
  89659. refreshRate: number;
  89660. /**
  89661. * Adds a post process to the render target rendering passes.
  89662. * @param postProcess define the post process to add
  89663. */
  89664. addPostProcess(postProcess: PostProcess): void;
  89665. /**
  89666. * Clear all the post processes attached to the render target
  89667. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  89668. */
  89669. clearPostProcesses(dispose?: boolean): void;
  89670. /**
  89671. * Remove one of the post process from the list of attached post processes to the texture
  89672. * @param postProcess define the post process to remove from the list
  89673. */
  89674. removePostProcess(postProcess: PostProcess): void;
  89675. /** @hidden */
  89676. _shouldRender(): boolean;
  89677. /**
  89678. * Gets the actual render size of the texture.
  89679. * @returns the width of the render size
  89680. */
  89681. getRenderSize(): number;
  89682. /**
  89683. * Gets the actual render width of the texture.
  89684. * @returns the width of the render size
  89685. */
  89686. getRenderWidth(): number;
  89687. /**
  89688. * Gets the actual render height of the texture.
  89689. * @returns the height of the render size
  89690. */
  89691. getRenderHeight(): number;
  89692. /**
  89693. * Get if the texture can be rescaled or not.
  89694. */
  89695. readonly canRescale: boolean;
  89696. /**
  89697. * Resize the texture using a ratio.
  89698. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  89699. */
  89700. scale(ratio: number): void;
  89701. /**
  89702. * Get the texture reflection matrix used to rotate/transform the reflection.
  89703. * @returns the reflection matrix
  89704. */
  89705. getReflectionTextureMatrix(): Matrix;
  89706. /**
  89707. * Resize the texture to a new desired size.
  89708. * Be carrefull as it will recreate all the data in the new texture.
  89709. * @param size Define the new size. It can be:
  89710. * - a number for squared texture,
  89711. * - an object containing { width: number, height: number }
  89712. * - or an object containing a ratio { ratio: number }
  89713. */
  89714. resize(size: number | {
  89715. width: number;
  89716. height: number;
  89717. } | {
  89718. ratio: number;
  89719. }): void;
  89720. /**
  89721. * Renders all the objects from the render list into the texture.
  89722. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  89723. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  89724. */
  89725. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  89726. private _bestReflectionRenderTargetDimension;
  89727. /**
  89728. * @hidden
  89729. * @param faceIndex face index to bind to if this is a cubetexture
  89730. */
  89731. _bindFrameBuffer(faceIndex?: number): void;
  89732. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  89733. private renderToTarget;
  89734. /**
  89735. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89736. * This allowed control for front to back rendering or reversly depending of the special needs.
  89737. *
  89738. * @param renderingGroupId The rendering group id corresponding to its index
  89739. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89740. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89741. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89742. */
  89743. 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;
  89744. /**
  89745. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89746. *
  89747. * @param renderingGroupId The rendering group id corresponding to its index
  89748. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89749. */
  89750. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  89751. /**
  89752. * Clones the texture.
  89753. * @returns the cloned texture
  89754. */
  89755. clone(): RenderTargetTexture;
  89756. /**
  89757. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  89758. * @returns The JSON representation of the texture
  89759. */
  89760. serialize(): any;
  89761. /**
  89762. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  89763. */
  89764. disposeFramebufferObjects(): void;
  89765. /**
  89766. * Dispose the texture and release its associated resources.
  89767. */
  89768. dispose(): void;
  89769. /** @hidden */
  89770. _rebuild(): void;
  89771. /**
  89772. * Clear the info related to rendering groups preventing retention point in material dispose.
  89773. */
  89774. freeRenderingGroups(): void;
  89775. /**
  89776. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  89777. * @returns the view count
  89778. */
  89779. getViewCount(): number;
  89780. }
  89781. }
  89782. declare module BABYLON {
  89783. /**
  89784. * Options for compiling materials.
  89785. */
  89786. export interface IMaterialCompilationOptions {
  89787. /**
  89788. * Defines whether clip planes are enabled.
  89789. */
  89790. clipPlane: boolean;
  89791. /**
  89792. * Defines whether instances are enabled.
  89793. */
  89794. useInstances: boolean;
  89795. }
  89796. /**
  89797. * Base class for the main features of a material in Babylon.js
  89798. */
  89799. export class Material implements IAnimatable {
  89800. /**
  89801. * Returns the triangle fill mode
  89802. */
  89803. static readonly TriangleFillMode: number;
  89804. /**
  89805. * Returns the wireframe mode
  89806. */
  89807. static readonly WireFrameFillMode: number;
  89808. /**
  89809. * Returns the point fill mode
  89810. */
  89811. static readonly PointFillMode: number;
  89812. /**
  89813. * Returns the point list draw mode
  89814. */
  89815. static readonly PointListDrawMode: number;
  89816. /**
  89817. * Returns the line list draw mode
  89818. */
  89819. static readonly LineListDrawMode: number;
  89820. /**
  89821. * Returns the line loop draw mode
  89822. */
  89823. static readonly LineLoopDrawMode: number;
  89824. /**
  89825. * Returns the line strip draw mode
  89826. */
  89827. static readonly LineStripDrawMode: number;
  89828. /**
  89829. * Returns the triangle strip draw mode
  89830. */
  89831. static readonly TriangleStripDrawMode: number;
  89832. /**
  89833. * Returns the triangle fan draw mode
  89834. */
  89835. static readonly TriangleFanDrawMode: number;
  89836. /**
  89837. * Stores the clock-wise side orientation
  89838. */
  89839. static readonly ClockWiseSideOrientation: number;
  89840. /**
  89841. * Stores the counter clock-wise side orientation
  89842. */
  89843. static readonly CounterClockWiseSideOrientation: number;
  89844. /**
  89845. * The dirty texture flag value
  89846. */
  89847. static readonly TextureDirtyFlag: number;
  89848. /**
  89849. * The dirty light flag value
  89850. */
  89851. static readonly LightDirtyFlag: number;
  89852. /**
  89853. * The dirty fresnel flag value
  89854. */
  89855. static readonly FresnelDirtyFlag: number;
  89856. /**
  89857. * The dirty attribute flag value
  89858. */
  89859. static readonly AttributesDirtyFlag: number;
  89860. /**
  89861. * The dirty misc flag value
  89862. */
  89863. static readonly MiscDirtyFlag: number;
  89864. /**
  89865. * The all dirty flag value
  89866. */
  89867. static readonly AllDirtyFlag: number;
  89868. /**
  89869. * The ID of the material
  89870. */
  89871. id: string;
  89872. /**
  89873. * Gets or sets the unique id of the material
  89874. */
  89875. uniqueId: number;
  89876. /**
  89877. * The name of the material
  89878. */
  89879. name: string;
  89880. /**
  89881. * Gets or sets user defined metadata
  89882. */
  89883. metadata: any;
  89884. /**
  89885. * For internal use only. Please do not use.
  89886. */
  89887. reservedDataStore: any;
  89888. /**
  89889. * Specifies if the ready state should be checked on each call
  89890. */
  89891. checkReadyOnEveryCall: boolean;
  89892. /**
  89893. * Specifies if the ready state should be checked once
  89894. */
  89895. checkReadyOnlyOnce: boolean;
  89896. /**
  89897. * The state of the material
  89898. */
  89899. state: string;
  89900. /**
  89901. * The alpha value of the material
  89902. */
  89903. protected _alpha: number;
  89904. /**
  89905. * List of inspectable custom properties (used by the Inspector)
  89906. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89907. */
  89908. inspectableCustomProperties: IInspectable[];
  89909. /**
  89910. * Sets the alpha value of the material
  89911. */
  89912. /**
  89913. * Gets the alpha value of the material
  89914. */
  89915. alpha: number;
  89916. /**
  89917. * Specifies if back face culling is enabled
  89918. */
  89919. protected _backFaceCulling: boolean;
  89920. /**
  89921. * Sets the back-face culling state
  89922. */
  89923. /**
  89924. * Gets the back-face culling state
  89925. */
  89926. backFaceCulling: boolean;
  89927. /**
  89928. * Stores the value for side orientation
  89929. */
  89930. sideOrientation: number;
  89931. /**
  89932. * Callback triggered when the material is compiled
  89933. */
  89934. onCompiled: Nullable<(effect: Effect) => void>;
  89935. /**
  89936. * Callback triggered when an error occurs
  89937. */
  89938. onError: Nullable<(effect: Effect, errors: string) => void>;
  89939. /**
  89940. * Callback triggered to get the render target textures
  89941. */
  89942. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  89943. /**
  89944. * Gets a boolean indicating that current material needs to register RTT
  89945. */
  89946. readonly hasRenderTargetTextures: boolean;
  89947. /**
  89948. * Specifies if the material should be serialized
  89949. */
  89950. doNotSerialize: boolean;
  89951. /**
  89952. * @hidden
  89953. */
  89954. _storeEffectOnSubMeshes: boolean;
  89955. /**
  89956. * Stores the animations for the material
  89957. */
  89958. animations: Nullable<Array<Animation>>;
  89959. /**
  89960. * An event triggered when the material is disposed
  89961. */
  89962. onDisposeObservable: Observable<Material>;
  89963. /**
  89964. * An observer which watches for dispose events
  89965. */
  89966. private _onDisposeObserver;
  89967. private _onUnBindObservable;
  89968. /**
  89969. * Called during a dispose event
  89970. */
  89971. onDispose: () => void;
  89972. private _onBindObservable;
  89973. /**
  89974. * An event triggered when the material is bound
  89975. */
  89976. readonly onBindObservable: Observable<AbstractMesh>;
  89977. /**
  89978. * An observer which watches for bind events
  89979. */
  89980. private _onBindObserver;
  89981. /**
  89982. * Called during a bind event
  89983. */
  89984. onBind: (Mesh: AbstractMesh) => void;
  89985. /**
  89986. * An event triggered when the material is unbound
  89987. */
  89988. readonly onUnBindObservable: Observable<Material>;
  89989. /**
  89990. * Stores the value of the alpha mode
  89991. */
  89992. private _alphaMode;
  89993. /**
  89994. * Sets the value of the alpha mode.
  89995. *
  89996. * | Value | Type | Description |
  89997. * | --- | --- | --- |
  89998. * | 0 | ALPHA_DISABLE | |
  89999. * | 1 | ALPHA_ADD | |
  90000. * | 2 | ALPHA_COMBINE | |
  90001. * | 3 | ALPHA_SUBTRACT | |
  90002. * | 4 | ALPHA_MULTIPLY | |
  90003. * | 5 | ALPHA_MAXIMIZED | |
  90004. * | 6 | ALPHA_ONEONE | |
  90005. * | 7 | ALPHA_PREMULTIPLIED | |
  90006. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  90007. * | 9 | ALPHA_INTERPOLATE | |
  90008. * | 10 | ALPHA_SCREENMODE | |
  90009. *
  90010. */
  90011. /**
  90012. * Gets the value of the alpha mode
  90013. */
  90014. alphaMode: number;
  90015. /**
  90016. * Stores the state of the need depth pre-pass value
  90017. */
  90018. private _needDepthPrePass;
  90019. /**
  90020. * Sets the need depth pre-pass value
  90021. */
  90022. /**
  90023. * Gets the depth pre-pass value
  90024. */
  90025. needDepthPrePass: boolean;
  90026. /**
  90027. * Specifies if depth writing should be disabled
  90028. */
  90029. disableDepthWrite: boolean;
  90030. /**
  90031. * Specifies if depth writing should be forced
  90032. */
  90033. forceDepthWrite: boolean;
  90034. /**
  90035. * Specifies the depth function that should be used. 0 means the default engine function
  90036. */
  90037. depthFunction: number;
  90038. /**
  90039. * Specifies if there should be a separate pass for culling
  90040. */
  90041. separateCullingPass: boolean;
  90042. /**
  90043. * Stores the state specifing if fog should be enabled
  90044. */
  90045. private _fogEnabled;
  90046. /**
  90047. * Sets the state for enabling fog
  90048. */
  90049. /**
  90050. * Gets the value of the fog enabled state
  90051. */
  90052. fogEnabled: boolean;
  90053. /**
  90054. * Stores the size of points
  90055. */
  90056. pointSize: number;
  90057. /**
  90058. * Stores the z offset value
  90059. */
  90060. zOffset: number;
  90061. /**
  90062. * Gets a value specifying if wireframe mode is enabled
  90063. */
  90064. /**
  90065. * Sets the state of wireframe mode
  90066. */
  90067. wireframe: boolean;
  90068. /**
  90069. * Gets the value specifying if point clouds are enabled
  90070. */
  90071. /**
  90072. * Sets the state of point cloud mode
  90073. */
  90074. pointsCloud: boolean;
  90075. /**
  90076. * Gets the material fill mode
  90077. */
  90078. /**
  90079. * Sets the material fill mode
  90080. */
  90081. fillMode: number;
  90082. /**
  90083. * @hidden
  90084. * Stores the effects for the material
  90085. */
  90086. _effect: Nullable<Effect>;
  90087. /**
  90088. * @hidden
  90089. * Specifies if the material was previously ready
  90090. */
  90091. _wasPreviouslyReady: boolean;
  90092. /**
  90093. * Specifies if uniform buffers should be used
  90094. */
  90095. private _useUBO;
  90096. /**
  90097. * Stores a reference to the scene
  90098. */
  90099. private _scene;
  90100. /**
  90101. * Stores the fill mode state
  90102. */
  90103. private _fillMode;
  90104. /**
  90105. * Specifies if the depth write state should be cached
  90106. */
  90107. private _cachedDepthWriteState;
  90108. /**
  90109. * Specifies if the depth function state should be cached
  90110. */
  90111. private _cachedDepthFunctionState;
  90112. /**
  90113. * Stores the uniform buffer
  90114. */
  90115. protected _uniformBuffer: UniformBuffer;
  90116. /** @hidden */
  90117. _indexInSceneMaterialArray: number;
  90118. /** @hidden */
  90119. meshMap: Nullable<{
  90120. [id: string]: AbstractMesh | undefined;
  90121. }>;
  90122. /**
  90123. * Creates a material instance
  90124. * @param name defines the name of the material
  90125. * @param scene defines the scene to reference
  90126. * @param doNotAdd specifies if the material should be added to the scene
  90127. */
  90128. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  90129. /**
  90130. * Returns a string representation of the current material
  90131. * @param fullDetails defines a boolean indicating which levels of logging is desired
  90132. * @returns a string with material information
  90133. */
  90134. toString(fullDetails?: boolean): string;
  90135. /**
  90136. * Gets the class name of the material
  90137. * @returns a string with the class name of the material
  90138. */
  90139. getClassName(): string;
  90140. /**
  90141. * Specifies if updates for the material been locked
  90142. */
  90143. readonly isFrozen: boolean;
  90144. /**
  90145. * Locks updates for the material
  90146. */
  90147. freeze(): void;
  90148. /**
  90149. * Unlocks updates for the material
  90150. */
  90151. unfreeze(): void;
  90152. /**
  90153. * Specifies if the material is ready to be used
  90154. * @param mesh defines the mesh to check
  90155. * @param useInstances specifies if instances should be used
  90156. * @returns a boolean indicating if the material is ready to be used
  90157. */
  90158. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  90159. /**
  90160. * Specifies that the submesh is ready to be used
  90161. * @param mesh defines the mesh to check
  90162. * @param subMesh defines which submesh to check
  90163. * @param useInstances specifies that instances should be used
  90164. * @returns a boolean indicating that the submesh is ready or not
  90165. */
  90166. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  90167. /**
  90168. * Returns the material effect
  90169. * @returns the effect associated with the material
  90170. */
  90171. getEffect(): Nullable<Effect>;
  90172. /**
  90173. * Returns the current scene
  90174. * @returns a Scene
  90175. */
  90176. getScene(): Scene;
  90177. /**
  90178. * Specifies if the material will require alpha blending
  90179. * @returns a boolean specifying if alpha blending is needed
  90180. */
  90181. needAlphaBlending(): boolean;
  90182. /**
  90183. * Specifies if the mesh will require alpha blending
  90184. * @param mesh defines the mesh to check
  90185. * @returns a boolean specifying if alpha blending is needed for the mesh
  90186. */
  90187. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  90188. /**
  90189. * Specifies if this material should be rendered in alpha test mode
  90190. * @returns a boolean specifying if an alpha test is needed.
  90191. */
  90192. needAlphaTesting(): boolean;
  90193. /**
  90194. * Gets the texture used for the alpha test
  90195. * @returns the texture to use for alpha testing
  90196. */
  90197. getAlphaTestTexture(): Nullable<BaseTexture>;
  90198. /**
  90199. * Marks the material to indicate that it needs to be re-calculated
  90200. */
  90201. markDirty(): void;
  90202. /** @hidden */
  90203. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  90204. /**
  90205. * Binds the material to the mesh
  90206. * @param world defines the world transformation matrix
  90207. * @param mesh defines the mesh to bind the material to
  90208. */
  90209. bind(world: Matrix, mesh?: Mesh): void;
  90210. /**
  90211. * Binds the submesh to the material
  90212. * @param world defines the world transformation matrix
  90213. * @param mesh defines the mesh containing the submesh
  90214. * @param subMesh defines the submesh to bind the material to
  90215. */
  90216. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  90217. /**
  90218. * Binds the world matrix to the material
  90219. * @param world defines the world transformation matrix
  90220. */
  90221. bindOnlyWorldMatrix(world: Matrix): void;
  90222. /**
  90223. * Binds the scene's uniform buffer to the effect.
  90224. * @param effect defines the effect to bind to the scene uniform buffer
  90225. * @param sceneUbo defines the uniform buffer storing scene data
  90226. */
  90227. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  90228. /**
  90229. * Binds the view matrix to the effect
  90230. * @param effect defines the effect to bind the view matrix to
  90231. */
  90232. bindView(effect: Effect): void;
  90233. /**
  90234. * Binds the view projection matrix to the effect
  90235. * @param effect defines the effect to bind the view projection matrix to
  90236. */
  90237. bindViewProjection(effect: Effect): void;
  90238. /**
  90239. * Specifies if material alpha testing should be turned on for the mesh
  90240. * @param mesh defines the mesh to check
  90241. */
  90242. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  90243. /**
  90244. * Processes to execute after binding the material to a mesh
  90245. * @param mesh defines the rendered mesh
  90246. */
  90247. protected _afterBind(mesh?: Mesh): void;
  90248. /**
  90249. * Unbinds the material from the mesh
  90250. */
  90251. unbind(): void;
  90252. /**
  90253. * Gets the active textures from the material
  90254. * @returns an array of textures
  90255. */
  90256. getActiveTextures(): BaseTexture[];
  90257. /**
  90258. * Specifies if the material uses a texture
  90259. * @param texture defines the texture to check against the material
  90260. * @returns a boolean specifying if the material uses the texture
  90261. */
  90262. hasTexture(texture: BaseTexture): boolean;
  90263. /**
  90264. * Makes a duplicate of the material, and gives it a new name
  90265. * @param name defines the new name for the duplicated material
  90266. * @returns the cloned material
  90267. */
  90268. clone(name: string): Nullable<Material>;
  90269. /**
  90270. * Gets the meshes bound to the material
  90271. * @returns an array of meshes bound to the material
  90272. */
  90273. getBindedMeshes(): AbstractMesh[];
  90274. /**
  90275. * Force shader compilation
  90276. * @param mesh defines the mesh associated with this material
  90277. * @param onCompiled defines a function to execute once the material is compiled
  90278. * @param options defines the options to configure the compilation
  90279. * @param onError defines a function to execute if the material fails compiling
  90280. */
  90281. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  90282. /**
  90283. * Force shader compilation
  90284. * @param mesh defines the mesh that will use this material
  90285. * @param options defines additional options for compiling the shaders
  90286. * @returns a promise that resolves when the compilation completes
  90287. */
  90288. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  90289. private static readonly _AllDirtyCallBack;
  90290. private static readonly _ImageProcessingDirtyCallBack;
  90291. private static readonly _TextureDirtyCallBack;
  90292. private static readonly _FresnelDirtyCallBack;
  90293. private static readonly _MiscDirtyCallBack;
  90294. private static readonly _LightsDirtyCallBack;
  90295. private static readonly _AttributeDirtyCallBack;
  90296. private static _FresnelAndMiscDirtyCallBack;
  90297. private static _TextureAndMiscDirtyCallBack;
  90298. private static readonly _DirtyCallbackArray;
  90299. private static readonly _RunDirtyCallBacks;
  90300. /**
  90301. * Marks a define in the material to indicate that it needs to be re-computed
  90302. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  90303. */
  90304. markAsDirty(flag: number): void;
  90305. /**
  90306. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  90307. * @param func defines a function which checks material defines against the submeshes
  90308. */
  90309. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  90310. /**
  90311. * Indicates that we need to re-calculated for all submeshes
  90312. */
  90313. protected _markAllSubMeshesAsAllDirty(): void;
  90314. /**
  90315. * Indicates that image processing needs to be re-calculated for all submeshes
  90316. */
  90317. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  90318. /**
  90319. * Indicates that textures need to be re-calculated for all submeshes
  90320. */
  90321. protected _markAllSubMeshesAsTexturesDirty(): void;
  90322. /**
  90323. * Indicates that fresnel needs to be re-calculated for all submeshes
  90324. */
  90325. protected _markAllSubMeshesAsFresnelDirty(): void;
  90326. /**
  90327. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  90328. */
  90329. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  90330. /**
  90331. * Indicates that lights need to be re-calculated for all submeshes
  90332. */
  90333. protected _markAllSubMeshesAsLightsDirty(): void;
  90334. /**
  90335. * Indicates that attributes need to be re-calculated for all submeshes
  90336. */
  90337. protected _markAllSubMeshesAsAttributesDirty(): void;
  90338. /**
  90339. * Indicates that misc needs to be re-calculated for all submeshes
  90340. */
  90341. protected _markAllSubMeshesAsMiscDirty(): void;
  90342. /**
  90343. * Indicates that textures and misc need to be re-calculated for all submeshes
  90344. */
  90345. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  90346. /**
  90347. * Disposes the material
  90348. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  90349. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  90350. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  90351. */
  90352. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  90353. /** @hidden */
  90354. private releaseVertexArrayObject;
  90355. /**
  90356. * Serializes this material
  90357. * @returns the serialized material object
  90358. */
  90359. serialize(): any;
  90360. /**
  90361. * Creates a material from parsed material data
  90362. * @param parsedMaterial defines parsed material data
  90363. * @param scene defines the hosting scene
  90364. * @param rootUrl defines the root URL to use to load textures
  90365. * @returns a new material
  90366. */
  90367. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  90368. }
  90369. }
  90370. declare module BABYLON {
  90371. /**
  90372. * A multi-material is used to apply different materials to different parts of the same object without the need of
  90373. * separate meshes. This can be use to improve performances.
  90374. * @see http://doc.babylonjs.com/how_to/multi_materials
  90375. */
  90376. export class MultiMaterial extends Material {
  90377. private _subMaterials;
  90378. /**
  90379. * Gets or Sets the list of Materials used within the multi material.
  90380. * They need to be ordered according to the submeshes order in the associated mesh
  90381. */
  90382. subMaterials: Nullable<Material>[];
  90383. /**
  90384. * Function used to align with Node.getChildren()
  90385. * @returns the list of Materials used within the multi material
  90386. */
  90387. getChildren(): Nullable<Material>[];
  90388. /**
  90389. * Instantiates a new Multi Material
  90390. * A multi-material is used to apply different materials to different parts of the same object without the need of
  90391. * separate meshes. This can be use to improve performances.
  90392. * @see http://doc.babylonjs.com/how_to/multi_materials
  90393. * @param name Define the name in the scene
  90394. * @param scene Define the scene the material belongs to
  90395. */
  90396. constructor(name: string, scene: Scene);
  90397. private _hookArray;
  90398. /**
  90399. * Get one of the submaterial by its index in the submaterials array
  90400. * @param index The index to look the sub material at
  90401. * @returns The Material if the index has been defined
  90402. */
  90403. getSubMaterial(index: number): Nullable<Material>;
  90404. /**
  90405. * Get the list of active textures for the whole sub materials list.
  90406. * @returns All the textures that will be used during the rendering
  90407. */
  90408. getActiveTextures(): BaseTexture[];
  90409. /**
  90410. * Gets the current class name of the material e.g. "MultiMaterial"
  90411. * Mainly use in serialization.
  90412. * @returns the class name
  90413. */
  90414. getClassName(): string;
  90415. /**
  90416. * Checks if the material is ready to render the requested sub mesh
  90417. * @param mesh Define the mesh the submesh belongs to
  90418. * @param subMesh Define the sub mesh to look readyness for
  90419. * @param useInstances Define whether or not the material is used with instances
  90420. * @returns true if ready, otherwise false
  90421. */
  90422. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  90423. /**
  90424. * Clones the current material and its related sub materials
  90425. * @param name Define the name of the newly cloned material
  90426. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  90427. * @returns the cloned material
  90428. */
  90429. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  90430. /**
  90431. * Serializes the materials into a JSON representation.
  90432. * @returns the JSON representation
  90433. */
  90434. serialize(): any;
  90435. /**
  90436. * Dispose the material and release its associated resources
  90437. * @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)
  90438. * @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)
  90439. * @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)
  90440. */
  90441. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  90442. /**
  90443. * Creates a MultiMaterial from parsed MultiMaterial data.
  90444. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  90445. * @param scene defines the hosting scene
  90446. * @returns a new MultiMaterial
  90447. */
  90448. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  90449. }
  90450. }
  90451. declare module BABYLON {
  90452. /**
  90453. * Base class for submeshes
  90454. */
  90455. export class BaseSubMesh {
  90456. /** @hidden */
  90457. _materialDefines: Nullable<MaterialDefines>;
  90458. /** @hidden */
  90459. _materialEffect: Nullable<Effect>;
  90460. /**
  90461. * Gets material defines used by the effect associated to the sub mesh
  90462. */
  90463. /**
  90464. * Sets material defines used by the effect associated to the sub mesh
  90465. */
  90466. materialDefines: Nullable<MaterialDefines>;
  90467. /**
  90468. * Gets associated effect
  90469. */
  90470. readonly effect: Nullable<Effect>;
  90471. /**
  90472. * Sets associated effect (effect used to render this submesh)
  90473. * @param effect defines the effect to associate with
  90474. * @param defines defines the set of defines used to compile this effect
  90475. */
  90476. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  90477. }
  90478. /**
  90479. * Defines a subdivision inside a mesh
  90480. */
  90481. export class SubMesh extends BaseSubMesh implements ICullable {
  90482. /** the material index to use */
  90483. materialIndex: number;
  90484. /** vertex index start */
  90485. verticesStart: number;
  90486. /** vertices count */
  90487. verticesCount: number;
  90488. /** index start */
  90489. indexStart: number;
  90490. /** indices count */
  90491. indexCount: number;
  90492. /** @hidden */
  90493. _linesIndexCount: number;
  90494. private _mesh;
  90495. private _renderingMesh;
  90496. private _boundingInfo;
  90497. private _linesIndexBuffer;
  90498. /** @hidden */
  90499. _lastColliderWorldVertices: Nullable<Vector3[]>;
  90500. /** @hidden */
  90501. _trianglePlanes: Plane[];
  90502. /** @hidden */
  90503. _lastColliderTransformMatrix: Nullable<Matrix>;
  90504. /** @hidden */
  90505. _renderId: number;
  90506. /** @hidden */
  90507. _alphaIndex: number;
  90508. /** @hidden */
  90509. _distanceToCamera: number;
  90510. /** @hidden */
  90511. _id: number;
  90512. private _currentMaterial;
  90513. /**
  90514. * Add a new submesh to a mesh
  90515. * @param materialIndex defines the material index to use
  90516. * @param verticesStart defines vertex index start
  90517. * @param verticesCount defines vertices count
  90518. * @param indexStart defines index start
  90519. * @param indexCount defines indices count
  90520. * @param mesh defines the parent mesh
  90521. * @param renderingMesh defines an optional rendering mesh
  90522. * @param createBoundingBox defines if bounding box should be created for this submesh
  90523. * @returns the new submesh
  90524. */
  90525. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  90526. /**
  90527. * Creates a new submesh
  90528. * @param materialIndex defines the material index to use
  90529. * @param verticesStart defines vertex index start
  90530. * @param verticesCount defines vertices count
  90531. * @param indexStart defines index start
  90532. * @param indexCount defines indices count
  90533. * @param mesh defines the parent mesh
  90534. * @param renderingMesh defines an optional rendering mesh
  90535. * @param createBoundingBox defines if bounding box should be created for this submesh
  90536. */
  90537. constructor(
  90538. /** the material index to use */
  90539. materialIndex: number,
  90540. /** vertex index start */
  90541. verticesStart: number,
  90542. /** vertices count */
  90543. verticesCount: number,
  90544. /** index start */
  90545. indexStart: number,
  90546. /** indices count */
  90547. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  90548. /**
  90549. * Returns true if this submesh covers the entire parent mesh
  90550. * @ignorenaming
  90551. */
  90552. readonly IsGlobal: boolean;
  90553. /**
  90554. * Returns the submesh BoudingInfo object
  90555. * @returns current bounding info (or mesh's one if the submesh is global)
  90556. */
  90557. getBoundingInfo(): BoundingInfo;
  90558. /**
  90559. * Sets the submesh BoundingInfo
  90560. * @param boundingInfo defines the new bounding info to use
  90561. * @returns the SubMesh
  90562. */
  90563. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  90564. /**
  90565. * Returns the mesh of the current submesh
  90566. * @return the parent mesh
  90567. */
  90568. getMesh(): AbstractMesh;
  90569. /**
  90570. * Returns the rendering mesh of the submesh
  90571. * @returns the rendering mesh (could be different from parent mesh)
  90572. */
  90573. getRenderingMesh(): Mesh;
  90574. /**
  90575. * Returns the submesh material
  90576. * @returns null or the current material
  90577. */
  90578. getMaterial(): Nullable<Material>;
  90579. /**
  90580. * Sets a new updated BoundingInfo object to the submesh
  90581. * @param data defines an optional position array to use to determine the bounding info
  90582. * @returns the SubMesh
  90583. */
  90584. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  90585. /** @hidden */
  90586. _checkCollision(collider: Collider): boolean;
  90587. /**
  90588. * Updates the submesh BoundingInfo
  90589. * @param world defines the world matrix to use to update the bounding info
  90590. * @returns the submesh
  90591. */
  90592. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  90593. /**
  90594. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  90595. * @param frustumPlanes defines the frustum planes
  90596. * @returns true if the submesh is intersecting with the frustum
  90597. */
  90598. isInFrustum(frustumPlanes: Plane[]): boolean;
  90599. /**
  90600. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  90601. * @param frustumPlanes defines the frustum planes
  90602. * @returns true if the submesh is inside the frustum
  90603. */
  90604. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  90605. /**
  90606. * Renders the submesh
  90607. * @param enableAlphaMode defines if alpha needs to be used
  90608. * @returns the submesh
  90609. */
  90610. render(enableAlphaMode: boolean): SubMesh;
  90611. /**
  90612. * @hidden
  90613. */
  90614. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  90615. /**
  90616. * Checks if the submesh intersects with a ray
  90617. * @param ray defines the ray to test
  90618. * @returns true is the passed ray intersects the submesh bounding box
  90619. */
  90620. canIntersects(ray: Ray): boolean;
  90621. /**
  90622. * Intersects current submesh with a ray
  90623. * @param ray defines the ray to test
  90624. * @param positions defines mesh's positions array
  90625. * @param indices defines mesh's indices array
  90626. * @param fastCheck defines if only bounding info should be used
  90627. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90628. * @returns intersection info or null if no intersection
  90629. */
  90630. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  90631. /** @hidden */
  90632. private _intersectLines;
  90633. /** @hidden */
  90634. private _intersectUnIndexedLines;
  90635. /** @hidden */
  90636. private _intersectTriangles;
  90637. /** @hidden */
  90638. private _intersectUnIndexedTriangles;
  90639. /** @hidden */
  90640. _rebuild(): void;
  90641. /**
  90642. * Creates a new submesh from the passed mesh
  90643. * @param newMesh defines the new hosting mesh
  90644. * @param newRenderingMesh defines an optional rendering mesh
  90645. * @returns the new submesh
  90646. */
  90647. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  90648. /**
  90649. * Release associated resources
  90650. */
  90651. dispose(): void;
  90652. /**
  90653. * Gets the class name
  90654. * @returns the string "SubMesh".
  90655. */
  90656. getClassName(): string;
  90657. /**
  90658. * Creates a new submesh from indices data
  90659. * @param materialIndex the index of the main mesh material
  90660. * @param startIndex the index where to start the copy in the mesh indices array
  90661. * @param indexCount the number of indices to copy then from the startIndex
  90662. * @param mesh the main mesh to create the submesh from
  90663. * @param renderingMesh the optional rendering mesh
  90664. * @returns a new submesh
  90665. */
  90666. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  90667. }
  90668. }
  90669. declare module BABYLON {
  90670. /**
  90671. * Class used to represent data loading progression
  90672. */
  90673. export class SceneLoaderFlags {
  90674. private static _ForceFullSceneLoadingForIncremental;
  90675. private static _ShowLoadingScreen;
  90676. private static _CleanBoneMatrixWeights;
  90677. private static _loggingLevel;
  90678. /**
  90679. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  90680. */
  90681. static ForceFullSceneLoadingForIncremental: boolean;
  90682. /**
  90683. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  90684. */
  90685. static ShowLoadingScreen: boolean;
  90686. /**
  90687. * Defines the current logging level (while loading the scene)
  90688. * @ignorenaming
  90689. */
  90690. static loggingLevel: number;
  90691. /**
  90692. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  90693. */
  90694. static CleanBoneMatrixWeights: boolean;
  90695. }
  90696. }
  90697. declare module BABYLON {
  90698. /**
  90699. * Class used to store geometry data (vertex buffers + index buffer)
  90700. */
  90701. export class Geometry implements IGetSetVerticesData {
  90702. /**
  90703. * Gets or sets the ID of the geometry
  90704. */
  90705. id: string;
  90706. /**
  90707. * Gets or sets the unique ID of the geometry
  90708. */
  90709. uniqueId: number;
  90710. /**
  90711. * Gets the delay loading state of the geometry (none by default which means not delayed)
  90712. */
  90713. delayLoadState: number;
  90714. /**
  90715. * Gets the file containing the data to load when running in delay load state
  90716. */
  90717. delayLoadingFile: Nullable<string>;
  90718. /**
  90719. * Callback called when the geometry is updated
  90720. */
  90721. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  90722. private _scene;
  90723. private _engine;
  90724. private _meshes;
  90725. private _totalVertices;
  90726. /** @hidden */
  90727. _indices: IndicesArray;
  90728. /** @hidden */
  90729. _vertexBuffers: {
  90730. [key: string]: VertexBuffer;
  90731. };
  90732. private _isDisposed;
  90733. private _extend;
  90734. private _boundingBias;
  90735. /** @hidden */
  90736. _delayInfo: Array<string>;
  90737. private _indexBuffer;
  90738. private _indexBufferIsUpdatable;
  90739. /** @hidden */
  90740. _boundingInfo: Nullable<BoundingInfo>;
  90741. /** @hidden */
  90742. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  90743. /** @hidden */
  90744. _softwareSkinningFrameId: number;
  90745. private _vertexArrayObjects;
  90746. private _updatable;
  90747. /** @hidden */
  90748. _positions: Nullable<Vector3[]>;
  90749. /**
  90750. * 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
  90751. */
  90752. /**
  90753. * 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
  90754. */
  90755. boundingBias: Vector2;
  90756. /**
  90757. * Static function used to attach a new empty geometry to a mesh
  90758. * @param mesh defines the mesh to attach the geometry to
  90759. * @returns the new Geometry
  90760. */
  90761. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  90762. /**
  90763. * Creates a new geometry
  90764. * @param id defines the unique ID
  90765. * @param scene defines the hosting scene
  90766. * @param vertexData defines the VertexData used to get geometry data
  90767. * @param updatable defines if geometry must be updatable (false by default)
  90768. * @param mesh defines the mesh that will be associated with the geometry
  90769. */
  90770. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  90771. /**
  90772. * Gets the current extend of the geometry
  90773. */
  90774. readonly extend: {
  90775. minimum: Vector3;
  90776. maximum: Vector3;
  90777. };
  90778. /**
  90779. * Gets the hosting scene
  90780. * @returns the hosting Scene
  90781. */
  90782. getScene(): Scene;
  90783. /**
  90784. * Gets the hosting engine
  90785. * @returns the hosting Engine
  90786. */
  90787. getEngine(): Engine;
  90788. /**
  90789. * Defines if the geometry is ready to use
  90790. * @returns true if the geometry is ready to be used
  90791. */
  90792. isReady(): boolean;
  90793. /**
  90794. * Gets a value indicating that the geometry should not be serialized
  90795. */
  90796. readonly doNotSerialize: boolean;
  90797. /** @hidden */
  90798. _rebuild(): void;
  90799. /**
  90800. * Affects all geometry data in one call
  90801. * @param vertexData defines the geometry data
  90802. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  90803. */
  90804. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  90805. /**
  90806. * Set specific vertex data
  90807. * @param kind defines the data kind (Position, normal, etc...)
  90808. * @param data defines the vertex data to use
  90809. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  90810. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  90811. */
  90812. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  90813. /**
  90814. * Removes a specific vertex data
  90815. * @param kind defines the data kind (Position, normal, etc...)
  90816. */
  90817. removeVerticesData(kind: string): void;
  90818. /**
  90819. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  90820. * @param buffer defines the vertex buffer to use
  90821. * @param totalVertices defines the total number of vertices for position kind (could be null)
  90822. */
  90823. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  90824. /**
  90825. * Update a specific vertex buffer
  90826. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  90827. * It will do nothing if the buffer is not updatable
  90828. * @param kind defines the data kind (Position, normal, etc...)
  90829. * @param data defines the data to use
  90830. * @param offset defines the offset in the target buffer where to store the data
  90831. * @param useBytes set to true if the offset is in bytes
  90832. */
  90833. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  90834. /**
  90835. * Update a specific vertex buffer
  90836. * This function will create a new buffer if the current one is not updatable
  90837. * @param kind defines the data kind (Position, normal, etc...)
  90838. * @param data defines the data to use
  90839. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  90840. */
  90841. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  90842. private _updateBoundingInfo;
  90843. /** @hidden */
  90844. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  90845. /**
  90846. * Gets total number of vertices
  90847. * @returns the total number of vertices
  90848. */
  90849. getTotalVertices(): number;
  90850. /**
  90851. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  90852. * @param kind defines the data kind (Position, normal, etc...)
  90853. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90854. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90855. * @returns a float array containing vertex data
  90856. */
  90857. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90858. /**
  90859. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  90860. * @param kind defines the data kind (Position, normal, etc...)
  90861. * @returns true if the vertex buffer with the specified kind is updatable
  90862. */
  90863. isVertexBufferUpdatable(kind: string): boolean;
  90864. /**
  90865. * Gets a specific vertex buffer
  90866. * @param kind defines the data kind (Position, normal, etc...)
  90867. * @returns a VertexBuffer
  90868. */
  90869. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90870. /**
  90871. * Returns all vertex buffers
  90872. * @return an object holding all vertex buffers indexed by kind
  90873. */
  90874. getVertexBuffers(): Nullable<{
  90875. [key: string]: VertexBuffer;
  90876. }>;
  90877. /**
  90878. * Gets a boolean indicating if specific vertex buffer is present
  90879. * @param kind defines the data kind (Position, normal, etc...)
  90880. * @returns true if data is present
  90881. */
  90882. isVerticesDataPresent(kind: string): boolean;
  90883. /**
  90884. * Gets a list of all attached data kinds (Position, normal, etc...)
  90885. * @returns a list of string containing all kinds
  90886. */
  90887. getVerticesDataKinds(): string[];
  90888. /**
  90889. * Update index buffer
  90890. * @param indices defines the indices to store in the index buffer
  90891. * @param offset defines the offset in the target buffer where to store the data
  90892. * @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)
  90893. */
  90894. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  90895. /**
  90896. * Creates a new index buffer
  90897. * @param indices defines the indices to store in the index buffer
  90898. * @param totalVertices defines the total number of vertices (could be null)
  90899. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  90900. */
  90901. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  90902. /**
  90903. * Return the total number of indices
  90904. * @returns the total number of indices
  90905. */
  90906. getTotalIndices(): number;
  90907. /**
  90908. * Gets the index buffer array
  90909. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90910. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90911. * @returns the index buffer array
  90912. */
  90913. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90914. /**
  90915. * Gets the index buffer
  90916. * @return the index buffer
  90917. */
  90918. getIndexBuffer(): Nullable<DataBuffer>;
  90919. /** @hidden */
  90920. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  90921. /**
  90922. * Release the associated resources for a specific mesh
  90923. * @param mesh defines the source mesh
  90924. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  90925. */
  90926. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  90927. /**
  90928. * Apply current geometry to a given mesh
  90929. * @param mesh defines the mesh to apply geometry to
  90930. */
  90931. applyToMesh(mesh: Mesh): void;
  90932. private _updateExtend;
  90933. private _applyToMesh;
  90934. private notifyUpdate;
  90935. /**
  90936. * Load the geometry if it was flagged as delay loaded
  90937. * @param scene defines the hosting scene
  90938. * @param onLoaded defines a callback called when the geometry is loaded
  90939. */
  90940. load(scene: Scene, onLoaded?: () => void): void;
  90941. private _queueLoad;
  90942. /**
  90943. * Invert the geometry to move from a right handed system to a left handed one.
  90944. */
  90945. toLeftHanded(): void;
  90946. /** @hidden */
  90947. _resetPointsArrayCache(): void;
  90948. /** @hidden */
  90949. _generatePointsArray(): boolean;
  90950. /**
  90951. * Gets a value indicating if the geometry is disposed
  90952. * @returns true if the geometry was disposed
  90953. */
  90954. isDisposed(): boolean;
  90955. private _disposeVertexArrayObjects;
  90956. /**
  90957. * Free all associated resources
  90958. */
  90959. dispose(): void;
  90960. /**
  90961. * Clone the current geometry into a new geometry
  90962. * @param id defines the unique ID of the new geometry
  90963. * @returns a new geometry object
  90964. */
  90965. copy(id: string): Geometry;
  90966. /**
  90967. * Serialize the current geometry info (and not the vertices data) into a JSON object
  90968. * @return a JSON representation of the current geometry data (without the vertices data)
  90969. */
  90970. serialize(): any;
  90971. private toNumberArray;
  90972. /**
  90973. * Serialize all vertices data into a JSON oject
  90974. * @returns a JSON representation of the current geometry data
  90975. */
  90976. serializeVerticeData(): any;
  90977. /**
  90978. * Extracts a clone of a mesh geometry
  90979. * @param mesh defines the source mesh
  90980. * @param id defines the unique ID of the new geometry object
  90981. * @returns the new geometry object
  90982. */
  90983. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  90984. /**
  90985. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  90986. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  90987. * Be aware Math.random() could cause collisions, but:
  90988. * "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"
  90989. * @returns a string containing a new GUID
  90990. */
  90991. static RandomId(): string;
  90992. /** @hidden */
  90993. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  90994. private static _CleanMatricesWeights;
  90995. /**
  90996. * Create a new geometry from persisted data (Using .babylon file format)
  90997. * @param parsedVertexData defines the persisted data
  90998. * @param scene defines the hosting scene
  90999. * @param rootUrl defines the root url to use to load assets (like delayed data)
  91000. * @returns the new geometry object
  91001. */
  91002. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  91003. }
  91004. }
  91005. declare module BABYLON {
  91006. /**
  91007. * Define an interface for all classes that will get and set the data on vertices
  91008. */
  91009. export interface IGetSetVerticesData {
  91010. /**
  91011. * Gets a boolean indicating if specific vertex data is present
  91012. * @param kind defines the vertex data kind to use
  91013. * @returns true is data kind is present
  91014. */
  91015. isVerticesDataPresent(kind: string): boolean;
  91016. /**
  91017. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  91018. * @param kind defines the data kind (Position, normal, etc...)
  91019. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  91020. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  91021. * @returns a float array containing vertex data
  91022. */
  91023. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  91024. /**
  91025. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  91026. * @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.
  91027. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  91028. * @returns the indices array or an empty array if the mesh has no geometry
  91029. */
  91030. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  91031. /**
  91032. * Set specific vertex data
  91033. * @param kind defines the data kind (Position, normal, etc...)
  91034. * @param data defines the vertex data to use
  91035. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  91036. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  91037. */
  91038. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  91039. /**
  91040. * Update a specific associated vertex buffer
  91041. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  91042. * - VertexBuffer.PositionKind
  91043. * - VertexBuffer.UVKind
  91044. * - VertexBuffer.UV2Kind
  91045. * - VertexBuffer.UV3Kind
  91046. * - VertexBuffer.UV4Kind
  91047. * - VertexBuffer.UV5Kind
  91048. * - VertexBuffer.UV6Kind
  91049. * - VertexBuffer.ColorKind
  91050. * - VertexBuffer.MatricesIndicesKind
  91051. * - VertexBuffer.MatricesIndicesExtraKind
  91052. * - VertexBuffer.MatricesWeightsKind
  91053. * - VertexBuffer.MatricesWeightsExtraKind
  91054. * @param data defines the data source
  91055. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  91056. * @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)
  91057. */
  91058. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  91059. /**
  91060. * Creates a new index buffer
  91061. * @param indices defines the indices to store in the index buffer
  91062. * @param totalVertices defines the total number of vertices (could be null)
  91063. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  91064. */
  91065. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  91066. }
  91067. /**
  91068. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  91069. */
  91070. export class VertexData {
  91071. /**
  91072. * Mesh side orientation : usually the external or front surface
  91073. */
  91074. static readonly FRONTSIDE: number;
  91075. /**
  91076. * Mesh side orientation : usually the internal or back surface
  91077. */
  91078. static readonly BACKSIDE: number;
  91079. /**
  91080. * Mesh side orientation : both internal and external or front and back surfaces
  91081. */
  91082. static readonly DOUBLESIDE: number;
  91083. /**
  91084. * Mesh side orientation : by default, `FRONTSIDE`
  91085. */
  91086. static readonly DEFAULTSIDE: number;
  91087. /**
  91088. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  91089. */
  91090. positions: Nullable<FloatArray>;
  91091. /**
  91092. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  91093. */
  91094. normals: Nullable<FloatArray>;
  91095. /**
  91096. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  91097. */
  91098. tangents: Nullable<FloatArray>;
  91099. /**
  91100. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  91101. */
  91102. uvs: Nullable<FloatArray>;
  91103. /**
  91104. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  91105. */
  91106. uvs2: Nullable<FloatArray>;
  91107. /**
  91108. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  91109. */
  91110. uvs3: Nullable<FloatArray>;
  91111. /**
  91112. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  91113. */
  91114. uvs4: Nullable<FloatArray>;
  91115. /**
  91116. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  91117. */
  91118. uvs5: Nullable<FloatArray>;
  91119. /**
  91120. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  91121. */
  91122. uvs6: Nullable<FloatArray>;
  91123. /**
  91124. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  91125. */
  91126. colors: Nullable<FloatArray>;
  91127. /**
  91128. * 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).
  91129. */
  91130. matricesIndices: Nullable<FloatArray>;
  91131. /**
  91132. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  91133. */
  91134. matricesWeights: Nullable<FloatArray>;
  91135. /**
  91136. * An array extending the number of possible indices
  91137. */
  91138. matricesIndicesExtra: Nullable<FloatArray>;
  91139. /**
  91140. * An array extending the number of possible weights when the number of indices is extended
  91141. */
  91142. matricesWeightsExtra: Nullable<FloatArray>;
  91143. /**
  91144. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  91145. */
  91146. indices: Nullable<IndicesArray>;
  91147. /**
  91148. * Uses the passed data array to set the set the values for the specified kind of data
  91149. * @param data a linear array of floating numbers
  91150. * @param kind the type of data that is being set, eg positions, colors etc
  91151. */
  91152. set(data: FloatArray, kind: string): void;
  91153. /**
  91154. * Associates the vertexData to the passed Mesh.
  91155. * Sets it as updatable or not (default `false`)
  91156. * @param mesh the mesh the vertexData is applied to
  91157. * @param updatable when used and having the value true allows new data to update the vertexData
  91158. * @returns the VertexData
  91159. */
  91160. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  91161. /**
  91162. * Associates the vertexData to the passed Geometry.
  91163. * Sets it as updatable or not (default `false`)
  91164. * @param geometry the geometry the vertexData is applied to
  91165. * @param updatable when used and having the value true allows new data to update the vertexData
  91166. * @returns VertexData
  91167. */
  91168. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  91169. /**
  91170. * Updates the associated mesh
  91171. * @param mesh the mesh to be updated
  91172. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  91173. * @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
  91174. * @returns VertexData
  91175. */
  91176. updateMesh(mesh: Mesh): VertexData;
  91177. /**
  91178. * Updates the associated geometry
  91179. * @param geometry the geometry to be updated
  91180. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  91181. * @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
  91182. * @returns VertexData.
  91183. */
  91184. updateGeometry(geometry: Geometry): VertexData;
  91185. private _applyTo;
  91186. private _update;
  91187. /**
  91188. * Transforms each position and each normal of the vertexData according to the passed Matrix
  91189. * @param matrix the transforming matrix
  91190. * @returns the VertexData
  91191. */
  91192. transform(matrix: Matrix): VertexData;
  91193. /**
  91194. * Merges the passed VertexData into the current one
  91195. * @param other the VertexData to be merged into the current one
  91196. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  91197. * @returns the modified VertexData
  91198. */
  91199. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  91200. private _mergeElement;
  91201. private _validate;
  91202. /**
  91203. * Serializes the VertexData
  91204. * @returns a serialized object
  91205. */
  91206. serialize(): any;
  91207. /**
  91208. * Extracts the vertexData from a mesh
  91209. * @param mesh the mesh from which to extract the VertexData
  91210. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  91211. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  91212. * @returns the object VertexData associated to the passed mesh
  91213. */
  91214. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  91215. /**
  91216. * Extracts the vertexData from the geometry
  91217. * @param geometry the geometry from which to extract the VertexData
  91218. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  91219. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  91220. * @returns the object VertexData associated to the passed mesh
  91221. */
  91222. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  91223. private static _ExtractFrom;
  91224. /**
  91225. * Creates the VertexData for a Ribbon
  91226. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  91227. * * pathArray array of paths, each of which an array of successive Vector3
  91228. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  91229. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  91230. * * 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
  91231. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91232. * * 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)
  91233. * * 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)
  91234. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  91235. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  91236. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  91237. * @returns the VertexData of the ribbon
  91238. */
  91239. static CreateRibbon(options: {
  91240. pathArray: Vector3[][];
  91241. closeArray?: boolean;
  91242. closePath?: boolean;
  91243. offset?: number;
  91244. sideOrientation?: number;
  91245. frontUVs?: Vector4;
  91246. backUVs?: Vector4;
  91247. invertUV?: boolean;
  91248. uvs?: Vector2[];
  91249. colors?: Color4[];
  91250. }): VertexData;
  91251. /**
  91252. * Creates the VertexData for a box
  91253. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91254. * * size sets the width, height and depth of the box to the value of size, optional default 1
  91255. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  91256. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  91257. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  91258. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  91259. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  91260. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91261. * * 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)
  91262. * * 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)
  91263. * @returns the VertexData of the box
  91264. */
  91265. static CreateBox(options: {
  91266. size?: number;
  91267. width?: number;
  91268. height?: number;
  91269. depth?: number;
  91270. faceUV?: Vector4[];
  91271. faceColors?: Color4[];
  91272. sideOrientation?: number;
  91273. frontUVs?: Vector4;
  91274. backUVs?: Vector4;
  91275. }): VertexData;
  91276. /**
  91277. * Creates the VertexData for a tiled box
  91278. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91279. * * faceTiles sets the pattern, tile size and number of tiles for a face
  91280. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  91281. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  91282. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91283. * @returns the VertexData of the box
  91284. */
  91285. static CreateTiledBox(options: {
  91286. pattern?: number;
  91287. width?: number;
  91288. height?: number;
  91289. depth?: number;
  91290. tileSize?: number;
  91291. tileWidth?: number;
  91292. tileHeight?: number;
  91293. alignHorizontal?: number;
  91294. alignVertical?: number;
  91295. faceUV?: Vector4[];
  91296. faceColors?: Color4[];
  91297. sideOrientation?: number;
  91298. }): VertexData;
  91299. /**
  91300. * Creates the VertexData for a tiled plane
  91301. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91302. * * pattern a limited pattern arrangement depending on the number
  91303. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  91304. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  91305. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  91306. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91307. * * 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)
  91308. * * 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)
  91309. * @returns the VertexData of the tiled plane
  91310. */
  91311. static CreateTiledPlane(options: {
  91312. pattern?: number;
  91313. tileSize?: number;
  91314. tileWidth?: number;
  91315. tileHeight?: number;
  91316. size?: number;
  91317. width?: number;
  91318. height?: number;
  91319. alignHorizontal?: number;
  91320. alignVertical?: number;
  91321. sideOrientation?: number;
  91322. frontUVs?: Vector4;
  91323. backUVs?: Vector4;
  91324. }): VertexData;
  91325. /**
  91326. * Creates the VertexData for an ellipsoid, defaults to a sphere
  91327. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91328. * * segments sets the number of horizontal strips optional, default 32
  91329. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  91330. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  91331. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  91332. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  91333. * * 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
  91334. * * 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
  91335. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91336. * * 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)
  91337. * * 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)
  91338. * @returns the VertexData of the ellipsoid
  91339. */
  91340. static CreateSphere(options: {
  91341. segments?: number;
  91342. diameter?: number;
  91343. diameterX?: number;
  91344. diameterY?: number;
  91345. diameterZ?: number;
  91346. arc?: number;
  91347. slice?: number;
  91348. sideOrientation?: number;
  91349. frontUVs?: Vector4;
  91350. backUVs?: Vector4;
  91351. }): VertexData;
  91352. /**
  91353. * Creates the VertexData for a cylinder, cone or prism
  91354. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91355. * * height sets the height (y direction) of the cylinder, optional, default 2
  91356. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  91357. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  91358. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  91359. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  91360. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  91361. * * 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
  91362. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91363. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91364. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  91365. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  91366. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91367. * * 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)
  91368. * * 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)
  91369. * @returns the VertexData of the cylinder, cone or prism
  91370. */
  91371. static CreateCylinder(options: {
  91372. height?: number;
  91373. diameterTop?: number;
  91374. diameterBottom?: number;
  91375. diameter?: number;
  91376. tessellation?: number;
  91377. subdivisions?: number;
  91378. arc?: number;
  91379. faceColors?: Color4[];
  91380. faceUV?: Vector4[];
  91381. hasRings?: boolean;
  91382. enclose?: boolean;
  91383. sideOrientation?: number;
  91384. frontUVs?: Vector4;
  91385. backUVs?: Vector4;
  91386. }): VertexData;
  91387. /**
  91388. * Creates the VertexData for a torus
  91389. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91390. * * diameter the diameter of the torus, optional default 1
  91391. * * thickness the diameter of the tube forming the torus, optional default 0.5
  91392. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  91393. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91394. * * 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)
  91395. * * 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)
  91396. * @returns the VertexData of the torus
  91397. */
  91398. static CreateTorus(options: {
  91399. diameter?: number;
  91400. thickness?: number;
  91401. tessellation?: number;
  91402. sideOrientation?: number;
  91403. frontUVs?: Vector4;
  91404. backUVs?: Vector4;
  91405. }): VertexData;
  91406. /**
  91407. * Creates the VertexData of the LineSystem
  91408. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  91409. * - lines an array of lines, each line being an array of successive Vector3
  91410. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  91411. * @returns the VertexData of the LineSystem
  91412. */
  91413. static CreateLineSystem(options: {
  91414. lines: Vector3[][];
  91415. colors?: Nullable<Color4[][]>;
  91416. }): VertexData;
  91417. /**
  91418. * Create the VertexData for a DashedLines
  91419. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  91420. * - points an array successive Vector3
  91421. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  91422. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  91423. * - dashNb the intended total number of dashes, optional, default 200
  91424. * @returns the VertexData for the DashedLines
  91425. */
  91426. static CreateDashedLines(options: {
  91427. points: Vector3[];
  91428. dashSize?: number;
  91429. gapSize?: number;
  91430. dashNb?: number;
  91431. }): VertexData;
  91432. /**
  91433. * Creates the VertexData for a Ground
  91434. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  91435. * - width the width (x direction) of the ground, optional, default 1
  91436. * - height the height (z direction) of the ground, optional, default 1
  91437. * - subdivisions the number of subdivisions per side, optional, default 1
  91438. * @returns the VertexData of the Ground
  91439. */
  91440. static CreateGround(options: {
  91441. width?: number;
  91442. height?: number;
  91443. subdivisions?: number;
  91444. subdivisionsX?: number;
  91445. subdivisionsY?: number;
  91446. }): VertexData;
  91447. /**
  91448. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  91449. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  91450. * * xmin the ground minimum X coordinate, optional, default -1
  91451. * * zmin the ground minimum Z coordinate, optional, default -1
  91452. * * xmax the ground maximum X coordinate, optional, default 1
  91453. * * zmax the ground maximum Z coordinate, optional, default 1
  91454. * * 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}
  91455. * * 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}
  91456. * @returns the VertexData of the TiledGround
  91457. */
  91458. static CreateTiledGround(options: {
  91459. xmin: number;
  91460. zmin: number;
  91461. xmax: number;
  91462. zmax: number;
  91463. subdivisions?: {
  91464. w: number;
  91465. h: number;
  91466. };
  91467. precision?: {
  91468. w: number;
  91469. h: number;
  91470. };
  91471. }): VertexData;
  91472. /**
  91473. * Creates the VertexData of the Ground designed from a heightmap
  91474. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  91475. * * width the width (x direction) of the ground
  91476. * * height the height (z direction) of the ground
  91477. * * subdivisions the number of subdivisions per side
  91478. * * minHeight the minimum altitude on the ground, optional, default 0
  91479. * * maxHeight the maximum altitude on the ground, optional default 1
  91480. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  91481. * * buffer the array holding the image color data
  91482. * * bufferWidth the width of image
  91483. * * bufferHeight the height of image
  91484. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  91485. * @returns the VertexData of the Ground designed from a heightmap
  91486. */
  91487. static CreateGroundFromHeightMap(options: {
  91488. width: number;
  91489. height: number;
  91490. subdivisions: number;
  91491. minHeight: number;
  91492. maxHeight: number;
  91493. colorFilter: Color3;
  91494. buffer: Uint8Array;
  91495. bufferWidth: number;
  91496. bufferHeight: number;
  91497. alphaFilter: number;
  91498. }): VertexData;
  91499. /**
  91500. * Creates the VertexData for a Plane
  91501. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  91502. * * size sets the width and height of the plane to the value of size, optional default 1
  91503. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  91504. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  91505. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91506. * * 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)
  91507. * * 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)
  91508. * @returns the VertexData of the box
  91509. */
  91510. static CreatePlane(options: {
  91511. size?: number;
  91512. width?: number;
  91513. height?: number;
  91514. sideOrientation?: number;
  91515. frontUVs?: Vector4;
  91516. backUVs?: Vector4;
  91517. }): VertexData;
  91518. /**
  91519. * Creates the VertexData of the Disc or regular Polygon
  91520. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  91521. * * radius the radius of the disc, optional default 0.5
  91522. * * tessellation the number of polygon sides, optional, default 64
  91523. * * 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
  91524. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91525. * * 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)
  91526. * * 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)
  91527. * @returns the VertexData of the box
  91528. */
  91529. static CreateDisc(options: {
  91530. radius?: number;
  91531. tessellation?: number;
  91532. arc?: number;
  91533. sideOrientation?: number;
  91534. frontUVs?: Vector4;
  91535. backUVs?: Vector4;
  91536. }): VertexData;
  91537. /**
  91538. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  91539. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  91540. * @param polygon a mesh built from polygonTriangulation.build()
  91541. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91542. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91543. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91544. * @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)
  91545. * @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)
  91546. * @returns the VertexData of the Polygon
  91547. */
  91548. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  91549. /**
  91550. * Creates the VertexData of the IcoSphere
  91551. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  91552. * * radius the radius of the IcoSphere, optional default 1
  91553. * * radiusX allows stretching in the x direction, optional, default radius
  91554. * * radiusY allows stretching in the y direction, optional, default radius
  91555. * * radiusZ allows stretching in the z direction, optional, default radius
  91556. * * flat when true creates a flat shaded mesh, optional, default true
  91557. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  91558. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91559. * * 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)
  91560. * * 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)
  91561. * @returns the VertexData of the IcoSphere
  91562. */
  91563. static CreateIcoSphere(options: {
  91564. radius?: number;
  91565. radiusX?: number;
  91566. radiusY?: number;
  91567. radiusZ?: number;
  91568. flat?: boolean;
  91569. subdivisions?: number;
  91570. sideOrientation?: number;
  91571. frontUVs?: Vector4;
  91572. backUVs?: Vector4;
  91573. }): VertexData;
  91574. /**
  91575. * Creates the VertexData for a Polyhedron
  91576. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  91577. * * type provided types are:
  91578. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  91579. * * 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)
  91580. * * size the size of the IcoSphere, optional default 1
  91581. * * sizeX allows stretching in the x direction, optional, default size
  91582. * * sizeY allows stretching in the y direction, optional, default size
  91583. * * sizeZ allows stretching in the z direction, optional, default size
  91584. * * 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
  91585. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91586. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91587. * * flat when true creates a flat shaded mesh, optional, default true
  91588. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  91589. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91590. * * 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)
  91591. * * 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)
  91592. * @returns the VertexData of the Polyhedron
  91593. */
  91594. static CreatePolyhedron(options: {
  91595. type?: number;
  91596. size?: number;
  91597. sizeX?: number;
  91598. sizeY?: number;
  91599. sizeZ?: number;
  91600. custom?: any;
  91601. faceUV?: Vector4[];
  91602. faceColors?: Color4[];
  91603. flat?: boolean;
  91604. sideOrientation?: number;
  91605. frontUVs?: Vector4;
  91606. backUVs?: Vector4;
  91607. }): VertexData;
  91608. /**
  91609. * Creates the VertexData for a TorusKnot
  91610. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  91611. * * radius the radius of the torus knot, optional, default 2
  91612. * * tube the thickness of the tube, optional, default 0.5
  91613. * * radialSegments the number of sides on each tube segments, optional, default 32
  91614. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  91615. * * p the number of windings around the z axis, optional, default 2
  91616. * * q the number of windings around the x axis, optional, default 3
  91617. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91618. * * 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)
  91619. * * 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)
  91620. * @returns the VertexData of the Torus Knot
  91621. */
  91622. static CreateTorusKnot(options: {
  91623. radius?: number;
  91624. tube?: number;
  91625. radialSegments?: number;
  91626. tubularSegments?: number;
  91627. p?: number;
  91628. q?: number;
  91629. sideOrientation?: number;
  91630. frontUVs?: Vector4;
  91631. backUVs?: Vector4;
  91632. }): VertexData;
  91633. /**
  91634. * Compute normals for given positions and indices
  91635. * @param positions an array of vertex positions, [...., x, y, z, ......]
  91636. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  91637. * @param normals an array of vertex normals, [...., x, y, z, ......]
  91638. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  91639. * * facetNormals : optional array of facet normals (vector3)
  91640. * * facetPositions : optional array of facet positions (vector3)
  91641. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  91642. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  91643. * * bInfo : optional bounding info, required for facetPartitioning computation
  91644. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  91645. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  91646. * * useRightHandedSystem: optional boolean to for right handed system computation
  91647. * * depthSort : optional boolean to enable the facet depth sort computation
  91648. * * distanceTo : optional Vector3 to compute the facet depth from this location
  91649. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  91650. */
  91651. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  91652. facetNormals?: any;
  91653. facetPositions?: any;
  91654. facetPartitioning?: any;
  91655. ratio?: number;
  91656. bInfo?: any;
  91657. bbSize?: Vector3;
  91658. subDiv?: any;
  91659. useRightHandedSystem?: boolean;
  91660. depthSort?: boolean;
  91661. distanceTo?: Vector3;
  91662. depthSortedFacets?: any;
  91663. }): void;
  91664. /** @hidden */
  91665. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  91666. /**
  91667. * Applies VertexData created from the imported parameters to the geometry
  91668. * @param parsedVertexData the parsed data from an imported file
  91669. * @param geometry the geometry to apply the VertexData to
  91670. */
  91671. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  91672. }
  91673. }
  91674. declare module BABYLON {
  91675. /**
  91676. * Defines a target to use with MorphTargetManager
  91677. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91678. */
  91679. export class MorphTarget implements IAnimatable {
  91680. /** defines the name of the target */
  91681. name: string;
  91682. /**
  91683. * Gets or sets the list of animations
  91684. */
  91685. animations: Animation[];
  91686. private _scene;
  91687. private _positions;
  91688. private _normals;
  91689. private _tangents;
  91690. private _uvs;
  91691. private _influence;
  91692. private _uniqueId;
  91693. /**
  91694. * Observable raised when the influence changes
  91695. */
  91696. onInfluenceChanged: Observable<boolean>;
  91697. /** @hidden */
  91698. _onDataLayoutChanged: Observable<void>;
  91699. /**
  91700. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  91701. */
  91702. influence: number;
  91703. /**
  91704. * Gets or sets the id of the morph Target
  91705. */
  91706. id: string;
  91707. private _animationPropertiesOverride;
  91708. /**
  91709. * Gets or sets the animation properties override
  91710. */
  91711. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91712. /**
  91713. * Creates a new MorphTarget
  91714. * @param name defines the name of the target
  91715. * @param influence defines the influence to use
  91716. * @param scene defines the scene the morphtarget belongs to
  91717. */
  91718. constructor(
  91719. /** defines the name of the target */
  91720. name: string, influence?: number, scene?: Nullable<Scene>);
  91721. /**
  91722. * Gets the unique ID of this manager
  91723. */
  91724. readonly uniqueId: number;
  91725. /**
  91726. * Gets a boolean defining if the target contains position data
  91727. */
  91728. readonly hasPositions: boolean;
  91729. /**
  91730. * Gets a boolean defining if the target contains normal data
  91731. */
  91732. readonly hasNormals: boolean;
  91733. /**
  91734. * Gets a boolean defining if the target contains tangent data
  91735. */
  91736. readonly hasTangents: boolean;
  91737. /**
  91738. * Gets a boolean defining if the target contains texture coordinates data
  91739. */
  91740. readonly hasUVs: boolean;
  91741. /**
  91742. * Affects position data to this target
  91743. * @param data defines the position data to use
  91744. */
  91745. setPositions(data: Nullable<FloatArray>): void;
  91746. /**
  91747. * Gets the position data stored in this target
  91748. * @returns a FloatArray containing the position data (or null if not present)
  91749. */
  91750. getPositions(): Nullable<FloatArray>;
  91751. /**
  91752. * Affects normal data to this target
  91753. * @param data defines the normal data to use
  91754. */
  91755. setNormals(data: Nullable<FloatArray>): void;
  91756. /**
  91757. * Gets the normal data stored in this target
  91758. * @returns a FloatArray containing the normal data (or null if not present)
  91759. */
  91760. getNormals(): Nullable<FloatArray>;
  91761. /**
  91762. * Affects tangent data to this target
  91763. * @param data defines the tangent data to use
  91764. */
  91765. setTangents(data: Nullable<FloatArray>): void;
  91766. /**
  91767. * Gets the tangent data stored in this target
  91768. * @returns a FloatArray containing the tangent data (or null if not present)
  91769. */
  91770. getTangents(): Nullable<FloatArray>;
  91771. /**
  91772. * Affects texture coordinates data to this target
  91773. * @param data defines the texture coordinates data to use
  91774. */
  91775. setUVs(data: Nullable<FloatArray>): void;
  91776. /**
  91777. * Gets the texture coordinates data stored in this target
  91778. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  91779. */
  91780. getUVs(): Nullable<FloatArray>;
  91781. /**
  91782. * Clone the current target
  91783. * @returns a new MorphTarget
  91784. */
  91785. clone(): MorphTarget;
  91786. /**
  91787. * Serializes the current target into a Serialization object
  91788. * @returns the serialized object
  91789. */
  91790. serialize(): any;
  91791. /**
  91792. * Returns the string "MorphTarget"
  91793. * @returns "MorphTarget"
  91794. */
  91795. getClassName(): string;
  91796. /**
  91797. * Creates a new target from serialized data
  91798. * @param serializationObject defines the serialized data to use
  91799. * @returns a new MorphTarget
  91800. */
  91801. static Parse(serializationObject: any): MorphTarget;
  91802. /**
  91803. * Creates a MorphTarget from mesh data
  91804. * @param mesh defines the source mesh
  91805. * @param name defines the name to use for the new target
  91806. * @param influence defines the influence to attach to the target
  91807. * @returns a new MorphTarget
  91808. */
  91809. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  91810. }
  91811. }
  91812. declare module BABYLON {
  91813. /**
  91814. * This class is used to deform meshes using morphing between different targets
  91815. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91816. */
  91817. export class MorphTargetManager {
  91818. private _targets;
  91819. private _targetInfluenceChangedObservers;
  91820. private _targetDataLayoutChangedObservers;
  91821. private _activeTargets;
  91822. private _scene;
  91823. private _influences;
  91824. private _supportsNormals;
  91825. private _supportsTangents;
  91826. private _supportsUVs;
  91827. private _vertexCount;
  91828. private _uniqueId;
  91829. private _tempInfluences;
  91830. /**
  91831. * Gets or sets a boolean indicating if normals must be morphed
  91832. */
  91833. enableNormalMorphing: boolean;
  91834. /**
  91835. * Gets or sets a boolean indicating if tangents must be morphed
  91836. */
  91837. enableTangentMorphing: boolean;
  91838. /**
  91839. * Gets or sets a boolean indicating if UV must be morphed
  91840. */
  91841. enableUVMorphing: boolean;
  91842. /**
  91843. * Creates a new MorphTargetManager
  91844. * @param scene defines the current scene
  91845. */
  91846. constructor(scene?: Nullable<Scene>);
  91847. /**
  91848. * Gets the unique ID of this manager
  91849. */
  91850. readonly uniqueId: number;
  91851. /**
  91852. * Gets the number of vertices handled by this manager
  91853. */
  91854. readonly vertexCount: number;
  91855. /**
  91856. * Gets a boolean indicating if this manager supports morphing of normals
  91857. */
  91858. readonly supportsNormals: boolean;
  91859. /**
  91860. * Gets a boolean indicating if this manager supports morphing of tangents
  91861. */
  91862. readonly supportsTangents: boolean;
  91863. /**
  91864. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  91865. */
  91866. readonly supportsUVs: boolean;
  91867. /**
  91868. * Gets the number of targets stored in this manager
  91869. */
  91870. readonly numTargets: number;
  91871. /**
  91872. * Gets the number of influencers (ie. the number of targets with influences > 0)
  91873. */
  91874. readonly numInfluencers: number;
  91875. /**
  91876. * Gets the list of influences (one per target)
  91877. */
  91878. readonly influences: Float32Array;
  91879. /**
  91880. * Gets the active target at specified index. An active target is a target with an influence > 0
  91881. * @param index defines the index to check
  91882. * @returns the requested target
  91883. */
  91884. getActiveTarget(index: number): MorphTarget;
  91885. /**
  91886. * Gets the target at specified index
  91887. * @param index defines the index to check
  91888. * @returns the requested target
  91889. */
  91890. getTarget(index: number): MorphTarget;
  91891. /**
  91892. * Add a new target to this manager
  91893. * @param target defines the target to add
  91894. */
  91895. addTarget(target: MorphTarget): void;
  91896. /**
  91897. * Removes a target from the manager
  91898. * @param target defines the target to remove
  91899. */
  91900. removeTarget(target: MorphTarget): void;
  91901. /**
  91902. * Clone the current manager
  91903. * @returns a new MorphTargetManager
  91904. */
  91905. clone(): MorphTargetManager;
  91906. /**
  91907. * Serializes the current manager into a Serialization object
  91908. * @returns the serialized object
  91909. */
  91910. serialize(): any;
  91911. private _syncActiveTargets;
  91912. /**
  91913. * Syncrhonize the targets with all the meshes using this morph target manager
  91914. */
  91915. synchronize(): void;
  91916. /**
  91917. * Creates a new MorphTargetManager from serialized data
  91918. * @param serializationObject defines the serialized data
  91919. * @param scene defines the hosting scene
  91920. * @returns the new MorphTargetManager
  91921. */
  91922. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  91923. }
  91924. }
  91925. declare module BABYLON {
  91926. /**
  91927. * Class used to represent a specific level of detail of a mesh
  91928. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  91929. */
  91930. export class MeshLODLevel {
  91931. /** Defines the distance where this level should start being displayed */
  91932. distance: number;
  91933. /** Defines the mesh to use to render this level */
  91934. mesh: Nullable<Mesh>;
  91935. /**
  91936. * Creates a new LOD level
  91937. * @param distance defines the distance where this level should star being displayed
  91938. * @param mesh defines the mesh to use to render this level
  91939. */
  91940. constructor(
  91941. /** Defines the distance where this level should start being displayed */
  91942. distance: number,
  91943. /** Defines the mesh to use to render this level */
  91944. mesh: Nullable<Mesh>);
  91945. }
  91946. }
  91947. declare module BABYLON {
  91948. /**
  91949. * Mesh representing the gorund
  91950. */
  91951. export class GroundMesh extends Mesh {
  91952. /** If octree should be generated */
  91953. generateOctree: boolean;
  91954. private _heightQuads;
  91955. /** @hidden */
  91956. _subdivisionsX: number;
  91957. /** @hidden */
  91958. _subdivisionsY: number;
  91959. /** @hidden */
  91960. _width: number;
  91961. /** @hidden */
  91962. _height: number;
  91963. /** @hidden */
  91964. _minX: number;
  91965. /** @hidden */
  91966. _maxX: number;
  91967. /** @hidden */
  91968. _minZ: number;
  91969. /** @hidden */
  91970. _maxZ: number;
  91971. constructor(name: string, scene: Scene);
  91972. /**
  91973. * "GroundMesh"
  91974. * @returns "GroundMesh"
  91975. */
  91976. getClassName(): string;
  91977. /**
  91978. * The minimum of x and y subdivisions
  91979. */
  91980. readonly subdivisions: number;
  91981. /**
  91982. * X subdivisions
  91983. */
  91984. readonly subdivisionsX: number;
  91985. /**
  91986. * Y subdivisions
  91987. */
  91988. readonly subdivisionsY: number;
  91989. /**
  91990. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  91991. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  91992. * @param chunksCount the number of subdivisions for x and y
  91993. * @param octreeBlocksSize (Default: 32)
  91994. */
  91995. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  91996. /**
  91997. * Returns a height (y) value in the Worl system :
  91998. * the ground altitude at the coordinates (x, z) expressed in the World system.
  91999. * @param x x coordinate
  92000. * @param z z coordinate
  92001. * @returns the ground y position if (x, z) are outside the ground surface.
  92002. */
  92003. getHeightAtCoordinates(x: number, z: number): number;
  92004. /**
  92005. * Returns a normalized vector (Vector3) orthogonal to the ground
  92006. * at the ground coordinates (x, z) expressed in the World system.
  92007. * @param x x coordinate
  92008. * @param z z coordinate
  92009. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  92010. */
  92011. getNormalAtCoordinates(x: number, z: number): Vector3;
  92012. /**
  92013. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  92014. * at the ground coordinates (x, z) expressed in the World system.
  92015. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  92016. * @param x x coordinate
  92017. * @param z z coordinate
  92018. * @param ref vector to store the result
  92019. * @returns the GroundMesh.
  92020. */
  92021. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  92022. /**
  92023. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  92024. * if the ground has been updated.
  92025. * This can be used in the render loop.
  92026. * @returns the GroundMesh.
  92027. */
  92028. updateCoordinateHeights(): GroundMesh;
  92029. private _getFacetAt;
  92030. private _initHeightQuads;
  92031. private _computeHeightQuads;
  92032. /**
  92033. * Serializes this ground mesh
  92034. * @param serializationObject object to write serialization to
  92035. */
  92036. serialize(serializationObject: any): void;
  92037. /**
  92038. * Parses a serialized ground mesh
  92039. * @param parsedMesh the serialized mesh
  92040. * @param scene the scene to create the ground mesh in
  92041. * @returns the created ground mesh
  92042. */
  92043. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  92044. }
  92045. }
  92046. declare module BABYLON {
  92047. /**
  92048. * Interface for Physics-Joint data
  92049. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92050. */
  92051. export interface PhysicsJointData {
  92052. /**
  92053. * The main pivot of the joint
  92054. */
  92055. mainPivot?: Vector3;
  92056. /**
  92057. * The connected pivot of the joint
  92058. */
  92059. connectedPivot?: Vector3;
  92060. /**
  92061. * The main axis of the joint
  92062. */
  92063. mainAxis?: Vector3;
  92064. /**
  92065. * The connected axis of the joint
  92066. */
  92067. connectedAxis?: Vector3;
  92068. /**
  92069. * The collision of the joint
  92070. */
  92071. collision?: boolean;
  92072. /**
  92073. * Native Oimo/Cannon/Energy data
  92074. */
  92075. nativeParams?: any;
  92076. }
  92077. /**
  92078. * This is a holder class for the physics joint created by the physics plugin
  92079. * It holds a set of functions to control the underlying joint
  92080. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92081. */
  92082. export class PhysicsJoint {
  92083. /**
  92084. * The type of the physics joint
  92085. */
  92086. type: number;
  92087. /**
  92088. * The data for the physics joint
  92089. */
  92090. jointData: PhysicsJointData;
  92091. private _physicsJoint;
  92092. protected _physicsPlugin: IPhysicsEnginePlugin;
  92093. /**
  92094. * Initializes the physics joint
  92095. * @param type The type of the physics joint
  92096. * @param jointData The data for the physics joint
  92097. */
  92098. constructor(
  92099. /**
  92100. * The type of the physics joint
  92101. */
  92102. type: number,
  92103. /**
  92104. * The data for the physics joint
  92105. */
  92106. jointData: PhysicsJointData);
  92107. /**
  92108. * Gets the physics joint
  92109. */
  92110. /**
  92111. * Sets the physics joint
  92112. */
  92113. physicsJoint: any;
  92114. /**
  92115. * Sets the physics plugin
  92116. */
  92117. physicsPlugin: IPhysicsEnginePlugin;
  92118. /**
  92119. * Execute a function that is physics-plugin specific.
  92120. * @param {Function} func the function that will be executed.
  92121. * It accepts two parameters: the physics world and the physics joint
  92122. */
  92123. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  92124. /**
  92125. * Distance-Joint type
  92126. */
  92127. static DistanceJoint: number;
  92128. /**
  92129. * Hinge-Joint type
  92130. */
  92131. static HingeJoint: number;
  92132. /**
  92133. * Ball-and-Socket joint type
  92134. */
  92135. static BallAndSocketJoint: number;
  92136. /**
  92137. * Wheel-Joint type
  92138. */
  92139. static WheelJoint: number;
  92140. /**
  92141. * Slider-Joint type
  92142. */
  92143. static SliderJoint: number;
  92144. /**
  92145. * Prismatic-Joint type
  92146. */
  92147. static PrismaticJoint: number;
  92148. /**
  92149. * Universal-Joint type
  92150. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  92151. */
  92152. static UniversalJoint: number;
  92153. /**
  92154. * Hinge-Joint 2 type
  92155. */
  92156. static Hinge2Joint: number;
  92157. /**
  92158. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  92159. */
  92160. static PointToPointJoint: number;
  92161. /**
  92162. * Spring-Joint type
  92163. */
  92164. static SpringJoint: number;
  92165. /**
  92166. * Lock-Joint type
  92167. */
  92168. static LockJoint: number;
  92169. }
  92170. /**
  92171. * A class representing a physics distance joint
  92172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92173. */
  92174. export class DistanceJoint extends PhysicsJoint {
  92175. /**
  92176. *
  92177. * @param jointData The data for the Distance-Joint
  92178. */
  92179. constructor(jointData: DistanceJointData);
  92180. /**
  92181. * Update the predefined distance.
  92182. * @param maxDistance The maximum preferred distance
  92183. * @param minDistance The minimum preferred distance
  92184. */
  92185. updateDistance(maxDistance: number, minDistance?: number): void;
  92186. }
  92187. /**
  92188. * Represents a Motor-Enabled Joint
  92189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92190. */
  92191. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  92192. /**
  92193. * Initializes the Motor-Enabled Joint
  92194. * @param type The type of the joint
  92195. * @param jointData The physica joint data for the joint
  92196. */
  92197. constructor(type: number, jointData: PhysicsJointData);
  92198. /**
  92199. * Set the motor values.
  92200. * Attention, this function is plugin specific. Engines won't react 100% the same.
  92201. * @param force the force to apply
  92202. * @param maxForce max force for this motor.
  92203. */
  92204. setMotor(force?: number, maxForce?: number): void;
  92205. /**
  92206. * Set the motor's limits.
  92207. * Attention, this function is plugin specific. Engines won't react 100% the same.
  92208. * @param upperLimit The upper limit of the motor
  92209. * @param lowerLimit The lower limit of the motor
  92210. */
  92211. setLimit(upperLimit: number, lowerLimit?: number): void;
  92212. }
  92213. /**
  92214. * This class represents a single physics Hinge-Joint
  92215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92216. */
  92217. export class HingeJoint extends MotorEnabledJoint {
  92218. /**
  92219. * Initializes the Hinge-Joint
  92220. * @param jointData The joint data for the Hinge-Joint
  92221. */
  92222. constructor(jointData: PhysicsJointData);
  92223. /**
  92224. * Set the motor values.
  92225. * Attention, this function is plugin specific. Engines won't react 100% the same.
  92226. * @param {number} force the force to apply
  92227. * @param {number} maxForce max force for this motor.
  92228. */
  92229. setMotor(force?: number, maxForce?: number): void;
  92230. /**
  92231. * Set the motor's limits.
  92232. * Attention, this function is plugin specific. Engines won't react 100% the same.
  92233. * @param upperLimit The upper limit of the motor
  92234. * @param lowerLimit The lower limit of the motor
  92235. */
  92236. setLimit(upperLimit: number, lowerLimit?: number): void;
  92237. }
  92238. /**
  92239. * This class represents a dual hinge physics joint (same as wheel joint)
  92240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92241. */
  92242. export class Hinge2Joint extends MotorEnabledJoint {
  92243. /**
  92244. * Initializes the Hinge2-Joint
  92245. * @param jointData The joint data for the Hinge2-Joint
  92246. */
  92247. constructor(jointData: PhysicsJointData);
  92248. /**
  92249. * Set the motor values.
  92250. * Attention, this function is plugin specific. Engines won't react 100% the same.
  92251. * @param {number} targetSpeed the speed the motor is to reach
  92252. * @param {number} maxForce max force for this motor.
  92253. * @param {motorIndex} the motor's index, 0 or 1.
  92254. */
  92255. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  92256. /**
  92257. * Set the motor limits.
  92258. * Attention, this function is plugin specific. Engines won't react 100% the same.
  92259. * @param {number} upperLimit the upper limit
  92260. * @param {number} lowerLimit lower limit
  92261. * @param {motorIndex} the motor's index, 0 or 1.
  92262. */
  92263. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  92264. }
  92265. /**
  92266. * Interface for a motor enabled joint
  92267. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92268. */
  92269. export interface IMotorEnabledJoint {
  92270. /**
  92271. * Physics joint
  92272. */
  92273. physicsJoint: any;
  92274. /**
  92275. * Sets the motor of the motor-enabled joint
  92276. * @param force The force of the motor
  92277. * @param maxForce The maximum force of the motor
  92278. * @param motorIndex The index of the motor
  92279. */
  92280. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  92281. /**
  92282. * Sets the limit of the motor
  92283. * @param upperLimit The upper limit of the motor
  92284. * @param lowerLimit The lower limit of the motor
  92285. * @param motorIndex The index of the motor
  92286. */
  92287. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  92288. }
  92289. /**
  92290. * Joint data for a Distance-Joint
  92291. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92292. */
  92293. export interface DistanceJointData extends PhysicsJointData {
  92294. /**
  92295. * Max distance the 2 joint objects can be apart
  92296. */
  92297. maxDistance: number;
  92298. }
  92299. /**
  92300. * Joint data from a spring joint
  92301. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92302. */
  92303. export interface SpringJointData extends PhysicsJointData {
  92304. /**
  92305. * Length of the spring
  92306. */
  92307. length: number;
  92308. /**
  92309. * Stiffness of the spring
  92310. */
  92311. stiffness: number;
  92312. /**
  92313. * Damping of the spring
  92314. */
  92315. damping: number;
  92316. /** this callback will be called when applying the force to the impostors. */
  92317. forceApplicationCallback: () => void;
  92318. }
  92319. }
  92320. declare module BABYLON {
  92321. /**
  92322. * Holds the data for the raycast result
  92323. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92324. */
  92325. export class PhysicsRaycastResult {
  92326. private _hasHit;
  92327. private _hitDistance;
  92328. private _hitNormalWorld;
  92329. private _hitPointWorld;
  92330. private _rayFromWorld;
  92331. private _rayToWorld;
  92332. /**
  92333. * Gets if there was a hit
  92334. */
  92335. readonly hasHit: boolean;
  92336. /**
  92337. * Gets the distance from the hit
  92338. */
  92339. readonly hitDistance: number;
  92340. /**
  92341. * Gets the hit normal/direction in the world
  92342. */
  92343. readonly hitNormalWorld: Vector3;
  92344. /**
  92345. * Gets the hit point in the world
  92346. */
  92347. readonly hitPointWorld: Vector3;
  92348. /**
  92349. * Gets the ray "start point" of the ray in the world
  92350. */
  92351. readonly rayFromWorld: Vector3;
  92352. /**
  92353. * Gets the ray "end point" of the ray in the world
  92354. */
  92355. readonly rayToWorld: Vector3;
  92356. /**
  92357. * Sets the hit data (normal & point in world space)
  92358. * @param hitNormalWorld defines the normal in world space
  92359. * @param hitPointWorld defines the point in world space
  92360. */
  92361. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  92362. /**
  92363. * Sets the distance from the start point to the hit point
  92364. * @param distance
  92365. */
  92366. setHitDistance(distance: number): void;
  92367. /**
  92368. * Calculates the distance manually
  92369. */
  92370. calculateHitDistance(): void;
  92371. /**
  92372. * Resets all the values to default
  92373. * @param from The from point on world space
  92374. * @param to The to point on world space
  92375. */
  92376. reset(from?: Vector3, to?: Vector3): void;
  92377. }
  92378. /**
  92379. * Interface for the size containing width and height
  92380. */
  92381. interface IXYZ {
  92382. /**
  92383. * X
  92384. */
  92385. x: number;
  92386. /**
  92387. * Y
  92388. */
  92389. y: number;
  92390. /**
  92391. * Z
  92392. */
  92393. z: number;
  92394. }
  92395. }
  92396. declare module BABYLON {
  92397. /**
  92398. * Interface used to describe a physics joint
  92399. */
  92400. export interface PhysicsImpostorJoint {
  92401. /** Defines the main impostor to which the joint is linked */
  92402. mainImpostor: PhysicsImpostor;
  92403. /** Defines the impostor that is connected to the main impostor using this joint */
  92404. connectedImpostor: PhysicsImpostor;
  92405. /** Defines the joint itself */
  92406. joint: PhysicsJoint;
  92407. }
  92408. /** @hidden */
  92409. export interface IPhysicsEnginePlugin {
  92410. world: any;
  92411. name: string;
  92412. setGravity(gravity: Vector3): void;
  92413. setTimeStep(timeStep: number): void;
  92414. getTimeStep(): number;
  92415. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  92416. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  92417. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  92418. generatePhysicsBody(impostor: PhysicsImpostor): void;
  92419. removePhysicsBody(impostor: PhysicsImpostor): void;
  92420. generateJoint(joint: PhysicsImpostorJoint): void;
  92421. removeJoint(joint: PhysicsImpostorJoint): void;
  92422. isSupported(): boolean;
  92423. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  92424. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  92425. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  92426. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  92427. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  92428. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  92429. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  92430. getBodyMass(impostor: PhysicsImpostor): number;
  92431. getBodyFriction(impostor: PhysicsImpostor): number;
  92432. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  92433. getBodyRestitution(impostor: PhysicsImpostor): number;
  92434. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  92435. getBodyPressure?(impostor: PhysicsImpostor): number;
  92436. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  92437. getBodyStiffness?(impostor: PhysicsImpostor): number;
  92438. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  92439. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  92440. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  92441. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  92442. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  92443. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  92444. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  92445. sleepBody(impostor: PhysicsImpostor): void;
  92446. wakeUpBody(impostor: PhysicsImpostor): void;
  92447. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  92448. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  92449. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  92450. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  92451. getRadius(impostor: PhysicsImpostor): number;
  92452. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  92453. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  92454. dispose(): void;
  92455. }
  92456. /**
  92457. * Interface used to define a physics engine
  92458. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  92459. */
  92460. export interface IPhysicsEngine {
  92461. /**
  92462. * Gets the gravity vector used by the simulation
  92463. */
  92464. gravity: Vector3;
  92465. /**
  92466. * Sets the gravity vector used by the simulation
  92467. * @param gravity defines the gravity vector to use
  92468. */
  92469. setGravity(gravity: Vector3): void;
  92470. /**
  92471. * Set the time step of the physics engine.
  92472. * Default is 1/60.
  92473. * To slow it down, enter 1/600 for example.
  92474. * To speed it up, 1/30
  92475. * @param newTimeStep the new timestep to apply to this world.
  92476. */
  92477. setTimeStep(newTimeStep: number): void;
  92478. /**
  92479. * Get the time step of the physics engine.
  92480. * @returns the current time step
  92481. */
  92482. getTimeStep(): number;
  92483. /**
  92484. * Set the sub time step of the physics engine.
  92485. * Default is 0 meaning there is no sub steps
  92486. * To increase physics resolution precision, set a small value (like 1 ms)
  92487. * @param subTimeStep defines the new sub timestep used for physics resolution.
  92488. */
  92489. setSubTimeStep(subTimeStep: number): void;
  92490. /**
  92491. * Get the sub time step of the physics engine.
  92492. * @returns the current sub time step
  92493. */
  92494. getSubTimeStep(): number;
  92495. /**
  92496. * Release all resources
  92497. */
  92498. dispose(): void;
  92499. /**
  92500. * Gets the name of the current physics plugin
  92501. * @returns the name of the plugin
  92502. */
  92503. getPhysicsPluginName(): string;
  92504. /**
  92505. * Adding a new impostor for the impostor tracking.
  92506. * This will be done by the impostor itself.
  92507. * @param impostor the impostor to add
  92508. */
  92509. addImpostor(impostor: PhysicsImpostor): void;
  92510. /**
  92511. * Remove an impostor from the engine.
  92512. * This impostor and its mesh will not longer be updated by the physics engine.
  92513. * @param impostor the impostor to remove
  92514. */
  92515. removeImpostor(impostor: PhysicsImpostor): void;
  92516. /**
  92517. * Add a joint to the physics engine
  92518. * @param mainImpostor defines the main impostor to which the joint is added.
  92519. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  92520. * @param joint defines the joint that will connect both impostors.
  92521. */
  92522. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  92523. /**
  92524. * Removes a joint from the simulation
  92525. * @param mainImpostor defines the impostor used with the joint
  92526. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  92527. * @param joint defines the joint to remove
  92528. */
  92529. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  92530. /**
  92531. * Gets the current plugin used to run the simulation
  92532. * @returns current plugin
  92533. */
  92534. getPhysicsPlugin(): IPhysicsEnginePlugin;
  92535. /**
  92536. * Gets the list of physic impostors
  92537. * @returns an array of PhysicsImpostor
  92538. */
  92539. getImpostors(): Array<PhysicsImpostor>;
  92540. /**
  92541. * Gets the impostor for a physics enabled object
  92542. * @param object defines the object impersonated by the impostor
  92543. * @returns the PhysicsImpostor or null if not found
  92544. */
  92545. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  92546. /**
  92547. * Gets the impostor for a physics body object
  92548. * @param body defines physics body used by the impostor
  92549. * @returns the PhysicsImpostor or null if not found
  92550. */
  92551. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  92552. /**
  92553. * Does a raycast in the physics world
  92554. * @param from when should the ray start?
  92555. * @param to when should the ray end?
  92556. * @returns PhysicsRaycastResult
  92557. */
  92558. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  92559. /**
  92560. * Called by the scene. No need to call it.
  92561. * @param delta defines the timespam between frames
  92562. */
  92563. _step(delta: number): void;
  92564. }
  92565. }
  92566. declare module BABYLON {
  92567. /**
  92568. * The interface for the physics imposter parameters
  92569. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92570. */
  92571. export interface PhysicsImpostorParameters {
  92572. /**
  92573. * The mass of the physics imposter
  92574. */
  92575. mass: number;
  92576. /**
  92577. * The friction of the physics imposter
  92578. */
  92579. friction?: number;
  92580. /**
  92581. * The coefficient of restitution of the physics imposter
  92582. */
  92583. restitution?: number;
  92584. /**
  92585. * The native options of the physics imposter
  92586. */
  92587. nativeOptions?: any;
  92588. /**
  92589. * Specifies if the parent should be ignored
  92590. */
  92591. ignoreParent?: boolean;
  92592. /**
  92593. * Specifies if bi-directional transformations should be disabled
  92594. */
  92595. disableBidirectionalTransformation?: boolean;
  92596. /**
  92597. * The pressure inside the physics imposter, soft object only
  92598. */
  92599. pressure?: number;
  92600. /**
  92601. * The stiffness the physics imposter, soft object only
  92602. */
  92603. stiffness?: number;
  92604. /**
  92605. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  92606. */
  92607. velocityIterations?: number;
  92608. /**
  92609. * The number of iterations used in maintaining consistent vertex positions, soft object only
  92610. */
  92611. positionIterations?: number;
  92612. /**
  92613. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  92614. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  92615. * Add to fix multiple points
  92616. */
  92617. fixedPoints?: number;
  92618. /**
  92619. * The collision margin around a soft object
  92620. */
  92621. margin?: number;
  92622. /**
  92623. * The collision margin around a soft object
  92624. */
  92625. damping?: number;
  92626. /**
  92627. * The path for a rope based on an extrusion
  92628. */
  92629. path?: any;
  92630. /**
  92631. * The shape of an extrusion used for a rope based on an extrusion
  92632. */
  92633. shape?: any;
  92634. }
  92635. /**
  92636. * Interface for a physics-enabled object
  92637. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92638. */
  92639. export interface IPhysicsEnabledObject {
  92640. /**
  92641. * The position of the physics-enabled object
  92642. */
  92643. position: Vector3;
  92644. /**
  92645. * The rotation of the physics-enabled object
  92646. */
  92647. rotationQuaternion: Nullable<Quaternion>;
  92648. /**
  92649. * The scale of the physics-enabled object
  92650. */
  92651. scaling: Vector3;
  92652. /**
  92653. * The rotation of the physics-enabled object
  92654. */
  92655. rotation?: Vector3;
  92656. /**
  92657. * The parent of the physics-enabled object
  92658. */
  92659. parent?: any;
  92660. /**
  92661. * The bounding info of the physics-enabled object
  92662. * @returns The bounding info of the physics-enabled object
  92663. */
  92664. getBoundingInfo(): BoundingInfo;
  92665. /**
  92666. * Computes the world matrix
  92667. * @param force Specifies if the world matrix should be computed by force
  92668. * @returns A world matrix
  92669. */
  92670. computeWorldMatrix(force: boolean): Matrix;
  92671. /**
  92672. * Gets the world matrix
  92673. * @returns A world matrix
  92674. */
  92675. getWorldMatrix?(): Matrix;
  92676. /**
  92677. * Gets the child meshes
  92678. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  92679. * @returns An array of abstract meshes
  92680. */
  92681. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  92682. /**
  92683. * Gets the vertex data
  92684. * @param kind The type of vertex data
  92685. * @returns A nullable array of numbers, or a float32 array
  92686. */
  92687. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  92688. /**
  92689. * Gets the indices from the mesh
  92690. * @returns A nullable array of index arrays
  92691. */
  92692. getIndices?(): Nullable<IndicesArray>;
  92693. /**
  92694. * Gets the scene from the mesh
  92695. * @returns the indices array or null
  92696. */
  92697. getScene?(): Scene;
  92698. /**
  92699. * Gets the absolute position from the mesh
  92700. * @returns the absolute position
  92701. */
  92702. getAbsolutePosition(): Vector3;
  92703. /**
  92704. * Gets the absolute pivot point from the mesh
  92705. * @returns the absolute pivot point
  92706. */
  92707. getAbsolutePivotPoint(): Vector3;
  92708. /**
  92709. * Rotates the mesh
  92710. * @param axis The axis of rotation
  92711. * @param amount The amount of rotation
  92712. * @param space The space of the rotation
  92713. * @returns The rotation transform node
  92714. */
  92715. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  92716. /**
  92717. * Translates the mesh
  92718. * @param axis The axis of translation
  92719. * @param distance The distance of translation
  92720. * @param space The space of the translation
  92721. * @returns The transform node
  92722. */
  92723. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  92724. /**
  92725. * Sets the absolute position of the mesh
  92726. * @param absolutePosition The absolute position of the mesh
  92727. * @returns The transform node
  92728. */
  92729. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  92730. /**
  92731. * Gets the class name of the mesh
  92732. * @returns The class name
  92733. */
  92734. getClassName(): string;
  92735. }
  92736. /**
  92737. * Represents a physics imposter
  92738. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92739. */
  92740. export class PhysicsImpostor {
  92741. /**
  92742. * The physics-enabled object used as the physics imposter
  92743. */
  92744. object: IPhysicsEnabledObject;
  92745. /**
  92746. * The type of the physics imposter
  92747. */
  92748. type: number;
  92749. private _options;
  92750. private _scene?;
  92751. /**
  92752. * The default object size of the imposter
  92753. */
  92754. static DEFAULT_OBJECT_SIZE: Vector3;
  92755. /**
  92756. * The identity quaternion of the imposter
  92757. */
  92758. static IDENTITY_QUATERNION: Quaternion;
  92759. /** @hidden */
  92760. _pluginData: any;
  92761. private _physicsEngine;
  92762. private _physicsBody;
  92763. private _bodyUpdateRequired;
  92764. private _onBeforePhysicsStepCallbacks;
  92765. private _onAfterPhysicsStepCallbacks;
  92766. /** @hidden */
  92767. _onPhysicsCollideCallbacks: Array<{
  92768. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  92769. otherImpostors: Array<PhysicsImpostor>;
  92770. }>;
  92771. private _deltaPosition;
  92772. private _deltaRotation;
  92773. private _deltaRotationConjugated;
  92774. /** @hidden */
  92775. _isFromLine: boolean;
  92776. private _parent;
  92777. private _isDisposed;
  92778. private static _tmpVecs;
  92779. private static _tmpQuat;
  92780. /**
  92781. * Specifies if the physics imposter is disposed
  92782. */
  92783. readonly isDisposed: boolean;
  92784. /**
  92785. * Gets the mass of the physics imposter
  92786. */
  92787. mass: number;
  92788. /**
  92789. * Gets the coefficient of friction
  92790. */
  92791. /**
  92792. * Sets the coefficient of friction
  92793. */
  92794. friction: number;
  92795. /**
  92796. * Gets the coefficient of restitution
  92797. */
  92798. /**
  92799. * Sets the coefficient of restitution
  92800. */
  92801. restitution: number;
  92802. /**
  92803. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  92804. */
  92805. /**
  92806. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  92807. */
  92808. pressure: number;
  92809. /**
  92810. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  92811. */
  92812. /**
  92813. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  92814. */
  92815. stiffness: number;
  92816. /**
  92817. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  92818. */
  92819. /**
  92820. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  92821. */
  92822. velocityIterations: number;
  92823. /**
  92824. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  92825. */
  92826. /**
  92827. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  92828. */
  92829. positionIterations: number;
  92830. /**
  92831. * The unique id of the physics imposter
  92832. * set by the physics engine when adding this impostor to the array
  92833. */
  92834. uniqueId: number;
  92835. /**
  92836. * @hidden
  92837. */
  92838. soft: boolean;
  92839. /**
  92840. * @hidden
  92841. */
  92842. segments: number;
  92843. private _joints;
  92844. /**
  92845. * Initializes the physics imposter
  92846. * @param object The physics-enabled object used as the physics imposter
  92847. * @param type The type of the physics imposter
  92848. * @param _options The options for the physics imposter
  92849. * @param _scene The Babylon scene
  92850. */
  92851. constructor(
  92852. /**
  92853. * The physics-enabled object used as the physics imposter
  92854. */
  92855. object: IPhysicsEnabledObject,
  92856. /**
  92857. * The type of the physics imposter
  92858. */
  92859. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  92860. /**
  92861. * This function will completly initialize this impostor.
  92862. * It will create a new body - but only if this mesh has no parent.
  92863. * If it has, this impostor will not be used other than to define the impostor
  92864. * of the child mesh.
  92865. * @hidden
  92866. */
  92867. _init(): void;
  92868. private _getPhysicsParent;
  92869. /**
  92870. * Should a new body be generated.
  92871. * @returns boolean specifying if body initialization is required
  92872. */
  92873. isBodyInitRequired(): boolean;
  92874. /**
  92875. * Sets the updated scaling
  92876. * @param updated Specifies if the scaling is updated
  92877. */
  92878. setScalingUpdated(): void;
  92879. /**
  92880. * Force a regeneration of this or the parent's impostor's body.
  92881. * Use under cautious - This will remove all joints already implemented.
  92882. */
  92883. forceUpdate(): void;
  92884. /**
  92885. * Gets the body that holds this impostor. Either its own, or its parent.
  92886. */
  92887. /**
  92888. * Set the physics body. Used mainly by the physics engine/plugin
  92889. */
  92890. physicsBody: any;
  92891. /**
  92892. * Get the parent of the physics imposter
  92893. * @returns Physics imposter or null
  92894. */
  92895. /**
  92896. * Sets the parent of the physics imposter
  92897. */
  92898. parent: Nullable<PhysicsImpostor>;
  92899. /**
  92900. * Resets the update flags
  92901. */
  92902. resetUpdateFlags(): void;
  92903. /**
  92904. * Gets the object extend size
  92905. * @returns the object extend size
  92906. */
  92907. getObjectExtendSize(): Vector3;
  92908. /**
  92909. * Gets the object center
  92910. * @returns The object center
  92911. */
  92912. getObjectCenter(): Vector3;
  92913. /**
  92914. * Get a specific parametes from the options parameter
  92915. * @param paramName The object parameter name
  92916. * @returns The object parameter
  92917. */
  92918. getParam(paramName: string): any;
  92919. /**
  92920. * Sets a specific parameter in the options given to the physics plugin
  92921. * @param paramName The parameter name
  92922. * @param value The value of the parameter
  92923. */
  92924. setParam(paramName: string, value: number): void;
  92925. /**
  92926. * Specifically change the body's mass option. Won't recreate the physics body object
  92927. * @param mass The mass of the physics imposter
  92928. */
  92929. setMass(mass: number): void;
  92930. /**
  92931. * Gets the linear velocity
  92932. * @returns linear velocity or null
  92933. */
  92934. getLinearVelocity(): Nullable<Vector3>;
  92935. /**
  92936. * Sets the linear velocity
  92937. * @param velocity linear velocity or null
  92938. */
  92939. setLinearVelocity(velocity: Nullable<Vector3>): void;
  92940. /**
  92941. * Gets the angular velocity
  92942. * @returns angular velocity or null
  92943. */
  92944. getAngularVelocity(): Nullable<Vector3>;
  92945. /**
  92946. * Sets the angular velocity
  92947. * @param velocity The velocity or null
  92948. */
  92949. setAngularVelocity(velocity: Nullable<Vector3>): void;
  92950. /**
  92951. * Execute a function with the physics plugin native code
  92952. * Provide a function the will have two variables - the world object and the physics body object
  92953. * @param func The function to execute with the physics plugin native code
  92954. */
  92955. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  92956. /**
  92957. * Register a function that will be executed before the physics world is stepping forward
  92958. * @param func The function to execute before the physics world is stepped forward
  92959. */
  92960. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92961. /**
  92962. * Unregister a function that will be executed before the physics world is stepping forward
  92963. * @param func The function to execute before the physics world is stepped forward
  92964. */
  92965. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92966. /**
  92967. * Register a function that will be executed after the physics step
  92968. * @param func The function to execute after physics step
  92969. */
  92970. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92971. /**
  92972. * Unregisters a function that will be executed after the physics step
  92973. * @param func The function to execute after physics step
  92974. */
  92975. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92976. /**
  92977. * register a function that will be executed when this impostor collides against a different body
  92978. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  92979. * @param func Callback that is executed on collision
  92980. */
  92981. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  92982. /**
  92983. * Unregisters the physics imposter on contact
  92984. * @param collideAgainst The physics object to collide against
  92985. * @param func Callback to execute on collision
  92986. */
  92987. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  92988. private _tmpQuat;
  92989. private _tmpQuat2;
  92990. /**
  92991. * Get the parent rotation
  92992. * @returns The parent rotation
  92993. */
  92994. getParentsRotation(): Quaternion;
  92995. /**
  92996. * this function is executed by the physics engine.
  92997. */
  92998. beforeStep: () => void;
  92999. /**
  93000. * this function is executed by the physics engine
  93001. */
  93002. afterStep: () => void;
  93003. /**
  93004. * Legacy collision detection event support
  93005. */
  93006. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  93007. /**
  93008. * event and body object due to cannon's event-based architecture.
  93009. */
  93010. onCollide: (e: {
  93011. body: any;
  93012. }) => void;
  93013. /**
  93014. * Apply a force
  93015. * @param force The force to apply
  93016. * @param contactPoint The contact point for the force
  93017. * @returns The physics imposter
  93018. */
  93019. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  93020. /**
  93021. * Apply an impulse
  93022. * @param force The impulse force
  93023. * @param contactPoint The contact point for the impulse force
  93024. * @returns The physics imposter
  93025. */
  93026. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  93027. /**
  93028. * A help function to create a joint
  93029. * @param otherImpostor A physics imposter used to create a joint
  93030. * @param jointType The type of joint
  93031. * @param jointData The data for the joint
  93032. * @returns The physics imposter
  93033. */
  93034. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  93035. /**
  93036. * Add a joint to this impostor with a different impostor
  93037. * @param otherImpostor A physics imposter used to add a joint
  93038. * @param joint The joint to add
  93039. * @returns The physics imposter
  93040. */
  93041. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  93042. /**
  93043. * Add an anchor to a cloth impostor
  93044. * @param otherImpostor rigid impostor to anchor to
  93045. * @param width ratio across width from 0 to 1
  93046. * @param height ratio up height from 0 to 1
  93047. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  93048. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  93049. * @returns impostor the soft imposter
  93050. */
  93051. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  93052. /**
  93053. * Add a hook to a rope impostor
  93054. * @param otherImpostor rigid impostor to anchor to
  93055. * @param length ratio across rope from 0 to 1
  93056. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  93057. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  93058. * @returns impostor the rope imposter
  93059. */
  93060. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  93061. /**
  93062. * Will keep this body still, in a sleep mode.
  93063. * @returns the physics imposter
  93064. */
  93065. sleep(): PhysicsImpostor;
  93066. /**
  93067. * Wake the body up.
  93068. * @returns The physics imposter
  93069. */
  93070. wakeUp(): PhysicsImpostor;
  93071. /**
  93072. * Clones the physics imposter
  93073. * @param newObject The physics imposter clones to this physics-enabled object
  93074. * @returns A nullable physics imposter
  93075. */
  93076. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  93077. /**
  93078. * Disposes the physics imposter
  93079. */
  93080. dispose(): void;
  93081. /**
  93082. * Sets the delta position
  93083. * @param position The delta position amount
  93084. */
  93085. setDeltaPosition(position: Vector3): void;
  93086. /**
  93087. * Sets the delta rotation
  93088. * @param rotation The delta rotation amount
  93089. */
  93090. setDeltaRotation(rotation: Quaternion): void;
  93091. /**
  93092. * Gets the box size of the physics imposter and stores the result in the input parameter
  93093. * @param result Stores the box size
  93094. * @returns The physics imposter
  93095. */
  93096. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  93097. /**
  93098. * Gets the radius of the physics imposter
  93099. * @returns Radius of the physics imposter
  93100. */
  93101. getRadius(): number;
  93102. /**
  93103. * Sync a bone with this impostor
  93104. * @param bone The bone to sync to the impostor.
  93105. * @param boneMesh The mesh that the bone is influencing.
  93106. * @param jointPivot The pivot of the joint / bone in local space.
  93107. * @param distToJoint Optional distance from the impostor to the joint.
  93108. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  93109. */
  93110. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  93111. /**
  93112. * Sync impostor to a bone
  93113. * @param bone The bone that the impostor will be synced to.
  93114. * @param boneMesh The mesh that the bone is influencing.
  93115. * @param jointPivot The pivot of the joint / bone in local space.
  93116. * @param distToJoint Optional distance from the impostor to the joint.
  93117. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  93118. * @param boneAxis Optional vector3 axis the bone is aligned with
  93119. */
  93120. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  93121. /**
  93122. * No-Imposter type
  93123. */
  93124. static NoImpostor: number;
  93125. /**
  93126. * Sphere-Imposter type
  93127. */
  93128. static SphereImpostor: number;
  93129. /**
  93130. * Box-Imposter type
  93131. */
  93132. static BoxImpostor: number;
  93133. /**
  93134. * Plane-Imposter type
  93135. */
  93136. static PlaneImpostor: number;
  93137. /**
  93138. * Mesh-imposter type
  93139. */
  93140. static MeshImpostor: number;
  93141. /**
  93142. * Capsule-Impostor type (Ammo.js plugin only)
  93143. */
  93144. static CapsuleImpostor: number;
  93145. /**
  93146. * Cylinder-Imposter type
  93147. */
  93148. static CylinderImpostor: number;
  93149. /**
  93150. * Particle-Imposter type
  93151. */
  93152. static ParticleImpostor: number;
  93153. /**
  93154. * Heightmap-Imposter type
  93155. */
  93156. static HeightmapImpostor: number;
  93157. /**
  93158. * ConvexHull-Impostor type (Ammo.js plugin only)
  93159. */
  93160. static ConvexHullImpostor: number;
  93161. /**
  93162. * Custom-Imposter type (Ammo.js plugin only)
  93163. */
  93164. static CustomImpostor: number;
  93165. /**
  93166. * Rope-Imposter type
  93167. */
  93168. static RopeImpostor: number;
  93169. /**
  93170. * Cloth-Imposter type
  93171. */
  93172. static ClothImpostor: number;
  93173. /**
  93174. * Softbody-Imposter type
  93175. */
  93176. static SoftbodyImpostor: number;
  93177. }
  93178. }
  93179. declare module BABYLON {
  93180. /**
  93181. * @hidden
  93182. **/
  93183. export class _CreationDataStorage {
  93184. closePath?: boolean;
  93185. closeArray?: boolean;
  93186. idx: number[];
  93187. dashSize: number;
  93188. gapSize: number;
  93189. path3D: Path3D;
  93190. pathArray: Vector3[][];
  93191. arc: number;
  93192. radius: number;
  93193. cap: number;
  93194. tessellation: number;
  93195. }
  93196. /**
  93197. * @hidden
  93198. **/
  93199. class _InstanceDataStorage {
  93200. visibleInstances: any;
  93201. batchCache: _InstancesBatch;
  93202. instancesBufferSize: number;
  93203. instancesBuffer: Nullable<Buffer>;
  93204. instancesData: Float32Array;
  93205. overridenInstanceCount: number;
  93206. isFrozen: boolean;
  93207. previousBatch: Nullable<_InstancesBatch>;
  93208. hardwareInstancedRendering: boolean;
  93209. sideOrientation: number;
  93210. manualUpdate: boolean;
  93211. }
  93212. /**
  93213. * @hidden
  93214. **/
  93215. export class _InstancesBatch {
  93216. mustReturn: boolean;
  93217. visibleInstances: Nullable<InstancedMesh[]>[];
  93218. renderSelf: boolean[];
  93219. hardwareInstancedRendering: boolean[];
  93220. }
  93221. /**
  93222. * Class used to represent renderable models
  93223. */
  93224. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  93225. /**
  93226. * Mesh side orientation : usually the external or front surface
  93227. */
  93228. static readonly FRONTSIDE: number;
  93229. /**
  93230. * Mesh side orientation : usually the internal or back surface
  93231. */
  93232. static readonly BACKSIDE: number;
  93233. /**
  93234. * Mesh side orientation : both internal and external or front and back surfaces
  93235. */
  93236. static readonly DOUBLESIDE: number;
  93237. /**
  93238. * Mesh side orientation : by default, `FRONTSIDE`
  93239. */
  93240. static readonly DEFAULTSIDE: number;
  93241. /**
  93242. * Mesh cap setting : no cap
  93243. */
  93244. static readonly NO_CAP: number;
  93245. /**
  93246. * Mesh cap setting : one cap at the beginning of the mesh
  93247. */
  93248. static readonly CAP_START: number;
  93249. /**
  93250. * Mesh cap setting : one cap at the end of the mesh
  93251. */
  93252. static readonly CAP_END: number;
  93253. /**
  93254. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  93255. */
  93256. static readonly CAP_ALL: number;
  93257. /**
  93258. * Mesh pattern setting : no flip or rotate
  93259. */
  93260. static readonly NO_FLIP: number;
  93261. /**
  93262. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  93263. */
  93264. static readonly FLIP_TILE: number;
  93265. /**
  93266. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  93267. */
  93268. static readonly ROTATE_TILE: number;
  93269. /**
  93270. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  93271. */
  93272. static readonly FLIP_ROW: number;
  93273. /**
  93274. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  93275. */
  93276. static readonly ROTATE_ROW: number;
  93277. /**
  93278. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  93279. */
  93280. static readonly FLIP_N_ROTATE_TILE: number;
  93281. /**
  93282. * Mesh pattern setting : rotate pattern and rotate
  93283. */
  93284. static readonly FLIP_N_ROTATE_ROW: number;
  93285. /**
  93286. * Mesh tile positioning : part tiles same on left/right or top/bottom
  93287. */
  93288. static readonly CENTER: number;
  93289. /**
  93290. * Mesh tile positioning : part tiles on left
  93291. */
  93292. static readonly LEFT: number;
  93293. /**
  93294. * Mesh tile positioning : part tiles on right
  93295. */
  93296. static readonly RIGHT: number;
  93297. /**
  93298. * Mesh tile positioning : part tiles on top
  93299. */
  93300. static readonly TOP: number;
  93301. /**
  93302. * Mesh tile positioning : part tiles on bottom
  93303. */
  93304. static readonly BOTTOM: number;
  93305. /**
  93306. * Gets the default side orientation.
  93307. * @param orientation the orientation to value to attempt to get
  93308. * @returns the default orientation
  93309. * @hidden
  93310. */
  93311. static _GetDefaultSideOrientation(orientation?: number): number;
  93312. private _internalMeshDataInfo;
  93313. /**
  93314. * An event triggered before rendering the mesh
  93315. */
  93316. readonly onBeforeRenderObservable: Observable<Mesh>;
  93317. /**
  93318. * An event triggered before binding the mesh
  93319. */
  93320. readonly onBeforeBindObservable: Observable<Mesh>;
  93321. /**
  93322. * An event triggered after rendering the mesh
  93323. */
  93324. readonly onAfterRenderObservable: Observable<Mesh>;
  93325. /**
  93326. * An event triggered before drawing the mesh
  93327. */
  93328. readonly onBeforeDrawObservable: Observable<Mesh>;
  93329. private _onBeforeDrawObserver;
  93330. /**
  93331. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  93332. */
  93333. onBeforeDraw: () => void;
  93334. readonly hasInstances: boolean;
  93335. /**
  93336. * Gets the delay loading state of the mesh (when delay loading is turned on)
  93337. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  93338. */
  93339. delayLoadState: number;
  93340. /**
  93341. * Gets the list of instances created from this mesh
  93342. * it is not supposed to be modified manually.
  93343. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  93344. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93345. */
  93346. instances: InstancedMesh[];
  93347. /**
  93348. * Gets the file containing delay loading data for this mesh
  93349. */
  93350. delayLoadingFile: string;
  93351. /** @hidden */
  93352. _binaryInfo: any;
  93353. /**
  93354. * User defined function used to change how LOD level selection is done
  93355. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  93356. */
  93357. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  93358. /**
  93359. * Gets or sets the morph target manager
  93360. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93361. */
  93362. morphTargetManager: Nullable<MorphTargetManager>;
  93363. /** @hidden */
  93364. _creationDataStorage: Nullable<_CreationDataStorage>;
  93365. /** @hidden */
  93366. _geometry: Nullable<Geometry>;
  93367. /** @hidden */
  93368. _delayInfo: Array<string>;
  93369. /** @hidden */
  93370. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  93371. /** @hidden */
  93372. _instanceDataStorage: _InstanceDataStorage;
  93373. private _effectiveMaterial;
  93374. /** @hidden */
  93375. _shouldGenerateFlatShading: boolean;
  93376. /** @hidden */
  93377. _originalBuilderSideOrientation: number;
  93378. /**
  93379. * Use this property to change the original side orientation defined at construction time
  93380. */
  93381. overrideMaterialSideOrientation: Nullable<number>;
  93382. /**
  93383. * Gets the source mesh (the one used to clone this one from)
  93384. */
  93385. readonly source: Nullable<Mesh>;
  93386. /**
  93387. * Gets or sets a boolean indicating that this mesh does not use index buffer
  93388. */
  93389. isUnIndexed: boolean;
  93390. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  93391. readonly worldMatrixInstancedBuffer: Float32Array;
  93392. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  93393. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  93394. /**
  93395. * @constructor
  93396. * @param name The value used by scene.getMeshByName() to do a lookup.
  93397. * @param scene The scene to add this mesh to.
  93398. * @param parent The parent of this mesh, if it has one
  93399. * @param source An optional Mesh from which geometry is shared, cloned.
  93400. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  93401. * When false, achieved by calling a clone(), also passing False.
  93402. * This will make creation of children, recursive.
  93403. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  93404. */
  93405. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  93406. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  93407. doNotInstantiate: boolean;
  93408. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  93409. /**
  93410. * Gets the class name
  93411. * @returns the string "Mesh".
  93412. */
  93413. getClassName(): string;
  93414. /** @hidden */
  93415. readonly _isMesh: boolean;
  93416. /**
  93417. * Returns a description of this mesh
  93418. * @param fullDetails define if full details about this mesh must be used
  93419. * @returns a descriptive string representing this mesh
  93420. */
  93421. toString(fullDetails?: boolean): string;
  93422. /** @hidden */
  93423. _unBindEffect(): void;
  93424. /**
  93425. * Gets a boolean indicating if this mesh has LOD
  93426. */
  93427. readonly hasLODLevels: boolean;
  93428. /**
  93429. * Gets the list of MeshLODLevel associated with the current mesh
  93430. * @returns an array of MeshLODLevel
  93431. */
  93432. getLODLevels(): MeshLODLevel[];
  93433. private _sortLODLevels;
  93434. /**
  93435. * Add a mesh as LOD level triggered at the given distance.
  93436. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  93437. * @param distance The distance from the center of the object to show this level
  93438. * @param mesh The mesh to be added as LOD level (can be null)
  93439. * @return This mesh (for chaining)
  93440. */
  93441. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  93442. /**
  93443. * Returns the LOD level mesh at the passed distance or null if not found.
  93444. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  93445. * @param distance The distance from the center of the object to show this level
  93446. * @returns a Mesh or `null`
  93447. */
  93448. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  93449. /**
  93450. * Remove a mesh from the LOD array
  93451. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  93452. * @param mesh defines the mesh to be removed
  93453. * @return This mesh (for chaining)
  93454. */
  93455. removeLODLevel(mesh: Mesh): Mesh;
  93456. /**
  93457. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  93458. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  93459. * @param camera defines the camera to use to compute distance
  93460. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  93461. * @return This mesh (for chaining)
  93462. */
  93463. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  93464. /**
  93465. * Gets the mesh internal Geometry object
  93466. */
  93467. readonly geometry: Nullable<Geometry>;
  93468. /**
  93469. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  93470. * @returns the total number of vertices
  93471. */
  93472. getTotalVertices(): number;
  93473. /**
  93474. * Returns the content of an associated vertex buffer
  93475. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  93476. * - VertexBuffer.PositionKind
  93477. * - VertexBuffer.UVKind
  93478. * - VertexBuffer.UV2Kind
  93479. * - VertexBuffer.UV3Kind
  93480. * - VertexBuffer.UV4Kind
  93481. * - VertexBuffer.UV5Kind
  93482. * - VertexBuffer.UV6Kind
  93483. * - VertexBuffer.ColorKind
  93484. * - VertexBuffer.MatricesIndicesKind
  93485. * - VertexBuffer.MatricesIndicesExtraKind
  93486. * - VertexBuffer.MatricesWeightsKind
  93487. * - VertexBuffer.MatricesWeightsExtraKind
  93488. * @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
  93489. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  93490. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  93491. */
  93492. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  93493. /**
  93494. * Returns the mesh VertexBuffer object from the requested `kind`
  93495. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  93496. * - VertexBuffer.PositionKind
  93497. * - VertexBuffer.NormalKind
  93498. * - VertexBuffer.UVKind
  93499. * - VertexBuffer.UV2Kind
  93500. * - VertexBuffer.UV3Kind
  93501. * - VertexBuffer.UV4Kind
  93502. * - VertexBuffer.UV5Kind
  93503. * - VertexBuffer.UV6Kind
  93504. * - VertexBuffer.ColorKind
  93505. * - VertexBuffer.MatricesIndicesKind
  93506. * - VertexBuffer.MatricesIndicesExtraKind
  93507. * - VertexBuffer.MatricesWeightsKind
  93508. * - VertexBuffer.MatricesWeightsExtraKind
  93509. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  93510. */
  93511. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  93512. /**
  93513. * Tests if a specific vertex buffer is associated with this mesh
  93514. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  93515. * - VertexBuffer.PositionKind
  93516. * - VertexBuffer.NormalKind
  93517. * - VertexBuffer.UVKind
  93518. * - VertexBuffer.UV2Kind
  93519. * - VertexBuffer.UV3Kind
  93520. * - VertexBuffer.UV4Kind
  93521. * - VertexBuffer.UV5Kind
  93522. * - VertexBuffer.UV6Kind
  93523. * - VertexBuffer.ColorKind
  93524. * - VertexBuffer.MatricesIndicesKind
  93525. * - VertexBuffer.MatricesIndicesExtraKind
  93526. * - VertexBuffer.MatricesWeightsKind
  93527. * - VertexBuffer.MatricesWeightsExtraKind
  93528. * @returns a boolean
  93529. */
  93530. isVerticesDataPresent(kind: string): boolean;
  93531. /**
  93532. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  93533. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  93534. * - VertexBuffer.PositionKind
  93535. * - VertexBuffer.UVKind
  93536. * - VertexBuffer.UV2Kind
  93537. * - VertexBuffer.UV3Kind
  93538. * - VertexBuffer.UV4Kind
  93539. * - VertexBuffer.UV5Kind
  93540. * - VertexBuffer.UV6Kind
  93541. * - VertexBuffer.ColorKind
  93542. * - VertexBuffer.MatricesIndicesKind
  93543. * - VertexBuffer.MatricesIndicesExtraKind
  93544. * - VertexBuffer.MatricesWeightsKind
  93545. * - VertexBuffer.MatricesWeightsExtraKind
  93546. * @returns a boolean
  93547. */
  93548. isVertexBufferUpdatable(kind: string): boolean;
  93549. /**
  93550. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  93551. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  93552. * - VertexBuffer.PositionKind
  93553. * - VertexBuffer.NormalKind
  93554. * - VertexBuffer.UVKind
  93555. * - VertexBuffer.UV2Kind
  93556. * - VertexBuffer.UV3Kind
  93557. * - VertexBuffer.UV4Kind
  93558. * - VertexBuffer.UV5Kind
  93559. * - VertexBuffer.UV6Kind
  93560. * - VertexBuffer.ColorKind
  93561. * - VertexBuffer.MatricesIndicesKind
  93562. * - VertexBuffer.MatricesIndicesExtraKind
  93563. * - VertexBuffer.MatricesWeightsKind
  93564. * - VertexBuffer.MatricesWeightsExtraKind
  93565. * @returns an array of strings
  93566. */
  93567. getVerticesDataKinds(): string[];
  93568. /**
  93569. * Returns a positive integer : the total number of indices in this mesh geometry.
  93570. * @returns the numner of indices or zero if the mesh has no geometry.
  93571. */
  93572. getTotalIndices(): number;
  93573. /**
  93574. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  93575. * @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.
  93576. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  93577. * @returns the indices array or an empty array if the mesh has no geometry
  93578. */
  93579. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  93580. readonly isBlocked: boolean;
  93581. /**
  93582. * Determine if the current mesh is ready to be rendered
  93583. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93584. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  93585. * @returns true if all associated assets are ready (material, textures, shaders)
  93586. */
  93587. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  93588. /**
  93589. * 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.
  93590. */
  93591. readonly areNormalsFrozen: boolean;
  93592. /**
  93593. * 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.
  93594. * @returns the current mesh
  93595. */
  93596. freezeNormals(): Mesh;
  93597. /**
  93598. * 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
  93599. * @returns the current mesh
  93600. */
  93601. unfreezeNormals(): Mesh;
  93602. /**
  93603. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  93604. */
  93605. overridenInstanceCount: number;
  93606. /** @hidden */
  93607. _preActivate(): Mesh;
  93608. /** @hidden */
  93609. _preActivateForIntermediateRendering(renderId: number): Mesh;
  93610. /** @hidden */
  93611. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  93612. /**
  93613. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93614. * This means the mesh underlying bounding box and sphere are recomputed.
  93615. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93616. * @returns the current mesh
  93617. */
  93618. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  93619. /** @hidden */
  93620. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  93621. /**
  93622. * This function will subdivide the mesh into multiple submeshes
  93623. * @param count defines the expected number of submeshes
  93624. */
  93625. subdivide(count: number): void;
  93626. /**
  93627. * Copy a FloatArray into a specific associated vertex buffer
  93628. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  93629. * - VertexBuffer.PositionKind
  93630. * - VertexBuffer.UVKind
  93631. * - VertexBuffer.UV2Kind
  93632. * - VertexBuffer.UV3Kind
  93633. * - VertexBuffer.UV4Kind
  93634. * - VertexBuffer.UV5Kind
  93635. * - VertexBuffer.UV6Kind
  93636. * - VertexBuffer.ColorKind
  93637. * - VertexBuffer.MatricesIndicesKind
  93638. * - VertexBuffer.MatricesIndicesExtraKind
  93639. * - VertexBuffer.MatricesWeightsKind
  93640. * - VertexBuffer.MatricesWeightsExtraKind
  93641. * @param data defines the data source
  93642. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  93643. * @param stride defines the data stride size (can be null)
  93644. * @returns the current mesh
  93645. */
  93646. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93647. /**
  93648. * Delete a vertex buffer associated with this mesh
  93649. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  93650. * - VertexBuffer.PositionKind
  93651. * - VertexBuffer.UVKind
  93652. * - VertexBuffer.UV2Kind
  93653. * - VertexBuffer.UV3Kind
  93654. * - VertexBuffer.UV4Kind
  93655. * - VertexBuffer.UV5Kind
  93656. * - VertexBuffer.UV6Kind
  93657. * - VertexBuffer.ColorKind
  93658. * - VertexBuffer.MatricesIndicesKind
  93659. * - VertexBuffer.MatricesIndicesExtraKind
  93660. * - VertexBuffer.MatricesWeightsKind
  93661. * - VertexBuffer.MatricesWeightsExtraKind
  93662. */
  93663. removeVerticesData(kind: string): void;
  93664. /**
  93665. * Flags an associated vertex buffer as updatable
  93666. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  93667. * - VertexBuffer.PositionKind
  93668. * - VertexBuffer.UVKind
  93669. * - VertexBuffer.UV2Kind
  93670. * - VertexBuffer.UV3Kind
  93671. * - VertexBuffer.UV4Kind
  93672. * - VertexBuffer.UV5Kind
  93673. * - VertexBuffer.UV6Kind
  93674. * - VertexBuffer.ColorKind
  93675. * - VertexBuffer.MatricesIndicesKind
  93676. * - VertexBuffer.MatricesIndicesExtraKind
  93677. * - VertexBuffer.MatricesWeightsKind
  93678. * - VertexBuffer.MatricesWeightsExtraKind
  93679. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  93680. */
  93681. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  93682. /**
  93683. * Sets the mesh global Vertex Buffer
  93684. * @param buffer defines the buffer to use
  93685. * @returns the current mesh
  93686. */
  93687. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  93688. /**
  93689. * Update a specific associated vertex buffer
  93690. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  93691. * - VertexBuffer.PositionKind
  93692. * - VertexBuffer.UVKind
  93693. * - VertexBuffer.UV2Kind
  93694. * - VertexBuffer.UV3Kind
  93695. * - VertexBuffer.UV4Kind
  93696. * - VertexBuffer.UV5Kind
  93697. * - VertexBuffer.UV6Kind
  93698. * - VertexBuffer.ColorKind
  93699. * - VertexBuffer.MatricesIndicesKind
  93700. * - VertexBuffer.MatricesIndicesExtraKind
  93701. * - VertexBuffer.MatricesWeightsKind
  93702. * - VertexBuffer.MatricesWeightsExtraKind
  93703. * @param data defines the data source
  93704. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  93705. * @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)
  93706. * @returns the current mesh
  93707. */
  93708. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  93709. /**
  93710. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  93711. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  93712. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  93713. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  93714. * @returns the current mesh
  93715. */
  93716. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  93717. /**
  93718. * Creates a un-shared specific occurence of the geometry for the mesh.
  93719. * @returns the current mesh
  93720. */
  93721. makeGeometryUnique(): Mesh;
  93722. /**
  93723. * Set the index buffer of this mesh
  93724. * @param indices defines the source data
  93725. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  93726. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  93727. * @returns the current mesh
  93728. */
  93729. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  93730. /**
  93731. * Update the current index buffer
  93732. * @param indices defines the source data
  93733. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93734. * @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)
  93735. * @returns the current mesh
  93736. */
  93737. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93738. /**
  93739. * Invert the geometry to move from a right handed system to a left handed one.
  93740. * @returns the current mesh
  93741. */
  93742. toLeftHanded(): Mesh;
  93743. /** @hidden */
  93744. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  93745. /** @hidden */
  93746. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  93747. /**
  93748. * Registers for this mesh a javascript function called just before the rendering process
  93749. * @param func defines the function to call before rendering this mesh
  93750. * @returns the current mesh
  93751. */
  93752. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  93753. /**
  93754. * Disposes a previously registered javascript function called before the rendering
  93755. * @param func defines the function to remove
  93756. * @returns the current mesh
  93757. */
  93758. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  93759. /**
  93760. * Registers for this mesh a javascript function called just after the rendering is complete
  93761. * @param func defines the function to call after rendering this mesh
  93762. * @returns the current mesh
  93763. */
  93764. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  93765. /**
  93766. * Disposes a previously registered javascript function called after the rendering.
  93767. * @param func defines the function to remove
  93768. * @returns the current mesh
  93769. */
  93770. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  93771. /** @hidden */
  93772. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  93773. /** @hidden */
  93774. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  93775. /** @hidden */
  93776. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  93777. /** @hidden */
  93778. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  93779. /** @hidden */
  93780. _rebuild(): void;
  93781. /** @hidden */
  93782. _freeze(): void;
  93783. /** @hidden */
  93784. _unFreeze(): void;
  93785. /**
  93786. * 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
  93787. * @param subMesh defines the subMesh to render
  93788. * @param enableAlphaMode defines if alpha mode can be changed
  93789. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  93790. * @returns the current mesh
  93791. */
  93792. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  93793. private _onBeforeDraw;
  93794. /**
  93795. * Renormalize the mesh and patch it up if there are no weights
  93796. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  93797. * However in the case of zero weights then we set just a single influence to 1.
  93798. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  93799. */
  93800. cleanMatrixWeights(): void;
  93801. private normalizeSkinFourWeights;
  93802. private normalizeSkinWeightsAndExtra;
  93803. /**
  93804. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  93805. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  93806. * the user know there was an issue with importing the mesh
  93807. * @returns a validation object with skinned, valid and report string
  93808. */
  93809. validateSkinning(): {
  93810. skinned: boolean;
  93811. valid: boolean;
  93812. report: string;
  93813. };
  93814. /** @hidden */
  93815. _checkDelayState(): Mesh;
  93816. private _queueLoad;
  93817. /**
  93818. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93819. * A mesh is in the frustum if its bounding box intersects the frustum
  93820. * @param frustumPlanes defines the frustum to test
  93821. * @returns true if the mesh is in the frustum planes
  93822. */
  93823. isInFrustum(frustumPlanes: Plane[]): boolean;
  93824. /**
  93825. * Sets the mesh material by the material or multiMaterial `id` property
  93826. * @param id is a string identifying the material or the multiMaterial
  93827. * @returns the current mesh
  93828. */
  93829. setMaterialByID(id: string): Mesh;
  93830. /**
  93831. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  93832. * @returns an array of IAnimatable
  93833. */
  93834. getAnimatables(): IAnimatable[];
  93835. /**
  93836. * Modifies the mesh geometry according to the passed transformation matrix.
  93837. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  93838. * The mesh normals are modified using the same transformation.
  93839. * Note that, under the hood, this method sets a new VertexBuffer each call.
  93840. * @param transform defines the transform matrix to use
  93841. * @see http://doc.babylonjs.com/resources/baking_transformations
  93842. * @returns the current mesh
  93843. */
  93844. bakeTransformIntoVertices(transform: Matrix): Mesh;
  93845. /**
  93846. * Modifies the mesh geometry according to its own current World Matrix.
  93847. * The mesh World Matrix is then reset.
  93848. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  93849. * Note that, under the hood, this method sets a new VertexBuffer each call.
  93850. * @see http://doc.babylonjs.com/resources/baking_transformations
  93851. * @returns the current mesh
  93852. */
  93853. bakeCurrentTransformIntoVertices(): Mesh;
  93854. /** @hidden */
  93855. readonly _positions: Nullable<Vector3[]>;
  93856. /** @hidden */
  93857. _resetPointsArrayCache(): Mesh;
  93858. /** @hidden */
  93859. _generatePointsArray(): boolean;
  93860. /**
  93861. * Returns a new Mesh object generated from the current mesh properties.
  93862. * This method must not get confused with createInstance()
  93863. * @param name is a string, the name given to the new mesh
  93864. * @param newParent can be any Node object (default `null`)
  93865. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  93866. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  93867. * @returns a new mesh
  93868. */
  93869. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  93870. /**
  93871. * Releases resources associated with this mesh.
  93872. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93873. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93874. */
  93875. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93876. /** @hidden */
  93877. _disposeInstanceSpecificData(): void;
  93878. /**
  93879. * Modifies the mesh geometry according to a displacement map.
  93880. * 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.
  93881. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  93882. * @param url is a string, the URL from the image file is to be downloaded.
  93883. * @param minHeight is the lower limit of the displacement.
  93884. * @param maxHeight is the upper limit of the displacement.
  93885. * @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.
  93886. * @param uvOffset is an optional vector2 used to offset UV.
  93887. * @param uvScale is an optional vector2 used to scale UV.
  93888. * @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.
  93889. * @returns the Mesh.
  93890. */
  93891. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  93892. /**
  93893. * Modifies the mesh geometry according to a displacementMap buffer.
  93894. * 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.
  93895. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  93896. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  93897. * @param heightMapWidth is the width of the buffer image.
  93898. * @param heightMapHeight is the height of the buffer image.
  93899. * @param minHeight is the lower limit of the displacement.
  93900. * @param maxHeight is the upper limit of the displacement.
  93901. * @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.
  93902. * @param uvOffset is an optional vector2 used to offset UV.
  93903. * @param uvScale is an optional vector2 used to scale UV.
  93904. * @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.
  93905. * @returns the Mesh.
  93906. */
  93907. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  93908. /**
  93909. * Modify the mesh to get a flat shading rendering.
  93910. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  93911. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  93912. * @returns current mesh
  93913. */
  93914. convertToFlatShadedMesh(): Mesh;
  93915. /**
  93916. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  93917. * In other words, more vertices, no more indices and a single bigger VBO.
  93918. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  93919. * @returns current mesh
  93920. */
  93921. convertToUnIndexedMesh(): Mesh;
  93922. /**
  93923. * Inverses facet orientations.
  93924. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93925. * @param flipNormals will also inverts the normals
  93926. * @returns current mesh
  93927. */
  93928. flipFaces(flipNormals?: boolean): Mesh;
  93929. /**
  93930. * Increase the number of facets and hence vertices in a mesh
  93931. * Vertex normals are interpolated from existing vertex normals
  93932. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93933. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  93934. */
  93935. increaseVertices(numberPerEdge: number): void;
  93936. /**
  93937. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  93938. * This will undo any application of covertToFlatShadedMesh
  93939. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93940. */
  93941. forceSharedVertices(): void;
  93942. /** @hidden */
  93943. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  93944. /** @hidden */
  93945. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  93946. /**
  93947. * Creates a new InstancedMesh object from the mesh model.
  93948. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93949. * @param name defines the name of the new instance
  93950. * @returns a new InstancedMesh
  93951. */
  93952. createInstance(name: string): InstancedMesh;
  93953. /**
  93954. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  93955. * After this call, all the mesh instances have the same submeshes than the current mesh.
  93956. * @returns the current mesh
  93957. */
  93958. synchronizeInstances(): Mesh;
  93959. /**
  93960. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  93961. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  93962. * This should be used together with the simplification to avoid disappearing triangles.
  93963. * @param successCallback an optional success callback to be called after the optimization finished.
  93964. * @returns the current mesh
  93965. */
  93966. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  93967. /**
  93968. * Serialize current mesh
  93969. * @param serializationObject defines the object which will receive the serialization data
  93970. */
  93971. serialize(serializationObject: any): void;
  93972. /** @hidden */
  93973. _syncGeometryWithMorphTargetManager(): void;
  93974. /** @hidden */
  93975. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  93976. /**
  93977. * Returns a new Mesh object parsed from the source provided.
  93978. * @param parsedMesh is the source
  93979. * @param scene defines the hosting scene
  93980. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  93981. * @returns a new Mesh
  93982. */
  93983. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  93984. /**
  93985. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  93986. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93987. * @param name defines the name of the mesh to create
  93988. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  93989. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  93990. * @param closePath creates a seam between the first and the last points of each path of the path array
  93991. * @param offset is taken in account only if the `pathArray` is containing a single path
  93992. * @param scene defines the hosting scene
  93993. * @param updatable defines if the mesh must be flagged as updatable
  93994. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93995. * @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)
  93996. * @returns a new Mesh
  93997. */
  93998. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93999. /**
  94000. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  94001. * @param name defines the name of the mesh to create
  94002. * @param radius sets the radius size (float) of the polygon (default 0.5)
  94003. * @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
  94004. * @param scene defines the hosting scene
  94005. * @param updatable defines if the mesh must be flagged as updatable
  94006. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94007. * @returns a new Mesh
  94008. */
  94009. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  94010. /**
  94011. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  94012. * @param name defines the name of the mesh to create
  94013. * @param size sets the size (float) of each box side (default 1)
  94014. * @param scene defines the hosting scene
  94015. * @param updatable defines if the mesh must be flagged as updatable
  94016. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94017. * @returns a new Mesh
  94018. */
  94019. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  94020. /**
  94021. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  94022. * @param name defines the name of the mesh to create
  94023. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  94024. * @param diameter sets the diameter size (float) of the sphere (default 1)
  94025. * @param scene defines the hosting scene
  94026. * @param updatable defines if the mesh must be flagged as updatable
  94027. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94028. * @returns a new Mesh
  94029. */
  94030. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  94031. /**
  94032. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  94033. * @param name defines the name of the mesh to create
  94034. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  94035. * @param diameter sets the diameter size (float) of the sphere (default 1)
  94036. * @param scene defines the hosting scene
  94037. * @returns a new Mesh
  94038. */
  94039. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  94040. /**
  94041. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  94042. * @param name defines the name of the mesh to create
  94043. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  94044. * @param diameterTop set the top cap diameter (floats, default 1)
  94045. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  94046. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  94047. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  94048. * @param scene defines the hosting scene
  94049. * @param updatable defines if the mesh must be flagged as updatable
  94050. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94051. * @returns a new Mesh
  94052. */
  94053. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  94054. /**
  94055. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  94056. * @param name defines the name of the mesh to create
  94057. * @param diameter sets the diameter size (float) of the torus (default 1)
  94058. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  94059. * @param tessellation sets the number of torus sides (postive integer, default 16)
  94060. * @param scene defines the hosting scene
  94061. * @param updatable defines if the mesh must be flagged as updatable
  94062. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94063. * @returns a new Mesh
  94064. */
  94065. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  94066. /**
  94067. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  94068. * @param name defines the name of the mesh to create
  94069. * @param radius sets the global radius size (float) of the torus knot (default 2)
  94070. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  94071. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  94072. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  94073. * @param p the number of windings on X axis (positive integers, default 2)
  94074. * @param q the number of windings on Y axis (positive integers, default 3)
  94075. * @param scene defines the hosting scene
  94076. * @param updatable defines if the mesh must be flagged as updatable
  94077. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94078. * @returns a new Mesh
  94079. */
  94080. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  94081. /**
  94082. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  94083. * @param name defines the name of the mesh to create
  94084. * @param points is an array successive Vector3
  94085. * @param scene defines the hosting scene
  94086. * @param updatable defines if the mesh must be flagged as updatable
  94087. * @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).
  94088. * @returns a new Mesh
  94089. */
  94090. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  94091. /**
  94092. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  94093. * @param name defines the name of the mesh to create
  94094. * @param points is an array successive Vector3
  94095. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  94096. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  94097. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  94098. * @param scene defines the hosting scene
  94099. * @param updatable defines if the mesh must be flagged as updatable
  94100. * @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)
  94101. * @returns a new Mesh
  94102. */
  94103. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  94104. /**
  94105. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  94106. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  94107. * 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.
  94108. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94109. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94110. * Remember you can only change the shape positions, not their number when updating a polygon.
  94111. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  94112. * @param name defines the name of the mesh to create
  94113. * @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
  94114. * @param scene defines the hosting scene
  94115. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  94116. * @param updatable defines if the mesh must be flagged as updatable
  94117. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94118. * @param earcutInjection can be used to inject your own earcut reference
  94119. * @returns a new Mesh
  94120. */
  94121. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  94122. /**
  94123. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  94124. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  94125. * @param name defines the name of the mesh to create
  94126. * @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
  94127. * @param depth defines the height of extrusion
  94128. * @param scene defines the hosting scene
  94129. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  94130. * @param updatable defines if the mesh must be flagged as updatable
  94131. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94132. * @param earcutInjection can be used to inject your own earcut reference
  94133. * @returns a new Mesh
  94134. */
  94135. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  94136. /**
  94137. * Creates an extruded shape mesh.
  94138. * 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
  94139. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  94140. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  94141. * @param name defines the name of the mesh to create
  94142. * @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
  94143. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  94144. * @param scale is the value to scale the shape
  94145. * @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
  94146. * @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
  94147. * @param scene defines the hosting scene
  94148. * @param updatable defines if the mesh must be flagged as updatable
  94149. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94150. * @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)
  94151. * @returns a new Mesh
  94152. */
  94153. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  94154. /**
  94155. * Creates an custom extruded shape mesh.
  94156. * The custom extrusion is a parametric shape.
  94157. * It has no predefined shape. Its final shape will depend on the input parameters.
  94158. * Please consider using the same method from the MeshBuilder class instead
  94159. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  94160. * @param name defines the name of the mesh to create
  94161. * @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
  94162. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  94163. * @param scaleFunction is a custom Javascript function called on each path point
  94164. * @param rotationFunction is a custom Javascript function called on each path point
  94165. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  94166. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  94167. * @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
  94168. * @param scene defines the hosting scene
  94169. * @param updatable defines if the mesh must be flagged as updatable
  94170. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94171. * @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)
  94172. * @returns a new Mesh
  94173. */
  94174. 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;
  94175. /**
  94176. * Creates lathe mesh.
  94177. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  94178. * Please consider using the same method from the MeshBuilder class instead
  94179. * @param name defines the name of the mesh to create
  94180. * @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
  94181. * @param radius is the radius value of the lathe
  94182. * @param tessellation is the side number of the lathe.
  94183. * @param scene defines the hosting scene
  94184. * @param updatable defines if the mesh must be flagged as updatable
  94185. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94186. * @returns a new Mesh
  94187. */
  94188. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  94189. /**
  94190. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  94191. * @param name defines the name of the mesh to create
  94192. * @param size sets the size (float) of both sides of the plane at once (default 1)
  94193. * @param scene defines the hosting scene
  94194. * @param updatable defines if the mesh must be flagged as updatable
  94195. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94196. * @returns a new Mesh
  94197. */
  94198. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  94199. /**
  94200. * Creates a ground mesh.
  94201. * Please consider using the same method from the MeshBuilder class instead
  94202. * @param name defines the name of the mesh to create
  94203. * @param width set the width of the ground
  94204. * @param height set the height of the ground
  94205. * @param subdivisions sets the number of subdivisions per side
  94206. * @param scene defines the hosting scene
  94207. * @param updatable defines if the mesh must be flagged as updatable
  94208. * @returns a new Mesh
  94209. */
  94210. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  94211. /**
  94212. * Creates a tiled ground mesh.
  94213. * Please consider using the same method from the MeshBuilder class instead
  94214. * @param name defines the name of the mesh to create
  94215. * @param xmin set the ground minimum X coordinate
  94216. * @param zmin set the ground minimum Y coordinate
  94217. * @param xmax set the ground maximum X coordinate
  94218. * @param zmax set the ground maximum Z coordinate
  94219. * @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
  94220. * @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
  94221. * @param scene defines the hosting scene
  94222. * @param updatable defines if the mesh must be flagged as updatable
  94223. * @returns a new Mesh
  94224. */
  94225. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  94226. w: number;
  94227. h: number;
  94228. }, precision: {
  94229. w: number;
  94230. h: number;
  94231. }, scene: Scene, updatable?: boolean): Mesh;
  94232. /**
  94233. * Creates a ground mesh from a height map.
  94234. * Please consider using the same method from the MeshBuilder class instead
  94235. * @see http://doc.babylonjs.com/babylon101/height_map
  94236. * @param name defines the name of the mesh to create
  94237. * @param url sets the URL of the height map image resource
  94238. * @param width set the ground width size
  94239. * @param height set the ground height size
  94240. * @param subdivisions sets the number of subdivision per side
  94241. * @param minHeight is the minimum altitude on the ground
  94242. * @param maxHeight is the maximum altitude on the ground
  94243. * @param scene defines the hosting scene
  94244. * @param updatable defines if the mesh must be flagged as updatable
  94245. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  94246. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  94247. * @returns a new Mesh
  94248. */
  94249. 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;
  94250. /**
  94251. * Creates a tube mesh.
  94252. * The tube is a parametric shape.
  94253. * It has no predefined shape. Its final shape will depend on the input parameters.
  94254. * Please consider using the same method from the MeshBuilder class instead
  94255. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  94256. * @param name defines the name of the mesh to create
  94257. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  94258. * @param radius sets the tube radius size
  94259. * @param tessellation is the number of sides on the tubular surface
  94260. * @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
  94261. * @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
  94262. * @param scene defines the hosting scene
  94263. * @param updatable defines if the mesh must be flagged as updatable
  94264. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94265. * @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)
  94266. * @returns a new Mesh
  94267. */
  94268. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  94269. (i: number, distance: number): number;
  94270. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  94271. /**
  94272. * Creates a polyhedron mesh.
  94273. * Please consider using the same method from the MeshBuilder class instead.
  94274. * * 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
  94275. * * The parameter `size` (positive float, default 1) sets the polygon size
  94276. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  94277. * * 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`
  94278. * * 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
  94279. * * 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)`)
  94280. * * 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
  94281. * * 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
  94282. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94283. * * If you create a double-sided mesh, you can choose what parts of 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
  94284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94285. * @param name defines the name of the mesh to create
  94286. * @param options defines the options used to create the mesh
  94287. * @param scene defines the hosting scene
  94288. * @returns a new Mesh
  94289. */
  94290. static CreatePolyhedron(name: string, options: {
  94291. type?: number;
  94292. size?: number;
  94293. sizeX?: number;
  94294. sizeY?: number;
  94295. sizeZ?: number;
  94296. custom?: any;
  94297. faceUV?: Vector4[];
  94298. faceColors?: Color4[];
  94299. updatable?: boolean;
  94300. sideOrientation?: number;
  94301. }, scene: Scene): Mesh;
  94302. /**
  94303. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  94304. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  94305. * * 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`)
  94306. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  94307. * * 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
  94308. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94309. * * If you create a double-sided mesh, you can choose what parts of 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
  94310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94311. * @param name defines the name of the mesh
  94312. * @param options defines the options used to create the mesh
  94313. * @param scene defines the hosting scene
  94314. * @returns a new Mesh
  94315. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  94316. */
  94317. static CreateIcoSphere(name: string, options: {
  94318. radius?: number;
  94319. flat?: boolean;
  94320. subdivisions?: number;
  94321. sideOrientation?: number;
  94322. updatable?: boolean;
  94323. }, scene: Scene): Mesh;
  94324. /**
  94325. * Creates a decal mesh.
  94326. * Please consider using the same method from the MeshBuilder class instead.
  94327. * A decal is a mesh usually applied as a model onto the surface of another mesh
  94328. * @param name defines the name of the mesh
  94329. * @param sourceMesh defines the mesh receiving the decal
  94330. * @param position sets the position of the decal in world coordinates
  94331. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  94332. * @param size sets the decal scaling
  94333. * @param angle sets the angle to rotate the decal
  94334. * @returns a new Mesh
  94335. */
  94336. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  94337. /**
  94338. * Prepare internal position array for software CPU skinning
  94339. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  94340. */
  94341. setPositionsForCPUSkinning(): Float32Array;
  94342. /**
  94343. * Prepare internal normal array for software CPU skinning
  94344. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  94345. */
  94346. setNormalsForCPUSkinning(): Float32Array;
  94347. /**
  94348. * Updates the vertex buffer by applying transformation from the bones
  94349. * @param skeleton defines the skeleton to apply to current mesh
  94350. * @returns the current mesh
  94351. */
  94352. applySkeleton(skeleton: Skeleton): Mesh;
  94353. /**
  94354. * 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
  94355. * @param meshes defines the list of meshes to scan
  94356. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  94357. */
  94358. static MinMax(meshes: AbstractMesh[]): {
  94359. min: Vector3;
  94360. max: Vector3;
  94361. };
  94362. /**
  94363. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  94364. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  94365. * @returns a vector3
  94366. */
  94367. static Center(meshesOrMinMaxVector: {
  94368. min: Vector3;
  94369. max: Vector3;
  94370. } | AbstractMesh[]): Vector3;
  94371. /**
  94372. * Merge the array of meshes into a single mesh for performance reasons.
  94373. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  94374. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  94375. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  94376. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  94377. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  94378. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  94379. * @returns a new mesh
  94380. */
  94381. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  94382. /** @hidden */
  94383. addInstance(instance: InstancedMesh): void;
  94384. /** @hidden */
  94385. removeInstance(instance: InstancedMesh): void;
  94386. }
  94387. }
  94388. declare module BABYLON {
  94389. /**
  94390. * This is the base class of all the camera used in the application.
  94391. * @see http://doc.babylonjs.com/features/cameras
  94392. */
  94393. export class Camera extends Node {
  94394. /** @hidden */
  94395. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  94396. /**
  94397. * This is the default projection mode used by the cameras.
  94398. * It helps recreating a feeling of perspective and better appreciate depth.
  94399. * This is the best way to simulate real life cameras.
  94400. */
  94401. static readonly PERSPECTIVE_CAMERA: number;
  94402. /**
  94403. * This helps creating camera with an orthographic mode.
  94404. * 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.
  94405. */
  94406. static readonly ORTHOGRAPHIC_CAMERA: number;
  94407. /**
  94408. * This is the default FOV mode for perspective cameras.
  94409. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  94410. */
  94411. static readonly FOVMODE_VERTICAL_FIXED: number;
  94412. /**
  94413. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  94414. */
  94415. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  94416. /**
  94417. * This specifies ther is no need for a camera rig.
  94418. * Basically only one eye is rendered corresponding to the camera.
  94419. */
  94420. static readonly RIG_MODE_NONE: number;
  94421. /**
  94422. * Simulates a camera Rig with one blue eye and one red eye.
  94423. * This can be use with 3d blue and red glasses.
  94424. */
  94425. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  94426. /**
  94427. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  94428. */
  94429. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  94430. /**
  94431. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  94432. */
  94433. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  94434. /**
  94435. * Defines that both eyes of the camera will be rendered over under each other.
  94436. */
  94437. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  94438. /**
  94439. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  94440. */
  94441. static readonly RIG_MODE_VR: number;
  94442. /**
  94443. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  94444. */
  94445. static readonly RIG_MODE_WEBVR: number;
  94446. /**
  94447. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  94448. */
  94449. static readonly RIG_MODE_CUSTOM: number;
  94450. /**
  94451. * Defines if by default attaching controls should prevent the default javascript event to continue.
  94452. */
  94453. static ForceAttachControlToAlwaysPreventDefault: boolean;
  94454. /**
  94455. * Define the input manager associated with the camera.
  94456. */
  94457. inputs: CameraInputsManager<Camera>;
  94458. /** @hidden */
  94459. _position: Vector3;
  94460. /**
  94461. * Define the current local position of the camera in the scene
  94462. */
  94463. position: Vector3;
  94464. /**
  94465. * The vector the camera should consider as up.
  94466. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  94467. */
  94468. upVector: Vector3;
  94469. /**
  94470. * Define the current limit on the left side for an orthographic camera
  94471. * In scene unit
  94472. */
  94473. orthoLeft: Nullable<number>;
  94474. /**
  94475. * Define the current limit on the right side for an orthographic camera
  94476. * In scene unit
  94477. */
  94478. orthoRight: Nullable<number>;
  94479. /**
  94480. * Define the current limit on the bottom side for an orthographic camera
  94481. * In scene unit
  94482. */
  94483. orthoBottom: Nullable<number>;
  94484. /**
  94485. * Define the current limit on the top side for an orthographic camera
  94486. * In scene unit
  94487. */
  94488. orthoTop: Nullable<number>;
  94489. /**
  94490. * Field Of View is set in Radians. (default is 0.8)
  94491. */
  94492. fov: number;
  94493. /**
  94494. * Define the minimum distance the camera can see from.
  94495. * This is important to note that the depth buffer are not infinite and the closer it starts
  94496. * the more your scene might encounter depth fighting issue.
  94497. */
  94498. minZ: number;
  94499. /**
  94500. * Define the maximum distance the camera can see to.
  94501. * This is important to note that the depth buffer are not infinite and the further it end
  94502. * the more your scene might encounter depth fighting issue.
  94503. */
  94504. maxZ: number;
  94505. /**
  94506. * Define the default inertia of the camera.
  94507. * This helps giving a smooth feeling to the camera movement.
  94508. */
  94509. inertia: number;
  94510. /**
  94511. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  94512. */
  94513. mode: number;
  94514. /**
  94515. * Define wether the camera is intermediate.
  94516. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  94517. */
  94518. isIntermediate: boolean;
  94519. /**
  94520. * Define the viewport of the camera.
  94521. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  94522. */
  94523. viewport: Viewport;
  94524. /**
  94525. * Restricts the camera to viewing objects with the same layerMask.
  94526. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  94527. */
  94528. layerMask: number;
  94529. /**
  94530. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  94531. */
  94532. fovMode: number;
  94533. /**
  94534. * Rig mode of the camera.
  94535. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  94536. * This is normally controlled byt the camera themselves as internal use.
  94537. */
  94538. cameraRigMode: number;
  94539. /**
  94540. * Defines the distance between both "eyes" in case of a RIG
  94541. */
  94542. interaxialDistance: number;
  94543. /**
  94544. * Defines if stereoscopic rendering is done side by side or over under.
  94545. */
  94546. isStereoscopicSideBySide: boolean;
  94547. /**
  94548. * 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
  94549. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  94550. * else in the scene. (Eg. security camera)
  94551. *
  94552. * 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)
  94553. */
  94554. customRenderTargets: RenderTargetTexture[];
  94555. /**
  94556. * When set, the camera will render to this render target instead of the default canvas
  94557. *
  94558. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  94559. */
  94560. outputRenderTarget: Nullable<RenderTargetTexture>;
  94561. /**
  94562. * Observable triggered when the camera view matrix has changed.
  94563. */
  94564. onViewMatrixChangedObservable: Observable<Camera>;
  94565. /**
  94566. * Observable triggered when the camera Projection matrix has changed.
  94567. */
  94568. onProjectionMatrixChangedObservable: Observable<Camera>;
  94569. /**
  94570. * Observable triggered when the inputs have been processed.
  94571. */
  94572. onAfterCheckInputsObservable: Observable<Camera>;
  94573. /**
  94574. * Observable triggered when reset has been called and applied to the camera.
  94575. */
  94576. onRestoreStateObservable: Observable<Camera>;
  94577. /** @hidden */
  94578. _cameraRigParams: any;
  94579. /** @hidden */
  94580. _rigCameras: Camera[];
  94581. /** @hidden */
  94582. _rigPostProcess: Nullable<PostProcess>;
  94583. protected _webvrViewMatrix: Matrix;
  94584. /** @hidden */
  94585. _skipRendering: boolean;
  94586. /** @hidden */
  94587. _projectionMatrix: Matrix;
  94588. /** @hidden */
  94589. _postProcesses: Nullable<PostProcess>[];
  94590. /** @hidden */
  94591. _activeMeshes: SmartArray<AbstractMesh>;
  94592. protected _globalPosition: Vector3;
  94593. /** @hidden */
  94594. _computedViewMatrix: Matrix;
  94595. private _doNotComputeProjectionMatrix;
  94596. private _transformMatrix;
  94597. private _frustumPlanes;
  94598. private _refreshFrustumPlanes;
  94599. private _storedFov;
  94600. private _stateStored;
  94601. /**
  94602. * Instantiates a new camera object.
  94603. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  94604. * @see http://doc.babylonjs.com/features/cameras
  94605. * @param name Defines the name of the camera in the scene
  94606. * @param position Defines the position of the camera
  94607. * @param scene Defines the scene the camera belongs too
  94608. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  94609. */
  94610. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94611. /**
  94612. * Store current camera state (fov, position, etc..)
  94613. * @returns the camera
  94614. */
  94615. storeState(): Camera;
  94616. /**
  94617. * Restores the camera state values if it has been stored. You must call storeState() first
  94618. */
  94619. protected _restoreStateValues(): boolean;
  94620. /**
  94621. * Restored camera state. You must call storeState() first.
  94622. * @returns true if restored and false otherwise
  94623. */
  94624. restoreState(): boolean;
  94625. /**
  94626. * Gets the class name of the camera.
  94627. * @returns the class name
  94628. */
  94629. getClassName(): string;
  94630. /** @hidden */
  94631. readonly _isCamera: boolean;
  94632. /**
  94633. * Gets a string representation of the camera useful for debug purpose.
  94634. * @param fullDetails Defines that a more verboe level of logging is required
  94635. * @returns the string representation
  94636. */
  94637. toString(fullDetails?: boolean): string;
  94638. /**
  94639. * Gets the current world space position of the camera.
  94640. */
  94641. readonly globalPosition: Vector3;
  94642. /**
  94643. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  94644. * @returns the active meshe list
  94645. */
  94646. getActiveMeshes(): SmartArray<AbstractMesh>;
  94647. /**
  94648. * Check wether a mesh is part of the current active mesh list of the camera
  94649. * @param mesh Defines the mesh to check
  94650. * @returns true if active, false otherwise
  94651. */
  94652. isActiveMesh(mesh: Mesh): boolean;
  94653. /**
  94654. * Is this camera ready to be used/rendered
  94655. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  94656. * @return true if the camera is ready
  94657. */
  94658. isReady(completeCheck?: boolean): boolean;
  94659. /** @hidden */
  94660. _initCache(): void;
  94661. /** @hidden */
  94662. _updateCache(ignoreParentClass?: boolean): void;
  94663. /** @hidden */
  94664. _isSynchronized(): boolean;
  94665. /** @hidden */
  94666. _isSynchronizedViewMatrix(): boolean;
  94667. /** @hidden */
  94668. _isSynchronizedProjectionMatrix(): boolean;
  94669. /**
  94670. * Attach the input controls to a specific dom element to get the input from.
  94671. * @param element Defines the element the controls should be listened from
  94672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94673. */
  94674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94675. /**
  94676. * Detach the current controls from the specified dom element.
  94677. * @param element Defines the element to stop listening the inputs from
  94678. */
  94679. detachControl(element: HTMLElement): void;
  94680. /**
  94681. * Update the camera state according to the different inputs gathered during the frame.
  94682. */
  94683. update(): void;
  94684. /** @hidden */
  94685. _checkInputs(): void;
  94686. /** @hidden */
  94687. readonly rigCameras: Camera[];
  94688. /**
  94689. * Gets the post process used by the rig cameras
  94690. */
  94691. readonly rigPostProcess: Nullable<PostProcess>;
  94692. /**
  94693. * Internal, gets the first post proces.
  94694. * @returns the first post process to be run on this camera.
  94695. */
  94696. _getFirstPostProcess(): Nullable<PostProcess>;
  94697. private _cascadePostProcessesToRigCams;
  94698. /**
  94699. * Attach a post process to the camera.
  94700. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  94701. * @param postProcess The post process to attach to the camera
  94702. * @param insertAt The position of the post process in case several of them are in use in the scene
  94703. * @returns the position the post process has been inserted at
  94704. */
  94705. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  94706. /**
  94707. * Detach a post process to the camera.
  94708. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  94709. * @param postProcess The post process to detach from the camera
  94710. */
  94711. detachPostProcess(postProcess: PostProcess): void;
  94712. /**
  94713. * Gets the current world matrix of the camera
  94714. */
  94715. getWorldMatrix(): Matrix;
  94716. /** @hidden */
  94717. _getViewMatrix(): Matrix;
  94718. /**
  94719. * Gets the current view matrix of the camera.
  94720. * @param force forces the camera to recompute the matrix without looking at the cached state
  94721. * @returns the view matrix
  94722. */
  94723. getViewMatrix(force?: boolean): Matrix;
  94724. /**
  94725. * Freeze the projection matrix.
  94726. * It will prevent the cache check of the camera projection compute and can speed up perf
  94727. * if no parameter of the camera are meant to change
  94728. * @param projection Defines manually a projection if necessary
  94729. */
  94730. freezeProjectionMatrix(projection?: Matrix): void;
  94731. /**
  94732. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  94733. */
  94734. unfreezeProjectionMatrix(): void;
  94735. /**
  94736. * Gets the current projection matrix of the camera.
  94737. * @param force forces the camera to recompute the matrix without looking at the cached state
  94738. * @returns the projection matrix
  94739. */
  94740. getProjectionMatrix(force?: boolean): Matrix;
  94741. /**
  94742. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  94743. * @returns a Matrix
  94744. */
  94745. getTransformationMatrix(): Matrix;
  94746. private _updateFrustumPlanes;
  94747. /**
  94748. * Checks if a cullable object (mesh...) is in the camera frustum
  94749. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  94750. * @param target The object to check
  94751. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  94752. * @returns true if the object is in frustum otherwise false
  94753. */
  94754. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  94755. /**
  94756. * Checks if a cullable object (mesh...) is in the camera frustum
  94757. * Unlike isInFrustum this cheks the full bounding box
  94758. * @param target The object to check
  94759. * @returns true if the object is in frustum otherwise false
  94760. */
  94761. isCompletelyInFrustum(target: ICullable): boolean;
  94762. /**
  94763. * Gets a ray in the forward direction from the camera.
  94764. * @param length Defines the length of the ray to create
  94765. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  94766. * @param origin Defines the start point of the ray which defaults to the camera position
  94767. * @returns the forward ray
  94768. */
  94769. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  94770. /**
  94771. * Releases resources associated with this node.
  94772. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94773. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94774. */
  94775. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94776. /** @hidden */
  94777. _isLeftCamera: boolean;
  94778. /**
  94779. * Gets the left camera of a rig setup in case of Rigged Camera
  94780. */
  94781. readonly isLeftCamera: boolean;
  94782. /** @hidden */
  94783. _isRightCamera: boolean;
  94784. /**
  94785. * Gets the right camera of a rig setup in case of Rigged Camera
  94786. */
  94787. readonly isRightCamera: boolean;
  94788. /**
  94789. * Gets the left camera of a rig setup in case of Rigged Camera
  94790. */
  94791. readonly leftCamera: Nullable<FreeCamera>;
  94792. /**
  94793. * Gets the right camera of a rig setup in case of Rigged Camera
  94794. */
  94795. readonly rightCamera: Nullable<FreeCamera>;
  94796. /**
  94797. * Gets the left camera target of a rig setup in case of Rigged Camera
  94798. * @returns the target position
  94799. */
  94800. getLeftTarget(): Nullable<Vector3>;
  94801. /**
  94802. * Gets the right camera target of a rig setup in case of Rigged Camera
  94803. * @returns the target position
  94804. */
  94805. getRightTarget(): Nullable<Vector3>;
  94806. /**
  94807. * @hidden
  94808. */
  94809. setCameraRigMode(mode: number, rigParams: any): void;
  94810. /** @hidden */
  94811. static _setStereoscopicRigMode(camera: Camera): void;
  94812. /** @hidden */
  94813. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  94814. /** @hidden */
  94815. static _setVRRigMode(camera: Camera, rigParams: any): void;
  94816. /** @hidden */
  94817. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  94818. /** @hidden */
  94819. _getVRProjectionMatrix(): Matrix;
  94820. protected _updateCameraRotationMatrix(): void;
  94821. protected _updateWebVRCameraRotationMatrix(): void;
  94822. /**
  94823. * This function MUST be overwritten by the different WebVR cameras available.
  94824. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  94825. * @hidden
  94826. */
  94827. _getWebVRProjectionMatrix(): Matrix;
  94828. /**
  94829. * This function MUST be overwritten by the different WebVR cameras available.
  94830. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  94831. * @hidden
  94832. */
  94833. _getWebVRViewMatrix(): Matrix;
  94834. /** @hidden */
  94835. setCameraRigParameter(name: string, value: any): void;
  94836. /**
  94837. * needs to be overridden by children so sub has required properties to be copied
  94838. * @hidden
  94839. */
  94840. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  94841. /**
  94842. * May need to be overridden by children
  94843. * @hidden
  94844. */
  94845. _updateRigCameras(): void;
  94846. /** @hidden */
  94847. _setupInputs(): void;
  94848. /**
  94849. * Serialiaze the camera setup to a json represention
  94850. * @returns the JSON representation
  94851. */
  94852. serialize(): any;
  94853. /**
  94854. * Clones the current camera.
  94855. * @param name The cloned camera name
  94856. * @returns the cloned camera
  94857. */
  94858. clone(name: string): Camera;
  94859. /**
  94860. * Gets the direction of the camera relative to a given local axis.
  94861. * @param localAxis Defines the reference axis to provide a relative direction.
  94862. * @return the direction
  94863. */
  94864. getDirection(localAxis: Vector3): Vector3;
  94865. /**
  94866. * Returns the current camera absolute rotation
  94867. */
  94868. readonly absoluteRotation: Quaternion;
  94869. /**
  94870. * Gets the direction of the camera relative to a given local axis into a passed vector.
  94871. * @param localAxis Defines the reference axis to provide a relative direction.
  94872. * @param result Defines the vector to store the result in
  94873. */
  94874. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  94875. /**
  94876. * Gets a camera constructor for a given camera type
  94877. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  94878. * @param name The name of the camera the result will be able to instantiate
  94879. * @param scene The scene the result will construct the camera in
  94880. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  94881. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  94882. * @returns a factory method to construc the camera
  94883. */
  94884. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  94885. /**
  94886. * Compute the world matrix of the camera.
  94887. * @returns the camera world matrix
  94888. */
  94889. computeWorldMatrix(): Matrix;
  94890. /**
  94891. * Parse a JSON and creates the camera from the parsed information
  94892. * @param parsedCamera The JSON to parse
  94893. * @param scene The scene to instantiate the camera in
  94894. * @returns the newly constructed camera
  94895. */
  94896. static Parse(parsedCamera: any, scene: Scene): Camera;
  94897. }
  94898. }
  94899. declare module BABYLON {
  94900. /**
  94901. * Class containing static functions to help procedurally build meshes
  94902. */
  94903. export class DiscBuilder {
  94904. /**
  94905. * Creates a plane polygonal mesh. By default, this is a disc
  94906. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  94907. * * 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
  94908. * * 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
  94909. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94910. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94912. * @param name defines the name of the mesh
  94913. * @param options defines the options used to create the mesh
  94914. * @param scene defines the hosting scene
  94915. * @returns the plane polygonal mesh
  94916. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  94917. */
  94918. static CreateDisc(name: string, options: {
  94919. radius?: number;
  94920. tessellation?: number;
  94921. arc?: number;
  94922. updatable?: boolean;
  94923. sideOrientation?: number;
  94924. frontUVs?: Vector4;
  94925. backUVs?: Vector4;
  94926. }, scene?: Nullable<Scene>): Mesh;
  94927. }
  94928. }
  94929. declare module BABYLON {
  94930. /**
  94931. * This represents all the required information to add a fresnel effect on a material:
  94932. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94933. */
  94934. export class FresnelParameters {
  94935. private _isEnabled;
  94936. /**
  94937. * Define if the fresnel effect is enable or not.
  94938. */
  94939. isEnabled: boolean;
  94940. /**
  94941. * Define the color used on edges (grazing angle)
  94942. */
  94943. leftColor: Color3;
  94944. /**
  94945. * Define the color used on center
  94946. */
  94947. rightColor: Color3;
  94948. /**
  94949. * Define bias applied to computed fresnel term
  94950. */
  94951. bias: number;
  94952. /**
  94953. * Defined the power exponent applied to fresnel term
  94954. */
  94955. power: number;
  94956. /**
  94957. * Clones the current fresnel and its valuues
  94958. * @returns a clone fresnel configuration
  94959. */
  94960. clone(): FresnelParameters;
  94961. /**
  94962. * Serializes the current fresnel parameters to a JSON representation.
  94963. * @return the JSON serialization
  94964. */
  94965. serialize(): any;
  94966. /**
  94967. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94968. * @param parsedFresnelParameters Define the JSON representation
  94969. * @returns the parsed parameters
  94970. */
  94971. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94972. }
  94973. }
  94974. declare module BABYLON {
  94975. /**
  94976. * Base class of materials working in push mode in babylon JS
  94977. * @hidden
  94978. */
  94979. export class PushMaterial extends Material {
  94980. protected _activeEffect: Effect;
  94981. protected _normalMatrix: Matrix;
  94982. /**
  94983. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  94984. * This means that the material can keep using a previous shader while a new one is being compiled.
  94985. * This is mostly used when shader parallel compilation is supported (true by default)
  94986. */
  94987. allowShaderHotSwapping: boolean;
  94988. constructor(name: string, scene: Scene);
  94989. getEffect(): Effect;
  94990. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94991. /**
  94992. * Binds the given world matrix to the active effect
  94993. *
  94994. * @param world the matrix to bind
  94995. */
  94996. bindOnlyWorldMatrix(world: Matrix): void;
  94997. /**
  94998. * Binds the given normal matrix to the active effect
  94999. *
  95000. * @param normalMatrix the matrix to bind
  95001. */
  95002. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  95003. bind(world: Matrix, mesh?: Mesh): void;
  95004. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  95005. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  95006. }
  95007. }
  95008. declare module BABYLON {
  95009. /**
  95010. * This groups all the flags used to control the materials channel.
  95011. */
  95012. export class MaterialFlags {
  95013. private static _DiffuseTextureEnabled;
  95014. /**
  95015. * Are diffuse textures enabled in the application.
  95016. */
  95017. static DiffuseTextureEnabled: boolean;
  95018. private static _AmbientTextureEnabled;
  95019. /**
  95020. * Are ambient textures enabled in the application.
  95021. */
  95022. static AmbientTextureEnabled: boolean;
  95023. private static _OpacityTextureEnabled;
  95024. /**
  95025. * Are opacity textures enabled in the application.
  95026. */
  95027. static OpacityTextureEnabled: boolean;
  95028. private static _ReflectionTextureEnabled;
  95029. /**
  95030. * Are reflection textures enabled in the application.
  95031. */
  95032. static ReflectionTextureEnabled: boolean;
  95033. private static _EmissiveTextureEnabled;
  95034. /**
  95035. * Are emissive textures enabled in the application.
  95036. */
  95037. static EmissiveTextureEnabled: boolean;
  95038. private static _SpecularTextureEnabled;
  95039. /**
  95040. * Are specular textures enabled in the application.
  95041. */
  95042. static SpecularTextureEnabled: boolean;
  95043. private static _BumpTextureEnabled;
  95044. /**
  95045. * Are bump textures enabled in the application.
  95046. */
  95047. static BumpTextureEnabled: boolean;
  95048. private static _LightmapTextureEnabled;
  95049. /**
  95050. * Are lightmap textures enabled in the application.
  95051. */
  95052. static LightmapTextureEnabled: boolean;
  95053. private static _RefractionTextureEnabled;
  95054. /**
  95055. * Are refraction textures enabled in the application.
  95056. */
  95057. static RefractionTextureEnabled: boolean;
  95058. private static _ColorGradingTextureEnabled;
  95059. /**
  95060. * Are color grading textures enabled in the application.
  95061. */
  95062. static ColorGradingTextureEnabled: boolean;
  95063. private static _FresnelEnabled;
  95064. /**
  95065. * Are fresnels enabled in the application.
  95066. */
  95067. static FresnelEnabled: boolean;
  95068. private static _ClearCoatTextureEnabled;
  95069. /**
  95070. * Are clear coat textures enabled in the application.
  95071. */
  95072. static ClearCoatTextureEnabled: boolean;
  95073. private static _ClearCoatBumpTextureEnabled;
  95074. /**
  95075. * Are clear coat bump textures enabled in the application.
  95076. */
  95077. static ClearCoatBumpTextureEnabled: boolean;
  95078. private static _ClearCoatTintTextureEnabled;
  95079. /**
  95080. * Are clear coat tint textures enabled in the application.
  95081. */
  95082. static ClearCoatTintTextureEnabled: boolean;
  95083. private static _SheenTextureEnabled;
  95084. /**
  95085. * Are sheen textures enabled in the application.
  95086. */
  95087. static SheenTextureEnabled: boolean;
  95088. private static _AnisotropicTextureEnabled;
  95089. /**
  95090. * Are anisotropic textures enabled in the application.
  95091. */
  95092. static AnisotropicTextureEnabled: boolean;
  95093. private static _ThicknessTextureEnabled;
  95094. /**
  95095. * Are thickness textures enabled in the application.
  95096. */
  95097. static ThicknessTextureEnabled: boolean;
  95098. }
  95099. }
  95100. declare module BABYLON {
  95101. /** @hidden */
  95102. export var defaultFragmentDeclaration: {
  95103. name: string;
  95104. shader: string;
  95105. };
  95106. }
  95107. declare module BABYLON {
  95108. /** @hidden */
  95109. export var defaultUboDeclaration: {
  95110. name: string;
  95111. shader: string;
  95112. };
  95113. }
  95114. declare module BABYLON {
  95115. /** @hidden */
  95116. export var lightFragmentDeclaration: {
  95117. name: string;
  95118. shader: string;
  95119. };
  95120. }
  95121. declare module BABYLON {
  95122. /** @hidden */
  95123. export var lightUboDeclaration: {
  95124. name: string;
  95125. shader: string;
  95126. };
  95127. }
  95128. declare module BABYLON {
  95129. /** @hidden */
  95130. export var lightsFragmentFunctions: {
  95131. name: string;
  95132. shader: string;
  95133. };
  95134. }
  95135. declare module BABYLON {
  95136. /** @hidden */
  95137. export var shadowsFragmentFunctions: {
  95138. name: string;
  95139. shader: string;
  95140. };
  95141. }
  95142. declare module BABYLON {
  95143. /** @hidden */
  95144. export var fresnelFunction: {
  95145. name: string;
  95146. shader: string;
  95147. };
  95148. }
  95149. declare module BABYLON {
  95150. /** @hidden */
  95151. export var reflectionFunction: {
  95152. name: string;
  95153. shader: string;
  95154. };
  95155. }
  95156. declare module BABYLON {
  95157. /** @hidden */
  95158. export var bumpFragmentFunctions: {
  95159. name: string;
  95160. shader: string;
  95161. };
  95162. }
  95163. declare module BABYLON {
  95164. /** @hidden */
  95165. export var logDepthDeclaration: {
  95166. name: string;
  95167. shader: string;
  95168. };
  95169. }
  95170. declare module BABYLON {
  95171. /** @hidden */
  95172. export var bumpFragment: {
  95173. name: string;
  95174. shader: string;
  95175. };
  95176. }
  95177. declare module BABYLON {
  95178. /** @hidden */
  95179. export var depthPrePass: {
  95180. name: string;
  95181. shader: string;
  95182. };
  95183. }
  95184. declare module BABYLON {
  95185. /** @hidden */
  95186. export var lightFragment: {
  95187. name: string;
  95188. shader: string;
  95189. };
  95190. }
  95191. declare module BABYLON {
  95192. /** @hidden */
  95193. export var logDepthFragment: {
  95194. name: string;
  95195. shader: string;
  95196. };
  95197. }
  95198. declare module BABYLON {
  95199. /** @hidden */
  95200. export var defaultPixelShader: {
  95201. name: string;
  95202. shader: string;
  95203. };
  95204. }
  95205. declare module BABYLON {
  95206. /** @hidden */
  95207. export var defaultVertexDeclaration: {
  95208. name: string;
  95209. shader: string;
  95210. };
  95211. }
  95212. declare module BABYLON {
  95213. /** @hidden */
  95214. export var bumpVertexDeclaration: {
  95215. name: string;
  95216. shader: string;
  95217. };
  95218. }
  95219. declare module BABYLON {
  95220. /** @hidden */
  95221. export var bumpVertex: {
  95222. name: string;
  95223. shader: string;
  95224. };
  95225. }
  95226. declare module BABYLON {
  95227. /** @hidden */
  95228. export var fogVertex: {
  95229. name: string;
  95230. shader: string;
  95231. };
  95232. }
  95233. declare module BABYLON {
  95234. /** @hidden */
  95235. export var shadowsVertex: {
  95236. name: string;
  95237. shader: string;
  95238. };
  95239. }
  95240. declare module BABYLON {
  95241. /** @hidden */
  95242. export var pointCloudVertex: {
  95243. name: string;
  95244. shader: string;
  95245. };
  95246. }
  95247. declare module BABYLON {
  95248. /** @hidden */
  95249. export var logDepthVertex: {
  95250. name: string;
  95251. shader: string;
  95252. };
  95253. }
  95254. declare module BABYLON {
  95255. /** @hidden */
  95256. export var defaultVertexShader: {
  95257. name: string;
  95258. shader: string;
  95259. };
  95260. }
  95261. declare module BABYLON {
  95262. /** @hidden */
  95263. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  95264. MAINUV1: boolean;
  95265. MAINUV2: boolean;
  95266. DIFFUSE: boolean;
  95267. DIFFUSEDIRECTUV: number;
  95268. AMBIENT: boolean;
  95269. AMBIENTDIRECTUV: number;
  95270. OPACITY: boolean;
  95271. OPACITYDIRECTUV: number;
  95272. OPACITYRGB: boolean;
  95273. REFLECTION: boolean;
  95274. EMISSIVE: boolean;
  95275. EMISSIVEDIRECTUV: number;
  95276. SPECULAR: boolean;
  95277. SPECULARDIRECTUV: number;
  95278. BUMP: boolean;
  95279. BUMPDIRECTUV: number;
  95280. PARALLAX: boolean;
  95281. PARALLAXOCCLUSION: boolean;
  95282. SPECULAROVERALPHA: boolean;
  95283. CLIPPLANE: boolean;
  95284. CLIPPLANE2: boolean;
  95285. CLIPPLANE3: boolean;
  95286. CLIPPLANE4: boolean;
  95287. ALPHATEST: boolean;
  95288. DEPTHPREPASS: boolean;
  95289. ALPHAFROMDIFFUSE: boolean;
  95290. POINTSIZE: boolean;
  95291. FOG: boolean;
  95292. SPECULARTERM: boolean;
  95293. DIFFUSEFRESNEL: boolean;
  95294. OPACITYFRESNEL: boolean;
  95295. REFLECTIONFRESNEL: boolean;
  95296. REFRACTIONFRESNEL: boolean;
  95297. EMISSIVEFRESNEL: boolean;
  95298. FRESNEL: boolean;
  95299. NORMAL: boolean;
  95300. UV1: boolean;
  95301. UV2: boolean;
  95302. VERTEXCOLOR: boolean;
  95303. VERTEXALPHA: boolean;
  95304. NUM_BONE_INFLUENCERS: number;
  95305. BonesPerMesh: number;
  95306. BONETEXTURE: boolean;
  95307. INSTANCES: boolean;
  95308. GLOSSINESS: boolean;
  95309. ROUGHNESS: boolean;
  95310. EMISSIVEASILLUMINATION: boolean;
  95311. LINKEMISSIVEWITHDIFFUSE: boolean;
  95312. REFLECTIONFRESNELFROMSPECULAR: boolean;
  95313. LIGHTMAP: boolean;
  95314. LIGHTMAPDIRECTUV: number;
  95315. OBJECTSPACE_NORMALMAP: boolean;
  95316. USELIGHTMAPASSHADOWMAP: boolean;
  95317. REFLECTIONMAP_3D: boolean;
  95318. REFLECTIONMAP_SPHERICAL: boolean;
  95319. REFLECTIONMAP_PLANAR: boolean;
  95320. REFLECTIONMAP_CUBIC: boolean;
  95321. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  95322. REFLECTIONMAP_PROJECTION: boolean;
  95323. REFLECTIONMAP_SKYBOX: boolean;
  95324. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  95325. REFLECTIONMAP_EXPLICIT: boolean;
  95326. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  95327. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  95328. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  95329. INVERTCUBICMAP: boolean;
  95330. LOGARITHMICDEPTH: boolean;
  95331. REFRACTION: boolean;
  95332. REFRACTIONMAP_3D: boolean;
  95333. REFLECTIONOVERALPHA: boolean;
  95334. TWOSIDEDLIGHTING: boolean;
  95335. SHADOWFLOAT: boolean;
  95336. MORPHTARGETS: boolean;
  95337. MORPHTARGETS_NORMAL: boolean;
  95338. MORPHTARGETS_TANGENT: boolean;
  95339. MORPHTARGETS_UV: boolean;
  95340. NUM_MORPH_INFLUENCERS: number;
  95341. NONUNIFORMSCALING: boolean;
  95342. PREMULTIPLYALPHA: boolean;
  95343. IMAGEPROCESSING: boolean;
  95344. VIGNETTE: boolean;
  95345. VIGNETTEBLENDMODEMULTIPLY: boolean;
  95346. VIGNETTEBLENDMODEOPAQUE: boolean;
  95347. TONEMAPPING: boolean;
  95348. TONEMAPPING_ACES: boolean;
  95349. CONTRAST: boolean;
  95350. COLORCURVES: boolean;
  95351. COLORGRADING: boolean;
  95352. COLORGRADING3D: boolean;
  95353. SAMPLER3DGREENDEPTH: boolean;
  95354. SAMPLER3DBGRMAP: boolean;
  95355. IMAGEPROCESSINGPOSTPROCESS: boolean;
  95356. MULTIVIEW: boolean;
  95357. /**
  95358. * If the reflection texture on this material is in linear color space
  95359. * @hidden
  95360. */
  95361. IS_REFLECTION_LINEAR: boolean;
  95362. /**
  95363. * If the refraction texture on this material is in linear color space
  95364. * @hidden
  95365. */
  95366. IS_REFRACTION_LINEAR: boolean;
  95367. EXPOSURE: boolean;
  95368. constructor();
  95369. setReflectionMode(modeToEnable: string): void;
  95370. }
  95371. /**
  95372. * This is the default material used in Babylon. It is the best trade off between quality
  95373. * and performances.
  95374. * @see http://doc.babylonjs.com/babylon101/materials
  95375. */
  95376. export class StandardMaterial extends PushMaterial {
  95377. private _diffuseTexture;
  95378. /**
  95379. * The basic texture of the material as viewed under a light.
  95380. */
  95381. diffuseTexture: Nullable<BaseTexture>;
  95382. private _ambientTexture;
  95383. /**
  95384. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  95385. */
  95386. ambientTexture: Nullable<BaseTexture>;
  95387. private _opacityTexture;
  95388. /**
  95389. * Define the transparency of the material from a texture.
  95390. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  95391. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  95392. */
  95393. opacityTexture: Nullable<BaseTexture>;
  95394. private _reflectionTexture;
  95395. /**
  95396. * Define the texture used to display the reflection.
  95397. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95398. */
  95399. reflectionTexture: Nullable<BaseTexture>;
  95400. private _emissiveTexture;
  95401. /**
  95402. * Define texture of the material as if self lit.
  95403. * This will be mixed in the final result even in the absence of light.
  95404. */
  95405. emissiveTexture: Nullable<BaseTexture>;
  95406. private _specularTexture;
  95407. /**
  95408. * Define how the color and intensity of the highlight given by the light in the material.
  95409. */
  95410. specularTexture: Nullable<BaseTexture>;
  95411. private _bumpTexture;
  95412. /**
  95413. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  95414. * 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.
  95415. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  95416. */
  95417. bumpTexture: Nullable<BaseTexture>;
  95418. private _lightmapTexture;
  95419. /**
  95420. * Complex lighting can be computationally expensive to compute at runtime.
  95421. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  95422. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  95423. */
  95424. lightmapTexture: Nullable<BaseTexture>;
  95425. private _refractionTexture;
  95426. /**
  95427. * Define the texture used to display the refraction.
  95428. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95429. */
  95430. refractionTexture: Nullable<BaseTexture>;
  95431. /**
  95432. * The color of the material lit by the environmental background lighting.
  95433. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  95434. */
  95435. ambientColor: Color3;
  95436. /**
  95437. * The basic color of the material as viewed under a light.
  95438. */
  95439. diffuseColor: Color3;
  95440. /**
  95441. * Define how the color and intensity of the highlight given by the light in the material.
  95442. */
  95443. specularColor: Color3;
  95444. /**
  95445. * Define the color of the material as if self lit.
  95446. * This will be mixed in the final result even in the absence of light.
  95447. */
  95448. emissiveColor: Color3;
  95449. /**
  95450. * Defines how sharp are the highlights in the material.
  95451. * The bigger the value the sharper giving a more glossy feeling to the result.
  95452. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  95453. */
  95454. specularPower: number;
  95455. private _useAlphaFromDiffuseTexture;
  95456. /**
  95457. * Does the transparency come from the diffuse texture alpha channel.
  95458. */
  95459. useAlphaFromDiffuseTexture: boolean;
  95460. private _useEmissiveAsIllumination;
  95461. /**
  95462. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  95463. */
  95464. useEmissiveAsIllumination: boolean;
  95465. private _linkEmissiveWithDiffuse;
  95466. /**
  95467. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  95468. * the emissive level when the final color is close to one.
  95469. */
  95470. linkEmissiveWithDiffuse: boolean;
  95471. private _useSpecularOverAlpha;
  95472. /**
  95473. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  95474. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  95475. */
  95476. useSpecularOverAlpha: boolean;
  95477. private _useReflectionOverAlpha;
  95478. /**
  95479. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  95480. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  95481. */
  95482. useReflectionOverAlpha: boolean;
  95483. private _disableLighting;
  95484. /**
  95485. * Does lights from the scene impacts this material.
  95486. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  95487. */
  95488. disableLighting: boolean;
  95489. private _useObjectSpaceNormalMap;
  95490. /**
  95491. * Allows using an object space normal map (instead of tangent space).
  95492. */
  95493. useObjectSpaceNormalMap: boolean;
  95494. private _useParallax;
  95495. /**
  95496. * Is parallax enabled or not.
  95497. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95498. */
  95499. useParallax: boolean;
  95500. private _useParallaxOcclusion;
  95501. /**
  95502. * Is parallax occlusion enabled or not.
  95503. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  95504. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95505. */
  95506. useParallaxOcclusion: boolean;
  95507. /**
  95508. * 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.
  95509. */
  95510. parallaxScaleBias: number;
  95511. private _roughness;
  95512. /**
  95513. * Helps to define how blurry the reflections should appears in the material.
  95514. */
  95515. roughness: number;
  95516. /**
  95517. * In case of refraction, define the value of the index of refraction.
  95518. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95519. */
  95520. indexOfRefraction: number;
  95521. /**
  95522. * Invert the refraction texture alongside the y axis.
  95523. * It can be useful with procedural textures or probe for instance.
  95524. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95525. */
  95526. invertRefractionY: boolean;
  95527. /**
  95528. * Defines the alpha limits in alpha test mode.
  95529. */
  95530. alphaCutOff: number;
  95531. private _useLightmapAsShadowmap;
  95532. /**
  95533. * In case of light mapping, define whether the map contains light or shadow informations.
  95534. */
  95535. useLightmapAsShadowmap: boolean;
  95536. private _diffuseFresnelParameters;
  95537. /**
  95538. * Define the diffuse fresnel parameters of the material.
  95539. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95540. */
  95541. diffuseFresnelParameters: FresnelParameters;
  95542. private _opacityFresnelParameters;
  95543. /**
  95544. * Define the opacity fresnel parameters of the material.
  95545. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95546. */
  95547. opacityFresnelParameters: FresnelParameters;
  95548. private _reflectionFresnelParameters;
  95549. /**
  95550. * Define the reflection fresnel parameters of the material.
  95551. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95552. */
  95553. reflectionFresnelParameters: FresnelParameters;
  95554. private _refractionFresnelParameters;
  95555. /**
  95556. * Define the refraction fresnel parameters of the material.
  95557. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95558. */
  95559. refractionFresnelParameters: FresnelParameters;
  95560. private _emissiveFresnelParameters;
  95561. /**
  95562. * Define the emissive fresnel parameters of the material.
  95563. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95564. */
  95565. emissiveFresnelParameters: FresnelParameters;
  95566. private _useReflectionFresnelFromSpecular;
  95567. /**
  95568. * If true automatically deducts the fresnels values from the material specularity.
  95569. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95570. */
  95571. useReflectionFresnelFromSpecular: boolean;
  95572. private _useGlossinessFromSpecularMapAlpha;
  95573. /**
  95574. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  95575. */
  95576. useGlossinessFromSpecularMapAlpha: boolean;
  95577. private _maxSimultaneousLights;
  95578. /**
  95579. * Defines the maximum number of lights that can be used in the material
  95580. */
  95581. maxSimultaneousLights: number;
  95582. private _invertNormalMapX;
  95583. /**
  95584. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  95585. */
  95586. invertNormalMapX: boolean;
  95587. private _invertNormalMapY;
  95588. /**
  95589. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  95590. */
  95591. invertNormalMapY: boolean;
  95592. private _twoSidedLighting;
  95593. /**
  95594. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  95595. */
  95596. twoSidedLighting: boolean;
  95597. /**
  95598. * Default configuration related to image processing available in the standard Material.
  95599. */
  95600. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95601. /**
  95602. * Gets the image processing configuration used either in this material.
  95603. */
  95604. /**
  95605. * Sets the Default image processing configuration used either in the this material.
  95606. *
  95607. * If sets to null, the scene one is in use.
  95608. */
  95609. imageProcessingConfiguration: ImageProcessingConfiguration;
  95610. /**
  95611. * Keep track of the image processing observer to allow dispose and replace.
  95612. */
  95613. private _imageProcessingObserver;
  95614. /**
  95615. * Attaches a new image processing configuration to the Standard Material.
  95616. * @param configuration
  95617. */
  95618. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  95619. /**
  95620. * Gets wether the color curves effect is enabled.
  95621. */
  95622. /**
  95623. * Sets wether the color curves effect is enabled.
  95624. */
  95625. cameraColorCurvesEnabled: boolean;
  95626. /**
  95627. * Gets wether the color grading effect is enabled.
  95628. */
  95629. /**
  95630. * Gets wether the color grading effect is enabled.
  95631. */
  95632. cameraColorGradingEnabled: boolean;
  95633. /**
  95634. * Gets wether tonemapping is enabled or not.
  95635. */
  95636. /**
  95637. * Sets wether tonemapping is enabled or not
  95638. */
  95639. cameraToneMappingEnabled: boolean;
  95640. /**
  95641. * The camera exposure used on this material.
  95642. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95643. * This corresponds to a photographic exposure.
  95644. */
  95645. /**
  95646. * The camera exposure used on this material.
  95647. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95648. * This corresponds to a photographic exposure.
  95649. */
  95650. cameraExposure: number;
  95651. /**
  95652. * Gets The camera contrast used on this material.
  95653. */
  95654. /**
  95655. * Sets The camera contrast used on this material.
  95656. */
  95657. cameraContrast: number;
  95658. /**
  95659. * Gets the Color Grading 2D Lookup Texture.
  95660. */
  95661. /**
  95662. * Sets the Color Grading 2D Lookup Texture.
  95663. */
  95664. cameraColorGradingTexture: Nullable<BaseTexture>;
  95665. /**
  95666. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95667. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95668. * 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;
  95669. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95670. */
  95671. /**
  95672. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95673. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95674. * 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;
  95675. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95676. */
  95677. cameraColorCurves: Nullable<ColorCurves>;
  95678. /**
  95679. * Custom callback helping to override the default shader used in the material.
  95680. */
  95681. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  95682. protected _renderTargets: SmartArray<RenderTargetTexture>;
  95683. protected _worldViewProjectionMatrix: Matrix;
  95684. protected _globalAmbientColor: Color3;
  95685. protected _useLogarithmicDepth: boolean;
  95686. protected _rebuildInParallel: boolean;
  95687. /**
  95688. * Instantiates a new standard material.
  95689. * This is the default material used in Babylon. It is the best trade off between quality
  95690. * and performances.
  95691. * @see http://doc.babylonjs.com/babylon101/materials
  95692. * @param name Define the name of the material in the scene
  95693. * @param scene Define the scene the material belong to
  95694. */
  95695. constructor(name: string, scene: Scene);
  95696. /**
  95697. * Gets a boolean indicating that current material needs to register RTT
  95698. */
  95699. readonly hasRenderTargetTextures: boolean;
  95700. /**
  95701. * Gets the current class name of the material e.g. "StandardMaterial"
  95702. * Mainly use in serialization.
  95703. * @returns the class name
  95704. */
  95705. getClassName(): string;
  95706. /**
  95707. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  95708. * You can try switching to logarithmic depth.
  95709. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  95710. */
  95711. useLogarithmicDepth: boolean;
  95712. /**
  95713. * Specifies if the material will require alpha blending
  95714. * @returns a boolean specifying if alpha blending is needed
  95715. */
  95716. needAlphaBlending(): boolean;
  95717. /**
  95718. * Specifies if this material should be rendered in alpha test mode
  95719. * @returns a boolean specifying if an alpha test is needed.
  95720. */
  95721. needAlphaTesting(): boolean;
  95722. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  95723. /**
  95724. * Get the texture used for alpha test purpose.
  95725. * @returns the diffuse texture in case of the standard material.
  95726. */
  95727. getAlphaTestTexture(): Nullable<BaseTexture>;
  95728. /**
  95729. * Get if the submesh is ready to be used and all its information available.
  95730. * Child classes can use it to update shaders
  95731. * @param mesh defines the mesh to check
  95732. * @param subMesh defines which submesh to check
  95733. * @param useInstances specifies that instances should be used
  95734. * @returns a boolean indicating that the submesh is ready or not
  95735. */
  95736. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95737. /**
  95738. * Builds the material UBO layouts.
  95739. * Used internally during the effect preparation.
  95740. */
  95741. buildUniformLayout(): void;
  95742. /**
  95743. * Unbinds the material from the mesh
  95744. */
  95745. unbind(): void;
  95746. /**
  95747. * Binds the submesh to this material by preparing the effect and shader to draw
  95748. * @param world defines the world transformation matrix
  95749. * @param mesh defines the mesh containing the submesh
  95750. * @param subMesh defines the submesh to bind the material to
  95751. */
  95752. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95753. /**
  95754. * Get the list of animatables in the material.
  95755. * @returns the list of animatables object used in the material
  95756. */
  95757. getAnimatables(): IAnimatable[];
  95758. /**
  95759. * Gets the active textures from the material
  95760. * @returns an array of textures
  95761. */
  95762. getActiveTextures(): BaseTexture[];
  95763. /**
  95764. * Specifies if the material uses a texture
  95765. * @param texture defines the texture to check against the material
  95766. * @returns a boolean specifying if the material uses the texture
  95767. */
  95768. hasTexture(texture: BaseTexture): boolean;
  95769. /**
  95770. * Disposes the material
  95771. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95772. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95773. */
  95774. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  95775. /**
  95776. * Makes a duplicate of the material, and gives it a new name
  95777. * @param name defines the new name for the duplicated material
  95778. * @returns the cloned material
  95779. */
  95780. clone(name: string): StandardMaterial;
  95781. /**
  95782. * Serializes this material in a JSON representation
  95783. * @returns the serialized material object
  95784. */
  95785. serialize(): any;
  95786. /**
  95787. * Creates a standard material from parsed material data
  95788. * @param source defines the JSON representation of the material
  95789. * @param scene defines the hosting scene
  95790. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95791. * @returns a new standard material
  95792. */
  95793. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  95794. /**
  95795. * Are diffuse textures enabled in the application.
  95796. */
  95797. static DiffuseTextureEnabled: boolean;
  95798. /**
  95799. * Are ambient textures enabled in the application.
  95800. */
  95801. static AmbientTextureEnabled: boolean;
  95802. /**
  95803. * Are opacity textures enabled in the application.
  95804. */
  95805. static OpacityTextureEnabled: boolean;
  95806. /**
  95807. * Are reflection textures enabled in the application.
  95808. */
  95809. static ReflectionTextureEnabled: boolean;
  95810. /**
  95811. * Are emissive textures enabled in the application.
  95812. */
  95813. static EmissiveTextureEnabled: boolean;
  95814. /**
  95815. * Are specular textures enabled in the application.
  95816. */
  95817. static SpecularTextureEnabled: boolean;
  95818. /**
  95819. * Are bump textures enabled in the application.
  95820. */
  95821. static BumpTextureEnabled: boolean;
  95822. /**
  95823. * Are lightmap textures enabled in the application.
  95824. */
  95825. static LightmapTextureEnabled: boolean;
  95826. /**
  95827. * Are refraction textures enabled in the application.
  95828. */
  95829. static RefractionTextureEnabled: boolean;
  95830. /**
  95831. * Are color grading textures enabled in the application.
  95832. */
  95833. static ColorGradingTextureEnabled: boolean;
  95834. /**
  95835. * Are fresnels enabled in the application.
  95836. */
  95837. static FresnelEnabled: boolean;
  95838. }
  95839. }
  95840. declare module BABYLON {
  95841. /**
  95842. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  95843. *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.
  95844. * The SPS is also a particle system. It provides some methods to manage the particles.
  95845. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  95846. *
  95847. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  95848. */
  95849. export class SolidParticleSystem implements IDisposable {
  95850. /**
  95851. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  95852. * Example : var p = SPS.particles[i];
  95853. */
  95854. particles: SolidParticle[];
  95855. /**
  95856. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  95857. */
  95858. nbParticles: number;
  95859. /**
  95860. * If the particles must ever face the camera (default false). Useful for planar particles.
  95861. */
  95862. billboard: boolean;
  95863. /**
  95864. * Recompute normals when adding a shape
  95865. */
  95866. recomputeNormals: boolean;
  95867. /**
  95868. * This a counter ofr your own usage. It's not set by any SPS functions.
  95869. */
  95870. counter: number;
  95871. /**
  95872. * The SPS name. This name is also given to the underlying mesh.
  95873. */
  95874. name: string;
  95875. /**
  95876. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  95877. */
  95878. mesh: Mesh;
  95879. /**
  95880. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  95881. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  95882. */
  95883. vars: any;
  95884. /**
  95885. * This array is populated when the SPS is set as 'pickable'.
  95886. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  95887. * Each element of this array is an object `{idx: int, faceId: int}`.
  95888. * `idx` is the picked particle index in the `SPS.particles` array
  95889. * `faceId` is the picked face index counted within this particle.
  95890. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  95891. */
  95892. pickedParticles: {
  95893. idx: number;
  95894. faceId: number;
  95895. }[];
  95896. /**
  95897. * This array is populated when `enableDepthSort` is set to true.
  95898. * Each element of this array is an instance of the class DepthSortedParticle.
  95899. */
  95900. depthSortedParticles: DepthSortedParticle[];
  95901. /**
  95902. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  95903. * @hidden
  95904. */
  95905. _bSphereOnly: boolean;
  95906. /**
  95907. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  95908. * @hidden
  95909. */
  95910. _bSphereRadiusFactor: number;
  95911. private _scene;
  95912. private _positions;
  95913. private _indices;
  95914. private _normals;
  95915. private _colors;
  95916. private _uvs;
  95917. private _indices32;
  95918. private _positions32;
  95919. private _normals32;
  95920. private _fixedNormal32;
  95921. private _colors32;
  95922. private _uvs32;
  95923. private _index;
  95924. private _updatable;
  95925. private _pickable;
  95926. private _isVisibilityBoxLocked;
  95927. private _alwaysVisible;
  95928. private _depthSort;
  95929. private _expandable;
  95930. private _shapeCounter;
  95931. private _copy;
  95932. private _color;
  95933. private _computeParticleColor;
  95934. private _computeParticleTexture;
  95935. private _computeParticleRotation;
  95936. private _computeParticleVertex;
  95937. private _computeBoundingBox;
  95938. private _depthSortParticles;
  95939. private _camera;
  95940. private _mustUnrotateFixedNormals;
  95941. private _particlesIntersect;
  95942. private _needs32Bits;
  95943. private _isNotBuilt;
  95944. private _lastParticleId;
  95945. private _idxOfId;
  95946. private _multimaterialEnabled;
  95947. private _useModelMaterial;
  95948. private _indicesByMaterial;
  95949. private _materialIndexes;
  95950. private _depthSortFunction;
  95951. private _materialSortFunction;
  95952. private _materials;
  95953. private _multimaterial;
  95954. private _materialIndexesById;
  95955. private _defaultMaterial;
  95956. private _autoUpdateSubMeshes;
  95957. /**
  95958. * Creates a SPS (Solid Particle System) object.
  95959. * @param name (String) is the SPS name, this will be the underlying mesh name.
  95960. * @param scene (Scene) is the scene in which the SPS is added.
  95961. * @param options defines the options of the sps e.g.
  95962. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  95963. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  95964. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  95965. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  95966. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  95967. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  95968. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  95969. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  95970. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  95971. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  95972. */
  95973. constructor(name: string, scene: Scene, options?: {
  95974. updatable?: boolean;
  95975. isPickable?: boolean;
  95976. enableDepthSort?: boolean;
  95977. particleIntersection?: boolean;
  95978. boundingSphereOnly?: boolean;
  95979. bSphereRadiusFactor?: number;
  95980. expandable?: boolean;
  95981. useModelMaterial?: boolean;
  95982. enableMultiMaterial?: boolean;
  95983. });
  95984. /**
  95985. * Builds the SPS underlying mesh. Returns a standard Mesh.
  95986. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  95987. * @returns the created mesh
  95988. */
  95989. buildMesh(): Mesh;
  95990. /**
  95991. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  95992. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  95993. * Thus the particles generated from `digest()` have their property `position` set yet.
  95994. * @param mesh ( Mesh ) is the mesh to be digested
  95995. * @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
  95996. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  95997. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  95998. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  95999. * @returns the current SPS
  96000. */
  96001. digest(mesh: Mesh, options?: {
  96002. facetNb?: number;
  96003. number?: number;
  96004. delta?: number;
  96005. storage?: [];
  96006. }): SolidParticleSystem;
  96007. /**
  96008. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  96009. * @hidden
  96010. */
  96011. private _unrotateFixedNormals;
  96012. /**
  96013. * Resets the temporary working copy particle
  96014. * @hidden
  96015. */
  96016. private _resetCopy;
  96017. /**
  96018. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  96019. * @param p the current index in the positions array to be updated
  96020. * @param ind the current index in the indices array
  96021. * @param shape a Vector3 array, the shape geometry
  96022. * @param positions the positions array to be updated
  96023. * @param meshInd the shape indices array
  96024. * @param indices the indices array to be updated
  96025. * @param meshUV the shape uv array
  96026. * @param uvs the uv array to be updated
  96027. * @param meshCol the shape color array
  96028. * @param colors the color array to be updated
  96029. * @param meshNor the shape normals array
  96030. * @param normals the normals array to be updated
  96031. * @param idx the particle index
  96032. * @param idxInShape the particle index in its shape
  96033. * @param options the addShape() method passed options
  96034. * @model the particle model
  96035. * @hidden
  96036. */
  96037. private _meshBuilder;
  96038. /**
  96039. * Returns a shape Vector3 array from positions float array
  96040. * @param positions float array
  96041. * @returns a vector3 array
  96042. * @hidden
  96043. */
  96044. private _posToShape;
  96045. /**
  96046. * Returns a shapeUV array from a float uvs (array deep copy)
  96047. * @param uvs as a float array
  96048. * @returns a shapeUV array
  96049. * @hidden
  96050. */
  96051. private _uvsToShapeUV;
  96052. /**
  96053. * Adds a new particle object in the particles array
  96054. * @param idx particle index in particles array
  96055. * @param id particle id
  96056. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  96057. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  96058. * @param model particle ModelShape object
  96059. * @param shapeId model shape identifier
  96060. * @param idxInShape index of the particle in the current model
  96061. * @param bInfo model bounding info object
  96062. * @param storage target storage array, if any
  96063. * @hidden
  96064. */
  96065. private _addParticle;
  96066. /**
  96067. * Adds some particles to the SPS from the model shape. Returns the shape id.
  96068. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  96069. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  96070. * @param nb (positive integer) the number of particles to be created from this model
  96071. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  96072. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  96073. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  96074. * @returns the number of shapes in the system
  96075. */
  96076. addShape(mesh: Mesh, nb: number, options?: {
  96077. positionFunction?: any;
  96078. vertexFunction?: any;
  96079. storage?: [];
  96080. }): number;
  96081. /**
  96082. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  96083. * @hidden
  96084. */
  96085. private _rebuildParticle;
  96086. /**
  96087. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  96088. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  96089. * @returns the SPS.
  96090. */
  96091. rebuildMesh(reset?: boolean): SolidParticleSystem;
  96092. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  96093. * Returns an array with the removed particles.
  96094. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  96095. * The SPS can't be empty so at least one particle needs to remain in place.
  96096. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  96097. * @param start index of the first particle to remove
  96098. * @param end index of the last particle to remove (included)
  96099. * @returns an array populated with the removed particles
  96100. */
  96101. removeParticles(start: number, end: number): SolidParticle[];
  96102. /**
  96103. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  96104. * @param solidParticleArray an array populated with Solid Particles objects
  96105. * @returns the SPS
  96106. */
  96107. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  96108. /**
  96109. * Creates a new particle and modifies the SPS mesh geometry :
  96110. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  96111. * - calls _addParticle() to populate the particle array
  96112. * factorized code from addShape() and insertParticlesFromArray()
  96113. * @param idx particle index in the particles array
  96114. * @param i particle index in its shape
  96115. * @param modelShape particle ModelShape object
  96116. * @param shape shape vertex array
  96117. * @param meshInd shape indices array
  96118. * @param meshUV shape uv array
  96119. * @param meshCol shape color array
  96120. * @param meshNor shape normals array
  96121. * @param bbInfo shape bounding info
  96122. * @param storage target particle storage
  96123. * @options addShape() passed options
  96124. * @hidden
  96125. */
  96126. private _insertNewParticle;
  96127. /**
  96128. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  96129. * This method calls `updateParticle()` for each particle of the SPS.
  96130. * For an animated SPS, it is usually called within the render loop.
  96131. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  96132. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  96133. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  96134. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  96135. * @returns the SPS.
  96136. */
  96137. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  96138. /**
  96139. * Disposes the SPS.
  96140. */
  96141. dispose(): void;
  96142. /**
  96143. * Returns a SolidParticle object from its identifier : particle.id
  96144. * @param id (integer) the particle Id
  96145. * @returns the searched particle or null if not found in the SPS.
  96146. */
  96147. getParticleById(id: number): Nullable<SolidParticle>;
  96148. /**
  96149. * Returns a new array populated with the particles having the passed shapeId.
  96150. * @param shapeId (integer) the shape identifier
  96151. * @returns a new solid particle array
  96152. */
  96153. getParticlesByShapeId(shapeId: number): SolidParticle[];
  96154. /**
  96155. * Populates the passed array "ref" with the particles having the passed shapeId.
  96156. * @param shapeId the shape identifier
  96157. * @returns the SPS
  96158. * @param ref
  96159. */
  96160. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  96161. /**
  96162. * Computes the required SubMeshes according the materials assigned to the particles.
  96163. * @returns the solid particle system.
  96164. * Does nothing if called before the SPS mesh is built.
  96165. */
  96166. computeSubMeshes(): SolidParticleSystem;
  96167. /**
  96168. * Sorts the solid particles by material when MultiMaterial is enabled.
  96169. * Updates the indices32 array.
  96170. * Updates the indicesByMaterial array.
  96171. * Updates the mesh indices array.
  96172. * @returns the SPS
  96173. * @hidden
  96174. */
  96175. private _sortParticlesByMaterial;
  96176. /**
  96177. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  96178. * @hidden
  96179. */
  96180. private _setMaterialIndexesById;
  96181. /**
  96182. * Returns an array with unique values of Materials from the passed array
  96183. * @param array the material array to be checked and filtered
  96184. * @hidden
  96185. */
  96186. private _filterUniqueMaterialId;
  96187. /**
  96188. * Sets a new Standard Material as _defaultMaterial if not already set.
  96189. * @hidden
  96190. */
  96191. private _setDefaultMaterial;
  96192. /**
  96193. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  96194. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  96195. * @returns the SPS.
  96196. */
  96197. refreshVisibleSize(): SolidParticleSystem;
  96198. /**
  96199. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  96200. * @param size the size (float) of the visibility box
  96201. * note : this doesn't lock the SPS mesh bounding box.
  96202. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  96203. */
  96204. setVisibilityBox(size: number): void;
  96205. /**
  96206. * Gets whether the SPS as always visible or not
  96207. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  96208. */
  96209. /**
  96210. * Sets the SPS as always visible or not
  96211. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  96212. */
  96213. isAlwaysVisible: boolean;
  96214. /**
  96215. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  96216. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  96217. */
  96218. /**
  96219. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  96220. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  96221. */
  96222. isVisibilityBoxLocked: boolean;
  96223. /**
  96224. * Tells to `setParticles()` to compute the particle rotations or not.
  96225. * Default value : true. The SPS is faster when it's set to false.
  96226. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  96227. */
  96228. /**
  96229. * Gets if `setParticles()` computes the particle rotations or not.
  96230. * Default value : true. The SPS is faster when it's set to false.
  96231. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  96232. */
  96233. computeParticleRotation: boolean;
  96234. /**
  96235. * Tells to `setParticles()` to compute the particle colors or not.
  96236. * Default value : true. The SPS is faster when it's set to false.
  96237. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  96238. */
  96239. /**
  96240. * Gets if `setParticles()` computes the particle colors or not.
  96241. * Default value : true. The SPS is faster when it's set to false.
  96242. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  96243. */
  96244. computeParticleColor: boolean;
  96245. /**
  96246. * Gets if `setParticles()` computes the particle textures or not.
  96247. * Default value : true. The SPS is faster when it's set to false.
  96248. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  96249. */
  96250. computeParticleTexture: boolean;
  96251. /**
  96252. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  96253. * Default value : false. The SPS is faster when it's set to false.
  96254. * Note : the particle custom vertex positions aren't stored values.
  96255. */
  96256. /**
  96257. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  96258. * Default value : false. The SPS is faster when it's set to false.
  96259. * Note : the particle custom vertex positions aren't stored values.
  96260. */
  96261. computeParticleVertex: boolean;
  96262. /**
  96263. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  96264. */
  96265. /**
  96266. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  96267. */
  96268. computeBoundingBox: boolean;
  96269. /**
  96270. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  96271. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  96272. * Default : `true`
  96273. */
  96274. /**
  96275. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  96276. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  96277. * Default : `true`
  96278. */
  96279. depthSortParticles: boolean;
  96280. /**
  96281. * Gets if the SPS is created as expandable at construction time.
  96282. * Default : `false`
  96283. */
  96284. readonly expandable: boolean;
  96285. /**
  96286. * Gets if the SPS supports the Multi Materials
  96287. */
  96288. readonly multimaterialEnabled: boolean;
  96289. /**
  96290. * Gets if the SPS uses the model materials for its own multimaterial.
  96291. */
  96292. readonly useModelMaterial: boolean;
  96293. /**
  96294. * The SPS used material array.
  96295. */
  96296. readonly materials: Material[];
  96297. /**
  96298. * Sets the SPS MultiMaterial from the passed materials.
  96299. * Note : the passed array is internally copied and not used then by reference.
  96300. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  96301. */
  96302. setMultiMaterial(materials: Material[]): void;
  96303. /**
  96304. * The SPS computed multimaterial object
  96305. */
  96306. multimaterial: MultiMaterial;
  96307. /**
  96308. * If the subMeshes must be updated on the next call to setParticles()
  96309. */
  96310. autoUpdateSubMeshes: boolean;
  96311. /**
  96312. * This function does nothing. It may be overwritten to set all the particle first values.
  96313. * The SPS doesn't call this function, you may have to call it by your own.
  96314. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  96315. */
  96316. initParticles(): void;
  96317. /**
  96318. * This function does nothing. It may be overwritten to recycle a particle.
  96319. * The SPS doesn't call this function, you may have to call it by your own.
  96320. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  96321. * @param particle The particle to recycle
  96322. * @returns the recycled particle
  96323. */
  96324. recycleParticle(particle: SolidParticle): SolidParticle;
  96325. /**
  96326. * Updates a particle : this function should be overwritten by the user.
  96327. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  96328. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  96329. * @example : just set a particle position or velocity and recycle conditions
  96330. * @param particle The particle to update
  96331. * @returns the updated particle
  96332. */
  96333. updateParticle(particle: SolidParticle): SolidParticle;
  96334. /**
  96335. * Updates a vertex of a particle : it can be overwritten by the user.
  96336. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  96337. * @param particle the current particle
  96338. * @param vertex the current index of the current particle
  96339. * @param pt the index of the current vertex in the particle shape
  96340. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  96341. * @example : just set a vertex particle position
  96342. * @returns the updated vertex
  96343. */
  96344. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  96345. /**
  96346. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  96347. * This does nothing and may be overwritten by the user.
  96348. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  96349. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  96350. * @param update the boolean update value actually passed to setParticles()
  96351. */
  96352. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  96353. /**
  96354. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  96355. * This will be passed three parameters.
  96356. * This does nothing and may be overwritten by the user.
  96357. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  96358. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  96359. * @param update the boolean update value actually passed to setParticles()
  96360. */
  96361. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  96362. }
  96363. }
  96364. declare module BABYLON {
  96365. /**
  96366. * Represents one particle of a solid particle system.
  96367. */
  96368. export class SolidParticle {
  96369. /**
  96370. * particle global index
  96371. */
  96372. idx: number;
  96373. /**
  96374. * particle identifier
  96375. */
  96376. id: number;
  96377. /**
  96378. * The color of the particle
  96379. */
  96380. color: Nullable<Color4>;
  96381. /**
  96382. * The world space position of the particle.
  96383. */
  96384. position: Vector3;
  96385. /**
  96386. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  96387. */
  96388. rotation: Vector3;
  96389. /**
  96390. * The world space rotation quaternion of the particle.
  96391. */
  96392. rotationQuaternion: Nullable<Quaternion>;
  96393. /**
  96394. * The scaling of the particle.
  96395. */
  96396. scaling: Vector3;
  96397. /**
  96398. * The uvs of the particle.
  96399. */
  96400. uvs: Vector4;
  96401. /**
  96402. * The current speed of the particle.
  96403. */
  96404. velocity: Vector3;
  96405. /**
  96406. * The pivot point in the particle local space.
  96407. */
  96408. pivot: Vector3;
  96409. /**
  96410. * Must the particle be translated from its pivot point in its local space ?
  96411. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  96412. * Default : false
  96413. */
  96414. translateFromPivot: boolean;
  96415. /**
  96416. * Is the particle active or not ?
  96417. */
  96418. alive: boolean;
  96419. /**
  96420. * Is the particle visible or not ?
  96421. */
  96422. isVisible: boolean;
  96423. /**
  96424. * Index of this particle in the global "positions" array (Internal use)
  96425. * @hidden
  96426. */
  96427. _pos: number;
  96428. /**
  96429. * @hidden Index of this particle in the global "indices" array (Internal use)
  96430. */
  96431. _ind: number;
  96432. /**
  96433. * @hidden ModelShape of this particle (Internal use)
  96434. */
  96435. _model: ModelShape;
  96436. /**
  96437. * ModelShape id of this particle
  96438. */
  96439. shapeId: number;
  96440. /**
  96441. * Index of the particle in its shape id
  96442. */
  96443. idxInShape: number;
  96444. /**
  96445. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  96446. */
  96447. _modelBoundingInfo: BoundingInfo;
  96448. /**
  96449. * @hidden Particle BoundingInfo object (Internal use)
  96450. */
  96451. _boundingInfo: BoundingInfo;
  96452. /**
  96453. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  96454. */
  96455. _sps: SolidParticleSystem;
  96456. /**
  96457. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  96458. */
  96459. _stillInvisible: boolean;
  96460. /**
  96461. * @hidden Last computed particle rotation matrix
  96462. */
  96463. _rotationMatrix: number[];
  96464. /**
  96465. * Parent particle Id, if any.
  96466. * Default null.
  96467. */
  96468. parentId: Nullable<number>;
  96469. /**
  96470. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  96471. */
  96472. materialIndex: Nullable<number>;
  96473. /**
  96474. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  96475. * The possible values are :
  96476. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  96477. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  96478. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  96479. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  96480. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  96481. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  96482. * */
  96483. cullingStrategy: number;
  96484. /**
  96485. * @hidden Internal global position in the SPS.
  96486. */
  96487. _globalPosition: Vector3;
  96488. /**
  96489. * Creates a Solid Particle object.
  96490. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  96491. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  96492. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  96493. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  96494. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  96495. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  96496. * @param shapeId (integer) is the model shape identifier in the SPS.
  96497. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  96498. * @param sps defines the sps it is associated to
  96499. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  96500. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  96501. */
  96502. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  96503. /**
  96504. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  96505. * @param target the particle target
  96506. * @returns the current particle
  96507. */
  96508. copyToRef(target: SolidParticle): SolidParticle;
  96509. /**
  96510. * Legacy support, changed scale to scaling
  96511. */
  96512. /**
  96513. * Legacy support, changed scale to scaling
  96514. */
  96515. scale: Vector3;
  96516. /**
  96517. * Legacy support, changed quaternion to rotationQuaternion
  96518. */
  96519. /**
  96520. * Legacy support, changed quaternion to rotationQuaternion
  96521. */
  96522. quaternion: Nullable<Quaternion>;
  96523. /**
  96524. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  96525. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  96526. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  96527. * @returns true if it intersects
  96528. */
  96529. intersectsMesh(target: Mesh | SolidParticle): boolean;
  96530. /**
  96531. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  96532. * A particle is in the frustum if its bounding box intersects the frustum
  96533. * @param frustumPlanes defines the frustum to test
  96534. * @returns true if the particle is in the frustum planes
  96535. */
  96536. isInFrustum(frustumPlanes: Plane[]): boolean;
  96537. /**
  96538. * get the rotation matrix of the particle
  96539. * @hidden
  96540. */
  96541. getRotationMatrix(m: Matrix): void;
  96542. }
  96543. /**
  96544. * Represents the shape of the model used by one particle of a solid particle system.
  96545. * SPS internal tool, don't use it manually.
  96546. */
  96547. export class ModelShape {
  96548. /**
  96549. * The shape id
  96550. * @hidden
  96551. */
  96552. shapeID: number;
  96553. /**
  96554. * flat array of model positions (internal use)
  96555. * @hidden
  96556. */
  96557. _shape: Vector3[];
  96558. /**
  96559. * flat array of model UVs (internal use)
  96560. * @hidden
  96561. */
  96562. _shapeUV: number[];
  96563. /**
  96564. * color array of the model
  96565. * @hidden
  96566. */
  96567. _shapeColors: number[];
  96568. /**
  96569. * indices array of the model
  96570. * @hidden
  96571. */
  96572. _indices: number[];
  96573. /**
  96574. * normals array of the model
  96575. * @hidden
  96576. */
  96577. _normals: number[];
  96578. /**
  96579. * length of the shape in the model indices array (internal use)
  96580. * @hidden
  96581. */
  96582. _indicesLength: number;
  96583. /**
  96584. * Custom position function (internal use)
  96585. * @hidden
  96586. */
  96587. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  96588. /**
  96589. * Custom vertex function (internal use)
  96590. * @hidden
  96591. */
  96592. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  96593. /**
  96594. * Model material (internal use)
  96595. * @hidden
  96596. */
  96597. _material: Nullable<Material>;
  96598. /**
  96599. * 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.
  96600. * SPS internal tool, don't use it manually.
  96601. * @hidden
  96602. */
  96603. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  96604. }
  96605. /**
  96606. * Represents a Depth Sorted Particle in the solid particle system.
  96607. * @hidden
  96608. */
  96609. export class DepthSortedParticle {
  96610. /**
  96611. * Index of the particle in the "indices" array
  96612. */
  96613. ind: number;
  96614. /**
  96615. * Length of the particle shape in the "indices" array
  96616. */
  96617. indicesLength: number;
  96618. /**
  96619. * Squared distance from the particle to the camera
  96620. */
  96621. sqDistance: number;
  96622. /**
  96623. * Material index when used with MultiMaterials
  96624. */
  96625. materialIndex: number;
  96626. /**
  96627. * Creates a new sorted particle
  96628. * @param materialIndex
  96629. */
  96630. constructor(ind: number, indLength: number, materialIndex: number);
  96631. }
  96632. }
  96633. declare module BABYLON {
  96634. /**
  96635. * @hidden
  96636. */
  96637. export class _MeshCollisionData {
  96638. _checkCollisions: boolean;
  96639. _collisionMask: number;
  96640. _collisionGroup: number;
  96641. _collider: Nullable<Collider>;
  96642. _oldPositionForCollisions: Vector3;
  96643. _diffPositionForCollisions: Vector3;
  96644. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  96645. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  96646. }
  96647. }
  96648. declare module BABYLON {
  96649. /** @hidden */
  96650. class _FacetDataStorage {
  96651. facetPositions: Vector3[];
  96652. facetNormals: Vector3[];
  96653. facetPartitioning: number[][];
  96654. facetNb: number;
  96655. partitioningSubdivisions: number;
  96656. partitioningBBoxRatio: number;
  96657. facetDataEnabled: boolean;
  96658. facetParameters: any;
  96659. bbSize: Vector3;
  96660. subDiv: {
  96661. max: number;
  96662. X: number;
  96663. Y: number;
  96664. Z: number;
  96665. };
  96666. facetDepthSort: boolean;
  96667. facetDepthSortEnabled: boolean;
  96668. depthSortedIndices: IndicesArray;
  96669. depthSortedFacets: {
  96670. ind: number;
  96671. sqDistance: number;
  96672. }[];
  96673. facetDepthSortFunction: (f1: {
  96674. ind: number;
  96675. sqDistance: number;
  96676. }, f2: {
  96677. ind: number;
  96678. sqDistance: number;
  96679. }) => number;
  96680. facetDepthSortFrom: Vector3;
  96681. facetDepthSortOrigin: Vector3;
  96682. invertedMatrix: Matrix;
  96683. }
  96684. /**
  96685. * @hidden
  96686. **/
  96687. class _InternalAbstractMeshDataInfo {
  96688. _hasVertexAlpha: boolean;
  96689. _useVertexColors: boolean;
  96690. _numBoneInfluencers: number;
  96691. _applyFog: boolean;
  96692. _receiveShadows: boolean;
  96693. _facetData: _FacetDataStorage;
  96694. _visibility: number;
  96695. _skeleton: Nullable<Skeleton>;
  96696. _layerMask: number;
  96697. _computeBonesUsingShaders: boolean;
  96698. _isActive: boolean;
  96699. _onlyForInstances: boolean;
  96700. _isActiveIntermediate: boolean;
  96701. _onlyForInstancesIntermediate: boolean;
  96702. _actAsRegularMesh: boolean;
  96703. }
  96704. /**
  96705. * Class used to store all common mesh properties
  96706. */
  96707. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  96708. /** No occlusion */
  96709. static OCCLUSION_TYPE_NONE: number;
  96710. /** Occlusion set to optimisitic */
  96711. static OCCLUSION_TYPE_OPTIMISTIC: number;
  96712. /** Occlusion set to strict */
  96713. static OCCLUSION_TYPE_STRICT: number;
  96714. /** Use an accurante occlusion algorithm */
  96715. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  96716. /** Use a conservative occlusion algorithm */
  96717. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  96718. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  96719. * Test order :
  96720. * Is the bounding sphere outside the frustum ?
  96721. * If not, are the bounding box vertices outside the frustum ?
  96722. * It not, then the cullable object is in the frustum.
  96723. */
  96724. static readonly CULLINGSTRATEGY_STANDARD: number;
  96725. /** Culling strategy : Bounding Sphere Only.
  96726. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  96727. * It's also less accurate than the standard because some not visible objects can still be selected.
  96728. * Test : is the bounding sphere outside the frustum ?
  96729. * If not, then the cullable object is in the frustum.
  96730. */
  96731. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  96732. /** Culling strategy : Optimistic Inclusion.
  96733. * This in an inclusion test first, then the standard exclusion test.
  96734. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  96735. * 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.
  96736. * Anyway, it's as accurate as the standard strategy.
  96737. * Test :
  96738. * Is the cullable object bounding sphere center in the frustum ?
  96739. * If not, apply the default culling strategy.
  96740. */
  96741. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  96742. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  96743. * This in an inclusion test first, then the bounding sphere only exclusion test.
  96744. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  96745. * 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.
  96746. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  96747. * Test :
  96748. * Is the cullable object bounding sphere center in the frustum ?
  96749. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  96750. */
  96751. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  96752. /**
  96753. * No billboard
  96754. */
  96755. static readonly BILLBOARDMODE_NONE: number;
  96756. /** Billboard on X axis */
  96757. static readonly BILLBOARDMODE_X: number;
  96758. /** Billboard on Y axis */
  96759. static readonly BILLBOARDMODE_Y: number;
  96760. /** Billboard on Z axis */
  96761. static readonly BILLBOARDMODE_Z: number;
  96762. /** Billboard on all axes */
  96763. static readonly BILLBOARDMODE_ALL: number;
  96764. /** Billboard on using position instead of orientation */
  96765. static readonly BILLBOARDMODE_USE_POSITION: number;
  96766. /** @hidden */
  96767. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  96768. /**
  96769. * The culling strategy to use to check whether the mesh must be rendered or not.
  96770. * This value can be changed at any time and will be used on the next render mesh selection.
  96771. * The possible values are :
  96772. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  96773. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  96774. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  96775. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  96776. * Please read each static variable documentation to get details about the culling process.
  96777. * */
  96778. cullingStrategy: number;
  96779. /**
  96780. * Gets the number of facets in the mesh
  96781. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  96782. */
  96783. readonly facetNb: number;
  96784. /**
  96785. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  96786. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  96787. */
  96788. partitioningSubdivisions: number;
  96789. /**
  96790. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  96791. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  96792. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  96793. */
  96794. partitioningBBoxRatio: number;
  96795. /**
  96796. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  96797. * Works only for updatable meshes.
  96798. * Doesn't work with multi-materials
  96799. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  96800. */
  96801. mustDepthSortFacets: boolean;
  96802. /**
  96803. * The location (Vector3) where the facet depth sort must be computed from.
  96804. * By default, the active camera position.
  96805. * Used only when facet depth sort is enabled
  96806. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  96807. */
  96808. facetDepthSortFrom: Vector3;
  96809. /**
  96810. * gets a boolean indicating if facetData is enabled
  96811. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  96812. */
  96813. readonly isFacetDataEnabled: boolean;
  96814. /** @hidden */
  96815. _updateNonUniformScalingState(value: boolean): boolean;
  96816. /**
  96817. * An event triggered when this mesh collides with another one
  96818. */
  96819. onCollideObservable: Observable<AbstractMesh>;
  96820. /** Set a function to call when this mesh collides with another one */
  96821. onCollide: () => void;
  96822. /**
  96823. * An event triggered when the collision's position changes
  96824. */
  96825. onCollisionPositionChangeObservable: Observable<Vector3>;
  96826. /** Set a function to call when the collision's position changes */
  96827. onCollisionPositionChange: () => void;
  96828. /**
  96829. * An event triggered when material is changed
  96830. */
  96831. onMaterialChangedObservable: Observable<AbstractMesh>;
  96832. /**
  96833. * Gets or sets the orientation for POV movement & rotation
  96834. */
  96835. definedFacingForward: boolean;
  96836. /** @hidden */
  96837. _occlusionQuery: Nullable<WebGLQuery>;
  96838. /** @hidden */
  96839. _renderingGroup: Nullable<RenderingGroup>;
  96840. /**
  96841. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  96842. */
  96843. /**
  96844. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  96845. */
  96846. visibility: number;
  96847. /** Gets or sets the alpha index used to sort transparent meshes
  96848. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  96849. */
  96850. alphaIndex: number;
  96851. /**
  96852. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  96853. */
  96854. isVisible: boolean;
  96855. /**
  96856. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  96857. */
  96858. isPickable: boolean;
  96859. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  96860. showSubMeshesBoundingBox: boolean;
  96861. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  96862. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  96863. */
  96864. isBlocker: boolean;
  96865. /**
  96866. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  96867. */
  96868. enablePointerMoveEvents: boolean;
  96869. /**
  96870. * Specifies the rendering group id for this mesh (0 by default)
  96871. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  96872. */
  96873. renderingGroupId: number;
  96874. private _material;
  96875. /** Gets or sets current material */
  96876. material: Nullable<Material>;
  96877. /**
  96878. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  96879. * @see http://doc.babylonjs.com/babylon101/shadows
  96880. */
  96881. receiveShadows: boolean;
  96882. /** Defines color to use when rendering outline */
  96883. outlineColor: Color3;
  96884. /** Define width to use when rendering outline */
  96885. outlineWidth: number;
  96886. /** Defines color to use when rendering overlay */
  96887. overlayColor: Color3;
  96888. /** Defines alpha to use when rendering overlay */
  96889. overlayAlpha: number;
  96890. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  96891. hasVertexAlpha: boolean;
  96892. /** 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) */
  96893. useVertexColors: boolean;
  96894. /**
  96895. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  96896. */
  96897. computeBonesUsingShaders: boolean;
  96898. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  96899. numBoneInfluencers: number;
  96900. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  96901. applyFog: boolean;
  96902. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  96903. useOctreeForRenderingSelection: boolean;
  96904. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  96905. useOctreeForPicking: boolean;
  96906. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  96907. useOctreeForCollisions: boolean;
  96908. /**
  96909. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  96910. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  96911. */
  96912. layerMask: number;
  96913. /**
  96914. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  96915. */
  96916. alwaysSelectAsActiveMesh: boolean;
  96917. /**
  96918. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  96919. */
  96920. doNotSyncBoundingInfo: boolean;
  96921. /**
  96922. * Gets or sets the current action manager
  96923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  96924. */
  96925. actionManager: Nullable<AbstractActionManager>;
  96926. private _meshCollisionData;
  96927. /**
  96928. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  96929. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96930. */
  96931. ellipsoid: Vector3;
  96932. /**
  96933. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  96934. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96935. */
  96936. ellipsoidOffset: Vector3;
  96937. /**
  96938. * Gets or sets a collision mask used to mask collisions (default is -1).
  96939. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  96940. */
  96941. collisionMask: number;
  96942. /**
  96943. * Gets or sets the current collision group mask (-1 by default).
  96944. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  96945. */
  96946. collisionGroup: number;
  96947. /**
  96948. * Defines edge width used when edgesRenderer is enabled
  96949. * @see https://www.babylonjs-playground.com/#10OJSG#13
  96950. */
  96951. edgesWidth: number;
  96952. /**
  96953. * Defines edge color used when edgesRenderer is enabled
  96954. * @see https://www.babylonjs-playground.com/#10OJSG#13
  96955. */
  96956. edgesColor: Color4;
  96957. /** @hidden */
  96958. _edgesRenderer: Nullable<IEdgesRenderer>;
  96959. /** @hidden */
  96960. _masterMesh: Nullable<AbstractMesh>;
  96961. /** @hidden */
  96962. _boundingInfo: Nullable<BoundingInfo>;
  96963. /** @hidden */
  96964. _renderId: number;
  96965. /**
  96966. * Gets or sets the list of subMeshes
  96967. * @see http://doc.babylonjs.com/how_to/multi_materials
  96968. */
  96969. subMeshes: SubMesh[];
  96970. /** @hidden */
  96971. _intersectionsInProgress: AbstractMesh[];
  96972. /** @hidden */
  96973. _unIndexed: boolean;
  96974. /** @hidden */
  96975. _lightSources: Light[];
  96976. /** Gets the list of lights affecting that mesh */
  96977. readonly lightSources: Light[];
  96978. /** @hidden */
  96979. readonly _positions: Nullable<Vector3[]>;
  96980. /** @hidden */
  96981. _waitingData: {
  96982. lods: Nullable<any>;
  96983. actions: Nullable<any>;
  96984. freezeWorldMatrix: Nullable<boolean>;
  96985. };
  96986. /** @hidden */
  96987. _bonesTransformMatrices: Nullable<Float32Array>;
  96988. /** @hidden */
  96989. _transformMatrixTexture: Nullable<RawTexture>;
  96990. /**
  96991. * Gets or sets a skeleton to apply skining transformations
  96992. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96993. */
  96994. skeleton: Nullable<Skeleton>;
  96995. /**
  96996. * An event triggered when the mesh is rebuilt.
  96997. */
  96998. onRebuildObservable: Observable<AbstractMesh>;
  96999. /**
  97000. * Creates a new AbstractMesh
  97001. * @param name defines the name of the mesh
  97002. * @param scene defines the hosting scene
  97003. */
  97004. constructor(name: string, scene?: Nullable<Scene>);
  97005. /**
  97006. * Returns the string "AbstractMesh"
  97007. * @returns "AbstractMesh"
  97008. */
  97009. getClassName(): string;
  97010. /**
  97011. * Gets a string representation of the current mesh
  97012. * @param fullDetails defines a boolean indicating if full details must be included
  97013. * @returns a string representation of the current mesh
  97014. */
  97015. toString(fullDetails?: boolean): string;
  97016. /**
  97017. * @hidden
  97018. */
  97019. protected _getEffectiveParent(): Nullable<Node>;
  97020. /** @hidden */
  97021. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  97022. /** @hidden */
  97023. _rebuild(): void;
  97024. /** @hidden */
  97025. _resyncLightSources(): void;
  97026. /** @hidden */
  97027. _resyncLightSource(light: Light): void;
  97028. /** @hidden */
  97029. _unBindEffect(): void;
  97030. /** @hidden */
  97031. _removeLightSource(light: Light, dispose: boolean): void;
  97032. private _markSubMeshesAsDirty;
  97033. /** @hidden */
  97034. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  97035. /** @hidden */
  97036. _markSubMeshesAsAttributesDirty(): void;
  97037. /** @hidden */
  97038. _markSubMeshesAsMiscDirty(): void;
  97039. /**
  97040. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  97041. */
  97042. scaling: Vector3;
  97043. /**
  97044. * Returns true if the mesh is blocked. Implemented by child classes
  97045. */
  97046. readonly isBlocked: boolean;
  97047. /**
  97048. * Returns the mesh itself by default. Implemented by child classes
  97049. * @param camera defines the camera to use to pick the right LOD level
  97050. * @returns the currentAbstractMesh
  97051. */
  97052. getLOD(camera: Camera): Nullable<AbstractMesh>;
  97053. /**
  97054. * Returns 0 by default. Implemented by child classes
  97055. * @returns an integer
  97056. */
  97057. getTotalVertices(): number;
  97058. /**
  97059. * Returns a positive integer : the total number of indices in this mesh geometry.
  97060. * @returns the numner of indices or zero if the mesh has no geometry.
  97061. */
  97062. getTotalIndices(): number;
  97063. /**
  97064. * Returns null by default. Implemented by child classes
  97065. * @returns null
  97066. */
  97067. getIndices(): Nullable<IndicesArray>;
  97068. /**
  97069. * Returns the array of the requested vertex data kind. Implemented by child classes
  97070. * @param kind defines the vertex data kind to use
  97071. * @returns null
  97072. */
  97073. getVerticesData(kind: string): Nullable<FloatArray>;
  97074. /**
  97075. * Sets the vertex data of the mesh geometry for the requested `kind`.
  97076. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  97077. * Note that a new underlying VertexBuffer object is created each call.
  97078. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  97079. * @param kind defines vertex data kind:
  97080. * * VertexBuffer.PositionKind
  97081. * * VertexBuffer.UVKind
  97082. * * VertexBuffer.UV2Kind
  97083. * * VertexBuffer.UV3Kind
  97084. * * VertexBuffer.UV4Kind
  97085. * * VertexBuffer.UV5Kind
  97086. * * VertexBuffer.UV6Kind
  97087. * * VertexBuffer.ColorKind
  97088. * * VertexBuffer.MatricesIndicesKind
  97089. * * VertexBuffer.MatricesIndicesExtraKind
  97090. * * VertexBuffer.MatricesWeightsKind
  97091. * * VertexBuffer.MatricesWeightsExtraKind
  97092. * @param data defines the data source
  97093. * @param updatable defines if the data must be flagged as updatable (or static)
  97094. * @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
  97095. * @returns the current mesh
  97096. */
  97097. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97098. /**
  97099. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  97100. * If the mesh has no geometry, it is simply returned as it is.
  97101. * @param kind defines vertex data kind:
  97102. * * VertexBuffer.PositionKind
  97103. * * VertexBuffer.UVKind
  97104. * * VertexBuffer.UV2Kind
  97105. * * VertexBuffer.UV3Kind
  97106. * * VertexBuffer.UV4Kind
  97107. * * VertexBuffer.UV5Kind
  97108. * * VertexBuffer.UV6Kind
  97109. * * VertexBuffer.ColorKind
  97110. * * VertexBuffer.MatricesIndicesKind
  97111. * * VertexBuffer.MatricesIndicesExtraKind
  97112. * * VertexBuffer.MatricesWeightsKind
  97113. * * VertexBuffer.MatricesWeightsExtraKind
  97114. * @param data defines the data source
  97115. * @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
  97116. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  97117. * @returns the current mesh
  97118. */
  97119. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  97120. /**
  97121. * Sets the mesh indices,
  97122. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  97123. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  97124. * @param totalVertices Defines the total number of vertices
  97125. * @returns the current mesh
  97126. */
  97127. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  97128. /**
  97129. * Gets a boolean indicating if specific vertex data is present
  97130. * @param kind defines the vertex data kind to use
  97131. * @returns true is data kind is present
  97132. */
  97133. isVerticesDataPresent(kind: string): boolean;
  97134. /**
  97135. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  97136. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  97137. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  97138. * @returns a BoundingInfo
  97139. */
  97140. getBoundingInfo(): BoundingInfo;
  97141. /**
  97142. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  97143. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  97144. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  97145. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  97146. * @returns the current mesh
  97147. */
  97148. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  97149. /**
  97150. * Overwrite the current bounding info
  97151. * @param boundingInfo defines the new bounding info
  97152. * @returns the current mesh
  97153. */
  97154. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  97155. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  97156. readonly useBones: boolean;
  97157. /** @hidden */
  97158. _preActivate(): void;
  97159. /** @hidden */
  97160. _preActivateForIntermediateRendering(renderId: number): void;
  97161. /** @hidden */
  97162. _activate(renderId: number, intermediateRendering: boolean): boolean;
  97163. /** @hidden */
  97164. _postActivate(): void;
  97165. /** @hidden */
  97166. _freeze(): void;
  97167. /** @hidden */
  97168. _unFreeze(): void;
  97169. /**
  97170. * Gets the current world matrix
  97171. * @returns a Matrix
  97172. */
  97173. getWorldMatrix(): Matrix;
  97174. /** @hidden */
  97175. _getWorldMatrixDeterminant(): number;
  97176. /**
  97177. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  97178. */
  97179. readonly isAnInstance: boolean;
  97180. /**
  97181. * Gets a boolean indicating if this mesh has instances
  97182. */
  97183. readonly hasInstances: boolean;
  97184. /**
  97185. * Perform relative position change from the point of view of behind the front of the mesh.
  97186. * This is performed taking into account the meshes current rotation, so you do not have to care.
  97187. * Supports definition of mesh facing forward or backward
  97188. * @param amountRight defines the distance on the right axis
  97189. * @param amountUp defines the distance on the up axis
  97190. * @param amountForward defines the distance on the forward axis
  97191. * @returns the current mesh
  97192. */
  97193. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  97194. /**
  97195. * Calculate relative position change from the point of view of behind the front of the mesh.
  97196. * This is performed taking into account the meshes current rotation, so you do not have to care.
  97197. * Supports definition of mesh facing forward or backward
  97198. * @param amountRight defines the distance on the right axis
  97199. * @param amountUp defines the distance on the up axis
  97200. * @param amountForward defines the distance on the forward axis
  97201. * @returns the new displacement vector
  97202. */
  97203. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  97204. /**
  97205. * Perform relative rotation change from the point of view of behind the front of the mesh.
  97206. * Supports definition of mesh facing forward or backward
  97207. * @param flipBack defines the flip
  97208. * @param twirlClockwise defines the twirl
  97209. * @param tiltRight defines the tilt
  97210. * @returns the current mesh
  97211. */
  97212. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  97213. /**
  97214. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  97215. * Supports definition of mesh facing forward or backward.
  97216. * @param flipBack defines the flip
  97217. * @param twirlClockwise defines the twirl
  97218. * @param tiltRight defines the tilt
  97219. * @returns the new rotation vector
  97220. */
  97221. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  97222. /**
  97223. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97224. * This means the mesh underlying bounding box and sphere are recomputed.
  97225. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97226. * @returns the current mesh
  97227. */
  97228. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  97229. /** @hidden */
  97230. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  97231. /** @hidden */
  97232. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  97233. /** @hidden */
  97234. _updateBoundingInfo(): AbstractMesh;
  97235. /** @hidden */
  97236. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  97237. /** @hidden */
  97238. protected _afterComputeWorldMatrix(): void;
  97239. /** @hidden */
  97240. readonly _effectiveMesh: AbstractMesh;
  97241. /**
  97242. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  97243. * A mesh is in the frustum if its bounding box intersects the frustum
  97244. * @param frustumPlanes defines the frustum to test
  97245. * @returns true if the mesh is in the frustum planes
  97246. */
  97247. isInFrustum(frustumPlanes: Plane[]): boolean;
  97248. /**
  97249. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  97250. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  97251. * @param frustumPlanes defines the frustum to test
  97252. * @returns true if the mesh is completely in the frustum planes
  97253. */
  97254. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  97255. /**
  97256. * True if the mesh intersects another mesh or a SolidParticle object
  97257. * @param mesh defines a target mesh or SolidParticle to test
  97258. * @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)
  97259. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  97260. * @returns true if there is an intersection
  97261. */
  97262. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  97263. /**
  97264. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  97265. * @param point defines the point to test
  97266. * @returns true if there is an intersection
  97267. */
  97268. intersectsPoint(point: Vector3): boolean;
  97269. /**
  97270. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  97271. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97272. */
  97273. checkCollisions: boolean;
  97274. /**
  97275. * Gets Collider object used to compute collisions (not physics)
  97276. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97277. */
  97278. readonly collider: Nullable<Collider>;
  97279. /**
  97280. * Move the mesh using collision engine
  97281. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97282. * @param displacement defines the requested displacement vector
  97283. * @returns the current mesh
  97284. */
  97285. moveWithCollisions(displacement: Vector3): AbstractMesh;
  97286. private _onCollisionPositionChange;
  97287. /** @hidden */
  97288. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  97289. /** @hidden */
  97290. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  97291. /** @hidden */
  97292. _checkCollision(collider: Collider): AbstractMesh;
  97293. /** @hidden */
  97294. _generatePointsArray(): boolean;
  97295. /**
  97296. * Checks if the passed Ray intersects with the mesh
  97297. * @param ray defines the ray to use
  97298. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  97299. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  97300. * @returns the picking info
  97301. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  97302. */
  97303. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  97304. /**
  97305. * Clones the current mesh
  97306. * @param name defines the mesh name
  97307. * @param newParent defines the new mesh parent
  97308. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  97309. * @returns the new mesh
  97310. */
  97311. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  97312. /**
  97313. * Disposes all the submeshes of the current meshnp
  97314. * @returns the current mesh
  97315. */
  97316. releaseSubMeshes(): AbstractMesh;
  97317. /**
  97318. * Releases resources associated with this abstract mesh.
  97319. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97320. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97321. */
  97322. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97323. /**
  97324. * Adds the passed mesh as a child to the current mesh
  97325. * @param mesh defines the child mesh
  97326. * @returns the current mesh
  97327. */
  97328. addChild(mesh: AbstractMesh): AbstractMesh;
  97329. /**
  97330. * Removes the passed mesh from the current mesh children list
  97331. * @param mesh defines the child mesh
  97332. * @returns the current mesh
  97333. */
  97334. removeChild(mesh: AbstractMesh): AbstractMesh;
  97335. /** @hidden */
  97336. private _initFacetData;
  97337. /**
  97338. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  97339. * This method can be called within the render loop.
  97340. * 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
  97341. * @returns the current mesh
  97342. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97343. */
  97344. updateFacetData(): AbstractMesh;
  97345. /**
  97346. * Returns the facetLocalNormals array.
  97347. * The normals are expressed in the mesh local spac
  97348. * @returns an array of Vector3
  97349. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97350. */
  97351. getFacetLocalNormals(): Vector3[];
  97352. /**
  97353. * Returns the facetLocalPositions array.
  97354. * The facet positions are expressed in the mesh local space
  97355. * @returns an array of Vector3
  97356. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97357. */
  97358. getFacetLocalPositions(): Vector3[];
  97359. /**
  97360. * Returns the facetLocalPartioning array
  97361. * @returns an array of array of numbers
  97362. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97363. */
  97364. getFacetLocalPartitioning(): number[][];
  97365. /**
  97366. * Returns the i-th facet position in the world system.
  97367. * This method allocates a new Vector3 per call
  97368. * @param i defines the facet index
  97369. * @returns a new Vector3
  97370. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97371. */
  97372. getFacetPosition(i: number): Vector3;
  97373. /**
  97374. * Sets the reference Vector3 with the i-th facet position in the world system
  97375. * @param i defines the facet index
  97376. * @param ref defines the target vector
  97377. * @returns the current mesh
  97378. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97379. */
  97380. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  97381. /**
  97382. * Returns the i-th facet normal in the world system.
  97383. * This method allocates a new Vector3 per call
  97384. * @param i defines the facet index
  97385. * @returns a new Vector3
  97386. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97387. */
  97388. getFacetNormal(i: number): Vector3;
  97389. /**
  97390. * Sets the reference Vector3 with the i-th facet normal in the world system
  97391. * @param i defines the facet index
  97392. * @param ref defines the target vector
  97393. * @returns the current mesh
  97394. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97395. */
  97396. getFacetNormalToRef(i: number, ref: Vector3): this;
  97397. /**
  97398. * 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)
  97399. * @param x defines x coordinate
  97400. * @param y defines y coordinate
  97401. * @param z defines z coordinate
  97402. * @returns the array of facet indexes
  97403. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97404. */
  97405. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  97406. /**
  97407. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  97408. * @param projected sets as the (x,y,z) world projection on the facet
  97409. * @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
  97410. * @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
  97411. * @param x defines x coordinate
  97412. * @param y defines y coordinate
  97413. * @param z defines z coordinate
  97414. * @returns the face index if found (or null instead)
  97415. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97416. */
  97417. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  97418. /**
  97419. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  97420. * @param projected sets as the (x,y,z) local projection on the facet
  97421. * @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
  97422. * @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
  97423. * @param x defines x coordinate
  97424. * @param y defines y coordinate
  97425. * @param z defines z coordinate
  97426. * @returns the face index if found (or null instead)
  97427. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97428. */
  97429. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  97430. /**
  97431. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  97432. * @returns the parameters
  97433. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97434. */
  97435. getFacetDataParameters(): any;
  97436. /**
  97437. * Disables the feature FacetData and frees the related memory
  97438. * @returns the current mesh
  97439. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97440. */
  97441. disableFacetData(): AbstractMesh;
  97442. /**
  97443. * Updates the AbstractMesh indices array
  97444. * @param indices defines the data source
  97445. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  97446. * @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)
  97447. * @returns the current mesh
  97448. */
  97449. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  97450. /**
  97451. * Creates new normals data for the mesh
  97452. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  97453. * @returns the current mesh
  97454. */
  97455. createNormals(updatable: boolean): AbstractMesh;
  97456. /**
  97457. * Align the mesh with a normal
  97458. * @param normal defines the normal to use
  97459. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  97460. * @returns the current mesh
  97461. */
  97462. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  97463. /** @hidden */
  97464. _checkOcclusionQuery(): boolean;
  97465. /**
  97466. * Disables the mesh edge rendering mode
  97467. * @returns the currentAbstractMesh
  97468. */
  97469. disableEdgesRendering(): AbstractMesh;
  97470. /**
  97471. * Enables the edge rendering mode on the mesh.
  97472. * This mode makes the mesh edges visible
  97473. * @param epsilon defines the maximal distance between two angles to detect a face
  97474. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97475. * @returns the currentAbstractMesh
  97476. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97477. */
  97478. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97479. }
  97480. }
  97481. declare module BABYLON {
  97482. /**
  97483. * Interface used to define ActionEvent
  97484. */
  97485. export interface IActionEvent {
  97486. /** The mesh or sprite that triggered the action */
  97487. source: any;
  97488. /** The X mouse cursor position at the time of the event */
  97489. pointerX: number;
  97490. /** The Y mouse cursor position at the time of the event */
  97491. pointerY: number;
  97492. /** The mesh that is currently pointed at (can be null) */
  97493. meshUnderPointer: Nullable<AbstractMesh>;
  97494. /** the original (browser) event that triggered the ActionEvent */
  97495. sourceEvent?: any;
  97496. /** additional data for the event */
  97497. additionalData?: any;
  97498. }
  97499. /**
  97500. * ActionEvent is the event being sent when an action is triggered.
  97501. */
  97502. export class ActionEvent implements IActionEvent {
  97503. /** The mesh or sprite that triggered the action */
  97504. source: any;
  97505. /** The X mouse cursor position at the time of the event */
  97506. pointerX: number;
  97507. /** The Y mouse cursor position at the time of the event */
  97508. pointerY: number;
  97509. /** The mesh that is currently pointed at (can be null) */
  97510. meshUnderPointer: Nullable<AbstractMesh>;
  97511. /** the original (browser) event that triggered the ActionEvent */
  97512. sourceEvent?: any;
  97513. /** additional data for the event */
  97514. additionalData?: any;
  97515. /**
  97516. * Creates a new ActionEvent
  97517. * @param source The mesh or sprite that triggered the action
  97518. * @param pointerX The X mouse cursor position at the time of the event
  97519. * @param pointerY The Y mouse cursor position at the time of the event
  97520. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  97521. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  97522. * @param additionalData additional data for the event
  97523. */
  97524. constructor(
  97525. /** The mesh or sprite that triggered the action */
  97526. source: any,
  97527. /** The X mouse cursor position at the time of the event */
  97528. pointerX: number,
  97529. /** The Y mouse cursor position at the time of the event */
  97530. pointerY: number,
  97531. /** The mesh that is currently pointed at (can be null) */
  97532. meshUnderPointer: Nullable<AbstractMesh>,
  97533. /** the original (browser) event that triggered the ActionEvent */
  97534. sourceEvent?: any,
  97535. /** additional data for the event */
  97536. additionalData?: any);
  97537. /**
  97538. * Helper function to auto-create an ActionEvent from a source mesh.
  97539. * @param source The source mesh that triggered the event
  97540. * @param evt The original (browser) event
  97541. * @param additionalData additional data for the event
  97542. * @returns the new ActionEvent
  97543. */
  97544. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  97545. /**
  97546. * Helper function to auto-create an ActionEvent from a source sprite
  97547. * @param source The source sprite that triggered the event
  97548. * @param scene Scene associated with the sprite
  97549. * @param evt The original (browser) event
  97550. * @param additionalData additional data for the event
  97551. * @returns the new ActionEvent
  97552. */
  97553. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  97554. /**
  97555. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  97556. * @param scene the scene where the event occurred
  97557. * @param evt The original (browser) event
  97558. * @returns the new ActionEvent
  97559. */
  97560. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  97561. /**
  97562. * Helper function to auto-create an ActionEvent from a primitive
  97563. * @param prim defines the target primitive
  97564. * @param pointerPos defines the pointer position
  97565. * @param evt The original (browser) event
  97566. * @param additionalData additional data for the event
  97567. * @returns the new ActionEvent
  97568. */
  97569. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  97570. }
  97571. }
  97572. declare module BABYLON {
  97573. /**
  97574. * Abstract class used to decouple action Manager from scene and meshes.
  97575. * Do not instantiate.
  97576. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97577. */
  97578. export abstract class AbstractActionManager implements IDisposable {
  97579. /** Gets the list of active triggers */
  97580. static Triggers: {
  97581. [key: string]: number;
  97582. };
  97583. /** Gets the cursor to use when hovering items */
  97584. hoverCursor: string;
  97585. /** Gets the list of actions */
  97586. actions: IAction[];
  97587. /**
  97588. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  97589. */
  97590. isRecursive: boolean;
  97591. /**
  97592. * Releases all associated resources
  97593. */
  97594. abstract dispose(): void;
  97595. /**
  97596. * Does this action manager has pointer triggers
  97597. */
  97598. abstract readonly hasPointerTriggers: boolean;
  97599. /**
  97600. * Does this action manager has pick triggers
  97601. */
  97602. abstract readonly hasPickTriggers: boolean;
  97603. /**
  97604. * Process a specific trigger
  97605. * @param trigger defines the trigger to process
  97606. * @param evt defines the event details to be processed
  97607. */
  97608. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  97609. /**
  97610. * Does this action manager handles actions of any of the given triggers
  97611. * @param triggers defines the triggers to be tested
  97612. * @return a boolean indicating whether one (or more) of the triggers is handled
  97613. */
  97614. abstract hasSpecificTriggers(triggers: number[]): boolean;
  97615. /**
  97616. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  97617. * speed.
  97618. * @param triggerA defines the trigger to be tested
  97619. * @param triggerB defines the trigger to be tested
  97620. * @return a boolean indicating whether one (or more) of the triggers is handled
  97621. */
  97622. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  97623. /**
  97624. * Does this action manager handles actions of a given trigger
  97625. * @param trigger defines the trigger to be tested
  97626. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  97627. * @return whether the trigger is handled
  97628. */
  97629. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  97630. /**
  97631. * Serialize this manager to a JSON object
  97632. * @param name defines the property name to store this manager
  97633. * @returns a JSON representation of this manager
  97634. */
  97635. abstract serialize(name: string): any;
  97636. /**
  97637. * Registers an action to this action manager
  97638. * @param action defines the action to be registered
  97639. * @return the action amended (prepared) after registration
  97640. */
  97641. abstract registerAction(action: IAction): Nullable<IAction>;
  97642. /**
  97643. * Unregisters an action to this action manager
  97644. * @param action defines the action to be unregistered
  97645. * @return a boolean indicating whether the action has been unregistered
  97646. */
  97647. abstract unregisterAction(action: IAction): Boolean;
  97648. /**
  97649. * Does exist one action manager with at least one trigger
  97650. **/
  97651. static readonly HasTriggers: boolean;
  97652. /**
  97653. * Does exist one action manager with at least one pick trigger
  97654. **/
  97655. static readonly HasPickTriggers: boolean;
  97656. /**
  97657. * Does exist one action manager that handles actions of a given trigger
  97658. * @param trigger defines the trigger to be tested
  97659. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  97660. **/
  97661. static HasSpecificTrigger(trigger: number): boolean;
  97662. }
  97663. }
  97664. declare module BABYLON {
  97665. /**
  97666. * Defines how a node can be built from a string name.
  97667. */
  97668. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  97669. /**
  97670. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  97671. */
  97672. export class Node implements IBehaviorAware<Node> {
  97673. /** @hidden */
  97674. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  97675. private static _NodeConstructors;
  97676. /**
  97677. * Add a new node constructor
  97678. * @param type defines the type name of the node to construct
  97679. * @param constructorFunc defines the constructor function
  97680. */
  97681. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  97682. /**
  97683. * Returns a node constructor based on type name
  97684. * @param type defines the type name
  97685. * @param name defines the new node name
  97686. * @param scene defines the hosting scene
  97687. * @param options defines optional options to transmit to constructors
  97688. * @returns the new constructor or null
  97689. */
  97690. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  97691. /**
  97692. * Gets or sets the name of the node
  97693. */
  97694. name: string;
  97695. /**
  97696. * Gets or sets the id of the node
  97697. */
  97698. id: string;
  97699. /**
  97700. * Gets or sets the unique id of the node
  97701. */
  97702. uniqueId: number;
  97703. /**
  97704. * Gets or sets a string used to store user defined state for the node
  97705. */
  97706. state: string;
  97707. /**
  97708. * Gets or sets an object used to store user defined information for the node
  97709. */
  97710. metadata: any;
  97711. /**
  97712. * For internal use only. Please do not use.
  97713. */
  97714. reservedDataStore: any;
  97715. /**
  97716. * List of inspectable custom properties (used by the Inspector)
  97717. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  97718. */
  97719. inspectableCustomProperties: IInspectable[];
  97720. private _doNotSerialize;
  97721. /**
  97722. * Gets or sets a boolean used to define if the node must be serialized
  97723. */
  97724. doNotSerialize: boolean;
  97725. /** @hidden */
  97726. _isDisposed: boolean;
  97727. /**
  97728. * Gets a list of Animations associated with the node
  97729. */
  97730. animations: Animation[];
  97731. protected _ranges: {
  97732. [name: string]: Nullable<AnimationRange>;
  97733. };
  97734. /**
  97735. * Callback raised when the node is ready to be used
  97736. */
  97737. onReady: Nullable<(node: Node) => void>;
  97738. private _isEnabled;
  97739. private _isParentEnabled;
  97740. private _isReady;
  97741. /** @hidden */
  97742. _currentRenderId: number;
  97743. private _parentUpdateId;
  97744. /** @hidden */
  97745. _childUpdateId: number;
  97746. /** @hidden */
  97747. _waitingParentId: Nullable<string>;
  97748. /** @hidden */
  97749. _scene: Scene;
  97750. /** @hidden */
  97751. _cache: any;
  97752. private _parentNode;
  97753. private _children;
  97754. /** @hidden */
  97755. _worldMatrix: Matrix;
  97756. /** @hidden */
  97757. _worldMatrixDeterminant: number;
  97758. /** @hidden */
  97759. _worldMatrixDeterminantIsDirty: boolean;
  97760. /** @hidden */
  97761. private _sceneRootNodesIndex;
  97762. /**
  97763. * Gets a boolean indicating if the node has been disposed
  97764. * @returns true if the node was disposed
  97765. */
  97766. isDisposed(): boolean;
  97767. /**
  97768. * Gets or sets the parent of the node (without keeping the current position in the scene)
  97769. * @see https://doc.babylonjs.com/how_to/parenting
  97770. */
  97771. parent: Nullable<Node>;
  97772. /** @hidden */
  97773. _addToSceneRootNodes(): void;
  97774. /** @hidden */
  97775. _removeFromSceneRootNodes(): void;
  97776. private _animationPropertiesOverride;
  97777. /**
  97778. * Gets or sets the animation properties override
  97779. */
  97780. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  97781. /**
  97782. * Gets a string idenfifying the name of the class
  97783. * @returns "Node" string
  97784. */
  97785. getClassName(): string;
  97786. /** @hidden */
  97787. readonly _isNode: boolean;
  97788. /**
  97789. * An event triggered when the mesh is disposed
  97790. */
  97791. onDisposeObservable: Observable<Node>;
  97792. private _onDisposeObserver;
  97793. /**
  97794. * Sets a callback that will be raised when the node will be disposed
  97795. */
  97796. onDispose: () => void;
  97797. /**
  97798. * Creates a new Node
  97799. * @param name the name and id to be given to this node
  97800. * @param scene the scene this node will be added to
  97801. */
  97802. constructor(name: string, scene?: Nullable<Scene>);
  97803. /**
  97804. * Gets the scene of the node
  97805. * @returns a scene
  97806. */
  97807. getScene(): Scene;
  97808. /**
  97809. * Gets the engine of the node
  97810. * @returns a Engine
  97811. */
  97812. getEngine(): Engine;
  97813. private _behaviors;
  97814. /**
  97815. * Attach a behavior to the node
  97816. * @see http://doc.babylonjs.com/features/behaviour
  97817. * @param behavior defines the behavior to attach
  97818. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  97819. * @returns the current Node
  97820. */
  97821. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  97822. /**
  97823. * Remove an attached behavior
  97824. * @see http://doc.babylonjs.com/features/behaviour
  97825. * @param behavior defines the behavior to attach
  97826. * @returns the current Node
  97827. */
  97828. removeBehavior(behavior: Behavior<Node>): Node;
  97829. /**
  97830. * Gets the list of attached behaviors
  97831. * @see http://doc.babylonjs.com/features/behaviour
  97832. */
  97833. readonly behaviors: Behavior<Node>[];
  97834. /**
  97835. * Gets an attached behavior by name
  97836. * @param name defines the name of the behavior to look for
  97837. * @see http://doc.babylonjs.com/features/behaviour
  97838. * @returns null if behavior was not found else the requested behavior
  97839. */
  97840. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  97841. /**
  97842. * Returns the latest update of the World matrix
  97843. * @returns a Matrix
  97844. */
  97845. getWorldMatrix(): Matrix;
  97846. /** @hidden */
  97847. _getWorldMatrixDeterminant(): number;
  97848. /**
  97849. * Returns directly the latest state of the mesh World matrix.
  97850. * A Matrix is returned.
  97851. */
  97852. readonly worldMatrixFromCache: Matrix;
  97853. /** @hidden */
  97854. _initCache(): void;
  97855. /** @hidden */
  97856. updateCache(force?: boolean): void;
  97857. /** @hidden */
  97858. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  97859. /** @hidden */
  97860. _updateCache(ignoreParentClass?: boolean): void;
  97861. /** @hidden */
  97862. _isSynchronized(): boolean;
  97863. /** @hidden */
  97864. _markSyncedWithParent(): void;
  97865. /** @hidden */
  97866. isSynchronizedWithParent(): boolean;
  97867. /** @hidden */
  97868. isSynchronized(): boolean;
  97869. /**
  97870. * Is this node ready to be used/rendered
  97871. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97872. * @return true if the node is ready
  97873. */
  97874. isReady(completeCheck?: boolean): boolean;
  97875. /**
  97876. * Is this node enabled?
  97877. * 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
  97878. * @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
  97879. * @return whether this node (and its parent) is enabled
  97880. */
  97881. isEnabled(checkAncestors?: boolean): boolean;
  97882. /** @hidden */
  97883. protected _syncParentEnabledState(): void;
  97884. /**
  97885. * Set the enabled state of this node
  97886. * @param value defines the new enabled state
  97887. */
  97888. setEnabled(value: boolean): void;
  97889. /**
  97890. * Is this node a descendant of the given node?
  97891. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  97892. * @param ancestor defines the parent node to inspect
  97893. * @returns a boolean indicating if this node is a descendant of the given node
  97894. */
  97895. isDescendantOf(ancestor: Node): boolean;
  97896. /** @hidden */
  97897. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  97898. /**
  97899. * Will return all nodes that have this node as ascendant
  97900. * @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
  97901. * @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
  97902. * @return all children nodes of all types
  97903. */
  97904. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  97905. /**
  97906. * Get all child-meshes of this node
  97907. * @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)
  97908. * @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
  97909. * @returns an array of AbstractMesh
  97910. */
  97911. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  97912. /**
  97913. * Get all direct children of this node
  97914. * @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
  97915. * @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)
  97916. * @returns an array of Node
  97917. */
  97918. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  97919. /** @hidden */
  97920. _setReady(state: boolean): void;
  97921. /**
  97922. * Get an animation by name
  97923. * @param name defines the name of the animation to look for
  97924. * @returns null if not found else the requested animation
  97925. */
  97926. getAnimationByName(name: string): Nullable<Animation>;
  97927. /**
  97928. * Creates an animation range for this node
  97929. * @param name defines the name of the range
  97930. * @param from defines the starting key
  97931. * @param to defines the end key
  97932. */
  97933. createAnimationRange(name: string, from: number, to: number): void;
  97934. /**
  97935. * Delete a specific animation range
  97936. * @param name defines the name of the range to delete
  97937. * @param deleteFrames defines if animation frames from the range must be deleted as well
  97938. */
  97939. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  97940. /**
  97941. * Get an animation range by name
  97942. * @param name defines the name of the animation range to look for
  97943. * @returns null if not found else the requested animation range
  97944. */
  97945. getAnimationRange(name: string): Nullable<AnimationRange>;
  97946. /**
  97947. * Gets the list of all animation ranges defined on this node
  97948. * @returns an array
  97949. */
  97950. getAnimationRanges(): Nullable<AnimationRange>[];
  97951. /**
  97952. * Will start the animation sequence
  97953. * @param name defines the range frames for animation sequence
  97954. * @param loop defines if the animation should loop (false by default)
  97955. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  97956. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  97957. * @returns the object created for this animation. If range does not exist, it will return null
  97958. */
  97959. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  97960. /**
  97961. * Serialize animation ranges into a JSON compatible object
  97962. * @returns serialization object
  97963. */
  97964. serializeAnimationRanges(): any;
  97965. /**
  97966. * Computes the world matrix of the node
  97967. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  97968. * @returns the world matrix
  97969. */
  97970. computeWorldMatrix(force?: boolean): Matrix;
  97971. /**
  97972. * Releases resources associated with this node.
  97973. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97974. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97975. */
  97976. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97977. /**
  97978. * Parse animation range data from a serialization object and store them into a given node
  97979. * @param node defines where to store the animation ranges
  97980. * @param parsedNode defines the serialization object to read data from
  97981. * @param scene defines the hosting scene
  97982. */
  97983. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  97984. /**
  97985. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  97986. * @param includeDescendants Include bounding info from descendants as well (true by default)
  97987. * @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
  97988. * @returns the new bounding vectors
  97989. */
  97990. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  97991. min: Vector3;
  97992. max: Vector3;
  97993. };
  97994. }
  97995. }
  97996. declare module BABYLON {
  97997. /**
  97998. * @hidden
  97999. */
  98000. export class _IAnimationState {
  98001. key: number;
  98002. repeatCount: number;
  98003. workValue?: any;
  98004. loopMode?: number;
  98005. offsetValue?: any;
  98006. highLimitValue?: any;
  98007. }
  98008. /**
  98009. * Class used to store any kind of animation
  98010. */
  98011. export class Animation {
  98012. /**Name of the animation */
  98013. name: string;
  98014. /**Property to animate */
  98015. targetProperty: string;
  98016. /**The frames per second of the animation */
  98017. framePerSecond: number;
  98018. /**The data type of the animation */
  98019. dataType: number;
  98020. /**The loop mode of the animation */
  98021. loopMode?: number | undefined;
  98022. /**Specifies if blending should be enabled */
  98023. enableBlending?: boolean | undefined;
  98024. /**
  98025. * Use matrix interpolation instead of using direct key value when animating matrices
  98026. */
  98027. static AllowMatricesInterpolation: boolean;
  98028. /**
  98029. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  98030. */
  98031. static AllowMatrixDecomposeForInterpolation: boolean;
  98032. /**
  98033. * Stores the key frames of the animation
  98034. */
  98035. private _keys;
  98036. /**
  98037. * Stores the easing function of the animation
  98038. */
  98039. private _easingFunction;
  98040. /**
  98041. * @hidden Internal use only
  98042. */
  98043. _runtimeAnimations: RuntimeAnimation[];
  98044. /**
  98045. * The set of event that will be linked to this animation
  98046. */
  98047. private _events;
  98048. /**
  98049. * Stores an array of target property paths
  98050. */
  98051. targetPropertyPath: string[];
  98052. /**
  98053. * Stores the blending speed of the animation
  98054. */
  98055. blendingSpeed: number;
  98056. /**
  98057. * Stores the animation ranges for the animation
  98058. */
  98059. private _ranges;
  98060. /**
  98061. * @hidden Internal use
  98062. */
  98063. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  98064. /**
  98065. * Sets up an animation
  98066. * @param property The property to animate
  98067. * @param animationType The animation type to apply
  98068. * @param framePerSecond The frames per second of the animation
  98069. * @param easingFunction The easing function used in the animation
  98070. * @returns The created animation
  98071. */
  98072. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  98073. /**
  98074. * Create and start an animation on a node
  98075. * @param name defines the name of the global animation that will be run on all nodes
  98076. * @param node defines the root node where the animation will take place
  98077. * @param targetProperty defines property to animate
  98078. * @param framePerSecond defines the number of frame per second yo use
  98079. * @param totalFrame defines the number of frames in total
  98080. * @param from defines the initial value
  98081. * @param to defines the final value
  98082. * @param loopMode defines which loop mode you want to use (off by default)
  98083. * @param easingFunction defines the easing function to use (linear by default)
  98084. * @param onAnimationEnd defines the callback to call when animation end
  98085. * @returns the animatable created for this animation
  98086. */
  98087. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  98088. /**
  98089. * Create and start an animation on a node and its descendants
  98090. * @param name defines the name of the global animation that will be run on all nodes
  98091. * @param node defines the root node where the animation will take place
  98092. * @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
  98093. * @param targetProperty defines property to animate
  98094. * @param framePerSecond defines the number of frame per second to use
  98095. * @param totalFrame defines the number of frames in total
  98096. * @param from defines the initial value
  98097. * @param to defines the final value
  98098. * @param loopMode defines which loop mode you want to use (off by default)
  98099. * @param easingFunction defines the easing function to use (linear by default)
  98100. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  98101. * @returns the list of animatables created for all nodes
  98102. * @example https://www.babylonjs-playground.com/#MH0VLI
  98103. */
  98104. 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[]>;
  98105. /**
  98106. * Creates a new animation, merges it with the existing animations and starts it
  98107. * @param name Name of the animation
  98108. * @param node Node which contains the scene that begins the animations
  98109. * @param targetProperty Specifies which property to animate
  98110. * @param framePerSecond The frames per second of the animation
  98111. * @param totalFrame The total number of frames
  98112. * @param from The frame at the beginning of the animation
  98113. * @param to The frame at the end of the animation
  98114. * @param loopMode Specifies the loop mode of the animation
  98115. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  98116. * @param onAnimationEnd Callback to run once the animation is complete
  98117. * @returns Nullable animation
  98118. */
  98119. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  98120. /**
  98121. * Transition property of an host to the target Value
  98122. * @param property The property to transition
  98123. * @param targetValue The target Value of the property
  98124. * @param host The object where the property to animate belongs
  98125. * @param scene Scene used to run the animation
  98126. * @param frameRate Framerate (in frame/s) to use
  98127. * @param transition The transition type we want to use
  98128. * @param duration The duration of the animation, in milliseconds
  98129. * @param onAnimationEnd Callback trigger at the end of the animation
  98130. * @returns Nullable animation
  98131. */
  98132. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  98133. /**
  98134. * Return the array of runtime animations currently using this animation
  98135. */
  98136. readonly runtimeAnimations: RuntimeAnimation[];
  98137. /**
  98138. * Specifies if any of the runtime animations are currently running
  98139. */
  98140. readonly hasRunningRuntimeAnimations: boolean;
  98141. /**
  98142. * Initializes the animation
  98143. * @param name Name of the animation
  98144. * @param targetProperty Property to animate
  98145. * @param framePerSecond The frames per second of the animation
  98146. * @param dataType The data type of the animation
  98147. * @param loopMode The loop mode of the animation
  98148. * @param enableBlending Specifies if blending should be enabled
  98149. */
  98150. constructor(
  98151. /**Name of the animation */
  98152. name: string,
  98153. /**Property to animate */
  98154. targetProperty: string,
  98155. /**The frames per second of the animation */
  98156. framePerSecond: number,
  98157. /**The data type of the animation */
  98158. dataType: number,
  98159. /**The loop mode of the animation */
  98160. loopMode?: number | undefined,
  98161. /**Specifies if blending should be enabled */
  98162. enableBlending?: boolean | undefined);
  98163. /**
  98164. * Converts the animation to a string
  98165. * @param fullDetails support for multiple levels of logging within scene loading
  98166. * @returns String form of the animation
  98167. */
  98168. toString(fullDetails?: boolean): string;
  98169. /**
  98170. * Add an event to this animation
  98171. * @param event Event to add
  98172. */
  98173. addEvent(event: AnimationEvent): void;
  98174. /**
  98175. * Remove all events found at the given frame
  98176. * @param frame The frame to remove events from
  98177. */
  98178. removeEvents(frame: number): void;
  98179. /**
  98180. * Retrieves all the events from the animation
  98181. * @returns Events from the animation
  98182. */
  98183. getEvents(): AnimationEvent[];
  98184. /**
  98185. * Creates an animation range
  98186. * @param name Name of the animation range
  98187. * @param from Starting frame of the animation range
  98188. * @param to Ending frame of the animation
  98189. */
  98190. createRange(name: string, from: number, to: number): void;
  98191. /**
  98192. * Deletes an animation range by name
  98193. * @param name Name of the animation range to delete
  98194. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  98195. */
  98196. deleteRange(name: string, deleteFrames?: boolean): void;
  98197. /**
  98198. * Gets the animation range by name, or null if not defined
  98199. * @param name Name of the animation range
  98200. * @returns Nullable animation range
  98201. */
  98202. getRange(name: string): Nullable<AnimationRange>;
  98203. /**
  98204. * Gets the key frames from the animation
  98205. * @returns The key frames of the animation
  98206. */
  98207. getKeys(): Array<IAnimationKey>;
  98208. /**
  98209. * Gets the highest frame rate of the animation
  98210. * @returns Highest frame rate of the animation
  98211. */
  98212. getHighestFrame(): number;
  98213. /**
  98214. * Gets the easing function of the animation
  98215. * @returns Easing function of the animation
  98216. */
  98217. getEasingFunction(): IEasingFunction;
  98218. /**
  98219. * Sets the easing function of the animation
  98220. * @param easingFunction A custom mathematical formula for animation
  98221. */
  98222. setEasingFunction(easingFunction: EasingFunction): void;
  98223. /**
  98224. * Interpolates a scalar linearly
  98225. * @param startValue Start value of the animation curve
  98226. * @param endValue End value of the animation curve
  98227. * @param gradient Scalar amount to interpolate
  98228. * @returns Interpolated scalar value
  98229. */
  98230. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  98231. /**
  98232. * Interpolates a scalar cubically
  98233. * @param startValue Start value of the animation curve
  98234. * @param outTangent End tangent of the animation
  98235. * @param endValue End value of the animation curve
  98236. * @param inTangent Start tangent of the animation curve
  98237. * @param gradient Scalar amount to interpolate
  98238. * @returns Interpolated scalar value
  98239. */
  98240. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  98241. /**
  98242. * Interpolates a quaternion using a spherical linear interpolation
  98243. * @param startValue Start value of the animation curve
  98244. * @param endValue End value of the animation curve
  98245. * @param gradient Scalar amount to interpolate
  98246. * @returns Interpolated quaternion value
  98247. */
  98248. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  98249. /**
  98250. * Interpolates a quaternion cubically
  98251. * @param startValue Start value of the animation curve
  98252. * @param outTangent End tangent of the animation curve
  98253. * @param endValue End value of the animation curve
  98254. * @param inTangent Start tangent of the animation curve
  98255. * @param gradient Scalar amount to interpolate
  98256. * @returns Interpolated quaternion value
  98257. */
  98258. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  98259. /**
  98260. * Interpolates a Vector3 linearl
  98261. * @param startValue Start value of the animation curve
  98262. * @param endValue End value of the animation curve
  98263. * @param gradient Scalar amount to interpolate
  98264. * @returns Interpolated scalar value
  98265. */
  98266. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  98267. /**
  98268. * Interpolates a Vector3 cubically
  98269. * @param startValue Start value of the animation curve
  98270. * @param outTangent End tangent of the animation
  98271. * @param endValue End value of the animation curve
  98272. * @param inTangent Start tangent of the animation curve
  98273. * @param gradient Scalar amount to interpolate
  98274. * @returns InterpolatedVector3 value
  98275. */
  98276. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  98277. /**
  98278. * Interpolates a Vector2 linearly
  98279. * @param startValue Start value of the animation curve
  98280. * @param endValue End value of the animation curve
  98281. * @param gradient Scalar amount to interpolate
  98282. * @returns Interpolated Vector2 value
  98283. */
  98284. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  98285. /**
  98286. * Interpolates a Vector2 cubically
  98287. * @param startValue Start value of the animation curve
  98288. * @param outTangent End tangent of the animation
  98289. * @param endValue End value of the animation curve
  98290. * @param inTangent Start tangent of the animation curve
  98291. * @param gradient Scalar amount to interpolate
  98292. * @returns Interpolated Vector2 value
  98293. */
  98294. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  98295. /**
  98296. * Interpolates a size linearly
  98297. * @param startValue Start value of the animation curve
  98298. * @param endValue End value of the animation curve
  98299. * @param gradient Scalar amount to interpolate
  98300. * @returns Interpolated Size value
  98301. */
  98302. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  98303. /**
  98304. * Interpolates a Color3 linearly
  98305. * @param startValue Start value of the animation curve
  98306. * @param endValue End value of the animation curve
  98307. * @param gradient Scalar amount to interpolate
  98308. * @returns Interpolated Color3 value
  98309. */
  98310. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  98311. /**
  98312. * Interpolates a Color4 linearly
  98313. * @param startValue Start value of the animation curve
  98314. * @param endValue End value of the animation curve
  98315. * @param gradient Scalar amount to interpolate
  98316. * @returns Interpolated Color3 value
  98317. */
  98318. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  98319. /**
  98320. * @hidden Internal use only
  98321. */
  98322. _getKeyValue(value: any): any;
  98323. /**
  98324. * @hidden Internal use only
  98325. */
  98326. _interpolate(currentFrame: number, state: _IAnimationState): any;
  98327. /**
  98328. * Defines the function to use to interpolate matrices
  98329. * @param startValue defines the start matrix
  98330. * @param endValue defines the end matrix
  98331. * @param gradient defines the gradient between both matrices
  98332. * @param result defines an optional target matrix where to store the interpolation
  98333. * @returns the interpolated matrix
  98334. */
  98335. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  98336. /**
  98337. * Makes a copy of the animation
  98338. * @returns Cloned animation
  98339. */
  98340. clone(): Animation;
  98341. /**
  98342. * Sets the key frames of the animation
  98343. * @param values The animation key frames to set
  98344. */
  98345. setKeys(values: Array<IAnimationKey>): void;
  98346. /**
  98347. * Serializes the animation to an object
  98348. * @returns Serialized object
  98349. */
  98350. serialize(): any;
  98351. /**
  98352. * Float animation type
  98353. */
  98354. static readonly ANIMATIONTYPE_FLOAT: number;
  98355. /**
  98356. * Vector3 animation type
  98357. */
  98358. static readonly ANIMATIONTYPE_VECTOR3: number;
  98359. /**
  98360. * Quaternion animation type
  98361. */
  98362. static readonly ANIMATIONTYPE_QUATERNION: number;
  98363. /**
  98364. * Matrix animation type
  98365. */
  98366. static readonly ANIMATIONTYPE_MATRIX: number;
  98367. /**
  98368. * Color3 animation type
  98369. */
  98370. static readonly ANIMATIONTYPE_COLOR3: number;
  98371. /**
  98372. * Color3 animation type
  98373. */
  98374. static readonly ANIMATIONTYPE_COLOR4: number;
  98375. /**
  98376. * Vector2 animation type
  98377. */
  98378. static readonly ANIMATIONTYPE_VECTOR2: number;
  98379. /**
  98380. * Size animation type
  98381. */
  98382. static readonly ANIMATIONTYPE_SIZE: number;
  98383. /**
  98384. * Relative Loop Mode
  98385. */
  98386. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  98387. /**
  98388. * Cycle Loop Mode
  98389. */
  98390. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  98391. /**
  98392. * Constant Loop Mode
  98393. */
  98394. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  98395. /** @hidden */
  98396. static _UniversalLerp(left: any, right: any, amount: number): any;
  98397. /**
  98398. * Parses an animation object and creates an animation
  98399. * @param parsedAnimation Parsed animation object
  98400. * @returns Animation object
  98401. */
  98402. static Parse(parsedAnimation: any): Animation;
  98403. /**
  98404. * Appends the serialized animations from the source animations
  98405. * @param source Source containing the animations
  98406. * @param destination Target to store the animations
  98407. */
  98408. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  98409. }
  98410. }
  98411. declare module BABYLON {
  98412. /**
  98413. * Interface containing an array of animations
  98414. */
  98415. export interface IAnimatable {
  98416. /**
  98417. * Array of animations
  98418. */
  98419. animations: Nullable<Array<Animation>>;
  98420. }
  98421. }
  98422. declare module BABYLON {
  98423. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  98424. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98425. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98426. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98427. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98428. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98429. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98430. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98431. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98432. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98433. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98434. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98435. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98436. /**
  98437. * Decorator used to define property that can be serialized as reference to a camera
  98438. * @param sourceName defines the name of the property to decorate
  98439. */
  98440. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98441. /**
  98442. * Class used to help serialization objects
  98443. */
  98444. export class SerializationHelper {
  98445. /** @hidden */
  98446. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  98447. /** @hidden */
  98448. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  98449. /** @hidden */
  98450. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  98451. /** @hidden */
  98452. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  98453. /**
  98454. * Appends the serialized animations from the source animations
  98455. * @param source Source containing the animations
  98456. * @param destination Target to store the animations
  98457. */
  98458. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  98459. /**
  98460. * Static function used to serialized a specific entity
  98461. * @param entity defines the entity to serialize
  98462. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  98463. * @returns a JSON compatible object representing the serialization of the entity
  98464. */
  98465. static Serialize<T>(entity: T, serializationObject?: any): any;
  98466. /**
  98467. * Creates a new entity from a serialization data object
  98468. * @param creationFunction defines a function used to instanciated the new entity
  98469. * @param source defines the source serialization data
  98470. * @param scene defines the hosting scene
  98471. * @param rootUrl defines the root url for resources
  98472. * @returns a new entity
  98473. */
  98474. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  98475. /**
  98476. * Clones an object
  98477. * @param creationFunction defines the function used to instanciate the new object
  98478. * @param source defines the source object
  98479. * @returns the cloned object
  98480. */
  98481. static Clone<T>(creationFunction: () => T, source: T): T;
  98482. /**
  98483. * Instanciates a new object based on a source one (some data will be shared between both object)
  98484. * @param creationFunction defines the function used to instanciate the new object
  98485. * @param source defines the source object
  98486. * @returns the new object
  98487. */
  98488. static Instanciate<T>(creationFunction: () => T, source: T): T;
  98489. }
  98490. }
  98491. declare module BABYLON {
  98492. /**
  98493. * Class used to manipulate GUIDs
  98494. */
  98495. export class GUID {
  98496. /**
  98497. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98498. * Be aware Math.random() could cause collisions, but:
  98499. * "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"
  98500. * @returns a pseudo random id
  98501. */
  98502. static RandomId(): string;
  98503. }
  98504. }
  98505. declare module BABYLON {
  98506. /**
  98507. * Base class of all the textures in babylon.
  98508. * It groups all the common properties the materials, post process, lights... might need
  98509. * in order to make a correct use of the texture.
  98510. */
  98511. export class BaseTexture implements IAnimatable {
  98512. /**
  98513. * Default anisotropic filtering level for the application.
  98514. * It is set to 4 as a good tradeoff between perf and quality.
  98515. */
  98516. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  98517. /**
  98518. * Gets or sets the unique id of the texture
  98519. */
  98520. uniqueId: number;
  98521. /**
  98522. * Define the name of the texture.
  98523. */
  98524. name: string;
  98525. /**
  98526. * Gets or sets an object used to store user defined information.
  98527. */
  98528. metadata: any;
  98529. /**
  98530. * For internal use only. Please do not use.
  98531. */
  98532. reservedDataStore: any;
  98533. private _hasAlpha;
  98534. /**
  98535. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  98536. */
  98537. hasAlpha: boolean;
  98538. /**
  98539. * Defines if the alpha value should be determined via the rgb values.
  98540. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  98541. */
  98542. getAlphaFromRGB: boolean;
  98543. /**
  98544. * Intensity or strength of the texture.
  98545. * It is commonly used by materials to fine tune the intensity of the texture
  98546. */
  98547. level: number;
  98548. /**
  98549. * Define the UV chanel to use starting from 0 and defaulting to 0.
  98550. * This is part of the texture as textures usually maps to one uv set.
  98551. */
  98552. coordinatesIndex: number;
  98553. private _coordinatesMode;
  98554. /**
  98555. * How a texture is mapped.
  98556. *
  98557. * | Value | Type | Description |
  98558. * | ----- | ----------------------------------- | ----------- |
  98559. * | 0 | EXPLICIT_MODE | |
  98560. * | 1 | SPHERICAL_MODE | |
  98561. * | 2 | PLANAR_MODE | |
  98562. * | 3 | CUBIC_MODE | |
  98563. * | 4 | PROJECTION_MODE | |
  98564. * | 5 | SKYBOX_MODE | |
  98565. * | 6 | INVCUBIC_MODE | |
  98566. * | 7 | EQUIRECTANGULAR_MODE | |
  98567. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  98568. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  98569. */
  98570. coordinatesMode: number;
  98571. /**
  98572. * | Value | Type | Description |
  98573. * | ----- | ------------------ | ----------- |
  98574. * | 0 | CLAMP_ADDRESSMODE | |
  98575. * | 1 | WRAP_ADDRESSMODE | |
  98576. * | 2 | MIRROR_ADDRESSMODE | |
  98577. */
  98578. wrapU: number;
  98579. /**
  98580. * | Value | Type | Description |
  98581. * | ----- | ------------------ | ----------- |
  98582. * | 0 | CLAMP_ADDRESSMODE | |
  98583. * | 1 | WRAP_ADDRESSMODE | |
  98584. * | 2 | MIRROR_ADDRESSMODE | |
  98585. */
  98586. wrapV: number;
  98587. /**
  98588. * | Value | Type | Description |
  98589. * | ----- | ------------------ | ----------- |
  98590. * | 0 | CLAMP_ADDRESSMODE | |
  98591. * | 1 | WRAP_ADDRESSMODE | |
  98592. * | 2 | MIRROR_ADDRESSMODE | |
  98593. */
  98594. wrapR: number;
  98595. /**
  98596. * With compliant hardware and browser (supporting anisotropic filtering)
  98597. * this defines the level of anisotropic filtering in the texture.
  98598. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  98599. */
  98600. anisotropicFilteringLevel: number;
  98601. /**
  98602. * Define if the texture is a cube texture or if false a 2d texture.
  98603. */
  98604. isCube: boolean;
  98605. /**
  98606. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  98607. */
  98608. is3D: boolean;
  98609. /**
  98610. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  98611. */
  98612. is2DArray: boolean;
  98613. /**
  98614. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  98615. * HDR texture are usually stored in linear space.
  98616. * This only impacts the PBR and Background materials
  98617. */
  98618. gammaSpace: boolean;
  98619. /**
  98620. * Gets or sets whether or not the texture contains RGBD data.
  98621. */
  98622. isRGBD: boolean;
  98623. /**
  98624. * Is Z inverted in the texture (useful in a cube texture).
  98625. */
  98626. invertZ: boolean;
  98627. /**
  98628. * Are mip maps generated for this texture or not.
  98629. */
  98630. readonly noMipmap: boolean;
  98631. /**
  98632. * @hidden
  98633. */
  98634. lodLevelInAlpha: boolean;
  98635. /**
  98636. * With prefiltered texture, defined the offset used during the prefiltering steps.
  98637. */
  98638. lodGenerationOffset: number;
  98639. /**
  98640. * With prefiltered texture, defined the scale used during the prefiltering steps.
  98641. */
  98642. lodGenerationScale: number;
  98643. /**
  98644. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  98645. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  98646. * average roughness values.
  98647. */
  98648. linearSpecularLOD: boolean;
  98649. /**
  98650. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  98651. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  98652. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  98653. */
  98654. irradianceTexture: Nullable<BaseTexture>;
  98655. /**
  98656. * Define if the texture is a render target.
  98657. */
  98658. isRenderTarget: boolean;
  98659. /**
  98660. * Define the unique id of the texture in the scene.
  98661. */
  98662. readonly uid: string;
  98663. /**
  98664. * Return a string representation of the texture.
  98665. * @returns the texture as a string
  98666. */
  98667. toString(): string;
  98668. /**
  98669. * Get the class name of the texture.
  98670. * @returns "BaseTexture"
  98671. */
  98672. getClassName(): string;
  98673. /**
  98674. * Define the list of animation attached to the texture.
  98675. */
  98676. animations: Animation[];
  98677. /**
  98678. * An event triggered when the texture is disposed.
  98679. */
  98680. onDisposeObservable: Observable<BaseTexture>;
  98681. private _onDisposeObserver;
  98682. /**
  98683. * Callback triggered when the texture has been disposed.
  98684. * Kept for back compatibility, you can use the onDisposeObservable instead.
  98685. */
  98686. onDispose: () => void;
  98687. /**
  98688. * Define the current state of the loading sequence when in delayed load mode.
  98689. */
  98690. delayLoadState: number;
  98691. private _scene;
  98692. /** @hidden */
  98693. _texture: Nullable<InternalTexture>;
  98694. private _uid;
  98695. /**
  98696. * Define if the texture is preventinga material to render or not.
  98697. * If not and the texture is not ready, the engine will use a default black texture instead.
  98698. */
  98699. readonly isBlocking: boolean;
  98700. /**
  98701. * Instantiates a new BaseTexture.
  98702. * Base class of all the textures in babylon.
  98703. * It groups all the common properties the materials, post process, lights... might need
  98704. * in order to make a correct use of the texture.
  98705. * @param scene Define the scene the texture blongs to
  98706. */
  98707. constructor(scene: Nullable<Scene>);
  98708. /**
  98709. * Get the scene the texture belongs to.
  98710. * @returns the scene or null if undefined
  98711. */
  98712. getScene(): Nullable<Scene>;
  98713. /**
  98714. * Get the texture transform matrix used to offset tile the texture for istance.
  98715. * @returns the transformation matrix
  98716. */
  98717. getTextureMatrix(): Matrix;
  98718. /**
  98719. * Get the texture reflection matrix used to rotate/transform the reflection.
  98720. * @returns the reflection matrix
  98721. */
  98722. getReflectionTextureMatrix(): Matrix;
  98723. /**
  98724. * Get the underlying lower level texture from Babylon.
  98725. * @returns the insternal texture
  98726. */
  98727. getInternalTexture(): Nullable<InternalTexture>;
  98728. /**
  98729. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  98730. * @returns true if ready or not blocking
  98731. */
  98732. isReadyOrNotBlocking(): boolean;
  98733. /**
  98734. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  98735. * @returns true if fully ready
  98736. */
  98737. isReady(): boolean;
  98738. private _cachedSize;
  98739. /**
  98740. * Get the size of the texture.
  98741. * @returns the texture size.
  98742. */
  98743. getSize(): ISize;
  98744. /**
  98745. * Get the base size of the texture.
  98746. * It can be different from the size if the texture has been resized for POT for instance
  98747. * @returns the base size
  98748. */
  98749. getBaseSize(): ISize;
  98750. /**
  98751. * Update the sampling mode of the texture.
  98752. * Default is Trilinear mode.
  98753. *
  98754. * | Value | Type | Description |
  98755. * | ----- | ------------------ | ----------- |
  98756. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  98757. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  98758. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  98759. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  98760. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  98761. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  98762. * | 7 | NEAREST_LINEAR | |
  98763. * | 8 | NEAREST_NEAREST | |
  98764. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  98765. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  98766. * | 11 | LINEAR_LINEAR | |
  98767. * | 12 | LINEAR_NEAREST | |
  98768. *
  98769. * > _mag_: magnification filter (close to the viewer)
  98770. * > _min_: minification filter (far from the viewer)
  98771. * > _mip_: filter used between mip map levels
  98772. *@param samplingMode Define the new sampling mode of the texture
  98773. */
  98774. updateSamplingMode(samplingMode: number): void;
  98775. /**
  98776. * Scales the texture if is `canRescale()`
  98777. * @param ratio the resize factor we want to use to rescale
  98778. */
  98779. scale(ratio: number): void;
  98780. /**
  98781. * Get if the texture can rescale.
  98782. */
  98783. readonly canRescale: boolean;
  98784. /** @hidden */
  98785. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  98786. /** @hidden */
  98787. _rebuild(): void;
  98788. /**
  98789. * Triggers the load sequence in delayed load mode.
  98790. */
  98791. delayLoad(): void;
  98792. /**
  98793. * Clones the texture.
  98794. * @returns the cloned texture
  98795. */
  98796. clone(): Nullable<BaseTexture>;
  98797. /**
  98798. * Get the texture underlying type (INT, FLOAT...)
  98799. */
  98800. readonly textureType: number;
  98801. /**
  98802. * Get the texture underlying format (RGB, RGBA...)
  98803. */
  98804. readonly textureFormat: number;
  98805. /**
  98806. * Indicates that textures need to be re-calculated for all materials
  98807. */
  98808. protected _markAllSubMeshesAsTexturesDirty(): void;
  98809. /**
  98810. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  98811. * This will returns an RGBA array buffer containing either in values (0-255) or
  98812. * float values (0-1) depending of the underlying buffer type.
  98813. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  98814. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  98815. * @param buffer defines a user defined buffer to fill with data (can be null)
  98816. * @returns The Array buffer containing the pixels data.
  98817. */
  98818. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  98819. /**
  98820. * Release and destroy the underlying lower level texture aka internalTexture.
  98821. */
  98822. releaseInternalTexture(): void;
  98823. /** @hidden */
  98824. readonly _lodTextureHigh: Nullable<BaseTexture>;
  98825. /** @hidden */
  98826. readonly _lodTextureMid: Nullable<BaseTexture>;
  98827. /** @hidden */
  98828. readonly _lodTextureLow: Nullable<BaseTexture>;
  98829. /**
  98830. * Dispose the texture and release its associated resources.
  98831. */
  98832. dispose(): void;
  98833. /**
  98834. * Serialize the texture into a JSON representation that can be parsed later on.
  98835. * @returns the JSON representation of the texture
  98836. */
  98837. serialize(): any;
  98838. /**
  98839. * Helper function to be called back once a list of texture contains only ready textures.
  98840. * @param textures Define the list of textures to wait for
  98841. * @param callback Define the callback triggered once the entire list will be ready
  98842. */
  98843. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  98844. }
  98845. }
  98846. declare module BABYLON {
  98847. /**
  98848. * Options to be used when creating an effect.
  98849. */
  98850. export interface IEffectCreationOptions {
  98851. /**
  98852. * Atrributes that will be used in the shader.
  98853. */
  98854. attributes: string[];
  98855. /**
  98856. * Uniform varible names that will be set in the shader.
  98857. */
  98858. uniformsNames: string[];
  98859. /**
  98860. * Uniform buffer variable names that will be set in the shader.
  98861. */
  98862. uniformBuffersNames: string[];
  98863. /**
  98864. * Sampler texture variable names that will be set in the shader.
  98865. */
  98866. samplers: string[];
  98867. /**
  98868. * Define statements that will be set in the shader.
  98869. */
  98870. defines: any;
  98871. /**
  98872. * Possible fallbacks for this effect to improve performance when needed.
  98873. */
  98874. fallbacks: Nullable<IEffectFallbacks>;
  98875. /**
  98876. * Callback that will be called when the shader is compiled.
  98877. */
  98878. onCompiled: Nullable<(effect: Effect) => void>;
  98879. /**
  98880. * Callback that will be called if an error occurs during shader compilation.
  98881. */
  98882. onError: Nullable<(effect: Effect, errors: string) => void>;
  98883. /**
  98884. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  98885. */
  98886. indexParameters?: any;
  98887. /**
  98888. * Max number of lights that can be used in the shader.
  98889. */
  98890. maxSimultaneousLights?: number;
  98891. /**
  98892. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  98893. */
  98894. transformFeedbackVaryings?: Nullable<string[]>;
  98895. }
  98896. /**
  98897. * Effect containing vertex and fragment shader that can be executed on an object.
  98898. */
  98899. export class Effect implements IDisposable {
  98900. /**
  98901. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  98902. */
  98903. static ShadersRepository: string;
  98904. /**
  98905. * Name of the effect.
  98906. */
  98907. name: any;
  98908. /**
  98909. * String container all the define statements that should be set on the shader.
  98910. */
  98911. defines: string;
  98912. /**
  98913. * Callback that will be called when the shader is compiled.
  98914. */
  98915. onCompiled: Nullable<(effect: Effect) => void>;
  98916. /**
  98917. * Callback that will be called if an error occurs during shader compilation.
  98918. */
  98919. onError: Nullable<(effect: Effect, errors: string) => void>;
  98920. /**
  98921. * Callback that will be called when effect is bound.
  98922. */
  98923. onBind: Nullable<(effect: Effect) => void>;
  98924. /**
  98925. * Unique ID of the effect.
  98926. */
  98927. uniqueId: number;
  98928. /**
  98929. * Observable that will be called when the shader is compiled.
  98930. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  98931. */
  98932. onCompileObservable: Observable<Effect>;
  98933. /**
  98934. * Observable that will be called if an error occurs during shader compilation.
  98935. */
  98936. onErrorObservable: Observable<Effect>;
  98937. /** @hidden */
  98938. _onBindObservable: Nullable<Observable<Effect>>;
  98939. /**
  98940. * Observable that will be called when effect is bound.
  98941. */
  98942. readonly onBindObservable: Observable<Effect>;
  98943. /** @hidden */
  98944. _bonesComputationForcedToCPU: boolean;
  98945. private static _uniqueIdSeed;
  98946. private _engine;
  98947. private _uniformBuffersNames;
  98948. private _uniformsNames;
  98949. private _samplerList;
  98950. private _samplers;
  98951. private _isReady;
  98952. private _compilationError;
  98953. private _allFallbacksProcessed;
  98954. private _attributesNames;
  98955. private _attributes;
  98956. private _attributeLocationByName;
  98957. private _uniforms;
  98958. /**
  98959. * Key for the effect.
  98960. * @hidden
  98961. */
  98962. _key: string;
  98963. private _indexParameters;
  98964. private _fallbacks;
  98965. private _vertexSourceCode;
  98966. private _fragmentSourceCode;
  98967. private _vertexSourceCodeOverride;
  98968. private _fragmentSourceCodeOverride;
  98969. private _transformFeedbackVaryings;
  98970. /**
  98971. * Compiled shader to webGL program.
  98972. * @hidden
  98973. */
  98974. _pipelineContext: Nullable<IPipelineContext>;
  98975. private _valueCache;
  98976. private static _baseCache;
  98977. /**
  98978. * Instantiates an effect.
  98979. * An effect can be used to create/manage/execute vertex and fragment shaders.
  98980. * @param baseName Name of the effect.
  98981. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  98982. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  98983. * @param samplers List of sampler variables that will be passed to the shader.
  98984. * @param engine Engine to be used to render the effect
  98985. * @param defines Define statements to be added to the shader.
  98986. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  98987. * @param onCompiled Callback that will be called when the shader is compiled.
  98988. * @param onError Callback that will be called if an error occurs during shader compilation.
  98989. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  98990. */
  98991. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  98992. private _useFinalCode;
  98993. /**
  98994. * Unique key for this effect
  98995. */
  98996. readonly key: string;
  98997. /**
  98998. * If the effect has been compiled and prepared.
  98999. * @returns if the effect is compiled and prepared.
  99000. */
  99001. isReady(): boolean;
  99002. private _isReadyInternal;
  99003. /**
  99004. * The engine the effect was initialized with.
  99005. * @returns the engine.
  99006. */
  99007. getEngine(): Engine;
  99008. /**
  99009. * The pipeline context for this effect
  99010. * @returns the associated pipeline context
  99011. */
  99012. getPipelineContext(): Nullable<IPipelineContext>;
  99013. /**
  99014. * The set of names of attribute variables for the shader.
  99015. * @returns An array of attribute names.
  99016. */
  99017. getAttributesNames(): string[];
  99018. /**
  99019. * Returns the attribute at the given index.
  99020. * @param index The index of the attribute.
  99021. * @returns The location of the attribute.
  99022. */
  99023. getAttributeLocation(index: number): number;
  99024. /**
  99025. * Returns the attribute based on the name of the variable.
  99026. * @param name of the attribute to look up.
  99027. * @returns the attribute location.
  99028. */
  99029. getAttributeLocationByName(name: string): number;
  99030. /**
  99031. * The number of attributes.
  99032. * @returns the numnber of attributes.
  99033. */
  99034. getAttributesCount(): number;
  99035. /**
  99036. * Gets the index of a uniform variable.
  99037. * @param uniformName of the uniform to look up.
  99038. * @returns the index.
  99039. */
  99040. getUniformIndex(uniformName: string): number;
  99041. /**
  99042. * Returns the attribute based on the name of the variable.
  99043. * @param uniformName of the uniform to look up.
  99044. * @returns the location of the uniform.
  99045. */
  99046. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  99047. /**
  99048. * Returns an array of sampler variable names
  99049. * @returns The array of sampler variable neames.
  99050. */
  99051. getSamplers(): string[];
  99052. /**
  99053. * The error from the last compilation.
  99054. * @returns the error string.
  99055. */
  99056. getCompilationError(): string;
  99057. /**
  99058. * Gets a boolean indicating that all fallbacks were used during compilation
  99059. * @returns true if all fallbacks were used
  99060. */
  99061. allFallbacksProcessed(): boolean;
  99062. /**
  99063. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  99064. * @param func The callback to be used.
  99065. */
  99066. executeWhenCompiled(func: (effect: Effect) => void): void;
  99067. private _checkIsReady;
  99068. private _loadShader;
  99069. /**
  99070. * Recompiles the webGL program
  99071. * @param vertexSourceCode The source code for the vertex shader.
  99072. * @param fragmentSourceCode The source code for the fragment shader.
  99073. * @param onCompiled Callback called when completed.
  99074. * @param onError Callback called on error.
  99075. * @hidden
  99076. */
  99077. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  99078. /**
  99079. * Prepares the effect
  99080. * @hidden
  99081. */
  99082. _prepareEffect(): void;
  99083. private _processCompilationErrors;
  99084. /**
  99085. * Checks if the effect is supported. (Must be called after compilation)
  99086. */
  99087. readonly isSupported: boolean;
  99088. /**
  99089. * Binds a texture to the engine to be used as output of the shader.
  99090. * @param channel Name of the output variable.
  99091. * @param texture Texture to bind.
  99092. * @hidden
  99093. */
  99094. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  99095. /**
  99096. * Sets a texture on the engine to be used in the shader.
  99097. * @param channel Name of the sampler variable.
  99098. * @param texture Texture to set.
  99099. */
  99100. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  99101. /**
  99102. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  99103. * @param channel Name of the sampler variable.
  99104. * @param texture Texture to set.
  99105. */
  99106. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  99107. /**
  99108. * Sets an array of textures on the engine to be used in the shader.
  99109. * @param channel Name of the variable.
  99110. * @param textures Textures to set.
  99111. */
  99112. setTextureArray(channel: string, textures: BaseTexture[]): void;
  99113. /**
  99114. * 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)
  99115. * @param channel Name of the sampler variable.
  99116. * @param postProcess Post process to get the input texture from.
  99117. */
  99118. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  99119. /**
  99120. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  99121. * 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)
  99122. * @param channel Name of the sampler variable.
  99123. * @param postProcess Post process to get the output texture from.
  99124. */
  99125. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  99126. /** @hidden */
  99127. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  99128. /** @hidden */
  99129. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  99130. /** @hidden */
  99131. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  99132. /** @hidden */
  99133. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  99134. /**
  99135. * Binds a buffer to a uniform.
  99136. * @param buffer Buffer to bind.
  99137. * @param name Name of the uniform variable to bind to.
  99138. */
  99139. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  99140. /**
  99141. * Binds block to a uniform.
  99142. * @param blockName Name of the block to bind.
  99143. * @param index Index to bind.
  99144. */
  99145. bindUniformBlock(blockName: string, index: number): void;
  99146. /**
  99147. * Sets an interger value on a uniform variable.
  99148. * @param uniformName Name of the variable.
  99149. * @param value Value to be set.
  99150. * @returns this effect.
  99151. */
  99152. setInt(uniformName: string, value: number): Effect;
  99153. /**
  99154. * Sets an int array on a uniform variable.
  99155. * @param uniformName Name of the variable.
  99156. * @param array array to be set.
  99157. * @returns this effect.
  99158. */
  99159. setIntArray(uniformName: string, array: Int32Array): Effect;
  99160. /**
  99161. * 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)
  99162. * @param uniformName Name of the variable.
  99163. * @param array array to be set.
  99164. * @returns this effect.
  99165. */
  99166. setIntArray2(uniformName: string, array: Int32Array): Effect;
  99167. /**
  99168. * 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)
  99169. * @param uniformName Name of the variable.
  99170. * @param array array to be set.
  99171. * @returns this effect.
  99172. */
  99173. setIntArray3(uniformName: string, array: Int32Array): Effect;
  99174. /**
  99175. * 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)
  99176. * @param uniformName Name of the variable.
  99177. * @param array array to be set.
  99178. * @returns this effect.
  99179. */
  99180. setIntArray4(uniformName: string, array: Int32Array): Effect;
  99181. /**
  99182. * Sets an float array on a uniform variable.
  99183. * @param uniformName Name of the variable.
  99184. * @param array array to be set.
  99185. * @returns this effect.
  99186. */
  99187. setFloatArray(uniformName: string, array: Float32Array): Effect;
  99188. /**
  99189. * 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)
  99190. * @param uniformName Name of the variable.
  99191. * @param array array to be set.
  99192. * @returns this effect.
  99193. */
  99194. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  99195. /**
  99196. * 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)
  99197. * @param uniformName Name of the variable.
  99198. * @param array array to be set.
  99199. * @returns this effect.
  99200. */
  99201. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  99202. /**
  99203. * 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)
  99204. * @param uniformName Name of the variable.
  99205. * @param array array to be set.
  99206. * @returns this effect.
  99207. */
  99208. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  99209. /**
  99210. * Sets an array on a uniform variable.
  99211. * @param uniformName Name of the variable.
  99212. * @param array array to be set.
  99213. * @returns this effect.
  99214. */
  99215. setArray(uniformName: string, array: number[]): Effect;
  99216. /**
  99217. * 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)
  99218. * @param uniformName Name of the variable.
  99219. * @param array array to be set.
  99220. * @returns this effect.
  99221. */
  99222. setArray2(uniformName: string, array: number[]): Effect;
  99223. /**
  99224. * 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)
  99225. * @param uniformName Name of the variable.
  99226. * @param array array to be set.
  99227. * @returns this effect.
  99228. */
  99229. setArray3(uniformName: string, array: number[]): Effect;
  99230. /**
  99231. * 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)
  99232. * @param uniformName Name of the variable.
  99233. * @param array array to be set.
  99234. * @returns this effect.
  99235. */
  99236. setArray4(uniformName: string, array: number[]): Effect;
  99237. /**
  99238. * Sets matrices on a uniform variable.
  99239. * @param uniformName Name of the variable.
  99240. * @param matrices matrices to be set.
  99241. * @returns this effect.
  99242. */
  99243. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  99244. /**
  99245. * Sets matrix on a uniform variable.
  99246. * @param uniformName Name of the variable.
  99247. * @param matrix matrix to be set.
  99248. * @returns this effect.
  99249. */
  99250. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  99251. /**
  99252. * 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)
  99253. * @param uniformName Name of the variable.
  99254. * @param matrix matrix to be set.
  99255. * @returns this effect.
  99256. */
  99257. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  99258. /**
  99259. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  99260. * @param uniformName Name of the variable.
  99261. * @param matrix matrix to be set.
  99262. * @returns this effect.
  99263. */
  99264. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  99265. /**
  99266. * Sets a float on a uniform variable.
  99267. * @param uniformName Name of the variable.
  99268. * @param value value to be set.
  99269. * @returns this effect.
  99270. */
  99271. setFloat(uniformName: string, value: number): Effect;
  99272. /**
  99273. * Sets a boolean on a uniform variable.
  99274. * @param uniformName Name of the variable.
  99275. * @param bool value to be set.
  99276. * @returns this effect.
  99277. */
  99278. setBool(uniformName: string, bool: boolean): Effect;
  99279. /**
  99280. * Sets a Vector2 on a uniform variable.
  99281. * @param uniformName Name of the variable.
  99282. * @param vector2 vector2 to be set.
  99283. * @returns this effect.
  99284. */
  99285. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  99286. /**
  99287. * Sets a float2 on a uniform variable.
  99288. * @param uniformName Name of the variable.
  99289. * @param x First float in float2.
  99290. * @param y Second float in float2.
  99291. * @returns this effect.
  99292. */
  99293. setFloat2(uniformName: string, x: number, y: number): Effect;
  99294. /**
  99295. * Sets a Vector3 on a uniform variable.
  99296. * @param uniformName Name of the variable.
  99297. * @param vector3 Value to be set.
  99298. * @returns this effect.
  99299. */
  99300. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  99301. /**
  99302. * Sets a float3 on a uniform variable.
  99303. * @param uniformName Name of the variable.
  99304. * @param x First float in float3.
  99305. * @param y Second float in float3.
  99306. * @param z Third float in float3.
  99307. * @returns this effect.
  99308. */
  99309. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  99310. /**
  99311. * Sets a Vector4 on a uniform variable.
  99312. * @param uniformName Name of the variable.
  99313. * @param vector4 Value to be set.
  99314. * @returns this effect.
  99315. */
  99316. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  99317. /**
  99318. * Sets a float4 on a uniform variable.
  99319. * @param uniformName Name of the variable.
  99320. * @param x First float in float4.
  99321. * @param y Second float in float4.
  99322. * @param z Third float in float4.
  99323. * @param w Fourth float in float4.
  99324. * @returns this effect.
  99325. */
  99326. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  99327. /**
  99328. * Sets a Color3 on a uniform variable.
  99329. * @param uniformName Name of the variable.
  99330. * @param color3 Value to be set.
  99331. * @returns this effect.
  99332. */
  99333. setColor3(uniformName: string, color3: IColor3Like): Effect;
  99334. /**
  99335. * Sets a Color4 on a uniform variable.
  99336. * @param uniformName Name of the variable.
  99337. * @param color3 Value to be set.
  99338. * @param alpha Alpha value to be set.
  99339. * @returns this effect.
  99340. */
  99341. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  99342. /**
  99343. * Sets a Color4 on a uniform variable
  99344. * @param uniformName defines the name of the variable
  99345. * @param color4 defines the value to be set
  99346. * @returns this effect.
  99347. */
  99348. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  99349. /** Release all associated resources */
  99350. dispose(): void;
  99351. /**
  99352. * This function will add a new shader to the shader store
  99353. * @param name the name of the shader
  99354. * @param pixelShader optional pixel shader content
  99355. * @param vertexShader optional vertex shader content
  99356. */
  99357. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  99358. /**
  99359. * Store of each shader (The can be looked up using effect.key)
  99360. */
  99361. static ShadersStore: {
  99362. [key: string]: string;
  99363. };
  99364. /**
  99365. * Store of each included file for a shader (The can be looked up using effect.key)
  99366. */
  99367. static IncludesShadersStore: {
  99368. [key: string]: string;
  99369. };
  99370. /**
  99371. * Resets the cache of effects.
  99372. */
  99373. static ResetCache(): void;
  99374. }
  99375. }
  99376. declare module BABYLON {
  99377. /**
  99378. * Interface used to describe the capabilities of the engine relatively to the current browser
  99379. */
  99380. export interface EngineCapabilities {
  99381. /** Maximum textures units per fragment shader */
  99382. maxTexturesImageUnits: number;
  99383. /** Maximum texture units per vertex shader */
  99384. maxVertexTextureImageUnits: number;
  99385. /** Maximum textures units in the entire pipeline */
  99386. maxCombinedTexturesImageUnits: number;
  99387. /** Maximum texture size */
  99388. maxTextureSize: number;
  99389. /** Maximum texture samples */
  99390. maxSamples?: number;
  99391. /** Maximum cube texture size */
  99392. maxCubemapTextureSize: number;
  99393. /** Maximum render texture size */
  99394. maxRenderTextureSize: number;
  99395. /** Maximum number of vertex attributes */
  99396. maxVertexAttribs: number;
  99397. /** Maximum number of varyings */
  99398. maxVaryingVectors: number;
  99399. /** Maximum number of uniforms per vertex shader */
  99400. maxVertexUniformVectors: number;
  99401. /** Maximum number of uniforms per fragment shader */
  99402. maxFragmentUniformVectors: number;
  99403. /** Defines if standard derivates (dx/dy) are supported */
  99404. standardDerivatives: boolean;
  99405. /** Defines if s3tc texture compression is supported */
  99406. s3tc?: WEBGL_compressed_texture_s3tc;
  99407. /** Defines if pvrtc texture compression is supported */
  99408. pvrtc: any;
  99409. /** Defines if etc1 texture compression is supported */
  99410. etc1: any;
  99411. /** Defines if etc2 texture compression is supported */
  99412. etc2: any;
  99413. /** Defines if astc texture compression is supported */
  99414. astc: any;
  99415. /** Defines if float textures are supported */
  99416. textureFloat: boolean;
  99417. /** Defines if vertex array objects are supported */
  99418. vertexArrayObject: boolean;
  99419. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  99420. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  99421. /** Gets the maximum level of anisotropy supported */
  99422. maxAnisotropy: number;
  99423. /** Defines if instancing is supported */
  99424. instancedArrays: boolean;
  99425. /** Defines if 32 bits indices are supported */
  99426. uintIndices: boolean;
  99427. /** Defines if high precision shaders are supported */
  99428. highPrecisionShaderSupported: boolean;
  99429. /** Defines if depth reading in the fragment shader is supported */
  99430. fragmentDepthSupported: boolean;
  99431. /** Defines if float texture linear filtering is supported*/
  99432. textureFloatLinearFiltering: boolean;
  99433. /** Defines if rendering to float textures is supported */
  99434. textureFloatRender: boolean;
  99435. /** Defines if half float textures are supported*/
  99436. textureHalfFloat: boolean;
  99437. /** Defines if half float texture linear filtering is supported*/
  99438. textureHalfFloatLinearFiltering: boolean;
  99439. /** Defines if rendering to half float textures is supported */
  99440. textureHalfFloatRender: boolean;
  99441. /** Defines if textureLOD shader command is supported */
  99442. textureLOD: boolean;
  99443. /** Defines if draw buffers extension is supported */
  99444. drawBuffersExtension: boolean;
  99445. /** Defines if depth textures are supported */
  99446. depthTextureExtension: boolean;
  99447. /** Defines if float color buffer are supported */
  99448. colorBufferFloat: boolean;
  99449. /** Gets disjoint timer query extension (null if not supported) */
  99450. timerQuery?: EXT_disjoint_timer_query;
  99451. /** Defines if timestamp can be used with timer query */
  99452. canUseTimestampForTimerQuery: boolean;
  99453. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  99454. multiview?: any;
  99455. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  99456. oculusMultiview?: any;
  99457. /** Function used to let the system compiles shaders in background */
  99458. parallelShaderCompile?: {
  99459. COMPLETION_STATUS_KHR: number;
  99460. };
  99461. /** Max number of texture samples for MSAA */
  99462. maxMSAASamples: number;
  99463. /** Defines if the blend min max extension is supported */
  99464. blendMinMax: boolean;
  99465. }
  99466. }
  99467. declare module BABYLON {
  99468. /**
  99469. * @hidden
  99470. **/
  99471. export class DepthCullingState {
  99472. private _isDepthTestDirty;
  99473. private _isDepthMaskDirty;
  99474. private _isDepthFuncDirty;
  99475. private _isCullFaceDirty;
  99476. private _isCullDirty;
  99477. private _isZOffsetDirty;
  99478. private _isFrontFaceDirty;
  99479. private _depthTest;
  99480. private _depthMask;
  99481. private _depthFunc;
  99482. private _cull;
  99483. private _cullFace;
  99484. private _zOffset;
  99485. private _frontFace;
  99486. /**
  99487. * Initializes the state.
  99488. */
  99489. constructor();
  99490. readonly isDirty: boolean;
  99491. zOffset: number;
  99492. cullFace: Nullable<number>;
  99493. cull: Nullable<boolean>;
  99494. depthFunc: Nullable<number>;
  99495. depthMask: boolean;
  99496. depthTest: boolean;
  99497. frontFace: Nullable<number>;
  99498. reset(): void;
  99499. apply(gl: WebGLRenderingContext): void;
  99500. }
  99501. }
  99502. declare module BABYLON {
  99503. /**
  99504. * @hidden
  99505. **/
  99506. export class StencilState {
  99507. /** 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 */
  99508. static readonly ALWAYS: number;
  99509. /** Passed to stencilOperation to specify that stencil value must be kept */
  99510. static readonly KEEP: number;
  99511. /** Passed to stencilOperation to specify that stencil value must be replaced */
  99512. static readonly REPLACE: number;
  99513. private _isStencilTestDirty;
  99514. private _isStencilMaskDirty;
  99515. private _isStencilFuncDirty;
  99516. private _isStencilOpDirty;
  99517. private _stencilTest;
  99518. private _stencilMask;
  99519. private _stencilFunc;
  99520. private _stencilFuncRef;
  99521. private _stencilFuncMask;
  99522. private _stencilOpStencilFail;
  99523. private _stencilOpDepthFail;
  99524. private _stencilOpStencilDepthPass;
  99525. readonly isDirty: boolean;
  99526. stencilFunc: number;
  99527. stencilFuncRef: number;
  99528. stencilFuncMask: number;
  99529. stencilOpStencilFail: number;
  99530. stencilOpDepthFail: number;
  99531. stencilOpStencilDepthPass: number;
  99532. stencilMask: number;
  99533. stencilTest: boolean;
  99534. constructor();
  99535. reset(): void;
  99536. apply(gl: WebGLRenderingContext): void;
  99537. }
  99538. }
  99539. declare module BABYLON {
  99540. /**
  99541. * @hidden
  99542. **/
  99543. export class AlphaState {
  99544. private _isAlphaBlendDirty;
  99545. private _isBlendFunctionParametersDirty;
  99546. private _isBlendEquationParametersDirty;
  99547. private _isBlendConstantsDirty;
  99548. private _alphaBlend;
  99549. private _blendFunctionParameters;
  99550. private _blendEquationParameters;
  99551. private _blendConstants;
  99552. /**
  99553. * Initializes the state.
  99554. */
  99555. constructor();
  99556. readonly isDirty: boolean;
  99557. alphaBlend: boolean;
  99558. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  99559. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  99560. setAlphaEquationParameters(rgb: number, alpha: number): void;
  99561. reset(): void;
  99562. apply(gl: WebGLRenderingContext): void;
  99563. }
  99564. }
  99565. declare module BABYLON {
  99566. /** @hidden */
  99567. export class WebGL2ShaderProcessor implements IShaderProcessor {
  99568. attributeProcessor(attribute: string): string;
  99569. varyingProcessor(varying: string, isFragment: boolean): string;
  99570. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  99571. }
  99572. }
  99573. declare module BABYLON {
  99574. /**
  99575. * Interface for attribute information associated with buffer instanciation
  99576. */
  99577. export interface InstancingAttributeInfo {
  99578. /**
  99579. * Name of the GLSL attribute
  99580. * if attribute index is not specified, this is used to retrieve the index from the effect
  99581. */
  99582. attributeName: string;
  99583. /**
  99584. * Index/offset of the attribute in the vertex shader
  99585. * if not specified, this will be computes from the name.
  99586. */
  99587. index?: number;
  99588. /**
  99589. * size of the attribute, 1, 2, 3 or 4
  99590. */
  99591. attributeSize: number;
  99592. /**
  99593. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  99594. */
  99595. offset: number;
  99596. /**
  99597. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  99598. * default to 1
  99599. */
  99600. divisor?: number;
  99601. /**
  99602. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  99603. * default is FLOAT
  99604. */
  99605. attributeType?: number;
  99606. /**
  99607. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  99608. */
  99609. normalized?: boolean;
  99610. }
  99611. }
  99612. declare module BABYLON {
  99613. interface ThinEngine {
  99614. /**
  99615. * Update a video texture
  99616. * @param texture defines the texture to update
  99617. * @param video defines the video element to use
  99618. * @param invertY defines if data must be stored with Y axis inverted
  99619. */
  99620. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  99621. }
  99622. }
  99623. declare module BABYLON {
  99624. /**
  99625. * Settings for finer control over video usage
  99626. */
  99627. export interface VideoTextureSettings {
  99628. /**
  99629. * Applies `autoplay` to video, if specified
  99630. */
  99631. autoPlay?: boolean;
  99632. /**
  99633. * Applies `loop` to video, if specified
  99634. */
  99635. loop?: boolean;
  99636. /**
  99637. * Automatically updates internal texture from video at every frame in the render loop
  99638. */
  99639. autoUpdateTexture: boolean;
  99640. /**
  99641. * Image src displayed during the video loading or until the user interacts with the video.
  99642. */
  99643. poster?: string;
  99644. }
  99645. /**
  99646. * If you want to display a video in your scene, this is the special texture for that.
  99647. * This special texture works similar to other textures, with the exception of a few parameters.
  99648. * @see https://doc.babylonjs.com/how_to/video_texture
  99649. */
  99650. export class VideoTexture extends Texture {
  99651. /**
  99652. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  99653. */
  99654. readonly autoUpdateTexture: boolean;
  99655. /**
  99656. * The video instance used by the texture internally
  99657. */
  99658. readonly video: HTMLVideoElement;
  99659. private _onUserActionRequestedObservable;
  99660. /**
  99661. * Event triggerd when a dom action is required by the user to play the video.
  99662. * This happens due to recent changes in browser policies preventing video to auto start.
  99663. */
  99664. readonly onUserActionRequestedObservable: Observable<Texture>;
  99665. private _generateMipMaps;
  99666. private _engine;
  99667. private _stillImageCaptured;
  99668. private _displayingPosterTexture;
  99669. private _settings;
  99670. private _createInternalTextureOnEvent;
  99671. private _frameId;
  99672. /**
  99673. * Creates a video texture.
  99674. * If you want to display a video in your scene, this is the special texture for that.
  99675. * This special texture works similar to other textures, with the exception of a few parameters.
  99676. * @see https://doc.babylonjs.com/how_to/video_texture
  99677. * @param name optional name, will detect from video source, if not defined
  99678. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  99679. * @param scene is obviously the current scene.
  99680. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  99681. * @param invertY is false by default but can be used to invert video on Y axis
  99682. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  99683. * @param settings allows finer control over video usage
  99684. */
  99685. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  99686. private _getName;
  99687. private _getVideo;
  99688. private _createInternalTexture;
  99689. private reset;
  99690. /**
  99691. * @hidden Internal method to initiate `update`.
  99692. */
  99693. _rebuild(): void;
  99694. /**
  99695. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  99696. */
  99697. update(): void;
  99698. /**
  99699. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  99700. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  99701. */
  99702. updateTexture(isVisible: boolean): void;
  99703. protected _updateInternalTexture: () => void;
  99704. /**
  99705. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  99706. * @param url New url.
  99707. */
  99708. updateURL(url: string): void;
  99709. /**
  99710. * Dispose the texture and release its associated resources.
  99711. */
  99712. dispose(): void;
  99713. /**
  99714. * Creates a video texture straight from a stream.
  99715. * @param scene Define the scene the texture should be created in
  99716. * @param stream Define the stream the texture should be created from
  99717. * @returns The created video texture as a promise
  99718. */
  99719. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  99720. /**
  99721. * Creates a video texture straight from your WebCam video feed.
  99722. * @param scene Define the scene the texture should be created in
  99723. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  99724. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  99725. * @returns The created video texture as a promise
  99726. */
  99727. static CreateFromWebCamAsync(scene: Scene, constraints: {
  99728. minWidth: number;
  99729. maxWidth: number;
  99730. minHeight: number;
  99731. maxHeight: number;
  99732. deviceId: string;
  99733. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  99734. /**
  99735. * Creates a video texture straight from your WebCam video feed.
  99736. * @param scene Define the scene the texture should be created in
  99737. * @param onReady Define a callback to triggered once the texture will be ready
  99738. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  99739. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  99740. */
  99741. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  99742. minWidth: number;
  99743. maxWidth: number;
  99744. minHeight: number;
  99745. maxHeight: number;
  99746. deviceId: string;
  99747. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  99748. }
  99749. }
  99750. declare module BABYLON {
  99751. /**
  99752. * Defines the interface used by objects working like Scene
  99753. * @hidden
  99754. */
  99755. interface ISceneLike {
  99756. _addPendingData(data: any): void;
  99757. _removePendingData(data: any): void;
  99758. offlineProvider: IOfflineProvider;
  99759. }
  99760. /** Interface defining initialization parameters for Engine class */
  99761. export interface EngineOptions extends WebGLContextAttributes {
  99762. /**
  99763. * Defines if the engine should no exceed a specified device ratio
  99764. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  99765. */
  99766. limitDeviceRatio?: number;
  99767. /**
  99768. * Defines if webvr should be enabled automatically
  99769. * @see http://doc.babylonjs.com/how_to/webvr_camera
  99770. */
  99771. autoEnableWebVR?: boolean;
  99772. /**
  99773. * Defines if webgl2 should be turned off even if supported
  99774. * @see http://doc.babylonjs.com/features/webgl2
  99775. */
  99776. disableWebGL2Support?: boolean;
  99777. /**
  99778. * Defines if webaudio should be initialized as well
  99779. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99780. */
  99781. audioEngine?: boolean;
  99782. /**
  99783. * Defines if animations should run using a deterministic lock step
  99784. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99785. */
  99786. deterministicLockstep?: boolean;
  99787. /** Defines the maximum steps to use with deterministic lock step mode */
  99788. lockstepMaxSteps?: number;
  99789. /** Defines the seconds between each deterministic lock step */
  99790. timeStep?: number;
  99791. /**
  99792. * Defines that engine should ignore context lost events
  99793. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  99794. */
  99795. doNotHandleContextLost?: boolean;
  99796. /**
  99797. * Defines that engine should ignore modifying touch action attribute and style
  99798. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  99799. */
  99800. doNotHandleTouchAction?: boolean;
  99801. /**
  99802. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  99803. */
  99804. useHighPrecisionFloats?: boolean;
  99805. }
  99806. /**
  99807. * The base engine class (root of all engines)
  99808. */
  99809. export class ThinEngine {
  99810. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  99811. static ExceptionList: ({
  99812. key: string;
  99813. capture: string;
  99814. captureConstraint: number;
  99815. targets: string[];
  99816. } | {
  99817. key: string;
  99818. capture: null;
  99819. captureConstraint: null;
  99820. targets: string[];
  99821. })[];
  99822. /** @hidden */
  99823. static _TextureLoaders: IInternalTextureLoader[];
  99824. /**
  99825. * Returns the current npm package of the sdk
  99826. */
  99827. static readonly NpmPackage: string;
  99828. /**
  99829. * Returns the current version of the framework
  99830. */
  99831. static readonly Version: string;
  99832. /**
  99833. * Returns a string describing the current engine
  99834. */
  99835. readonly description: string;
  99836. /**
  99837. * Gets or sets the epsilon value used by collision engine
  99838. */
  99839. static CollisionsEpsilon: number;
  99840. /**
  99841. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  99842. */
  99843. static ShadersRepository: string;
  99844. /**
  99845. * Gets or sets the textures that the engine should not attempt to load as compressed
  99846. */
  99847. protected _excludedCompressedTextures: string[];
  99848. /**
  99849. * Filters the compressed texture formats to only include
  99850. * files that are not included in the skippable list
  99851. *
  99852. * @param url the current extension
  99853. * @param textureFormatInUse the current compressed texture format
  99854. * @returns "format" string
  99855. */
  99856. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  99857. /** @hidden */
  99858. _shaderProcessor: IShaderProcessor;
  99859. /**
  99860. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  99861. */
  99862. forcePOTTextures: boolean;
  99863. /**
  99864. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  99865. */
  99866. isFullscreen: boolean;
  99867. /**
  99868. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  99869. */
  99870. cullBackFaces: boolean;
  99871. /**
  99872. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  99873. */
  99874. renderEvenInBackground: boolean;
  99875. /**
  99876. * Gets or sets a boolean indicating that cache can be kept between frames
  99877. */
  99878. preventCacheWipeBetweenFrames: boolean;
  99879. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  99880. validateShaderPrograms: boolean;
  99881. /**
  99882. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  99883. * This can provide greater z depth for distant objects.
  99884. */
  99885. useReverseDepthBuffer: boolean;
  99886. /**
  99887. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  99888. */
  99889. disableUniformBuffers: boolean;
  99890. /** @hidden */
  99891. _uniformBuffers: UniformBuffer[];
  99892. /**
  99893. * Gets a boolean indicating that the engine supports uniform buffers
  99894. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  99895. */
  99896. readonly supportsUniformBuffers: boolean;
  99897. /** @hidden */
  99898. _gl: WebGLRenderingContext;
  99899. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  99900. protected _windowIsBackground: boolean;
  99901. protected _webGLVersion: number;
  99902. protected _creationOptions: EngineOptions;
  99903. protected _highPrecisionShadersAllowed: boolean;
  99904. /** @hidden */
  99905. readonly _shouldUseHighPrecisionShader: boolean;
  99906. /**
  99907. * Gets a boolean indicating that only power of 2 textures are supported
  99908. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  99909. */
  99910. readonly needPOTTextures: boolean;
  99911. /** @hidden */
  99912. _badOS: boolean;
  99913. /** @hidden */
  99914. _badDesktopOS: boolean;
  99915. private _hardwareScalingLevel;
  99916. /** @hidden */
  99917. _caps: EngineCapabilities;
  99918. private _isStencilEnable;
  99919. private _glVersion;
  99920. private _glRenderer;
  99921. private _glVendor;
  99922. /** @hidden */
  99923. _videoTextureSupported: boolean;
  99924. protected _renderingQueueLaunched: boolean;
  99925. protected _activeRenderLoops: (() => void)[];
  99926. /**
  99927. * Observable signaled when a context lost event is raised
  99928. */
  99929. onContextLostObservable: Observable<ThinEngine>;
  99930. /**
  99931. * Observable signaled when a context restored event is raised
  99932. */
  99933. onContextRestoredObservable: Observable<ThinEngine>;
  99934. private _onContextLost;
  99935. private _onContextRestored;
  99936. protected _contextWasLost: boolean;
  99937. /** @hidden */
  99938. _doNotHandleContextLost: boolean;
  99939. /**
  99940. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  99941. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  99942. */
  99943. doNotHandleContextLost: boolean;
  99944. /**
  99945. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  99946. */
  99947. disableVertexArrayObjects: boolean;
  99948. /** @hidden */
  99949. protected _colorWrite: boolean;
  99950. /** @hidden */
  99951. protected _colorWriteChanged: boolean;
  99952. /** @hidden */
  99953. protected _depthCullingState: DepthCullingState;
  99954. /** @hidden */
  99955. protected _stencilState: StencilState;
  99956. /** @hidden */
  99957. _alphaState: AlphaState;
  99958. /** @hidden */
  99959. _alphaMode: number;
  99960. /** @hidden */
  99961. _alphaEquation: number;
  99962. /** @hidden */
  99963. _internalTexturesCache: InternalTexture[];
  99964. /** @hidden */
  99965. protected _activeChannel: number;
  99966. private _currentTextureChannel;
  99967. /** @hidden */
  99968. protected _boundTexturesCache: {
  99969. [key: string]: Nullable<InternalTexture>;
  99970. };
  99971. /** @hidden */
  99972. protected _currentEffect: Nullable<Effect>;
  99973. /** @hidden */
  99974. protected _currentProgram: Nullable<WebGLProgram>;
  99975. private _compiledEffects;
  99976. private _vertexAttribArraysEnabled;
  99977. /** @hidden */
  99978. protected _cachedViewport: Nullable<IViewportLike>;
  99979. private _cachedVertexArrayObject;
  99980. /** @hidden */
  99981. protected _cachedVertexBuffers: any;
  99982. /** @hidden */
  99983. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  99984. /** @hidden */
  99985. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  99986. /** @hidden */
  99987. _currentRenderTarget: Nullable<InternalTexture>;
  99988. private _uintIndicesCurrentlySet;
  99989. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  99990. /** @hidden */
  99991. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  99992. private _currentBufferPointers;
  99993. private _currentInstanceLocations;
  99994. private _currentInstanceBuffers;
  99995. private _textureUnits;
  99996. /** @hidden */
  99997. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  99998. /** @hidden */
  99999. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  100000. /** @hidden */
  100001. _boundRenderFunction: any;
  100002. private _vaoRecordInProgress;
  100003. private _mustWipeVertexAttributes;
  100004. private _emptyTexture;
  100005. private _emptyCubeTexture;
  100006. private _emptyTexture3D;
  100007. private _emptyTexture2DArray;
  100008. /** @hidden */
  100009. _frameHandler: number;
  100010. private _nextFreeTextureSlots;
  100011. private _maxSimultaneousTextures;
  100012. private _activeRequests;
  100013. protected _texturesSupported: string[];
  100014. /** @hidden */
  100015. _textureFormatInUse: Nullable<string>;
  100016. protected readonly _supportsHardwareTextureRescaling: boolean;
  100017. /**
  100018. * Gets the list of texture formats supported
  100019. */
  100020. readonly texturesSupported: Array<string>;
  100021. /**
  100022. * Gets the list of texture formats in use
  100023. */
  100024. readonly textureFormatInUse: Nullable<string>;
  100025. /**
  100026. * Gets the current viewport
  100027. */
  100028. readonly currentViewport: Nullable<IViewportLike>;
  100029. /**
  100030. * Gets the default empty texture
  100031. */
  100032. readonly emptyTexture: InternalTexture;
  100033. /**
  100034. * Gets the default empty 3D texture
  100035. */
  100036. readonly emptyTexture3D: InternalTexture;
  100037. /**
  100038. * Gets the default empty 2D array texture
  100039. */
  100040. readonly emptyTexture2DArray: InternalTexture;
  100041. /**
  100042. * Gets the default empty cube texture
  100043. */
  100044. readonly emptyCubeTexture: InternalTexture;
  100045. /**
  100046. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  100047. */
  100048. readonly premultipliedAlpha: boolean;
  100049. /**
  100050. * Observable event triggered before each texture is initialized
  100051. */
  100052. onBeforeTextureInitObservable: Observable<Texture>;
  100053. /**
  100054. * Creates a new engine
  100055. * @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
  100056. * @param antialias defines enable antialiasing (default: false)
  100057. * @param options defines further options to be sent to the getContext() function
  100058. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  100059. */
  100060. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  100061. private _rebuildInternalTextures;
  100062. private _rebuildEffects;
  100063. /**
  100064. * Gets a boolean indicating if all created effects are ready
  100065. * @returns true if all effects are ready
  100066. */
  100067. areAllEffectsReady(): boolean;
  100068. protected _rebuildBuffers(): void;
  100069. private _initGLContext;
  100070. /**
  100071. * Gets version of the current webGL context
  100072. */
  100073. readonly webGLVersion: number;
  100074. /**
  100075. * Gets a string idenfifying the name of the class
  100076. * @returns "Engine" string
  100077. */
  100078. getClassName(): string;
  100079. /**
  100080. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  100081. */
  100082. readonly isStencilEnable: boolean;
  100083. /** @hidden */
  100084. _prepareWorkingCanvas(): void;
  100085. /**
  100086. * Reset the texture cache to empty state
  100087. */
  100088. resetTextureCache(): void;
  100089. /**
  100090. * Gets an object containing information about the current webGL context
  100091. * @returns an object containing the vender, the renderer and the version of the current webGL context
  100092. */
  100093. getGlInfo(): {
  100094. vendor: string;
  100095. renderer: string;
  100096. version: string;
  100097. };
  100098. /**
  100099. * Defines the hardware scaling level.
  100100. * By default the hardware scaling level is computed from the window device ratio.
  100101. * 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.
  100102. * @param level defines the level to use
  100103. */
  100104. setHardwareScalingLevel(level: number): void;
  100105. /**
  100106. * Gets the current hardware scaling level.
  100107. * By default the hardware scaling level is computed from the window device ratio.
  100108. * 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.
  100109. * @returns a number indicating the current hardware scaling level
  100110. */
  100111. getHardwareScalingLevel(): number;
  100112. /**
  100113. * Gets the list of loaded textures
  100114. * @returns an array containing all loaded textures
  100115. */
  100116. getLoadedTexturesCache(): InternalTexture[];
  100117. /**
  100118. * Gets the object containing all engine capabilities
  100119. * @returns the EngineCapabilities object
  100120. */
  100121. getCaps(): EngineCapabilities;
  100122. /**
  100123. * stop executing a render loop function and remove it from the execution array
  100124. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  100125. */
  100126. stopRenderLoop(renderFunction?: () => void): void;
  100127. /** @hidden */
  100128. _renderLoop(): void;
  100129. /**
  100130. * Gets the HTML canvas attached with the current webGL context
  100131. * @returns a HTML canvas
  100132. */
  100133. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  100134. /**
  100135. * Gets host window
  100136. * @returns the host window object
  100137. */
  100138. getHostWindow(): Nullable<Window>;
  100139. /**
  100140. * Gets the current render width
  100141. * @param useScreen defines if screen size must be used (or the current render target if any)
  100142. * @returns a number defining the current render width
  100143. */
  100144. getRenderWidth(useScreen?: boolean): number;
  100145. /**
  100146. * Gets the current render height
  100147. * @param useScreen defines if screen size must be used (or the current render target if any)
  100148. * @returns a number defining the current render height
  100149. */
  100150. getRenderHeight(useScreen?: boolean): number;
  100151. /**
  100152. * Can be used to override the current requestAnimationFrame requester.
  100153. * @hidden
  100154. */
  100155. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  100156. /**
  100157. * Register and execute a render loop. The engine can have more than one render function
  100158. * @param renderFunction defines the function to continuously execute
  100159. */
  100160. runRenderLoop(renderFunction: () => void): void;
  100161. /**
  100162. * Clear the current render buffer or the current render target (if any is set up)
  100163. * @param color defines the color to use
  100164. * @param backBuffer defines if the back buffer must be cleared
  100165. * @param depth defines if the depth buffer must be cleared
  100166. * @param stencil defines if the stencil buffer must be cleared
  100167. */
  100168. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  100169. private _viewportCached;
  100170. /** @hidden */
  100171. _viewport(x: number, y: number, width: number, height: number): void;
  100172. /**
  100173. * Set the WebGL's viewport
  100174. * @param viewport defines the viewport element to be used
  100175. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  100176. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  100177. */
  100178. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  100179. /**
  100180. * Begin a new frame
  100181. */
  100182. beginFrame(): void;
  100183. /**
  100184. * Enf the current frame
  100185. */
  100186. endFrame(): void;
  100187. /**
  100188. * Resize the view according to the canvas' size
  100189. */
  100190. resize(): void;
  100191. /**
  100192. * Force a specific size of the canvas
  100193. * @param width defines the new canvas' width
  100194. * @param height defines the new canvas' height
  100195. */
  100196. setSize(width: number, height: number): void;
  100197. /**
  100198. * Binds the frame buffer to the specified texture.
  100199. * @param texture The texture to render to or null for the default canvas
  100200. * @param faceIndex The face of the texture to render to in case of cube texture
  100201. * @param requiredWidth The width of the target to render to
  100202. * @param requiredHeight The height of the target to render to
  100203. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  100204. * @param depthStencilTexture The depth stencil texture to use to render
  100205. * @param lodLevel defines le lod level to bind to the frame buffer
  100206. */
  100207. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  100208. /** @hidden */
  100209. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  100210. /**
  100211. * Unbind the current render target texture from the webGL context
  100212. * @param texture defines the render target texture to unbind
  100213. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  100214. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  100215. */
  100216. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  100217. /**
  100218. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  100219. */
  100220. flushFramebuffer(): void;
  100221. /**
  100222. * Unbind the current render target and bind the default framebuffer
  100223. */
  100224. restoreDefaultFramebuffer(): void;
  100225. /** @hidden */
  100226. protected _resetVertexBufferBinding(): void;
  100227. /**
  100228. * Creates a vertex buffer
  100229. * @param data the data for the vertex buffer
  100230. * @returns the new WebGL static buffer
  100231. */
  100232. createVertexBuffer(data: DataArray): DataBuffer;
  100233. private _createVertexBuffer;
  100234. /**
  100235. * Creates a dynamic vertex buffer
  100236. * @param data the data for the dynamic vertex buffer
  100237. * @returns the new WebGL dynamic buffer
  100238. */
  100239. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  100240. protected _resetIndexBufferBinding(): void;
  100241. /**
  100242. * Creates a new index buffer
  100243. * @param indices defines the content of the index buffer
  100244. * @param updatable defines if the index buffer must be updatable
  100245. * @returns a new webGL buffer
  100246. */
  100247. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  100248. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  100249. /**
  100250. * Bind a webGL buffer to the webGL context
  100251. * @param buffer defines the buffer to bind
  100252. */
  100253. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  100254. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  100255. private bindBuffer;
  100256. /**
  100257. * update the bound buffer with the given data
  100258. * @param data defines the data to update
  100259. */
  100260. updateArrayBuffer(data: Float32Array): void;
  100261. private _vertexAttribPointer;
  100262. private _bindIndexBufferWithCache;
  100263. private _bindVertexBuffersAttributes;
  100264. /**
  100265. * Records a vertex array object
  100266. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  100267. * @param vertexBuffers defines the list of vertex buffers to store
  100268. * @param indexBuffer defines the index buffer to store
  100269. * @param effect defines the effect to store
  100270. * @returns the new vertex array object
  100271. */
  100272. recordVertexArrayObject(vertexBuffers: {
  100273. [key: string]: VertexBuffer;
  100274. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  100275. /**
  100276. * Bind a specific vertex array object
  100277. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  100278. * @param vertexArrayObject defines the vertex array object to bind
  100279. * @param indexBuffer defines the index buffer to bind
  100280. */
  100281. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  100282. /**
  100283. * Bind webGl buffers directly to the webGL context
  100284. * @param vertexBuffer defines the vertex buffer to bind
  100285. * @param indexBuffer defines the index buffer to bind
  100286. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  100287. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  100288. * @param effect defines the effect associated with the vertex buffer
  100289. */
  100290. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  100291. private _unbindVertexArrayObject;
  100292. /**
  100293. * Bind a list of vertex buffers to the webGL context
  100294. * @param vertexBuffers defines the list of vertex buffers to bind
  100295. * @param indexBuffer defines the index buffer to bind
  100296. * @param effect defines the effect associated with the vertex buffers
  100297. */
  100298. bindBuffers(vertexBuffers: {
  100299. [key: string]: Nullable<VertexBuffer>;
  100300. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  100301. /**
  100302. * Unbind all instance attributes
  100303. */
  100304. unbindInstanceAttributes(): void;
  100305. /**
  100306. * Release and free the memory of a vertex array object
  100307. * @param vao defines the vertex array object to delete
  100308. */
  100309. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  100310. /** @hidden */
  100311. _releaseBuffer(buffer: DataBuffer): boolean;
  100312. protected _deleteBuffer(buffer: DataBuffer): void;
  100313. /**
  100314. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  100315. * @param instancesBuffer defines the webGL buffer to update and bind
  100316. * @param data defines the data to store in the buffer
  100317. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  100318. */
  100319. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  100320. /**
  100321. * Bind the content of a webGL buffer used with instanciation
  100322. * @param instancesBuffer defines the webGL buffer to bind
  100323. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  100324. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  100325. */
  100326. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  100327. /**
  100328. * Disable the instance attribute corresponding to the name in parameter
  100329. * @param name defines the name of the attribute to disable
  100330. */
  100331. disableInstanceAttributeByName(name: string): void;
  100332. /**
  100333. * Disable the instance attribute corresponding to the location in parameter
  100334. * @param attributeLocation defines the attribute location of the attribute to disable
  100335. */
  100336. disableInstanceAttribute(attributeLocation: number): void;
  100337. /**
  100338. * Disable the attribute corresponding to the location in parameter
  100339. * @param attributeLocation defines the attribute location of the attribute to disable
  100340. */
  100341. disableAttributeByIndex(attributeLocation: number): void;
  100342. /**
  100343. * Send a draw order
  100344. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  100345. * @param indexStart defines the starting index
  100346. * @param indexCount defines the number of index to draw
  100347. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  100348. */
  100349. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  100350. /**
  100351. * Draw a list of points
  100352. * @param verticesStart defines the index of first vertex to draw
  100353. * @param verticesCount defines the count of vertices to draw
  100354. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  100355. */
  100356. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100357. /**
  100358. * Draw a list of unindexed primitives
  100359. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  100360. * @param verticesStart defines the index of first vertex to draw
  100361. * @param verticesCount defines the count of vertices to draw
  100362. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  100363. */
  100364. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100365. /**
  100366. * Draw a list of indexed primitives
  100367. * @param fillMode defines the primitive to use
  100368. * @param indexStart defines the starting index
  100369. * @param indexCount defines the number of index to draw
  100370. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  100371. */
  100372. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  100373. /**
  100374. * Draw a list of unindexed primitives
  100375. * @param fillMode defines the primitive to use
  100376. * @param verticesStart defines the index of first vertex to draw
  100377. * @param verticesCount defines the count of vertices to draw
  100378. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  100379. */
  100380. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100381. private _drawMode;
  100382. /** @hidden */
  100383. protected _reportDrawCall(): void;
  100384. /** @hidden */
  100385. _releaseEffect(effect: Effect): void;
  100386. /** @hidden */
  100387. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  100388. /**
  100389. * Create a new effect (used to store vertex/fragment shaders)
  100390. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  100391. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  100392. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  100393. * @param samplers defines an array of string used to represent textures
  100394. * @param defines defines the string containing the defines to use to compile the shaders
  100395. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  100396. * @param onCompiled defines a function to call when the effect creation is successful
  100397. * @param onError defines a function to call when the effect creation has failed
  100398. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  100399. * @returns the new Effect
  100400. */
  100401. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  100402. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  100403. private _compileShader;
  100404. private _compileRawShader;
  100405. /**
  100406. * Directly creates a webGL program
  100407. * @param pipelineContext defines the pipeline context to attach to
  100408. * @param vertexCode defines the vertex shader code to use
  100409. * @param fragmentCode defines the fragment shader code to use
  100410. * @param context defines the webGL context to use (if not set, the current one will be used)
  100411. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  100412. * @returns the new webGL program
  100413. */
  100414. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100415. /**
  100416. * Creates a webGL program
  100417. * @param pipelineContext defines the pipeline context to attach to
  100418. * @param vertexCode defines the vertex shader code to use
  100419. * @param fragmentCode defines the fragment shader code to use
  100420. * @param defines defines the string containing the defines to use to compile the shaders
  100421. * @param context defines the webGL context to use (if not set, the current one will be used)
  100422. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  100423. * @returns the new webGL program
  100424. */
  100425. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100426. /**
  100427. * Creates a new pipeline context
  100428. * @returns the new pipeline
  100429. */
  100430. createPipelineContext(): IPipelineContext;
  100431. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100432. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  100433. /** @hidden */
  100434. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  100435. /** @hidden */
  100436. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  100437. /** @hidden */
  100438. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  100439. /**
  100440. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  100441. * @param pipelineContext defines the pipeline context to use
  100442. * @param uniformsNames defines the list of uniform names
  100443. * @returns an array of webGL uniform locations
  100444. */
  100445. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  100446. /**
  100447. * Gets the lsit of active attributes for a given webGL program
  100448. * @param pipelineContext defines the pipeline context to use
  100449. * @param attributesNames defines the list of attribute names to get
  100450. * @returns an array of indices indicating the offset of each attribute
  100451. */
  100452. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  100453. /**
  100454. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  100455. * @param effect defines the effect to activate
  100456. */
  100457. enableEffect(effect: Nullable<Effect>): void;
  100458. /**
  100459. * Set the value of an uniform to a number (int)
  100460. * @param uniform defines the webGL uniform location where to store the value
  100461. * @param value defines the int number to store
  100462. */
  100463. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  100464. /**
  100465. * Set the value of an uniform to an array of int32
  100466. * @param uniform defines the webGL uniform location where to store the value
  100467. * @param array defines the array of int32 to store
  100468. */
  100469. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  100470. /**
  100471. * Set the value of an uniform to an array of int32 (stored as vec2)
  100472. * @param uniform defines the webGL uniform location where to store the value
  100473. * @param array defines the array of int32 to store
  100474. */
  100475. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  100476. /**
  100477. * Set the value of an uniform to an array of int32 (stored as vec3)
  100478. * @param uniform defines the webGL uniform location where to store the value
  100479. * @param array defines the array of int32 to store
  100480. */
  100481. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  100482. /**
  100483. * Set the value of an uniform to an array of int32 (stored as vec4)
  100484. * @param uniform defines the webGL uniform location where to store the value
  100485. * @param array defines the array of int32 to store
  100486. */
  100487. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  100488. /**
  100489. * Set the value of an uniform to an array of number
  100490. * @param uniform defines the webGL uniform location where to store the value
  100491. * @param array defines the array of number to store
  100492. */
  100493. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  100494. /**
  100495. * Set the value of an uniform to an array of number (stored as vec2)
  100496. * @param uniform defines the webGL uniform location where to store the value
  100497. * @param array defines the array of number to store
  100498. */
  100499. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  100500. /**
  100501. * Set the value of an uniform to an array of number (stored as vec3)
  100502. * @param uniform defines the webGL uniform location where to store the value
  100503. * @param array defines the array of number to store
  100504. */
  100505. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  100506. /**
  100507. * Set the value of an uniform to an array of number (stored as vec4)
  100508. * @param uniform defines the webGL uniform location where to store the value
  100509. * @param array defines the array of number to store
  100510. */
  100511. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  100512. /**
  100513. * Set the value of an uniform to an array of float32 (stored as matrices)
  100514. * @param uniform defines the webGL uniform location where to store the value
  100515. * @param matrices defines the array of float32 to store
  100516. */
  100517. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  100518. /**
  100519. * Set the value of an uniform to a matrix (3x3)
  100520. * @param uniform defines the webGL uniform location where to store the value
  100521. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  100522. */
  100523. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  100524. /**
  100525. * Set the value of an uniform to a matrix (2x2)
  100526. * @param uniform defines the webGL uniform location where to store the value
  100527. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  100528. */
  100529. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  100530. /**
  100531. * Set the value of an uniform to a number (float)
  100532. * @param uniform defines the webGL uniform location where to store the value
  100533. * @param value defines the float number to store
  100534. */
  100535. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  100536. /**
  100537. * Set the value of an uniform to a vec2
  100538. * @param uniform defines the webGL uniform location where to store the value
  100539. * @param x defines the 1st component of the value
  100540. * @param y defines the 2nd component of the value
  100541. */
  100542. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  100543. /**
  100544. * Set the value of an uniform to a vec3
  100545. * @param uniform defines the webGL uniform location where to store the value
  100546. * @param x defines the 1st component of the value
  100547. * @param y defines the 2nd component of the value
  100548. * @param z defines the 3rd component of the value
  100549. */
  100550. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  100551. /**
  100552. * Set the value of an uniform to a vec4
  100553. * @param uniform defines the webGL uniform location where to store the value
  100554. * @param x defines the 1st component of the value
  100555. * @param y defines the 2nd component of the value
  100556. * @param z defines the 3rd component of the value
  100557. * @param w defines the 4th component of the value
  100558. */
  100559. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  100560. /**
  100561. * Apply all cached states (depth, culling, stencil and alpha)
  100562. */
  100563. applyStates(): void;
  100564. /**
  100565. * Enable or disable color writing
  100566. * @param enable defines the state to set
  100567. */
  100568. setColorWrite(enable: boolean): void;
  100569. /**
  100570. * Gets a boolean indicating if color writing is enabled
  100571. * @returns the current color writing state
  100572. */
  100573. getColorWrite(): boolean;
  100574. /**
  100575. * Gets the depth culling state manager
  100576. */
  100577. readonly depthCullingState: DepthCullingState;
  100578. /**
  100579. * Gets the alpha state manager
  100580. */
  100581. readonly alphaState: AlphaState;
  100582. /**
  100583. * Gets the stencil state manager
  100584. */
  100585. readonly stencilState: StencilState;
  100586. /**
  100587. * Clears the list of texture accessible through engine.
  100588. * This can help preventing texture load conflict due to name collision.
  100589. */
  100590. clearInternalTexturesCache(): void;
  100591. /**
  100592. * Force the entire cache to be cleared
  100593. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  100594. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  100595. */
  100596. wipeCaches(bruteForce?: boolean): void;
  100597. /** @hidden */
  100598. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  100599. min: number;
  100600. mag: number;
  100601. };
  100602. /** @hidden */
  100603. _createTexture(): WebGLTexture;
  100604. /**
  100605. * Usually called from Texture.ts.
  100606. * Passed information to create a WebGLTexture
  100607. * @param urlArg defines a value which contains one of the following:
  100608. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  100609. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  100610. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  100611. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  100612. * @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)
  100613. * @param scene needed for loading to the correct scene
  100614. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  100615. * @param onLoad optional callback to be called upon successful completion
  100616. * @param onError optional callback to be called upon failure
  100617. * @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
  100618. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  100619. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  100620. * @param forcedExtension defines the extension to use to pick the right loader
  100621. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  100622. * @param mimeType defines an optional mime type
  100623. * @returns a InternalTexture for assignment back into BABYLON.Texture
  100624. */
  100625. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  100626. /**
  100627. * @hidden
  100628. */
  100629. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  100630. /**
  100631. * Creates a raw texture
  100632. * @param data defines the data to store in the texture
  100633. * @param width defines the width of the texture
  100634. * @param height defines the height of the texture
  100635. * @param format defines the format of the data
  100636. * @param generateMipMaps defines if the engine should generate the mip levels
  100637. * @param invertY defines if data must be stored with Y axis inverted
  100638. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  100639. * @param compression defines the compression used (null by default)
  100640. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  100641. * @returns the raw texture inside an InternalTexture
  100642. */
  100643. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  100644. /**
  100645. * Creates a new raw cube texture
  100646. * @param data defines the array of data to use to create each face
  100647. * @param size defines the size of the textures
  100648. * @param format defines the format of the data
  100649. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  100650. * @param generateMipMaps defines if the engine should generate the mip levels
  100651. * @param invertY defines if data must be stored with Y axis inverted
  100652. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  100653. * @param compression defines the compression used (null by default)
  100654. * @returns the cube texture as an InternalTexture
  100655. */
  100656. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  100657. /**
  100658. * Creates a new raw 3D texture
  100659. * @param data defines the data used to create the texture
  100660. * @param width defines the width of the texture
  100661. * @param height defines the height of the texture
  100662. * @param depth defines the depth of the texture
  100663. * @param format defines the format of the texture
  100664. * @param generateMipMaps defines if the engine must generate mip levels
  100665. * @param invertY defines if data must be stored with Y axis inverted
  100666. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  100667. * @param compression defines the compressed used (can be null)
  100668. * @param textureType defines the compressed used (can be null)
  100669. * @returns a new raw 3D texture (stored in an InternalTexture)
  100670. */
  100671. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  100672. /**
  100673. * Creates a new raw 2D array texture
  100674. * @param data defines the data used to create the texture
  100675. * @param width defines the width of the texture
  100676. * @param height defines the height of the texture
  100677. * @param depth defines the number of layers of the texture
  100678. * @param format defines the format of the texture
  100679. * @param generateMipMaps defines if the engine must generate mip levels
  100680. * @param invertY defines if data must be stored with Y axis inverted
  100681. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  100682. * @param compression defines the compressed used (can be null)
  100683. * @param textureType defines the compressed used (can be null)
  100684. * @returns a new raw 2D array texture (stored in an InternalTexture)
  100685. */
  100686. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  100687. private _unpackFlipYCached;
  100688. /**
  100689. * In case you are sharing the context with other applications, it might
  100690. * be interested to not cache the unpack flip y state to ensure a consistent
  100691. * value would be set.
  100692. */
  100693. enableUnpackFlipYCached: boolean;
  100694. /** @hidden */
  100695. _unpackFlipY(value: boolean): void;
  100696. /** @hidden */
  100697. _getUnpackAlignement(): number;
  100698. private _getTextureTarget;
  100699. /**
  100700. * Update the sampling mode of a given texture
  100701. * @param samplingMode defines the required sampling mode
  100702. * @param texture defines the texture to update
  100703. * @param generateMipMaps defines whether to generate mipmaps for the texture
  100704. */
  100705. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  100706. /**
  100707. * Update the sampling mode of a given texture
  100708. * @param texture defines the texture to update
  100709. * @param wrapU defines the texture wrap mode of the u coordinates
  100710. * @param wrapV defines the texture wrap mode of the v coordinates
  100711. * @param wrapR defines the texture wrap mode of the r coordinates
  100712. */
  100713. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  100714. /** @hidden */
  100715. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  100716. width: number;
  100717. height: number;
  100718. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  100719. /** @hidden */
  100720. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100721. /** @hidden */
  100722. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  100723. /** @hidden */
  100724. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100725. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  100726. private _prepareWebGLTexture;
  100727. /** @hidden */
  100728. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  100729. private _getDepthStencilBuffer;
  100730. /** @hidden */
  100731. _releaseFramebufferObjects(texture: InternalTexture): void;
  100732. /** @hidden */
  100733. _releaseTexture(texture: InternalTexture): void;
  100734. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  100735. protected _setProgram(program: WebGLProgram): void;
  100736. protected _boundUniforms: {
  100737. [key: number]: WebGLUniformLocation;
  100738. };
  100739. /**
  100740. * Binds an effect to the webGL context
  100741. * @param effect defines the effect to bind
  100742. */
  100743. bindSamplers(effect: Effect): void;
  100744. private _activateCurrentTexture;
  100745. /** @hidden */
  100746. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  100747. /** @hidden */
  100748. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  100749. /**
  100750. * Unbind all textures from the webGL context
  100751. */
  100752. unbindAllTextures(): void;
  100753. /**
  100754. * Sets a texture to the according uniform.
  100755. * @param channel The texture channel
  100756. * @param uniform The uniform to set
  100757. * @param texture The texture to apply
  100758. */
  100759. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  100760. private _bindSamplerUniformToChannel;
  100761. private _getTextureWrapMode;
  100762. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  100763. /**
  100764. * Sets an array of texture to the webGL context
  100765. * @param channel defines the channel where the texture array must be set
  100766. * @param uniform defines the associated uniform location
  100767. * @param textures defines the array of textures to bind
  100768. */
  100769. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  100770. /** @hidden */
  100771. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  100772. private _setTextureParameterFloat;
  100773. private _setTextureParameterInteger;
  100774. /**
  100775. * Unbind all vertex attributes from the webGL context
  100776. */
  100777. unbindAllAttributes(): void;
  100778. /**
  100779. * 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
  100780. */
  100781. releaseEffects(): void;
  100782. /**
  100783. * Dispose and release all associated resources
  100784. */
  100785. dispose(): void;
  100786. /**
  100787. * Attach a new callback raised when context lost event is fired
  100788. * @param callback defines the callback to call
  100789. */
  100790. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  100791. /**
  100792. * Attach a new callback raised when context restored event is fired
  100793. * @param callback defines the callback to call
  100794. */
  100795. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  100796. /**
  100797. * Get the current error code of the webGL context
  100798. * @returns the error code
  100799. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  100800. */
  100801. getError(): number;
  100802. private _canRenderToFloatFramebuffer;
  100803. private _canRenderToHalfFloatFramebuffer;
  100804. private _canRenderToFramebuffer;
  100805. /** @hidden */
  100806. _getWebGLTextureType(type: number): number;
  100807. /** @hidden */
  100808. _getInternalFormat(format: number): number;
  100809. /** @hidden */
  100810. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  100811. /** @hidden */
  100812. _getRGBAMultiSampleBufferFormat(type: number): number;
  100813. /** @hidden */
  100814. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  100815. /**
  100816. * Reads pixels from the current frame buffer. Please note that this function can be slow
  100817. * @param x defines the x coordinate of the rectangle where pixels must be read
  100818. * @param y defines the y coordinate of the rectangle where pixels must be read
  100819. * @param width defines the width of the rectangle where pixels must be read
  100820. * @param height defines the height of the rectangle where pixels must be read
  100821. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  100822. * @returns a Uint8Array containing RGBA colors
  100823. */
  100824. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  100825. /**
  100826. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  100827. * @returns true if the engine can be created
  100828. * @ignorenaming
  100829. */
  100830. static isSupported(): boolean;
  100831. /**
  100832. * Find the next highest power of two.
  100833. * @param x Number to start search from.
  100834. * @return Next highest power of two.
  100835. */
  100836. static CeilingPOT(x: number): number;
  100837. /**
  100838. * Find the next lowest power of two.
  100839. * @param x Number to start search from.
  100840. * @return Next lowest power of two.
  100841. */
  100842. static FloorPOT(x: number): number;
  100843. /**
  100844. * Find the nearest power of two.
  100845. * @param x Number to start search from.
  100846. * @return Next nearest power of two.
  100847. */
  100848. static NearestPOT(x: number): number;
  100849. /**
  100850. * Get the closest exponent of two
  100851. * @param value defines the value to approximate
  100852. * @param max defines the maximum value to return
  100853. * @param mode defines how to define the closest value
  100854. * @returns closest exponent of two of the given value
  100855. */
  100856. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  100857. /**
  100858. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  100859. * @param func - the function to be called
  100860. * @param requester - the object that will request the next frame. Falls back to window.
  100861. * @returns frame number
  100862. */
  100863. static QueueNewFrame(func: () => void, requester?: any): number;
  100864. /**
  100865. * Gets host document
  100866. * @returns the host document object
  100867. */
  100868. getHostDocument(): Document;
  100869. }
  100870. }
  100871. declare module BABYLON {
  100872. /**
  100873. * Class representing spherical harmonics coefficients to the 3rd degree
  100874. */
  100875. export class SphericalHarmonics {
  100876. /**
  100877. * Defines whether or not the harmonics have been prescaled for rendering.
  100878. */
  100879. preScaled: boolean;
  100880. /**
  100881. * The l0,0 coefficients of the spherical harmonics
  100882. */
  100883. l00: Vector3;
  100884. /**
  100885. * The l1,-1 coefficients of the spherical harmonics
  100886. */
  100887. l1_1: Vector3;
  100888. /**
  100889. * The l1,0 coefficients of the spherical harmonics
  100890. */
  100891. l10: Vector3;
  100892. /**
  100893. * The l1,1 coefficients of the spherical harmonics
  100894. */
  100895. l11: Vector3;
  100896. /**
  100897. * The l2,-2 coefficients of the spherical harmonics
  100898. */
  100899. l2_2: Vector3;
  100900. /**
  100901. * The l2,-1 coefficients of the spherical harmonics
  100902. */
  100903. l2_1: Vector3;
  100904. /**
  100905. * The l2,0 coefficients of the spherical harmonics
  100906. */
  100907. l20: Vector3;
  100908. /**
  100909. * The l2,1 coefficients of the spherical harmonics
  100910. */
  100911. l21: Vector3;
  100912. /**
  100913. * The l2,2 coefficients of the spherical harmonics
  100914. */
  100915. l22: Vector3;
  100916. /**
  100917. * Adds a light to the spherical harmonics
  100918. * @param direction the direction of the light
  100919. * @param color the color of the light
  100920. * @param deltaSolidAngle the delta solid angle of the light
  100921. */
  100922. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  100923. /**
  100924. * Scales the spherical harmonics by the given amount
  100925. * @param scale the amount to scale
  100926. */
  100927. scaleInPlace(scale: number): void;
  100928. /**
  100929. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  100930. *
  100931. * ```
  100932. * E_lm = A_l * L_lm
  100933. * ```
  100934. *
  100935. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  100936. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  100937. * the scaling factors are given in equation 9.
  100938. */
  100939. convertIncidentRadianceToIrradiance(): void;
  100940. /**
  100941. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  100942. *
  100943. * ```
  100944. * L = (1/pi) * E * rho
  100945. * ```
  100946. *
  100947. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  100948. */
  100949. convertIrradianceToLambertianRadiance(): void;
  100950. /**
  100951. * Integrates the reconstruction coefficients directly in to the SH preventing further
  100952. * required operations at run time.
  100953. *
  100954. * This is simply done by scaling back the SH with Ylm constants parameter.
  100955. * The trigonometric part being applied by the shader at run time.
  100956. */
  100957. preScaleForRendering(): void;
  100958. /**
  100959. * Constructs a spherical harmonics from an array.
  100960. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  100961. * @returns the spherical harmonics
  100962. */
  100963. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  100964. /**
  100965. * Gets the spherical harmonics from polynomial
  100966. * @param polynomial the spherical polynomial
  100967. * @returns the spherical harmonics
  100968. */
  100969. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  100970. }
  100971. /**
  100972. * Class representing spherical polynomial coefficients to the 3rd degree
  100973. */
  100974. export class SphericalPolynomial {
  100975. private _harmonics;
  100976. /**
  100977. * The spherical harmonics used to create the polynomials.
  100978. */
  100979. readonly preScaledHarmonics: SphericalHarmonics;
  100980. /**
  100981. * The x coefficients of the spherical polynomial
  100982. */
  100983. x: Vector3;
  100984. /**
  100985. * The y coefficients of the spherical polynomial
  100986. */
  100987. y: Vector3;
  100988. /**
  100989. * The z coefficients of the spherical polynomial
  100990. */
  100991. z: Vector3;
  100992. /**
  100993. * The xx coefficients of the spherical polynomial
  100994. */
  100995. xx: Vector3;
  100996. /**
  100997. * The yy coefficients of the spherical polynomial
  100998. */
  100999. yy: Vector3;
  101000. /**
  101001. * The zz coefficients of the spherical polynomial
  101002. */
  101003. zz: Vector3;
  101004. /**
  101005. * The xy coefficients of the spherical polynomial
  101006. */
  101007. xy: Vector3;
  101008. /**
  101009. * The yz coefficients of the spherical polynomial
  101010. */
  101011. yz: Vector3;
  101012. /**
  101013. * The zx coefficients of the spherical polynomial
  101014. */
  101015. zx: Vector3;
  101016. /**
  101017. * Adds an ambient color to the spherical polynomial
  101018. * @param color the color to add
  101019. */
  101020. addAmbient(color: Color3): void;
  101021. /**
  101022. * Scales the spherical polynomial by the given amount
  101023. * @param scale the amount to scale
  101024. */
  101025. scaleInPlace(scale: number): void;
  101026. /**
  101027. * Gets the spherical polynomial from harmonics
  101028. * @param harmonics the spherical harmonics
  101029. * @returns the spherical polynomial
  101030. */
  101031. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  101032. /**
  101033. * Constructs a spherical polynomial from an array.
  101034. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  101035. * @returns the spherical polynomial
  101036. */
  101037. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  101038. }
  101039. }
  101040. declare module BABYLON {
  101041. /**
  101042. * Defines the source of the internal texture
  101043. */
  101044. export enum InternalTextureSource {
  101045. /**
  101046. * The source of the texture data is unknown
  101047. */
  101048. Unknown = 0,
  101049. /**
  101050. * Texture data comes from an URL
  101051. */
  101052. Url = 1,
  101053. /**
  101054. * Texture data is only used for temporary storage
  101055. */
  101056. Temp = 2,
  101057. /**
  101058. * Texture data comes from raw data (ArrayBuffer)
  101059. */
  101060. Raw = 3,
  101061. /**
  101062. * Texture content is dynamic (video or dynamic texture)
  101063. */
  101064. Dynamic = 4,
  101065. /**
  101066. * Texture content is generated by rendering to it
  101067. */
  101068. RenderTarget = 5,
  101069. /**
  101070. * Texture content is part of a multi render target process
  101071. */
  101072. MultiRenderTarget = 6,
  101073. /**
  101074. * Texture data comes from a cube data file
  101075. */
  101076. Cube = 7,
  101077. /**
  101078. * Texture data comes from a raw cube data
  101079. */
  101080. CubeRaw = 8,
  101081. /**
  101082. * Texture data come from a prefiltered cube data file
  101083. */
  101084. CubePrefiltered = 9,
  101085. /**
  101086. * Texture content is raw 3D data
  101087. */
  101088. Raw3D = 10,
  101089. /**
  101090. * Texture content is raw 2D array data
  101091. */
  101092. Raw2DArray = 11,
  101093. /**
  101094. * Texture content is a depth texture
  101095. */
  101096. Depth = 12,
  101097. /**
  101098. * Texture data comes from a raw cube data encoded with RGBD
  101099. */
  101100. CubeRawRGBD = 13
  101101. }
  101102. /**
  101103. * Class used to store data associated with WebGL texture data for the engine
  101104. * This class should not be used directly
  101105. */
  101106. export class InternalTexture {
  101107. /** @hidden */
  101108. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  101109. /**
  101110. * Defines if the texture is ready
  101111. */
  101112. isReady: boolean;
  101113. /**
  101114. * Defines if the texture is a cube texture
  101115. */
  101116. isCube: boolean;
  101117. /**
  101118. * Defines if the texture contains 3D data
  101119. */
  101120. is3D: boolean;
  101121. /**
  101122. * Defines if the texture contains 2D array data
  101123. */
  101124. is2DArray: boolean;
  101125. /**
  101126. * Defines if the texture contains multiview data
  101127. */
  101128. isMultiview: boolean;
  101129. /**
  101130. * Gets the URL used to load this texture
  101131. */
  101132. url: string;
  101133. /**
  101134. * Gets the sampling mode of the texture
  101135. */
  101136. samplingMode: number;
  101137. /**
  101138. * Gets a boolean indicating if the texture needs mipmaps generation
  101139. */
  101140. generateMipMaps: boolean;
  101141. /**
  101142. * Gets the number of samples used by the texture (WebGL2+ only)
  101143. */
  101144. samples: number;
  101145. /**
  101146. * Gets the type of the texture (int, float...)
  101147. */
  101148. type: number;
  101149. /**
  101150. * Gets the format of the texture (RGB, RGBA...)
  101151. */
  101152. format: number;
  101153. /**
  101154. * Observable called when the texture is loaded
  101155. */
  101156. onLoadedObservable: Observable<InternalTexture>;
  101157. /**
  101158. * Gets the width of the texture
  101159. */
  101160. width: number;
  101161. /**
  101162. * Gets the height of the texture
  101163. */
  101164. height: number;
  101165. /**
  101166. * Gets the depth of the texture
  101167. */
  101168. depth: number;
  101169. /**
  101170. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  101171. */
  101172. baseWidth: number;
  101173. /**
  101174. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  101175. */
  101176. baseHeight: number;
  101177. /**
  101178. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  101179. */
  101180. baseDepth: number;
  101181. /**
  101182. * Gets a boolean indicating if the texture is inverted on Y axis
  101183. */
  101184. invertY: boolean;
  101185. /** @hidden */
  101186. _invertVScale: boolean;
  101187. /** @hidden */
  101188. _associatedChannel: number;
  101189. /** @hidden */
  101190. _source: InternalTextureSource;
  101191. /** @hidden */
  101192. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  101193. /** @hidden */
  101194. _bufferView: Nullable<ArrayBufferView>;
  101195. /** @hidden */
  101196. _bufferViewArray: Nullable<ArrayBufferView[]>;
  101197. /** @hidden */
  101198. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  101199. /** @hidden */
  101200. _size: number;
  101201. /** @hidden */
  101202. _extension: string;
  101203. /** @hidden */
  101204. _files: Nullable<string[]>;
  101205. /** @hidden */
  101206. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  101207. /** @hidden */
  101208. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  101209. /** @hidden */
  101210. _framebuffer: Nullable<WebGLFramebuffer>;
  101211. /** @hidden */
  101212. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  101213. /** @hidden */
  101214. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  101215. /** @hidden */
  101216. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  101217. /** @hidden */
  101218. _attachments: Nullable<number[]>;
  101219. /** @hidden */
  101220. _cachedCoordinatesMode: Nullable<number>;
  101221. /** @hidden */
  101222. _cachedWrapU: Nullable<number>;
  101223. /** @hidden */
  101224. _cachedWrapV: Nullable<number>;
  101225. /** @hidden */
  101226. _cachedWrapR: Nullable<number>;
  101227. /** @hidden */
  101228. _cachedAnisotropicFilteringLevel: Nullable<number>;
  101229. /** @hidden */
  101230. _isDisabled: boolean;
  101231. /** @hidden */
  101232. _compression: Nullable<string>;
  101233. /** @hidden */
  101234. _generateStencilBuffer: boolean;
  101235. /** @hidden */
  101236. _generateDepthBuffer: boolean;
  101237. /** @hidden */
  101238. _comparisonFunction: number;
  101239. /** @hidden */
  101240. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  101241. /** @hidden */
  101242. _lodGenerationScale: number;
  101243. /** @hidden */
  101244. _lodGenerationOffset: number;
  101245. /** @hidden */
  101246. _colorTextureArray: Nullable<WebGLTexture>;
  101247. /** @hidden */
  101248. _depthStencilTextureArray: Nullable<WebGLTexture>;
  101249. /** @hidden */
  101250. _lodTextureHigh: Nullable<BaseTexture>;
  101251. /** @hidden */
  101252. _lodTextureMid: Nullable<BaseTexture>;
  101253. /** @hidden */
  101254. _lodTextureLow: Nullable<BaseTexture>;
  101255. /** @hidden */
  101256. _isRGBD: boolean;
  101257. /** @hidden */
  101258. _linearSpecularLOD: boolean;
  101259. /** @hidden */
  101260. _irradianceTexture: Nullable<BaseTexture>;
  101261. /** @hidden */
  101262. _webGLTexture: Nullable<WebGLTexture>;
  101263. /** @hidden */
  101264. _references: number;
  101265. private _engine;
  101266. /**
  101267. * Gets the Engine the texture belongs to.
  101268. * @returns The babylon engine
  101269. */
  101270. getEngine(): ThinEngine;
  101271. /**
  101272. * Gets the data source type of the texture
  101273. */
  101274. readonly source: InternalTextureSource;
  101275. /**
  101276. * Creates a new InternalTexture
  101277. * @param engine defines the engine to use
  101278. * @param source defines the type of data that will be used
  101279. * @param delayAllocation if the texture allocation should be delayed (default: false)
  101280. */
  101281. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  101282. /**
  101283. * Increments the number of references (ie. the number of Texture that point to it)
  101284. */
  101285. incrementReferences(): void;
  101286. /**
  101287. * Change the size of the texture (not the size of the content)
  101288. * @param width defines the new width
  101289. * @param height defines the new height
  101290. * @param depth defines the new depth (1 by default)
  101291. */
  101292. updateSize(width: int, height: int, depth?: int): void;
  101293. /** @hidden */
  101294. _rebuild(): void;
  101295. /** @hidden */
  101296. _swapAndDie(target: InternalTexture): void;
  101297. /**
  101298. * Dispose the current allocated resources
  101299. */
  101300. dispose(): void;
  101301. }
  101302. }
  101303. declare module BABYLON {
  101304. /**
  101305. * Class used to work with sound analyzer using fast fourier transform (FFT)
  101306. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101307. */
  101308. export class Analyser {
  101309. /**
  101310. * Gets or sets the smoothing
  101311. * @ignorenaming
  101312. */
  101313. SMOOTHING: number;
  101314. /**
  101315. * Gets or sets the FFT table size
  101316. * @ignorenaming
  101317. */
  101318. FFT_SIZE: number;
  101319. /**
  101320. * Gets or sets the bar graph amplitude
  101321. * @ignorenaming
  101322. */
  101323. BARGRAPHAMPLITUDE: number;
  101324. /**
  101325. * Gets or sets the position of the debug canvas
  101326. * @ignorenaming
  101327. */
  101328. DEBUGCANVASPOS: {
  101329. x: number;
  101330. y: number;
  101331. };
  101332. /**
  101333. * Gets or sets the debug canvas size
  101334. * @ignorenaming
  101335. */
  101336. DEBUGCANVASSIZE: {
  101337. width: number;
  101338. height: number;
  101339. };
  101340. private _byteFreqs;
  101341. private _byteTime;
  101342. private _floatFreqs;
  101343. private _webAudioAnalyser;
  101344. private _debugCanvas;
  101345. private _debugCanvasContext;
  101346. private _scene;
  101347. private _registerFunc;
  101348. private _audioEngine;
  101349. /**
  101350. * Creates a new analyser
  101351. * @param scene defines hosting scene
  101352. */
  101353. constructor(scene: Scene);
  101354. /**
  101355. * Get the number of data values you will have to play with for the visualization
  101356. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  101357. * @returns a number
  101358. */
  101359. getFrequencyBinCount(): number;
  101360. /**
  101361. * Gets the current frequency data as a byte array
  101362. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  101363. * @returns a Uint8Array
  101364. */
  101365. getByteFrequencyData(): Uint8Array;
  101366. /**
  101367. * Gets the current waveform as a byte array
  101368. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  101369. * @returns a Uint8Array
  101370. */
  101371. getByteTimeDomainData(): Uint8Array;
  101372. /**
  101373. * Gets the current frequency data as a float array
  101374. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  101375. * @returns a Float32Array
  101376. */
  101377. getFloatFrequencyData(): Float32Array;
  101378. /**
  101379. * Renders the debug canvas
  101380. */
  101381. drawDebugCanvas(): void;
  101382. /**
  101383. * Stops rendering the debug canvas and removes it
  101384. */
  101385. stopDebugCanvas(): void;
  101386. /**
  101387. * Connects two audio nodes
  101388. * @param inputAudioNode defines first node to connect
  101389. * @param outputAudioNode defines second node to connect
  101390. */
  101391. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  101392. /**
  101393. * Releases all associated resources
  101394. */
  101395. dispose(): void;
  101396. }
  101397. }
  101398. declare module BABYLON {
  101399. /**
  101400. * This represents an audio engine and it is responsible
  101401. * to play, synchronize and analyse sounds throughout the application.
  101402. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101403. */
  101404. export interface IAudioEngine extends IDisposable {
  101405. /**
  101406. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  101407. */
  101408. readonly canUseWebAudio: boolean;
  101409. /**
  101410. * Gets the current AudioContext if available.
  101411. */
  101412. readonly audioContext: Nullable<AudioContext>;
  101413. /**
  101414. * The master gain node defines the global audio volume of your audio engine.
  101415. */
  101416. readonly masterGain: GainNode;
  101417. /**
  101418. * Gets whether or not mp3 are supported by your browser.
  101419. */
  101420. readonly isMP3supported: boolean;
  101421. /**
  101422. * Gets whether or not ogg are supported by your browser.
  101423. */
  101424. readonly isOGGsupported: boolean;
  101425. /**
  101426. * Defines if Babylon should emit a warning if WebAudio is not supported.
  101427. * @ignoreNaming
  101428. */
  101429. WarnedWebAudioUnsupported: boolean;
  101430. /**
  101431. * Defines if the audio engine relies on a custom unlocked button.
  101432. * In this case, the embedded button will not be displayed.
  101433. */
  101434. useCustomUnlockedButton: boolean;
  101435. /**
  101436. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  101437. */
  101438. readonly unlocked: boolean;
  101439. /**
  101440. * Event raised when audio has been unlocked on the browser.
  101441. */
  101442. onAudioUnlockedObservable: Observable<AudioEngine>;
  101443. /**
  101444. * Event raised when audio has been locked on the browser.
  101445. */
  101446. onAudioLockedObservable: Observable<AudioEngine>;
  101447. /**
  101448. * Flags the audio engine in Locked state.
  101449. * This happens due to new browser policies preventing audio to autoplay.
  101450. */
  101451. lock(): void;
  101452. /**
  101453. * Unlocks the audio engine once a user action has been done on the dom.
  101454. * This is helpful to resume play once browser policies have been satisfied.
  101455. */
  101456. unlock(): void;
  101457. }
  101458. /**
  101459. * This represents the default audio engine used in babylon.
  101460. * It is responsible to play, synchronize and analyse sounds throughout the application.
  101461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101462. */
  101463. export class AudioEngine implements IAudioEngine {
  101464. private _audioContext;
  101465. private _audioContextInitialized;
  101466. private _muteButton;
  101467. private _hostElement;
  101468. /**
  101469. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  101470. */
  101471. canUseWebAudio: boolean;
  101472. /**
  101473. * The master gain node defines the global audio volume of your audio engine.
  101474. */
  101475. masterGain: GainNode;
  101476. /**
  101477. * Defines if Babylon should emit a warning if WebAudio is not supported.
  101478. * @ignoreNaming
  101479. */
  101480. WarnedWebAudioUnsupported: boolean;
  101481. /**
  101482. * Gets whether or not mp3 are supported by your browser.
  101483. */
  101484. isMP3supported: boolean;
  101485. /**
  101486. * Gets whether or not ogg are supported by your browser.
  101487. */
  101488. isOGGsupported: boolean;
  101489. /**
  101490. * Gets whether audio has been unlocked on the device.
  101491. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  101492. * a user interaction has happened.
  101493. */
  101494. unlocked: boolean;
  101495. /**
  101496. * Defines if the audio engine relies on a custom unlocked button.
  101497. * In this case, the embedded button will not be displayed.
  101498. */
  101499. useCustomUnlockedButton: boolean;
  101500. /**
  101501. * Event raised when audio has been unlocked on the browser.
  101502. */
  101503. onAudioUnlockedObservable: Observable<AudioEngine>;
  101504. /**
  101505. * Event raised when audio has been locked on the browser.
  101506. */
  101507. onAudioLockedObservable: Observable<AudioEngine>;
  101508. /**
  101509. * Gets the current AudioContext if available.
  101510. */
  101511. readonly audioContext: Nullable<AudioContext>;
  101512. private _connectedAnalyser;
  101513. /**
  101514. * Instantiates a new audio engine.
  101515. *
  101516. * There should be only one per page as some browsers restrict the number
  101517. * of audio contexts you can create.
  101518. * @param hostElement defines the host element where to display the mute icon if necessary
  101519. */
  101520. constructor(hostElement?: Nullable<HTMLElement>);
  101521. /**
  101522. * Flags the audio engine in Locked state.
  101523. * This happens due to new browser policies preventing audio to autoplay.
  101524. */
  101525. lock(): void;
  101526. /**
  101527. * Unlocks the audio engine once a user action has been done on the dom.
  101528. * This is helpful to resume play once browser policies have been satisfied.
  101529. */
  101530. unlock(): void;
  101531. private _resumeAudioContext;
  101532. private _initializeAudioContext;
  101533. private _tryToRun;
  101534. private _triggerRunningState;
  101535. private _triggerSuspendedState;
  101536. private _displayMuteButton;
  101537. private _moveButtonToTopLeft;
  101538. private _onResize;
  101539. private _hideMuteButton;
  101540. /**
  101541. * Destroy and release the resources associated with the audio ccontext.
  101542. */
  101543. dispose(): void;
  101544. /**
  101545. * Gets the global volume sets on the master gain.
  101546. * @returns the global volume if set or -1 otherwise
  101547. */
  101548. getGlobalVolume(): number;
  101549. /**
  101550. * Sets the global volume of your experience (sets on the master gain).
  101551. * @param newVolume Defines the new global volume of the application
  101552. */
  101553. setGlobalVolume(newVolume: number): void;
  101554. /**
  101555. * Connect the audio engine to an audio analyser allowing some amazing
  101556. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  101557. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  101558. * @param analyser The analyser to connect to the engine
  101559. */
  101560. connectToAnalyser(analyser: Analyser): void;
  101561. }
  101562. }
  101563. declare module BABYLON {
  101564. /**
  101565. * Interface used to present a loading screen while loading a scene
  101566. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  101567. */
  101568. export interface ILoadingScreen {
  101569. /**
  101570. * Function called to display the loading screen
  101571. */
  101572. displayLoadingUI: () => void;
  101573. /**
  101574. * Function called to hide the loading screen
  101575. */
  101576. hideLoadingUI: () => void;
  101577. /**
  101578. * Gets or sets the color to use for the background
  101579. */
  101580. loadingUIBackgroundColor: string;
  101581. /**
  101582. * Gets or sets the text to display while loading
  101583. */
  101584. loadingUIText: string;
  101585. }
  101586. /**
  101587. * Class used for the default loading screen
  101588. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  101589. */
  101590. export class DefaultLoadingScreen implements ILoadingScreen {
  101591. private _renderingCanvas;
  101592. private _loadingText;
  101593. private _loadingDivBackgroundColor;
  101594. private _loadingDiv;
  101595. private _loadingTextDiv;
  101596. /** Gets or sets the logo url to use for the default loading screen */
  101597. static DefaultLogoUrl: string;
  101598. /** Gets or sets the spinner url to use for the default loading screen */
  101599. static DefaultSpinnerUrl: string;
  101600. /**
  101601. * Creates a new default loading screen
  101602. * @param _renderingCanvas defines the canvas used to render the scene
  101603. * @param _loadingText defines the default text to display
  101604. * @param _loadingDivBackgroundColor defines the default background color
  101605. */
  101606. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  101607. /**
  101608. * Function called to display the loading screen
  101609. */
  101610. displayLoadingUI(): void;
  101611. /**
  101612. * Function called to hide the loading screen
  101613. */
  101614. hideLoadingUI(): void;
  101615. /**
  101616. * Gets or sets the text to display while loading
  101617. */
  101618. loadingUIText: string;
  101619. /**
  101620. * Gets or sets the color to use for the background
  101621. */
  101622. loadingUIBackgroundColor: string;
  101623. private _resizeLoadingUI;
  101624. }
  101625. }
  101626. declare module BABYLON {
  101627. /**
  101628. * Interface for any object that can request an animation frame
  101629. */
  101630. export interface ICustomAnimationFrameRequester {
  101631. /**
  101632. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  101633. */
  101634. renderFunction?: Function;
  101635. /**
  101636. * Called to request the next frame to render to
  101637. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  101638. */
  101639. requestAnimationFrame: Function;
  101640. /**
  101641. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  101642. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  101643. */
  101644. requestID?: number;
  101645. }
  101646. }
  101647. declare module BABYLON {
  101648. /**
  101649. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  101650. */
  101651. export class PerformanceMonitor {
  101652. private _enabled;
  101653. private _rollingFrameTime;
  101654. private _lastFrameTimeMs;
  101655. /**
  101656. * constructor
  101657. * @param frameSampleSize The number of samples required to saturate the sliding window
  101658. */
  101659. constructor(frameSampleSize?: number);
  101660. /**
  101661. * Samples current frame
  101662. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  101663. */
  101664. sampleFrame(timeMs?: number): void;
  101665. /**
  101666. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  101667. */
  101668. readonly averageFrameTime: number;
  101669. /**
  101670. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  101671. */
  101672. readonly averageFrameTimeVariance: number;
  101673. /**
  101674. * Returns the frame time of the most recent frame
  101675. */
  101676. readonly instantaneousFrameTime: number;
  101677. /**
  101678. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  101679. */
  101680. readonly averageFPS: number;
  101681. /**
  101682. * Returns the average framerate in frames per second using the most recent frame time
  101683. */
  101684. readonly instantaneousFPS: number;
  101685. /**
  101686. * Returns true if enough samples have been taken to completely fill the sliding window
  101687. */
  101688. readonly isSaturated: boolean;
  101689. /**
  101690. * Enables contributions to the sliding window sample set
  101691. */
  101692. enable(): void;
  101693. /**
  101694. * Disables contributions to the sliding window sample set
  101695. * Samples will not be interpolated over the disabled period
  101696. */
  101697. disable(): void;
  101698. /**
  101699. * Returns true if sampling is enabled
  101700. */
  101701. readonly isEnabled: boolean;
  101702. /**
  101703. * Resets performance monitor
  101704. */
  101705. reset(): void;
  101706. }
  101707. /**
  101708. * RollingAverage
  101709. *
  101710. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  101711. */
  101712. export class RollingAverage {
  101713. /**
  101714. * Current average
  101715. */
  101716. average: number;
  101717. /**
  101718. * Current variance
  101719. */
  101720. variance: number;
  101721. protected _samples: Array<number>;
  101722. protected _sampleCount: number;
  101723. protected _pos: number;
  101724. protected _m2: number;
  101725. /**
  101726. * constructor
  101727. * @param length The number of samples required to saturate the sliding window
  101728. */
  101729. constructor(length: number);
  101730. /**
  101731. * Adds a sample to the sample set
  101732. * @param v The sample value
  101733. */
  101734. add(v: number): void;
  101735. /**
  101736. * Returns previously added values or null if outside of history or outside the sliding window domain
  101737. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  101738. * @return Value previously recorded with add() or null if outside of range
  101739. */
  101740. history(i: number): number;
  101741. /**
  101742. * Returns true if enough samples have been taken to completely fill the sliding window
  101743. * @return true if sample-set saturated
  101744. */
  101745. isSaturated(): boolean;
  101746. /**
  101747. * Resets the rolling average (equivalent to 0 samples taken so far)
  101748. */
  101749. reset(): void;
  101750. /**
  101751. * Wraps a value around the sample range boundaries
  101752. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  101753. * @return Wrapped position in sample range
  101754. */
  101755. protected _wrapPosition(i: number): number;
  101756. }
  101757. }
  101758. declare module BABYLON {
  101759. /**
  101760. * This class is used to track a performance counter which is number based.
  101761. * The user has access to many properties which give statistics of different nature.
  101762. *
  101763. * The implementer can track two kinds of Performance Counter: time and count.
  101764. * 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.
  101765. * 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.
  101766. */
  101767. export class PerfCounter {
  101768. /**
  101769. * Gets or sets a global boolean to turn on and off all the counters
  101770. */
  101771. static Enabled: boolean;
  101772. /**
  101773. * Returns the smallest value ever
  101774. */
  101775. readonly min: number;
  101776. /**
  101777. * Returns the biggest value ever
  101778. */
  101779. readonly max: number;
  101780. /**
  101781. * Returns the average value since the performance counter is running
  101782. */
  101783. readonly average: number;
  101784. /**
  101785. * Returns the average value of the last second the counter was monitored
  101786. */
  101787. readonly lastSecAverage: number;
  101788. /**
  101789. * Returns the current value
  101790. */
  101791. readonly current: number;
  101792. /**
  101793. * Gets the accumulated total
  101794. */
  101795. readonly total: number;
  101796. /**
  101797. * Gets the total value count
  101798. */
  101799. readonly count: number;
  101800. /**
  101801. * Creates a new counter
  101802. */
  101803. constructor();
  101804. /**
  101805. * Call this method to start monitoring a new frame.
  101806. * 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.
  101807. */
  101808. fetchNewFrame(): void;
  101809. /**
  101810. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  101811. * @param newCount the count value to add to the monitored count
  101812. * @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.
  101813. */
  101814. addCount(newCount: number, fetchResult: boolean): void;
  101815. /**
  101816. * Start monitoring this performance counter
  101817. */
  101818. beginMonitoring(): void;
  101819. /**
  101820. * Compute the time lapsed since the previous beginMonitoring() call.
  101821. * @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
  101822. */
  101823. endMonitoring(newFrame?: boolean): void;
  101824. private _fetchResult;
  101825. private _startMonitoringTime;
  101826. private _min;
  101827. private _max;
  101828. private _average;
  101829. private _current;
  101830. private _totalValueCount;
  101831. private _totalAccumulated;
  101832. private _lastSecAverage;
  101833. private _lastSecAccumulated;
  101834. private _lastSecTime;
  101835. private _lastSecValueCount;
  101836. }
  101837. }
  101838. declare module BABYLON {
  101839. interface ThinEngine {
  101840. /**
  101841. * Sets alpha constants used by some alpha blending modes
  101842. * @param r defines the red component
  101843. * @param g defines the green component
  101844. * @param b defines the blue component
  101845. * @param a defines the alpha component
  101846. */
  101847. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  101848. /**
  101849. * Sets the current alpha mode
  101850. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  101851. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  101852. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  101853. */
  101854. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  101855. /**
  101856. * Gets the current alpha mode
  101857. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  101858. * @returns the current alpha mode
  101859. */
  101860. getAlphaMode(): number;
  101861. /**
  101862. * Sets the current alpha equation
  101863. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  101864. */
  101865. setAlphaEquation(equation: number): void;
  101866. /**
  101867. * Gets the current alpha equation.
  101868. * @returns the current alpha equation
  101869. */
  101870. getAlphaEquation(): number;
  101871. }
  101872. }
  101873. declare module BABYLON {
  101874. /**
  101875. * Defines the interface used by display changed events
  101876. */
  101877. export interface IDisplayChangedEventArgs {
  101878. /** Gets the vrDisplay object (if any) */
  101879. vrDisplay: Nullable<any>;
  101880. /** Gets a boolean indicating if webVR is supported */
  101881. vrSupported: boolean;
  101882. }
  101883. /**
  101884. * Defines the interface used by objects containing a viewport (like a camera)
  101885. */
  101886. interface IViewportOwnerLike {
  101887. /**
  101888. * Gets or sets the viewport
  101889. */
  101890. viewport: IViewportLike;
  101891. }
  101892. /**
  101893. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  101894. */
  101895. export class Engine extends ThinEngine {
  101896. /** Defines that alpha blending is disabled */
  101897. static readonly ALPHA_DISABLE: number;
  101898. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  101899. static readonly ALPHA_ADD: number;
  101900. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  101901. static readonly ALPHA_COMBINE: number;
  101902. /** Defines that alpha blending to DEST - SRC * DEST */
  101903. static readonly ALPHA_SUBTRACT: number;
  101904. /** Defines that alpha blending to SRC * DEST */
  101905. static readonly ALPHA_MULTIPLY: number;
  101906. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  101907. static readonly ALPHA_MAXIMIZED: number;
  101908. /** Defines that alpha blending to SRC + DEST */
  101909. static readonly ALPHA_ONEONE: number;
  101910. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  101911. static readonly ALPHA_PREMULTIPLIED: number;
  101912. /**
  101913. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  101914. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  101915. */
  101916. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  101917. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  101918. static readonly ALPHA_INTERPOLATE: number;
  101919. /**
  101920. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  101921. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  101922. */
  101923. static readonly ALPHA_SCREENMODE: number;
  101924. /** Defines that the ressource is not delayed*/
  101925. static readonly DELAYLOADSTATE_NONE: number;
  101926. /** Defines that the ressource was successfully delay loaded */
  101927. static readonly DELAYLOADSTATE_LOADED: number;
  101928. /** Defines that the ressource is currently delay loading */
  101929. static readonly DELAYLOADSTATE_LOADING: number;
  101930. /** Defines that the ressource is delayed and has not started loading */
  101931. static readonly DELAYLOADSTATE_NOTLOADED: number;
  101932. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  101933. static readonly NEVER: number;
  101934. /** 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 */
  101935. static readonly ALWAYS: number;
  101936. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  101937. static readonly LESS: number;
  101938. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  101939. static readonly EQUAL: number;
  101940. /** 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 */
  101941. static readonly LEQUAL: number;
  101942. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  101943. static readonly GREATER: number;
  101944. /** 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 */
  101945. static readonly GEQUAL: number;
  101946. /** 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 */
  101947. static readonly NOTEQUAL: number;
  101948. /** Passed to stencilOperation to specify that stencil value must be kept */
  101949. static readonly KEEP: number;
  101950. /** Passed to stencilOperation to specify that stencil value must be replaced */
  101951. static readonly REPLACE: number;
  101952. /** Passed to stencilOperation to specify that stencil value must be incremented */
  101953. static readonly INCR: number;
  101954. /** Passed to stencilOperation to specify that stencil value must be decremented */
  101955. static readonly DECR: number;
  101956. /** Passed to stencilOperation to specify that stencil value must be inverted */
  101957. static readonly INVERT: number;
  101958. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  101959. static readonly INCR_WRAP: number;
  101960. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  101961. static readonly DECR_WRAP: number;
  101962. /** Texture is not repeating outside of 0..1 UVs */
  101963. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  101964. /** Texture is repeating outside of 0..1 UVs */
  101965. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  101966. /** Texture is repeating and mirrored */
  101967. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  101968. /** ALPHA */
  101969. static readonly TEXTUREFORMAT_ALPHA: number;
  101970. /** LUMINANCE */
  101971. static readonly TEXTUREFORMAT_LUMINANCE: number;
  101972. /** LUMINANCE_ALPHA */
  101973. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  101974. /** RGB */
  101975. static readonly TEXTUREFORMAT_RGB: number;
  101976. /** RGBA */
  101977. static readonly TEXTUREFORMAT_RGBA: number;
  101978. /** RED */
  101979. static readonly TEXTUREFORMAT_RED: number;
  101980. /** RED (2nd reference) */
  101981. static readonly TEXTUREFORMAT_R: number;
  101982. /** RG */
  101983. static readonly TEXTUREFORMAT_RG: number;
  101984. /** RED_INTEGER */
  101985. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  101986. /** RED_INTEGER (2nd reference) */
  101987. static readonly TEXTUREFORMAT_R_INTEGER: number;
  101988. /** RG_INTEGER */
  101989. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  101990. /** RGB_INTEGER */
  101991. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  101992. /** RGBA_INTEGER */
  101993. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  101994. /** UNSIGNED_BYTE */
  101995. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  101996. /** UNSIGNED_BYTE (2nd reference) */
  101997. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  101998. /** FLOAT */
  101999. static readonly TEXTURETYPE_FLOAT: number;
  102000. /** HALF_FLOAT */
  102001. static readonly TEXTURETYPE_HALF_FLOAT: number;
  102002. /** BYTE */
  102003. static readonly TEXTURETYPE_BYTE: number;
  102004. /** SHORT */
  102005. static readonly TEXTURETYPE_SHORT: number;
  102006. /** UNSIGNED_SHORT */
  102007. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  102008. /** INT */
  102009. static readonly TEXTURETYPE_INT: number;
  102010. /** UNSIGNED_INT */
  102011. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  102012. /** UNSIGNED_SHORT_4_4_4_4 */
  102013. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  102014. /** UNSIGNED_SHORT_5_5_5_1 */
  102015. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  102016. /** UNSIGNED_SHORT_5_6_5 */
  102017. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  102018. /** UNSIGNED_INT_2_10_10_10_REV */
  102019. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  102020. /** UNSIGNED_INT_24_8 */
  102021. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  102022. /** UNSIGNED_INT_10F_11F_11F_REV */
  102023. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  102024. /** UNSIGNED_INT_5_9_9_9_REV */
  102025. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  102026. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  102027. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  102028. /** nearest is mag = nearest and min = nearest and mip = linear */
  102029. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  102030. /** Bilinear is mag = linear and min = linear and mip = nearest */
  102031. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  102032. /** Trilinear is mag = linear and min = linear and mip = linear */
  102033. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  102034. /** nearest is mag = nearest and min = nearest and mip = linear */
  102035. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  102036. /** Bilinear is mag = linear and min = linear and mip = nearest */
  102037. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  102038. /** Trilinear is mag = linear and min = linear and mip = linear */
  102039. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  102040. /** mag = nearest and min = nearest and mip = nearest */
  102041. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  102042. /** mag = nearest and min = linear and mip = nearest */
  102043. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  102044. /** mag = nearest and min = linear and mip = linear */
  102045. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  102046. /** mag = nearest and min = linear and mip = none */
  102047. static readonly TEXTURE_NEAREST_LINEAR: number;
  102048. /** mag = nearest and min = nearest and mip = none */
  102049. static readonly TEXTURE_NEAREST_NEAREST: number;
  102050. /** mag = linear and min = nearest and mip = nearest */
  102051. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  102052. /** mag = linear and min = nearest and mip = linear */
  102053. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  102054. /** mag = linear and min = linear and mip = none */
  102055. static readonly TEXTURE_LINEAR_LINEAR: number;
  102056. /** mag = linear and min = nearest and mip = none */
  102057. static readonly TEXTURE_LINEAR_NEAREST: number;
  102058. /** Explicit coordinates mode */
  102059. static readonly TEXTURE_EXPLICIT_MODE: number;
  102060. /** Spherical coordinates mode */
  102061. static readonly TEXTURE_SPHERICAL_MODE: number;
  102062. /** Planar coordinates mode */
  102063. static readonly TEXTURE_PLANAR_MODE: number;
  102064. /** Cubic coordinates mode */
  102065. static readonly TEXTURE_CUBIC_MODE: number;
  102066. /** Projection coordinates mode */
  102067. static readonly TEXTURE_PROJECTION_MODE: number;
  102068. /** Skybox coordinates mode */
  102069. static readonly TEXTURE_SKYBOX_MODE: number;
  102070. /** Inverse Cubic coordinates mode */
  102071. static readonly TEXTURE_INVCUBIC_MODE: number;
  102072. /** Equirectangular coordinates mode */
  102073. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  102074. /** Equirectangular Fixed coordinates mode */
  102075. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  102076. /** Equirectangular Fixed Mirrored coordinates mode */
  102077. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  102078. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  102079. static readonly SCALEMODE_FLOOR: number;
  102080. /** Defines that texture rescaling will look for the nearest power of 2 size */
  102081. static readonly SCALEMODE_NEAREST: number;
  102082. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  102083. static readonly SCALEMODE_CEILING: number;
  102084. /**
  102085. * Returns the current npm package of the sdk
  102086. */
  102087. static readonly NpmPackage: string;
  102088. /**
  102089. * Returns the current version of the framework
  102090. */
  102091. static readonly Version: string;
  102092. /** Gets the list of created engines */
  102093. static readonly Instances: Engine[];
  102094. /**
  102095. * Gets the latest created engine
  102096. */
  102097. static readonly LastCreatedEngine: Nullable<Engine>;
  102098. /**
  102099. * Gets the latest created scene
  102100. */
  102101. static readonly LastCreatedScene: Nullable<Scene>;
  102102. /**
  102103. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  102104. * @param flag defines which part of the materials must be marked as dirty
  102105. * @param predicate defines a predicate used to filter which materials should be affected
  102106. */
  102107. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  102108. /**
  102109. * Method called to create the default loading screen.
  102110. * This can be overriden in your own app.
  102111. * @param canvas The rendering canvas element
  102112. * @returns The loading screen
  102113. */
  102114. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  102115. /**
  102116. * Method called to create the default rescale post process on each engine.
  102117. */
  102118. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  102119. /**
  102120. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  102121. **/
  102122. enableOfflineSupport: boolean;
  102123. /**
  102124. * 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)
  102125. **/
  102126. disableManifestCheck: boolean;
  102127. /**
  102128. * Gets the list of created scenes
  102129. */
  102130. scenes: Scene[];
  102131. /**
  102132. * Event raised when a new scene is created
  102133. */
  102134. onNewSceneAddedObservable: Observable<Scene>;
  102135. /**
  102136. * Gets the list of created postprocesses
  102137. */
  102138. postProcesses: PostProcess[];
  102139. /**
  102140. * Gets a boolean indicating if the pointer is currently locked
  102141. */
  102142. isPointerLock: boolean;
  102143. /**
  102144. * Observable event triggered each time the rendering canvas is resized
  102145. */
  102146. onResizeObservable: Observable<Engine>;
  102147. /**
  102148. * Observable event triggered each time the canvas loses focus
  102149. */
  102150. onCanvasBlurObservable: Observable<Engine>;
  102151. /**
  102152. * Observable event triggered each time the canvas gains focus
  102153. */
  102154. onCanvasFocusObservable: Observable<Engine>;
  102155. /**
  102156. * Observable event triggered each time the canvas receives pointerout event
  102157. */
  102158. onCanvasPointerOutObservable: Observable<PointerEvent>;
  102159. /**
  102160. * Observable raised when the engine begins a new frame
  102161. */
  102162. onBeginFrameObservable: Observable<Engine>;
  102163. /**
  102164. * If set, will be used to request the next animation frame for the render loop
  102165. */
  102166. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  102167. /**
  102168. * Observable raised when the engine ends the current frame
  102169. */
  102170. onEndFrameObservable: Observable<Engine>;
  102171. /**
  102172. * Observable raised when the engine is about to compile a shader
  102173. */
  102174. onBeforeShaderCompilationObservable: Observable<Engine>;
  102175. /**
  102176. * Observable raised when the engine has jsut compiled a shader
  102177. */
  102178. onAfterShaderCompilationObservable: Observable<Engine>;
  102179. /**
  102180. * Gets the audio engine
  102181. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102182. * @ignorenaming
  102183. */
  102184. static audioEngine: IAudioEngine;
  102185. /**
  102186. * Default AudioEngine factory responsible of creating the Audio Engine.
  102187. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  102188. */
  102189. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  102190. /**
  102191. * Default offline support factory responsible of creating a tool used to store data locally.
  102192. * By default, this will create a Database object if the workload has been embedded.
  102193. */
  102194. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  102195. private _loadingScreen;
  102196. private _pointerLockRequested;
  102197. private _dummyFramebuffer;
  102198. private _rescalePostProcess;
  102199. private _deterministicLockstep;
  102200. private _lockstepMaxSteps;
  102201. private _timeStep;
  102202. protected readonly _supportsHardwareTextureRescaling: boolean;
  102203. private _fps;
  102204. private _deltaTime;
  102205. /** @hidden */
  102206. _drawCalls: PerfCounter;
  102207. /**
  102208. * Turn this value on if you want to pause FPS computation when in background
  102209. */
  102210. disablePerformanceMonitorInBackground: boolean;
  102211. private _performanceMonitor;
  102212. /**
  102213. * Gets the performance monitor attached to this engine
  102214. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  102215. */
  102216. readonly performanceMonitor: PerformanceMonitor;
  102217. private _onFocus;
  102218. private _onBlur;
  102219. private _onCanvasPointerOut;
  102220. private _onCanvasBlur;
  102221. private _onCanvasFocus;
  102222. private _onFullscreenChange;
  102223. private _onPointerLockChange;
  102224. /**
  102225. * Gets the HTML element used to attach event listeners
  102226. * @returns a HTML element
  102227. */
  102228. getInputElement(): Nullable<HTMLElement>;
  102229. /**
  102230. * Creates a new engine
  102231. * @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
  102232. * @param antialias defines enable antialiasing (default: false)
  102233. * @param options defines further options to be sent to the getContext() function
  102234. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  102235. */
  102236. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  102237. /**
  102238. * Gets current aspect ratio
  102239. * @param viewportOwner defines the camera to use to get the aspect ratio
  102240. * @param useScreen defines if screen size must be used (or the current render target if any)
  102241. * @returns a number defining the aspect ratio
  102242. */
  102243. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  102244. /**
  102245. * Gets current screen aspect ratio
  102246. * @returns a number defining the aspect ratio
  102247. */
  102248. getScreenAspectRatio(): number;
  102249. /**
  102250. * Gets the client rect of the HTML canvas attached with the current webGL context
  102251. * @returns a client rectanglee
  102252. */
  102253. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  102254. /**
  102255. * Gets the client rect of the HTML element used for events
  102256. * @returns a client rectanglee
  102257. */
  102258. getInputElementClientRect(): Nullable<ClientRect>;
  102259. /**
  102260. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  102261. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102262. * @returns true if engine is in deterministic lock step mode
  102263. */
  102264. isDeterministicLockStep(): boolean;
  102265. /**
  102266. * Gets the max steps when engine is running in deterministic lock step
  102267. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102268. * @returns the max steps
  102269. */
  102270. getLockstepMaxSteps(): number;
  102271. /**
  102272. * Returns the time in ms between steps when using deterministic lock step.
  102273. * @returns time step in (ms)
  102274. */
  102275. getTimeStep(): number;
  102276. /**
  102277. * Force the mipmap generation for the given render target texture
  102278. * @param texture defines the render target texture to use
  102279. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  102280. */
  102281. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  102282. /** States */
  102283. /**
  102284. * Set various states to the webGL context
  102285. * @param culling defines backface culling state
  102286. * @param zOffset defines the value to apply to zOffset (0 by default)
  102287. * @param force defines if states must be applied even if cache is up to date
  102288. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  102289. */
  102290. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  102291. /**
  102292. * Set the z offset to apply to current rendering
  102293. * @param value defines the offset to apply
  102294. */
  102295. setZOffset(value: number): void;
  102296. /**
  102297. * Gets the current value of the zOffset
  102298. * @returns the current zOffset state
  102299. */
  102300. getZOffset(): number;
  102301. /**
  102302. * Enable or disable depth buffering
  102303. * @param enable defines the state to set
  102304. */
  102305. setDepthBuffer(enable: boolean): void;
  102306. /**
  102307. * Gets a boolean indicating if depth writing is enabled
  102308. * @returns the current depth writing state
  102309. */
  102310. getDepthWrite(): boolean;
  102311. /**
  102312. * Enable or disable depth writing
  102313. * @param enable defines the state to set
  102314. */
  102315. setDepthWrite(enable: boolean): void;
  102316. /**
  102317. * Gets a boolean indicating if stencil buffer is enabled
  102318. * @returns the current stencil buffer state
  102319. */
  102320. getStencilBuffer(): boolean;
  102321. /**
  102322. * Enable or disable the stencil buffer
  102323. * @param enable defines if the stencil buffer must be enabled or disabled
  102324. */
  102325. setStencilBuffer(enable: boolean): void;
  102326. /**
  102327. * Gets the current stencil mask
  102328. * @returns a number defining the new stencil mask to use
  102329. */
  102330. getStencilMask(): number;
  102331. /**
  102332. * Sets the current stencil mask
  102333. * @param mask defines the new stencil mask to use
  102334. */
  102335. setStencilMask(mask: number): void;
  102336. /**
  102337. * Gets the current stencil function
  102338. * @returns a number defining the stencil function to use
  102339. */
  102340. getStencilFunction(): number;
  102341. /**
  102342. * Gets the current stencil reference value
  102343. * @returns a number defining the stencil reference value to use
  102344. */
  102345. getStencilFunctionReference(): number;
  102346. /**
  102347. * Gets the current stencil mask
  102348. * @returns a number defining the stencil mask to use
  102349. */
  102350. getStencilFunctionMask(): number;
  102351. /**
  102352. * Sets the current stencil function
  102353. * @param stencilFunc defines the new stencil function to use
  102354. */
  102355. setStencilFunction(stencilFunc: number): void;
  102356. /**
  102357. * Sets the current stencil reference
  102358. * @param reference defines the new stencil reference to use
  102359. */
  102360. setStencilFunctionReference(reference: number): void;
  102361. /**
  102362. * Sets the current stencil mask
  102363. * @param mask defines the new stencil mask to use
  102364. */
  102365. setStencilFunctionMask(mask: number): void;
  102366. /**
  102367. * Gets the current stencil operation when stencil fails
  102368. * @returns a number defining stencil operation to use when stencil fails
  102369. */
  102370. getStencilOperationFail(): number;
  102371. /**
  102372. * Gets the current stencil operation when depth fails
  102373. * @returns a number defining stencil operation to use when depth fails
  102374. */
  102375. getStencilOperationDepthFail(): number;
  102376. /**
  102377. * Gets the current stencil operation when stencil passes
  102378. * @returns a number defining stencil operation to use when stencil passes
  102379. */
  102380. getStencilOperationPass(): number;
  102381. /**
  102382. * Sets the stencil operation to use when stencil fails
  102383. * @param operation defines the stencil operation to use when stencil fails
  102384. */
  102385. setStencilOperationFail(operation: number): void;
  102386. /**
  102387. * Sets the stencil operation to use when depth fails
  102388. * @param operation defines the stencil operation to use when depth fails
  102389. */
  102390. setStencilOperationDepthFail(operation: number): void;
  102391. /**
  102392. * Sets the stencil operation to use when stencil passes
  102393. * @param operation defines the stencil operation to use when stencil passes
  102394. */
  102395. setStencilOperationPass(operation: number): void;
  102396. /**
  102397. * Sets a boolean indicating if the dithering state is enabled or disabled
  102398. * @param value defines the dithering state
  102399. */
  102400. setDitheringState(value: boolean): void;
  102401. /**
  102402. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  102403. * @param value defines the rasterizer state
  102404. */
  102405. setRasterizerState(value: boolean): void;
  102406. /**
  102407. * Gets the current depth function
  102408. * @returns a number defining the depth function
  102409. */
  102410. getDepthFunction(): Nullable<number>;
  102411. /**
  102412. * Sets the current depth function
  102413. * @param depthFunc defines the function to use
  102414. */
  102415. setDepthFunction(depthFunc: number): void;
  102416. /**
  102417. * Sets the current depth function to GREATER
  102418. */
  102419. setDepthFunctionToGreater(): void;
  102420. /**
  102421. * Sets the current depth function to GEQUAL
  102422. */
  102423. setDepthFunctionToGreaterOrEqual(): void;
  102424. /**
  102425. * Sets the current depth function to LESS
  102426. */
  102427. setDepthFunctionToLess(): void;
  102428. /**
  102429. * Sets the current depth function to LEQUAL
  102430. */
  102431. setDepthFunctionToLessOrEqual(): void;
  102432. private _cachedStencilBuffer;
  102433. private _cachedStencilFunction;
  102434. private _cachedStencilMask;
  102435. private _cachedStencilOperationPass;
  102436. private _cachedStencilOperationFail;
  102437. private _cachedStencilOperationDepthFail;
  102438. private _cachedStencilReference;
  102439. /**
  102440. * Caches the the state of the stencil buffer
  102441. */
  102442. cacheStencilState(): void;
  102443. /**
  102444. * Restores the state of the stencil buffer
  102445. */
  102446. restoreStencilState(): void;
  102447. /**
  102448. * Directly set the WebGL Viewport
  102449. * @param x defines the x coordinate of the viewport (in screen space)
  102450. * @param y defines the y coordinate of the viewport (in screen space)
  102451. * @param width defines the width of the viewport (in screen space)
  102452. * @param height defines the height of the viewport (in screen space)
  102453. * @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
  102454. */
  102455. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  102456. /**
  102457. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  102458. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  102459. * @param y defines the y-coordinate of the corner of the clear rectangle
  102460. * @param width defines the width of the clear rectangle
  102461. * @param height defines the height of the clear rectangle
  102462. * @param clearColor defines the clear color
  102463. */
  102464. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  102465. /**
  102466. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  102467. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  102468. * @param y defines the y-coordinate of the corner of the clear rectangle
  102469. * @param width defines the width of the clear rectangle
  102470. * @param height defines the height of the clear rectangle
  102471. */
  102472. enableScissor(x: number, y: number, width: number, height: number): void;
  102473. /**
  102474. * Disable previously set scissor test rectangle
  102475. */
  102476. disableScissor(): void;
  102477. protected _reportDrawCall(): void;
  102478. /**
  102479. * Initializes a webVR display and starts listening to display change events
  102480. * The onVRDisplayChangedObservable will be notified upon these changes
  102481. * @returns The onVRDisplayChangedObservable
  102482. */
  102483. initWebVR(): Observable<IDisplayChangedEventArgs>;
  102484. /** @hidden */
  102485. _prepareVRComponent(): void;
  102486. /** @hidden */
  102487. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  102488. /** @hidden */
  102489. _submitVRFrame(): void;
  102490. /**
  102491. * Call this function to leave webVR mode
  102492. * Will do nothing if webVR is not supported or if there is no webVR device
  102493. * @see http://doc.babylonjs.com/how_to/webvr_camera
  102494. */
  102495. disableVR(): void;
  102496. /**
  102497. * Gets a boolean indicating that the system is in VR mode and is presenting
  102498. * @returns true if VR mode is engaged
  102499. */
  102500. isVRPresenting(): boolean;
  102501. /** @hidden */
  102502. _requestVRFrame(): void;
  102503. /** @hidden */
  102504. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  102505. /**
  102506. * Gets the source code of the vertex shader associated with a specific webGL program
  102507. * @param program defines the program to use
  102508. * @returns a string containing the source code of the vertex shader associated with the program
  102509. */
  102510. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  102511. /**
  102512. * Gets the source code of the fragment shader associated with a specific webGL program
  102513. * @param program defines the program to use
  102514. * @returns a string containing the source code of the fragment shader associated with the program
  102515. */
  102516. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  102517. /**
  102518. * Sets a depth stencil texture from a render target to the according uniform.
  102519. * @param channel The texture channel
  102520. * @param uniform The uniform to set
  102521. * @param texture The render target texture containing the depth stencil texture to apply
  102522. */
  102523. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  102524. /**
  102525. * Sets a texture to the webGL context from a postprocess
  102526. * @param channel defines the channel to use
  102527. * @param postProcess defines the source postprocess
  102528. */
  102529. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  102530. /**
  102531. * Binds the output of the passed in post process to the texture channel specified
  102532. * @param channel The channel the texture should be bound to
  102533. * @param postProcess The post process which's output should be bound
  102534. */
  102535. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  102536. /** @hidden */
  102537. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  102538. protected _rebuildBuffers(): void;
  102539. /** @hidden */
  102540. _renderFrame(): void;
  102541. _renderLoop(): void;
  102542. /** @hidden */
  102543. _renderViews(): boolean;
  102544. /**
  102545. * Toggle full screen mode
  102546. * @param requestPointerLock defines if a pointer lock should be requested from the user
  102547. */
  102548. switchFullscreen(requestPointerLock: boolean): void;
  102549. /**
  102550. * Enters full screen mode
  102551. * @param requestPointerLock defines if a pointer lock should be requested from the user
  102552. */
  102553. enterFullscreen(requestPointerLock: boolean): void;
  102554. /**
  102555. * Exits full screen mode
  102556. */
  102557. exitFullscreen(): void;
  102558. /**
  102559. * Enters Pointerlock mode
  102560. */
  102561. enterPointerlock(): void;
  102562. /**
  102563. * Exits Pointerlock mode
  102564. */
  102565. exitPointerlock(): void;
  102566. /**
  102567. * Begin a new frame
  102568. */
  102569. beginFrame(): void;
  102570. /**
  102571. * Enf the current frame
  102572. */
  102573. endFrame(): void;
  102574. resize(): void;
  102575. /**
  102576. * Set the compressed texture format to use, based on the formats you have, and the formats
  102577. * supported by the hardware / browser.
  102578. *
  102579. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  102580. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  102581. * to API arguments needed to compressed textures. This puts the burden on the container
  102582. * generator to house the arcane code for determining these for current & future formats.
  102583. *
  102584. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  102585. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  102586. *
  102587. * Note: The result of this call is not taken into account when a texture is base64.
  102588. *
  102589. * @param formatsAvailable defines the list of those format families you have created
  102590. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  102591. *
  102592. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  102593. * @returns The extension selected.
  102594. */
  102595. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  102596. /**
  102597. * Set the compressed texture extensions or file names to skip.
  102598. *
  102599. * @param skippedFiles defines the list of those texture files you want to skip
  102600. * Example: [".dds", ".env", "myfile.png"]
  102601. */
  102602. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  102603. /**
  102604. * Force a specific size of the canvas
  102605. * @param width defines the new canvas' width
  102606. * @param height defines the new canvas' height
  102607. */
  102608. setSize(width: number, height: number): void;
  102609. /**
  102610. * Updates a dynamic vertex buffer.
  102611. * @param vertexBuffer the vertex buffer to update
  102612. * @param data the data used to update the vertex buffer
  102613. * @param byteOffset the byte offset of the data
  102614. * @param byteLength the byte length of the data
  102615. */
  102616. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  102617. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  102618. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102619. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102620. _releaseTexture(texture: InternalTexture): void;
  102621. /**
  102622. * @hidden
  102623. * Rescales a texture
  102624. * @param source input texutre
  102625. * @param destination destination texture
  102626. * @param scene scene to use to render the resize
  102627. * @param internalFormat format to use when resizing
  102628. * @param onComplete callback to be called when resize has completed
  102629. */
  102630. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  102631. /**
  102632. * Gets the current framerate
  102633. * @returns a number representing the framerate
  102634. */
  102635. getFps(): number;
  102636. /**
  102637. * Gets the time spent between current and previous frame
  102638. * @returns a number representing the delta time in ms
  102639. */
  102640. getDeltaTime(): number;
  102641. private _measureFps;
  102642. /** @hidden */
  102643. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  102644. /**
  102645. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  102646. * @param renderTarget The render target to set the frame buffer for
  102647. */
  102648. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  102649. /**
  102650. * Update a dynamic index buffer
  102651. * @param indexBuffer defines the target index buffer
  102652. * @param indices defines the data to update
  102653. * @param offset defines the offset in the target index buffer where update should start
  102654. */
  102655. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  102656. /**
  102657. * Updates the sample count of a render target texture
  102658. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  102659. * @param texture defines the texture to update
  102660. * @param samples defines the sample count to set
  102661. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  102662. */
  102663. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  102664. /**
  102665. * Updates a depth texture Comparison Mode and Function.
  102666. * If the comparison Function is equal to 0, the mode will be set to none.
  102667. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  102668. * @param texture The texture to set the comparison function for
  102669. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  102670. */
  102671. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  102672. /**
  102673. * Creates a webGL buffer to use with instanciation
  102674. * @param capacity defines the size of the buffer
  102675. * @returns the webGL buffer
  102676. */
  102677. createInstancesBuffer(capacity: number): DataBuffer;
  102678. /**
  102679. * Delete a webGL buffer used with instanciation
  102680. * @param buffer defines the webGL buffer to delete
  102681. */
  102682. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  102683. /** @hidden */
  102684. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  102685. dispose(): void;
  102686. private _disableTouchAction;
  102687. /**
  102688. * Display the loading screen
  102689. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102690. */
  102691. displayLoadingUI(): void;
  102692. /**
  102693. * Hide the loading screen
  102694. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102695. */
  102696. hideLoadingUI(): void;
  102697. /**
  102698. * Gets the current loading screen object
  102699. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102700. */
  102701. /**
  102702. * Sets the current loading screen object
  102703. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102704. */
  102705. loadingScreen: ILoadingScreen;
  102706. /**
  102707. * Sets the current loading screen text
  102708. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102709. */
  102710. loadingUIText: string;
  102711. /**
  102712. * Sets the current loading screen background color
  102713. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102714. */
  102715. loadingUIBackgroundColor: string;
  102716. /** Pointerlock and fullscreen */
  102717. /**
  102718. * Ask the browser to promote the current element to pointerlock mode
  102719. * @param element defines the DOM element to promote
  102720. */
  102721. static _RequestPointerlock(element: HTMLElement): void;
  102722. /**
  102723. * Asks the browser to exit pointerlock mode
  102724. */
  102725. static _ExitPointerlock(): void;
  102726. /**
  102727. * Ask the browser to promote the current element to fullscreen rendering mode
  102728. * @param element defines the DOM element to promote
  102729. */
  102730. static _RequestFullscreen(element: HTMLElement): void;
  102731. /**
  102732. * Asks the browser to exit fullscreen mode
  102733. */
  102734. static _ExitFullscreen(): void;
  102735. }
  102736. }
  102737. declare module BABYLON {
  102738. /**
  102739. * The engine store class is responsible to hold all the instances of Engine and Scene created
  102740. * during the life time of the application.
  102741. */
  102742. export class EngineStore {
  102743. /** Gets the list of created engines */
  102744. static Instances: Engine[];
  102745. /** @hidden */
  102746. static _LastCreatedScene: Nullable<Scene>;
  102747. /**
  102748. * Gets the latest created engine
  102749. */
  102750. static readonly LastCreatedEngine: Nullable<Engine>;
  102751. /**
  102752. * Gets the latest created scene
  102753. */
  102754. static readonly LastCreatedScene: Nullable<Scene>;
  102755. /**
  102756. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  102757. * @ignorenaming
  102758. */
  102759. static UseFallbackTexture: boolean;
  102760. /**
  102761. * Texture content used if a texture cannot loaded
  102762. * @ignorenaming
  102763. */
  102764. static FallbackTexture: string;
  102765. }
  102766. }
  102767. declare module BABYLON {
  102768. /**
  102769. * Helper class that provides a small promise polyfill
  102770. */
  102771. export class PromisePolyfill {
  102772. /**
  102773. * Static function used to check if the polyfill is required
  102774. * If this is the case then the function will inject the polyfill to window.Promise
  102775. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  102776. */
  102777. static Apply(force?: boolean): void;
  102778. }
  102779. }
  102780. declare module BABYLON {
  102781. /**
  102782. * Interface for screenshot methods with describe argument called `size` as object with options
  102783. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  102784. */
  102785. export interface IScreenshotSize {
  102786. /**
  102787. * number in pixels for canvas height
  102788. */
  102789. height?: number;
  102790. /**
  102791. * multiplier allowing render at a higher or lower resolution
  102792. * If value is defined then height and width will be ignored and taken from camera
  102793. */
  102794. precision?: number;
  102795. /**
  102796. * number in pixels for canvas width
  102797. */
  102798. width?: number;
  102799. }
  102800. }
  102801. declare module BABYLON {
  102802. interface IColor4Like {
  102803. r: float;
  102804. g: float;
  102805. b: float;
  102806. a: float;
  102807. }
  102808. /**
  102809. * Class containing a set of static utilities functions
  102810. */
  102811. export class Tools {
  102812. /**
  102813. * Gets or sets the base URL to use to load assets
  102814. */
  102815. static BaseUrl: string;
  102816. /**
  102817. * Enable/Disable Custom HTTP Request Headers globally.
  102818. * default = false
  102819. * @see CustomRequestHeaders
  102820. */
  102821. static UseCustomRequestHeaders: boolean;
  102822. /**
  102823. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  102824. * i.e. when loading files, where the server/service expects an Authorization header
  102825. */
  102826. static CustomRequestHeaders: {
  102827. [key: string]: string;
  102828. };
  102829. /**
  102830. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  102831. */
  102832. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  102833. /**
  102834. * Default behaviour for cors in the application.
  102835. * It can be a string if the expected behavior is identical in the entire app.
  102836. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  102837. */
  102838. static CorsBehavior: string | ((url: string | string[]) => string);
  102839. /**
  102840. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  102841. * @ignorenaming
  102842. */
  102843. static UseFallbackTexture: boolean;
  102844. /**
  102845. * Use this object to register external classes like custom textures or material
  102846. * to allow the laoders to instantiate them
  102847. */
  102848. static RegisteredExternalClasses: {
  102849. [key: string]: Object;
  102850. };
  102851. /**
  102852. * Texture content used if a texture cannot loaded
  102853. * @ignorenaming
  102854. */
  102855. static fallbackTexture: string;
  102856. /**
  102857. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  102858. * @param u defines the coordinate on X axis
  102859. * @param v defines the coordinate on Y axis
  102860. * @param width defines the width of the source data
  102861. * @param height defines the height of the source data
  102862. * @param pixels defines the source byte array
  102863. * @param color defines the output color
  102864. */
  102865. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  102866. /**
  102867. * Interpolates between a and b via alpha
  102868. * @param a The lower value (returned when alpha = 0)
  102869. * @param b The upper value (returned when alpha = 1)
  102870. * @param alpha The interpolation-factor
  102871. * @return The mixed value
  102872. */
  102873. static Mix(a: number, b: number, alpha: number): number;
  102874. /**
  102875. * Tries to instantiate a new object from a given class name
  102876. * @param className defines the class name to instantiate
  102877. * @returns the new object or null if the system was not able to do the instantiation
  102878. */
  102879. static Instantiate(className: string): any;
  102880. /**
  102881. * Provides a slice function that will work even on IE
  102882. * @param data defines the array to slice
  102883. * @param start defines the start of the data (optional)
  102884. * @param end defines the end of the data (optional)
  102885. * @returns the new sliced array
  102886. */
  102887. static Slice<T>(data: T, start?: number, end?: number): T;
  102888. /**
  102889. * Polyfill for setImmediate
  102890. * @param action defines the action to execute after the current execution block
  102891. */
  102892. static SetImmediate(action: () => void): void;
  102893. /**
  102894. * Function indicating if a number is an exponent of 2
  102895. * @param value defines the value to test
  102896. * @returns true if the value is an exponent of 2
  102897. */
  102898. static IsExponentOfTwo(value: number): boolean;
  102899. private static _tmpFloatArray;
  102900. /**
  102901. * Returns the nearest 32-bit single precision float representation of a Number
  102902. * @param value A Number. If the parameter is of a different type, it will get converted
  102903. * to a number or to NaN if it cannot be converted
  102904. * @returns number
  102905. */
  102906. static FloatRound(value: number): number;
  102907. /**
  102908. * Extracts the filename from a path
  102909. * @param path defines the path to use
  102910. * @returns the filename
  102911. */
  102912. static GetFilename(path: string): string;
  102913. /**
  102914. * Extracts the "folder" part of a path (everything before the filename).
  102915. * @param uri The URI to extract the info from
  102916. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  102917. * @returns The "folder" part of the path
  102918. */
  102919. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  102920. /**
  102921. * Extracts text content from a DOM element hierarchy
  102922. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  102923. */
  102924. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  102925. /**
  102926. * Convert an angle in radians to degrees
  102927. * @param angle defines the angle to convert
  102928. * @returns the angle in degrees
  102929. */
  102930. static ToDegrees(angle: number): number;
  102931. /**
  102932. * Convert an angle in degrees to radians
  102933. * @param angle defines the angle to convert
  102934. * @returns the angle in radians
  102935. */
  102936. static ToRadians(angle: number): number;
  102937. /**
  102938. * Returns an array if obj is not an array
  102939. * @param obj defines the object to evaluate as an array
  102940. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  102941. * @returns either obj directly if obj is an array or a new array containing obj
  102942. */
  102943. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  102944. /**
  102945. * Gets the pointer prefix to use
  102946. * @returns "pointer" if touch is enabled. Else returns "mouse"
  102947. */
  102948. static GetPointerPrefix(): string;
  102949. /**
  102950. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  102951. * @param url define the url we are trying
  102952. * @param element define the dom element where to configure the cors policy
  102953. */
  102954. static SetCorsBehavior(url: string | string[], element: {
  102955. crossOrigin: string | null;
  102956. }): void;
  102957. /**
  102958. * Removes unwanted characters from an url
  102959. * @param url defines the url to clean
  102960. * @returns the cleaned url
  102961. */
  102962. static CleanUrl(url: string): string;
  102963. /**
  102964. * Gets or sets a function used to pre-process url before using them to load assets
  102965. */
  102966. static PreprocessUrl: (url: string) => string;
  102967. /**
  102968. * Loads an image as an HTMLImageElement.
  102969. * @param input url string, ArrayBuffer, or Blob to load
  102970. * @param onLoad callback called when the image successfully loads
  102971. * @param onError callback called when the image fails to load
  102972. * @param offlineProvider offline provider for caching
  102973. * @param mimeType optional mime type
  102974. * @returns the HTMLImageElement of the loaded image
  102975. */
  102976. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  102977. /**
  102978. * Loads a file from a url
  102979. * @param url url string, ArrayBuffer, or Blob to load
  102980. * @param onSuccess callback called when the file successfully loads
  102981. * @param onProgress callback called while file is loading (if the server supports this mode)
  102982. * @param offlineProvider defines the offline provider for caching
  102983. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  102984. * @param onError callback called when the file fails to load
  102985. * @returns a file request object
  102986. */
  102987. 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;
  102988. /**
  102989. * Loads a file from a url
  102990. * @param url the file url to load
  102991. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  102992. */
  102993. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  102994. /**
  102995. * Load a script (identified by an url). When the url returns, the
  102996. * content of this file is added into a new script element, attached to the DOM (body element)
  102997. * @param scriptUrl defines the url of the script to laod
  102998. * @param onSuccess defines the callback called when the script is loaded
  102999. * @param onError defines the callback to call if an error occurs
  103000. * @param scriptId defines the id of the script element
  103001. */
  103002. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  103003. /**
  103004. * Load an asynchronous script (identified by an url). When the url returns, the
  103005. * content of this file is added into a new script element, attached to the DOM (body element)
  103006. * @param scriptUrl defines the url of the script to laod
  103007. * @param scriptId defines the id of the script element
  103008. * @returns a promise request object
  103009. */
  103010. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  103011. /**
  103012. * Loads a file from a blob
  103013. * @param fileToLoad defines the blob to use
  103014. * @param callback defines the callback to call when data is loaded
  103015. * @param progressCallback defines the callback to call during loading process
  103016. * @returns a file request object
  103017. */
  103018. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  103019. /**
  103020. * Reads a file from a File object
  103021. * @param file defines the file to load
  103022. * @param onSuccess defines the callback to call when data is loaded
  103023. * @param onProgress defines the callback to call during loading process
  103024. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  103025. * @param onError defines the callback to call when an error occurs
  103026. * @returns a file request object
  103027. */
  103028. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  103029. /**
  103030. * Creates a data url from a given string content
  103031. * @param content defines the content to convert
  103032. * @returns the new data url link
  103033. */
  103034. static FileAsURL(content: string): string;
  103035. /**
  103036. * Format the given number to a specific decimal format
  103037. * @param value defines the number to format
  103038. * @param decimals defines the number of decimals to use
  103039. * @returns the formatted string
  103040. */
  103041. static Format(value: number, decimals?: number): string;
  103042. /**
  103043. * Tries to copy an object by duplicating every property
  103044. * @param source defines the source object
  103045. * @param destination defines the target object
  103046. * @param doNotCopyList defines a list of properties to avoid
  103047. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  103048. */
  103049. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  103050. /**
  103051. * Gets a boolean indicating if the given object has no own property
  103052. * @param obj defines the object to test
  103053. * @returns true if object has no own property
  103054. */
  103055. static IsEmpty(obj: any): boolean;
  103056. /**
  103057. * Function used to register events at window level
  103058. * @param windowElement defines the Window object to use
  103059. * @param events defines the events to register
  103060. */
  103061. static RegisterTopRootEvents(windowElement: Window, events: {
  103062. name: string;
  103063. handler: Nullable<(e: FocusEvent) => any>;
  103064. }[]): void;
  103065. /**
  103066. * Function used to unregister events from window level
  103067. * @param windowElement defines the Window object to use
  103068. * @param events defines the events to unregister
  103069. */
  103070. static UnregisterTopRootEvents(windowElement: Window, events: {
  103071. name: string;
  103072. handler: Nullable<(e: FocusEvent) => any>;
  103073. }[]): void;
  103074. /**
  103075. * @ignore
  103076. */
  103077. static _ScreenshotCanvas: HTMLCanvasElement;
  103078. /**
  103079. * Dumps the current bound framebuffer
  103080. * @param width defines the rendering width
  103081. * @param height defines the rendering height
  103082. * @param engine defines the hosting engine
  103083. * @param successCallback defines the callback triggered once the data are available
  103084. * @param mimeType defines the mime type of the result
  103085. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  103086. */
  103087. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  103088. /**
  103089. * Converts the canvas data to blob.
  103090. * This acts as a polyfill for browsers not supporting the to blob function.
  103091. * @param canvas Defines the canvas to extract the data from
  103092. * @param successCallback Defines the callback triggered once the data are available
  103093. * @param mimeType Defines the mime type of the result
  103094. */
  103095. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  103096. /**
  103097. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  103098. * @param successCallback defines the callback triggered once the data are available
  103099. * @param mimeType defines the mime type of the result
  103100. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  103101. */
  103102. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  103103. /**
  103104. * Downloads a blob in the browser
  103105. * @param blob defines the blob to download
  103106. * @param fileName defines the name of the downloaded file
  103107. */
  103108. static Download(blob: Blob, fileName: string): void;
  103109. /**
  103110. * Captures a screenshot of the current rendering
  103111. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  103112. * @param engine defines the rendering engine
  103113. * @param camera defines the source camera
  103114. * @param size This parameter can be set to a single number or to an object with the
  103115. * following (optional) properties: precision, width, height. If a single number is passed,
  103116. * it will be used for both width and height. If an object is passed, the screenshot size
  103117. * will be derived from the parameters. The precision property is a multiplier allowing
  103118. * rendering at a higher or lower resolution
  103119. * @param successCallback defines the callback receives a single parameter which contains the
  103120. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  103121. * src parameter of an <img> to display it
  103122. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  103123. * Check your browser for supported MIME types
  103124. */
  103125. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  103126. /**
  103127. * Captures a screenshot of the current rendering
  103128. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  103129. * @param engine defines the rendering engine
  103130. * @param camera defines the source camera
  103131. * @param size This parameter can be set to a single number or to an object with the
  103132. * following (optional) properties: precision, width, height. If a single number is passed,
  103133. * it will be used for both width and height. If an object is passed, the screenshot size
  103134. * will be derived from the parameters. The precision property is a multiplier allowing
  103135. * rendering at a higher or lower resolution
  103136. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  103137. * Check your browser for supported MIME types
  103138. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  103139. * to the src parameter of an <img> to display it
  103140. */
  103141. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  103142. /**
  103143. * Generates an image screenshot from the specified camera.
  103144. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  103145. * @param engine The engine to use for rendering
  103146. * @param camera The camera to use for rendering
  103147. * @param size This parameter can be set to a single number or to an object with the
  103148. * following (optional) properties: precision, width, height. If a single number is passed,
  103149. * it will be used for both width and height. If an object is passed, the screenshot size
  103150. * will be derived from the parameters. The precision property is a multiplier allowing
  103151. * rendering at a higher or lower resolution
  103152. * @param successCallback The callback receives a single parameter which contains the
  103153. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  103154. * src parameter of an <img> to display it
  103155. * @param mimeType The MIME type of the screenshot image (default: image/png).
  103156. * Check your browser for supported MIME types
  103157. * @param samples Texture samples (default: 1)
  103158. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  103159. * @param fileName A name for for the downloaded file.
  103160. */
  103161. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  103162. /**
  103163. * Generates an image screenshot from the specified camera.
  103164. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  103165. * @param engine The engine to use for rendering
  103166. * @param camera The camera to use for rendering
  103167. * @param size This parameter can be set to a single number or to an object with the
  103168. * following (optional) properties: precision, width, height. If a single number is passed,
  103169. * it will be used for both width and height. If an object is passed, the screenshot size
  103170. * will be derived from the parameters. The precision property is a multiplier allowing
  103171. * rendering at a higher or lower resolution
  103172. * @param mimeType The MIME type of the screenshot image (default: image/png).
  103173. * Check your browser for supported MIME types
  103174. * @param samples Texture samples (default: 1)
  103175. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  103176. * @param fileName A name for for the downloaded file.
  103177. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  103178. * to the src parameter of an <img> to display it
  103179. */
  103180. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  103181. /**
  103182. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103183. * Be aware Math.random() could cause collisions, but:
  103184. * "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"
  103185. * @returns a pseudo random id
  103186. */
  103187. static RandomId(): string;
  103188. /**
  103189. * Test if the given uri is a base64 string
  103190. * @param uri The uri to test
  103191. * @return True if the uri is a base64 string or false otherwise
  103192. */
  103193. static IsBase64(uri: string): boolean;
  103194. /**
  103195. * Decode the given base64 uri.
  103196. * @param uri The uri to decode
  103197. * @return The decoded base64 data.
  103198. */
  103199. static DecodeBase64(uri: string): ArrayBuffer;
  103200. /**
  103201. * Gets the absolute url.
  103202. * @param url the input url
  103203. * @return the absolute url
  103204. */
  103205. static GetAbsoluteUrl(url: string): string;
  103206. /**
  103207. * No log
  103208. */
  103209. static readonly NoneLogLevel: number;
  103210. /**
  103211. * Only message logs
  103212. */
  103213. static readonly MessageLogLevel: number;
  103214. /**
  103215. * Only warning logs
  103216. */
  103217. static readonly WarningLogLevel: number;
  103218. /**
  103219. * Only error logs
  103220. */
  103221. static readonly ErrorLogLevel: number;
  103222. /**
  103223. * All logs
  103224. */
  103225. static readonly AllLogLevel: number;
  103226. /**
  103227. * Gets a value indicating the number of loading errors
  103228. * @ignorenaming
  103229. */
  103230. static readonly errorsCount: number;
  103231. /**
  103232. * Callback called when a new log is added
  103233. */
  103234. static OnNewCacheEntry: (entry: string) => void;
  103235. /**
  103236. * Log a message to the console
  103237. * @param message defines the message to log
  103238. */
  103239. static Log(message: string): void;
  103240. /**
  103241. * Write a warning message to the console
  103242. * @param message defines the message to log
  103243. */
  103244. static Warn(message: string): void;
  103245. /**
  103246. * Write an error message to the console
  103247. * @param message defines the message to log
  103248. */
  103249. static Error(message: string): void;
  103250. /**
  103251. * Gets current log cache (list of logs)
  103252. */
  103253. static readonly LogCache: string;
  103254. /**
  103255. * Clears the log cache
  103256. */
  103257. static ClearLogCache(): void;
  103258. /**
  103259. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  103260. */
  103261. static LogLevels: number;
  103262. /**
  103263. * Checks if the window object exists
  103264. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  103265. */
  103266. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  103267. /**
  103268. * No performance log
  103269. */
  103270. static readonly PerformanceNoneLogLevel: number;
  103271. /**
  103272. * Use user marks to log performance
  103273. */
  103274. static readonly PerformanceUserMarkLogLevel: number;
  103275. /**
  103276. * Log performance to the console
  103277. */
  103278. static readonly PerformanceConsoleLogLevel: number;
  103279. private static _performance;
  103280. /**
  103281. * Sets the current performance log level
  103282. */
  103283. static PerformanceLogLevel: number;
  103284. private static _StartPerformanceCounterDisabled;
  103285. private static _EndPerformanceCounterDisabled;
  103286. private static _StartUserMark;
  103287. private static _EndUserMark;
  103288. private static _StartPerformanceConsole;
  103289. private static _EndPerformanceConsole;
  103290. /**
  103291. * Starts a performance counter
  103292. */
  103293. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  103294. /**
  103295. * Ends a specific performance coutner
  103296. */
  103297. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  103298. /**
  103299. * Gets either window.performance.now() if supported or Date.now() else
  103300. */
  103301. static readonly Now: number;
  103302. /**
  103303. * This method will return the name of the class used to create the instance of the given object.
  103304. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  103305. * @param object the object to get the class name from
  103306. * @param isType defines if the object is actually a type
  103307. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  103308. */
  103309. static GetClassName(object: any, isType?: boolean): string;
  103310. /**
  103311. * Gets the first element of an array satisfying a given predicate
  103312. * @param array defines the array to browse
  103313. * @param predicate defines the predicate to use
  103314. * @returns null if not found or the element
  103315. */
  103316. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  103317. /**
  103318. * This method will return the name of the full name of the class, including its owning module (if any).
  103319. * 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).
  103320. * @param object the object to get the class name from
  103321. * @param isType defines if the object is actually a type
  103322. * @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.
  103323. * @ignorenaming
  103324. */
  103325. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  103326. /**
  103327. * Returns a promise that resolves after the given amount of time.
  103328. * @param delay Number of milliseconds to delay
  103329. * @returns Promise that resolves after the given amount of time
  103330. */
  103331. static DelayAsync(delay: number): Promise<void>;
  103332. }
  103333. /**
  103334. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  103335. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  103336. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  103337. * @param name The name of the class, case should be preserved
  103338. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  103339. */
  103340. export function className(name: string, module?: string): (target: Object) => void;
  103341. /**
  103342. * An implementation of a loop for asynchronous functions.
  103343. */
  103344. export class AsyncLoop {
  103345. /**
  103346. * Defines the number of iterations for the loop
  103347. */
  103348. iterations: number;
  103349. /**
  103350. * Defines the current index of the loop.
  103351. */
  103352. index: number;
  103353. private _done;
  103354. private _fn;
  103355. private _successCallback;
  103356. /**
  103357. * Constructor.
  103358. * @param iterations the number of iterations.
  103359. * @param func the function to run each iteration
  103360. * @param successCallback the callback that will be called upon succesful execution
  103361. * @param offset starting offset.
  103362. */
  103363. constructor(
  103364. /**
  103365. * Defines the number of iterations for the loop
  103366. */
  103367. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  103368. /**
  103369. * Execute the next iteration. Must be called after the last iteration was finished.
  103370. */
  103371. executeNext(): void;
  103372. /**
  103373. * Break the loop and run the success callback.
  103374. */
  103375. breakLoop(): void;
  103376. /**
  103377. * Create and run an async loop.
  103378. * @param iterations the number of iterations.
  103379. * @param fn the function to run each iteration
  103380. * @param successCallback the callback that will be called upon succesful execution
  103381. * @param offset starting offset.
  103382. * @returns the created async loop object
  103383. */
  103384. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  103385. /**
  103386. * A for-loop that will run a given number of iterations synchronous and the rest async.
  103387. * @param iterations total number of iterations
  103388. * @param syncedIterations number of synchronous iterations in each async iteration.
  103389. * @param fn the function to call each iteration.
  103390. * @param callback a success call back that will be called when iterating stops.
  103391. * @param breakFunction a break condition (optional)
  103392. * @param timeout timeout settings for the setTimeout function. default - 0.
  103393. * @returns the created async loop object
  103394. */
  103395. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  103396. }
  103397. }
  103398. declare module BABYLON {
  103399. /**
  103400. * This class implement a typical dictionary using a string as key and the generic type T as value.
  103401. * The underlying implementation relies on an associative array to ensure the best performances.
  103402. * The value can be anything including 'null' but except 'undefined'
  103403. */
  103404. export class StringDictionary<T> {
  103405. /**
  103406. * This will clear this dictionary and copy the content from the 'source' one.
  103407. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  103408. * @param source the dictionary to take the content from and copy to this dictionary
  103409. */
  103410. copyFrom(source: StringDictionary<T>): void;
  103411. /**
  103412. * Get a value based from its key
  103413. * @param key the given key to get the matching value from
  103414. * @return the value if found, otherwise undefined is returned
  103415. */
  103416. get(key: string): T | undefined;
  103417. /**
  103418. * Get a value from its key or add it if it doesn't exist.
  103419. * This method will ensure you that a given key/data will be present in the dictionary.
  103420. * @param key the given key to get the matching value from
  103421. * @param factory the factory that will create the value if the key is not present in the dictionary.
  103422. * The factory will only be invoked if there's no data for the given key.
  103423. * @return the value corresponding to the key.
  103424. */
  103425. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  103426. /**
  103427. * Get a value from its key if present in the dictionary otherwise add it
  103428. * @param key the key to get the value from
  103429. * @param val if there's no such key/value pair in the dictionary add it with this value
  103430. * @return the value corresponding to the key
  103431. */
  103432. getOrAdd(key: string, val: T): T;
  103433. /**
  103434. * Check if there's a given key in the dictionary
  103435. * @param key the key to check for
  103436. * @return true if the key is present, false otherwise
  103437. */
  103438. contains(key: string): boolean;
  103439. /**
  103440. * Add a new key and its corresponding value
  103441. * @param key the key to add
  103442. * @param value the value corresponding to the key
  103443. * @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
  103444. */
  103445. add(key: string, value: T): boolean;
  103446. /**
  103447. * Update a specific value associated to a key
  103448. * @param key defines the key to use
  103449. * @param value defines the value to store
  103450. * @returns true if the value was updated (or false if the key was not found)
  103451. */
  103452. set(key: string, value: T): boolean;
  103453. /**
  103454. * Get the element of the given key and remove it from the dictionary
  103455. * @param key defines the key to search
  103456. * @returns the value associated with the key or null if not found
  103457. */
  103458. getAndRemove(key: string): Nullable<T>;
  103459. /**
  103460. * Remove a key/value from the dictionary.
  103461. * @param key the key to remove
  103462. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  103463. */
  103464. remove(key: string): boolean;
  103465. /**
  103466. * Clear the whole content of the dictionary
  103467. */
  103468. clear(): void;
  103469. /**
  103470. * Gets the current count
  103471. */
  103472. readonly count: number;
  103473. /**
  103474. * Execute a callback on each key/val of the dictionary.
  103475. * Note that you can remove any element in this dictionary in the callback implementation
  103476. * @param callback the callback to execute on a given key/value pair
  103477. */
  103478. forEach(callback: (key: string, val: T) => void): void;
  103479. /**
  103480. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  103481. * If the callback returns null or undefined the method will iterate to the next key/value pair
  103482. * Note that you can remove any element in this dictionary in the callback implementation
  103483. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  103484. * @returns the first item
  103485. */
  103486. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  103487. private _count;
  103488. private _data;
  103489. }
  103490. }
  103491. declare module BABYLON {
  103492. /** @hidden */
  103493. export interface ICollisionCoordinator {
  103494. createCollider(): Collider;
  103495. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  103496. init(scene: Scene): void;
  103497. }
  103498. /** @hidden */
  103499. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  103500. private _scene;
  103501. private _scaledPosition;
  103502. private _scaledVelocity;
  103503. private _finalPosition;
  103504. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  103505. createCollider(): Collider;
  103506. init(scene: Scene): void;
  103507. private _collideWithWorld;
  103508. }
  103509. }
  103510. declare module BABYLON {
  103511. /**
  103512. * Class used to manage all inputs for the scene.
  103513. */
  103514. export class InputManager {
  103515. /** The distance in pixel that you have to move to prevent some events */
  103516. static DragMovementThreshold: number;
  103517. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  103518. static LongPressDelay: number;
  103519. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  103520. static DoubleClickDelay: number;
  103521. /** If you need to check double click without raising a single click at first click, enable this flag */
  103522. static ExclusiveDoubleClickMode: boolean;
  103523. private _wheelEventName;
  103524. private _onPointerMove;
  103525. private _onPointerDown;
  103526. private _onPointerUp;
  103527. private _initClickEvent;
  103528. private _initActionManager;
  103529. private _delayedSimpleClick;
  103530. private _delayedSimpleClickTimeout;
  103531. private _previousDelayedSimpleClickTimeout;
  103532. private _meshPickProceed;
  103533. private _previousButtonPressed;
  103534. private _currentPickResult;
  103535. private _previousPickResult;
  103536. private _totalPointersPressed;
  103537. private _doubleClickOccured;
  103538. private _pointerOverMesh;
  103539. private _pickedDownMesh;
  103540. private _pickedUpMesh;
  103541. private _pointerX;
  103542. private _pointerY;
  103543. private _unTranslatedPointerX;
  103544. private _unTranslatedPointerY;
  103545. private _startingPointerPosition;
  103546. private _previousStartingPointerPosition;
  103547. private _startingPointerTime;
  103548. private _previousStartingPointerTime;
  103549. private _pointerCaptures;
  103550. private _onKeyDown;
  103551. private _onKeyUp;
  103552. private _onCanvasFocusObserver;
  103553. private _onCanvasBlurObserver;
  103554. private _scene;
  103555. /**
  103556. * Creates a new InputManager
  103557. * @param scene defines the hosting scene
  103558. */
  103559. constructor(scene: Scene);
  103560. /**
  103561. * Gets the mesh that is currently under the pointer
  103562. */
  103563. readonly meshUnderPointer: Nullable<AbstractMesh>;
  103564. /**
  103565. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  103566. */
  103567. readonly unTranslatedPointer: Vector2;
  103568. /**
  103569. * Gets or sets the current on-screen X position of the pointer
  103570. */
  103571. pointerX: number;
  103572. /**
  103573. * Gets or sets the current on-screen Y position of the pointer
  103574. */
  103575. pointerY: number;
  103576. private _updatePointerPosition;
  103577. private _processPointerMove;
  103578. private _setRayOnPointerInfo;
  103579. private _checkPrePointerObservable;
  103580. /**
  103581. * Use this method to simulate a pointer move on a mesh
  103582. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  103583. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  103584. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  103585. */
  103586. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  103587. /**
  103588. * Use this method to simulate a pointer down on a mesh
  103589. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  103590. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  103591. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  103592. */
  103593. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  103594. private _processPointerDown;
  103595. /** @hidden */
  103596. _isPointerSwiping(): boolean;
  103597. /**
  103598. * Use this method to simulate a pointer up on a mesh
  103599. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  103600. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  103601. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  103602. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  103603. */
  103604. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  103605. private _processPointerUp;
  103606. /**
  103607. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  103608. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  103609. * @returns true if the pointer was captured
  103610. */
  103611. isPointerCaptured(pointerId?: number): boolean;
  103612. /**
  103613. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  103614. * @param attachUp defines if you want to attach events to pointerup
  103615. * @param attachDown defines if you want to attach events to pointerdown
  103616. * @param attachMove defines if you want to attach events to pointermove
  103617. */
  103618. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  103619. /**
  103620. * Detaches all event handlers
  103621. */
  103622. detachControl(): void;
  103623. /**
  103624. * Force the value of meshUnderPointer
  103625. * @param mesh defines the mesh to use
  103626. */
  103627. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  103628. /**
  103629. * Gets the mesh under the pointer
  103630. * @returns a Mesh or null if no mesh is under the pointer
  103631. */
  103632. getPointerOverMesh(): Nullable<AbstractMesh>;
  103633. }
  103634. }
  103635. declare module BABYLON {
  103636. /**
  103637. * Helper class used to generate session unique ID
  103638. */
  103639. export class UniqueIdGenerator {
  103640. private static _UniqueIdCounter;
  103641. /**
  103642. * Gets an unique (relatively to the current scene) Id
  103643. */
  103644. static readonly UniqueId: number;
  103645. }
  103646. }
  103647. declare module BABYLON {
  103648. /**
  103649. * This class defines the direct association between an animation and a target
  103650. */
  103651. export class TargetedAnimation {
  103652. /**
  103653. * Animation to perform
  103654. */
  103655. animation: Animation;
  103656. /**
  103657. * Target to animate
  103658. */
  103659. target: any;
  103660. /**
  103661. * Serialize the object
  103662. * @returns the JSON object representing the current entity
  103663. */
  103664. serialize(): any;
  103665. }
  103666. /**
  103667. * Use this class to create coordinated animations on multiple targets
  103668. */
  103669. export class AnimationGroup implements IDisposable {
  103670. /** The name of the animation group */
  103671. name: string;
  103672. private _scene;
  103673. private _targetedAnimations;
  103674. private _animatables;
  103675. private _from;
  103676. private _to;
  103677. private _isStarted;
  103678. private _isPaused;
  103679. private _speedRatio;
  103680. private _loopAnimation;
  103681. /**
  103682. * Gets or sets the unique id of the node
  103683. */
  103684. uniqueId: number;
  103685. /**
  103686. * This observable will notify when one animation have ended
  103687. */
  103688. onAnimationEndObservable: Observable<TargetedAnimation>;
  103689. /**
  103690. * Observer raised when one animation loops
  103691. */
  103692. onAnimationLoopObservable: Observable<TargetedAnimation>;
  103693. /**
  103694. * Observer raised when all animations have looped
  103695. */
  103696. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  103697. /**
  103698. * This observable will notify when all animations have ended.
  103699. */
  103700. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  103701. /**
  103702. * This observable will notify when all animations have paused.
  103703. */
  103704. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  103705. /**
  103706. * This observable will notify when all animations are playing.
  103707. */
  103708. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  103709. /**
  103710. * Gets the first frame
  103711. */
  103712. readonly from: number;
  103713. /**
  103714. * Gets the last frame
  103715. */
  103716. readonly to: number;
  103717. /**
  103718. * Define if the animations are started
  103719. */
  103720. readonly isStarted: boolean;
  103721. /**
  103722. * Gets a value indicating that the current group is playing
  103723. */
  103724. readonly isPlaying: boolean;
  103725. /**
  103726. * Gets or sets the speed ratio to use for all animations
  103727. */
  103728. /**
  103729. * Gets or sets the speed ratio to use for all animations
  103730. */
  103731. speedRatio: number;
  103732. /**
  103733. * Gets or sets if all animations should loop or not
  103734. */
  103735. loopAnimation: boolean;
  103736. /**
  103737. * Gets the targeted animations for this animation group
  103738. */
  103739. readonly targetedAnimations: Array<TargetedAnimation>;
  103740. /**
  103741. * returning the list of animatables controlled by this animation group.
  103742. */
  103743. readonly animatables: Array<Animatable>;
  103744. /**
  103745. * Instantiates a new Animation Group.
  103746. * This helps managing several animations at once.
  103747. * @see http://doc.babylonjs.com/how_to/group
  103748. * @param name Defines the name of the group
  103749. * @param scene Defines the scene the group belongs to
  103750. */
  103751. constructor(
  103752. /** The name of the animation group */
  103753. name: string, scene?: Nullable<Scene>);
  103754. /**
  103755. * Add an animation (with its target) in the group
  103756. * @param animation defines the animation we want to add
  103757. * @param target defines the target of the animation
  103758. * @returns the TargetedAnimation object
  103759. */
  103760. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  103761. /**
  103762. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  103763. * It can add constant keys at begin or end
  103764. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  103765. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  103766. * @returns the animation group
  103767. */
  103768. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  103769. private _animationLoopCount;
  103770. private _animationLoopFlags;
  103771. private _processLoop;
  103772. /**
  103773. * Start all animations on given targets
  103774. * @param loop defines if animations must loop
  103775. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  103776. * @param from defines the from key (optional)
  103777. * @param to defines the to key (optional)
  103778. * @returns the current animation group
  103779. */
  103780. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  103781. /**
  103782. * Pause all animations
  103783. * @returns the animation group
  103784. */
  103785. pause(): AnimationGroup;
  103786. /**
  103787. * Play all animations to initial state
  103788. * This function will start() the animations if they were not started or will restart() them if they were paused
  103789. * @param loop defines if animations must loop
  103790. * @returns the animation group
  103791. */
  103792. play(loop?: boolean): AnimationGroup;
  103793. /**
  103794. * Reset all animations to initial state
  103795. * @returns the animation group
  103796. */
  103797. reset(): AnimationGroup;
  103798. /**
  103799. * Restart animations from key 0
  103800. * @returns the animation group
  103801. */
  103802. restart(): AnimationGroup;
  103803. /**
  103804. * Stop all animations
  103805. * @returns the animation group
  103806. */
  103807. stop(): AnimationGroup;
  103808. /**
  103809. * Set animation weight for all animatables
  103810. * @param weight defines the weight to use
  103811. * @return the animationGroup
  103812. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  103813. */
  103814. setWeightForAllAnimatables(weight: number): AnimationGroup;
  103815. /**
  103816. * Synchronize and normalize all animatables with a source animatable
  103817. * @param root defines the root animatable to synchronize with
  103818. * @return the animationGroup
  103819. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  103820. */
  103821. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  103822. /**
  103823. * Goes to a specific frame in this animation group
  103824. * @param frame the frame number to go to
  103825. * @return the animationGroup
  103826. */
  103827. goToFrame(frame: number): AnimationGroup;
  103828. /**
  103829. * Dispose all associated resources
  103830. */
  103831. dispose(): void;
  103832. private _checkAnimationGroupEnded;
  103833. /**
  103834. * Clone the current animation group and returns a copy
  103835. * @param newName defines the name of the new group
  103836. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  103837. * @returns the new aniamtion group
  103838. */
  103839. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  103840. /**
  103841. * Serializes the animationGroup to an object
  103842. * @returns Serialized object
  103843. */
  103844. serialize(): any;
  103845. /**
  103846. * Returns a new AnimationGroup object parsed from the source provided.
  103847. * @param parsedAnimationGroup defines the source
  103848. * @param scene defines the scene that will receive the animationGroup
  103849. * @returns a new AnimationGroup
  103850. */
  103851. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  103852. /**
  103853. * Returns the string "AnimationGroup"
  103854. * @returns "AnimationGroup"
  103855. */
  103856. getClassName(): string;
  103857. /**
  103858. * Creates a detailled string about the object
  103859. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  103860. * @returns a string representing the object
  103861. */
  103862. toString(fullDetails?: boolean): string;
  103863. }
  103864. }
  103865. declare module BABYLON {
  103866. /**
  103867. * Define an interface for all classes that will hold resources
  103868. */
  103869. export interface IDisposable {
  103870. /**
  103871. * Releases all held resources
  103872. */
  103873. dispose(): void;
  103874. }
  103875. /** Interface defining initialization parameters for Scene class */
  103876. export interface SceneOptions {
  103877. /**
  103878. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  103879. * It will improve performance when the number of geometries becomes important.
  103880. */
  103881. useGeometryUniqueIdsMap?: boolean;
  103882. /**
  103883. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  103884. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  103885. */
  103886. useMaterialMeshMap?: boolean;
  103887. /**
  103888. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  103889. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  103890. */
  103891. useClonedMeshhMap?: boolean;
  103892. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  103893. virtual?: boolean;
  103894. }
  103895. /**
  103896. * Represents a scene to be rendered by the engine.
  103897. * @see http://doc.babylonjs.com/features/scene
  103898. */
  103899. export class Scene extends AbstractScene implements IAnimatable {
  103900. /** The fog is deactivated */
  103901. static readonly FOGMODE_NONE: number;
  103902. /** The fog density is following an exponential function */
  103903. static readonly FOGMODE_EXP: number;
  103904. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  103905. static readonly FOGMODE_EXP2: number;
  103906. /** The fog density is following a linear function. */
  103907. static readonly FOGMODE_LINEAR: number;
  103908. /**
  103909. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  103910. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103911. */
  103912. static MinDeltaTime: number;
  103913. /**
  103914. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  103915. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103916. */
  103917. static MaxDeltaTime: number;
  103918. /**
  103919. * Factory used to create the default material.
  103920. * @param name The name of the material to create
  103921. * @param scene The scene to create the material for
  103922. * @returns The default material
  103923. */
  103924. static DefaultMaterialFactory(scene: Scene): Material;
  103925. /**
  103926. * Factory used to create the a collision coordinator.
  103927. * @returns The collision coordinator
  103928. */
  103929. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  103930. /** @hidden */
  103931. _inputManager: InputManager;
  103932. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  103933. cameraToUseForPointers: Nullable<Camera>;
  103934. /** @hidden */
  103935. readonly _isScene: boolean;
  103936. /**
  103937. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  103938. */
  103939. autoClear: boolean;
  103940. /**
  103941. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  103942. */
  103943. autoClearDepthAndStencil: boolean;
  103944. /**
  103945. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  103946. */
  103947. clearColor: Color4;
  103948. /**
  103949. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  103950. */
  103951. ambientColor: Color3;
  103952. /**
  103953. * This is use to store the default BRDF lookup for PBR materials in your scene.
  103954. * It should only be one of the following (if not the default embedded one):
  103955. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  103956. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  103957. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  103958. * The material properties need to be setup according to the type of texture in use.
  103959. */
  103960. environmentBRDFTexture: BaseTexture;
  103961. /** @hidden */
  103962. protected _environmentTexture: Nullable<BaseTexture>;
  103963. /**
  103964. * Texture used in all pbr material as the reflection texture.
  103965. * As in the majority of the scene they are the same (exception for multi room and so on),
  103966. * this is easier to reference from here than from all the materials.
  103967. */
  103968. /**
  103969. * Texture used in all pbr material as the reflection texture.
  103970. * As in the majority of the scene they are the same (exception for multi room and so on),
  103971. * this is easier to set here than in all the materials.
  103972. */
  103973. environmentTexture: Nullable<BaseTexture>;
  103974. /** @hidden */
  103975. protected _environmentIntensity: number;
  103976. /**
  103977. * Intensity of the environment in all pbr material.
  103978. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  103979. * As in the majority of the scene they are the same (exception for multi room and so on),
  103980. * this is easier to reference from here than from all the materials.
  103981. */
  103982. /**
  103983. * Intensity of the environment in all pbr material.
  103984. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  103985. * As in the majority of the scene they are the same (exception for multi room and so on),
  103986. * this is easier to set here than in all the materials.
  103987. */
  103988. environmentIntensity: number;
  103989. /** @hidden */
  103990. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103991. /**
  103992. * Default image processing configuration used either in the rendering
  103993. * Forward main pass or through the imageProcessingPostProcess if present.
  103994. * As in the majority of the scene they are the same (exception for multi camera),
  103995. * this is easier to reference from here than from all the materials and post process.
  103996. *
  103997. * No setter as we it is a shared configuration, you can set the values instead.
  103998. */
  103999. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  104000. private _forceWireframe;
  104001. /**
  104002. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  104003. */
  104004. forceWireframe: boolean;
  104005. private _forcePointsCloud;
  104006. /**
  104007. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  104008. */
  104009. forcePointsCloud: boolean;
  104010. /**
  104011. * Gets or sets the active clipplane 1
  104012. */
  104013. clipPlane: Nullable<Plane>;
  104014. /**
  104015. * Gets or sets the active clipplane 2
  104016. */
  104017. clipPlane2: Nullable<Plane>;
  104018. /**
  104019. * Gets or sets the active clipplane 3
  104020. */
  104021. clipPlane3: Nullable<Plane>;
  104022. /**
  104023. * Gets or sets the active clipplane 4
  104024. */
  104025. clipPlane4: Nullable<Plane>;
  104026. /**
  104027. * Gets or sets a boolean indicating if animations are enabled
  104028. */
  104029. animationsEnabled: boolean;
  104030. private _animationPropertiesOverride;
  104031. /**
  104032. * Gets or sets the animation properties override
  104033. */
  104034. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  104035. /**
  104036. * Gets or sets a boolean indicating if a constant deltatime has to be used
  104037. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  104038. */
  104039. useConstantAnimationDeltaTime: boolean;
  104040. /**
  104041. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  104042. * Please note that it requires to run a ray cast through the scene on every frame
  104043. */
  104044. constantlyUpdateMeshUnderPointer: boolean;
  104045. /**
  104046. * Defines the HTML cursor to use when hovering over interactive elements
  104047. */
  104048. hoverCursor: string;
  104049. /**
  104050. * Defines the HTML default cursor to use (empty by default)
  104051. */
  104052. defaultCursor: string;
  104053. /**
  104054. * Defines wether cursors are handled by the scene.
  104055. */
  104056. doNotHandleCursors: boolean;
  104057. /**
  104058. * This is used to call preventDefault() on pointer down
  104059. * in order to block unwanted artifacts like system double clicks
  104060. */
  104061. preventDefaultOnPointerDown: boolean;
  104062. /**
  104063. * This is used to call preventDefault() on pointer up
  104064. * in order to block unwanted artifacts like system double clicks
  104065. */
  104066. preventDefaultOnPointerUp: boolean;
  104067. /**
  104068. * Gets or sets user defined metadata
  104069. */
  104070. metadata: any;
  104071. /**
  104072. * For internal use only. Please do not use.
  104073. */
  104074. reservedDataStore: any;
  104075. /**
  104076. * Gets the name of the plugin used to load this scene (null by default)
  104077. */
  104078. loadingPluginName: string;
  104079. /**
  104080. * Use this array to add regular expressions used to disable offline support for specific urls
  104081. */
  104082. disableOfflineSupportExceptionRules: RegExp[];
  104083. /**
  104084. * An event triggered when the scene is disposed.
  104085. */
  104086. onDisposeObservable: Observable<Scene>;
  104087. private _onDisposeObserver;
  104088. /** Sets a function to be executed when this scene is disposed. */
  104089. onDispose: () => void;
  104090. /**
  104091. * An event triggered before rendering the scene (right after animations and physics)
  104092. */
  104093. onBeforeRenderObservable: Observable<Scene>;
  104094. private _onBeforeRenderObserver;
  104095. /** Sets a function to be executed before rendering this scene */
  104096. beforeRender: Nullable<() => void>;
  104097. /**
  104098. * An event triggered after rendering the scene
  104099. */
  104100. onAfterRenderObservable: Observable<Scene>;
  104101. /**
  104102. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  104103. */
  104104. onAfterRenderCameraObservable: Observable<Camera>;
  104105. private _onAfterRenderObserver;
  104106. /** Sets a function to be executed after rendering this scene */
  104107. afterRender: Nullable<() => void>;
  104108. /**
  104109. * An event triggered before animating the scene
  104110. */
  104111. onBeforeAnimationsObservable: Observable<Scene>;
  104112. /**
  104113. * An event triggered after animations processing
  104114. */
  104115. onAfterAnimationsObservable: Observable<Scene>;
  104116. /**
  104117. * An event triggered before draw calls are ready to be sent
  104118. */
  104119. onBeforeDrawPhaseObservable: Observable<Scene>;
  104120. /**
  104121. * An event triggered after draw calls have been sent
  104122. */
  104123. onAfterDrawPhaseObservable: Observable<Scene>;
  104124. /**
  104125. * An event triggered when the scene is ready
  104126. */
  104127. onReadyObservable: Observable<Scene>;
  104128. /**
  104129. * An event triggered before rendering a camera
  104130. */
  104131. onBeforeCameraRenderObservable: Observable<Camera>;
  104132. private _onBeforeCameraRenderObserver;
  104133. /** Sets a function to be executed before rendering a camera*/
  104134. beforeCameraRender: () => void;
  104135. /**
  104136. * An event triggered after rendering a camera
  104137. */
  104138. onAfterCameraRenderObservable: Observable<Camera>;
  104139. private _onAfterCameraRenderObserver;
  104140. /** Sets a function to be executed after rendering a camera*/
  104141. afterCameraRender: () => void;
  104142. /**
  104143. * An event triggered when active meshes evaluation is about to start
  104144. */
  104145. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  104146. /**
  104147. * An event triggered when active meshes evaluation is done
  104148. */
  104149. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  104150. /**
  104151. * An event triggered when particles rendering is about to start
  104152. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  104153. */
  104154. onBeforeParticlesRenderingObservable: Observable<Scene>;
  104155. /**
  104156. * An event triggered when particles rendering is done
  104157. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  104158. */
  104159. onAfterParticlesRenderingObservable: Observable<Scene>;
  104160. /**
  104161. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  104162. */
  104163. onDataLoadedObservable: Observable<Scene>;
  104164. /**
  104165. * An event triggered when a camera is created
  104166. */
  104167. onNewCameraAddedObservable: Observable<Camera>;
  104168. /**
  104169. * An event triggered when a camera is removed
  104170. */
  104171. onCameraRemovedObservable: Observable<Camera>;
  104172. /**
  104173. * An event triggered when a light is created
  104174. */
  104175. onNewLightAddedObservable: Observable<Light>;
  104176. /**
  104177. * An event triggered when a light is removed
  104178. */
  104179. onLightRemovedObservable: Observable<Light>;
  104180. /**
  104181. * An event triggered when a geometry is created
  104182. */
  104183. onNewGeometryAddedObservable: Observable<Geometry>;
  104184. /**
  104185. * An event triggered when a geometry is removed
  104186. */
  104187. onGeometryRemovedObservable: Observable<Geometry>;
  104188. /**
  104189. * An event triggered when a transform node is created
  104190. */
  104191. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  104192. /**
  104193. * An event triggered when a transform node is removed
  104194. */
  104195. onTransformNodeRemovedObservable: Observable<TransformNode>;
  104196. /**
  104197. * An event triggered when a mesh is created
  104198. */
  104199. onNewMeshAddedObservable: Observable<AbstractMesh>;
  104200. /**
  104201. * An event triggered when a mesh is removed
  104202. */
  104203. onMeshRemovedObservable: Observable<AbstractMesh>;
  104204. /**
  104205. * An event triggered when a skeleton is created
  104206. */
  104207. onNewSkeletonAddedObservable: Observable<Skeleton>;
  104208. /**
  104209. * An event triggered when a skeleton is removed
  104210. */
  104211. onSkeletonRemovedObservable: Observable<Skeleton>;
  104212. /**
  104213. * An event triggered when a material is created
  104214. */
  104215. onNewMaterialAddedObservable: Observable<Material>;
  104216. /**
  104217. * An event triggered when a material is removed
  104218. */
  104219. onMaterialRemovedObservable: Observable<Material>;
  104220. /**
  104221. * An event triggered when a texture is created
  104222. */
  104223. onNewTextureAddedObservable: Observable<BaseTexture>;
  104224. /**
  104225. * An event triggered when a texture is removed
  104226. */
  104227. onTextureRemovedObservable: Observable<BaseTexture>;
  104228. /**
  104229. * An event triggered when render targets are about to be rendered
  104230. * Can happen multiple times per frame.
  104231. */
  104232. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  104233. /**
  104234. * An event triggered when render targets were rendered.
  104235. * Can happen multiple times per frame.
  104236. */
  104237. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  104238. /**
  104239. * An event triggered before calculating deterministic simulation step
  104240. */
  104241. onBeforeStepObservable: Observable<Scene>;
  104242. /**
  104243. * An event triggered after calculating deterministic simulation step
  104244. */
  104245. onAfterStepObservable: Observable<Scene>;
  104246. /**
  104247. * An event triggered when the activeCamera property is updated
  104248. */
  104249. onActiveCameraChanged: Observable<Scene>;
  104250. /**
  104251. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  104252. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  104253. * 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)
  104254. */
  104255. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  104256. /**
  104257. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  104258. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  104259. * 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)
  104260. */
  104261. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  104262. /**
  104263. * This Observable will when a mesh has been imported into the scene.
  104264. */
  104265. onMeshImportedObservable: Observable<AbstractMesh>;
  104266. /**
  104267. * This Observable will when an animation file has been imported into the scene.
  104268. */
  104269. onAnimationFileImportedObservable: Observable<Scene>;
  104270. /**
  104271. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  104272. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  104273. */
  104274. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  104275. /** @hidden */
  104276. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  104277. /**
  104278. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  104279. */
  104280. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  104281. /**
  104282. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  104283. */
  104284. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  104285. /**
  104286. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  104287. */
  104288. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  104289. /** Callback called when a pointer move is detected */
  104290. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  104291. /** Callback called when a pointer down is detected */
  104292. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  104293. /** Callback called when a pointer up is detected */
  104294. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  104295. /** Callback called when a pointer pick is detected */
  104296. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  104297. /**
  104298. * 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).
  104299. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  104300. */
  104301. onPrePointerObservable: Observable<PointerInfoPre>;
  104302. /**
  104303. * Observable event triggered each time an input event is received from the rendering canvas
  104304. */
  104305. onPointerObservable: Observable<PointerInfo>;
  104306. /**
  104307. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  104308. */
  104309. readonly unTranslatedPointer: Vector2;
  104310. /**
  104311. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  104312. */
  104313. static DragMovementThreshold: number;
  104314. /**
  104315. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  104316. */
  104317. static LongPressDelay: number;
  104318. /**
  104319. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  104320. */
  104321. static DoubleClickDelay: number;
  104322. /** If you need to check double click without raising a single click at first click, enable this flag */
  104323. static ExclusiveDoubleClickMode: boolean;
  104324. /** @hidden */
  104325. _mirroredCameraPosition: Nullable<Vector3>;
  104326. /**
  104327. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  104328. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  104329. */
  104330. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  104331. /**
  104332. * Observable event triggered each time an keyboard event is received from the hosting window
  104333. */
  104334. onKeyboardObservable: Observable<KeyboardInfo>;
  104335. private _useRightHandedSystem;
  104336. /**
  104337. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  104338. */
  104339. useRightHandedSystem: boolean;
  104340. private _timeAccumulator;
  104341. private _currentStepId;
  104342. private _currentInternalStep;
  104343. /**
  104344. * Sets the step Id used by deterministic lock step
  104345. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104346. * @param newStepId defines the step Id
  104347. */
  104348. setStepId(newStepId: number): void;
  104349. /**
  104350. * Gets the step Id used by deterministic lock step
  104351. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104352. * @returns the step Id
  104353. */
  104354. getStepId(): number;
  104355. /**
  104356. * Gets the internal step used by deterministic lock step
  104357. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104358. * @returns the internal step
  104359. */
  104360. getInternalStep(): number;
  104361. private _fogEnabled;
  104362. /**
  104363. * Gets or sets a boolean indicating if fog is enabled on this scene
  104364. * @see http://doc.babylonjs.com/babylon101/environment#fog
  104365. * (Default is true)
  104366. */
  104367. fogEnabled: boolean;
  104368. private _fogMode;
  104369. /**
  104370. * Gets or sets the fog mode to use
  104371. * @see http://doc.babylonjs.com/babylon101/environment#fog
  104372. * | mode | value |
  104373. * | --- | --- |
  104374. * | FOGMODE_NONE | 0 |
  104375. * | FOGMODE_EXP | 1 |
  104376. * | FOGMODE_EXP2 | 2 |
  104377. * | FOGMODE_LINEAR | 3 |
  104378. */
  104379. fogMode: number;
  104380. /**
  104381. * Gets or sets the fog color to use
  104382. * @see http://doc.babylonjs.com/babylon101/environment#fog
  104383. * (Default is Color3(0.2, 0.2, 0.3))
  104384. */
  104385. fogColor: Color3;
  104386. /**
  104387. * Gets or sets the fog density to use
  104388. * @see http://doc.babylonjs.com/babylon101/environment#fog
  104389. * (Default is 0.1)
  104390. */
  104391. fogDensity: number;
  104392. /**
  104393. * Gets or sets the fog start distance to use
  104394. * @see http://doc.babylonjs.com/babylon101/environment#fog
  104395. * (Default is 0)
  104396. */
  104397. fogStart: number;
  104398. /**
  104399. * Gets or sets the fog end distance to use
  104400. * @see http://doc.babylonjs.com/babylon101/environment#fog
  104401. * (Default is 1000)
  104402. */
  104403. fogEnd: number;
  104404. private _shadowsEnabled;
  104405. /**
  104406. * Gets or sets a boolean indicating if shadows are enabled on this scene
  104407. */
  104408. shadowsEnabled: boolean;
  104409. private _lightsEnabled;
  104410. /**
  104411. * Gets or sets a boolean indicating if lights are enabled on this scene
  104412. */
  104413. lightsEnabled: boolean;
  104414. /** All of the active cameras added to this scene. */
  104415. activeCameras: Camera[];
  104416. /** @hidden */
  104417. _activeCamera: Nullable<Camera>;
  104418. /** Gets or sets the current active camera */
  104419. activeCamera: Nullable<Camera>;
  104420. private _defaultMaterial;
  104421. /** The default material used on meshes when no material is affected */
  104422. /** The default material used on meshes when no material is affected */
  104423. defaultMaterial: Material;
  104424. private _texturesEnabled;
  104425. /**
  104426. * Gets or sets a boolean indicating if textures are enabled on this scene
  104427. */
  104428. texturesEnabled: boolean;
  104429. /**
  104430. * Gets or sets a boolean indicating if particles are enabled on this scene
  104431. */
  104432. particlesEnabled: boolean;
  104433. /**
  104434. * Gets or sets a boolean indicating if sprites are enabled on this scene
  104435. */
  104436. spritesEnabled: boolean;
  104437. private _skeletonsEnabled;
  104438. /**
  104439. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  104440. */
  104441. skeletonsEnabled: boolean;
  104442. /**
  104443. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  104444. */
  104445. lensFlaresEnabled: boolean;
  104446. /**
  104447. * Gets or sets a boolean indicating if collisions are enabled on this scene
  104448. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104449. */
  104450. collisionsEnabled: boolean;
  104451. private _collisionCoordinator;
  104452. /** @hidden */
  104453. readonly collisionCoordinator: ICollisionCoordinator;
  104454. /**
  104455. * Defines the gravity applied to this scene (used only for collisions)
  104456. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104457. */
  104458. gravity: Vector3;
  104459. /**
  104460. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  104461. */
  104462. postProcessesEnabled: boolean;
  104463. /**
  104464. * The list of postprocesses added to the scene
  104465. */
  104466. postProcesses: PostProcess[];
  104467. /**
  104468. * Gets the current postprocess manager
  104469. */
  104470. postProcessManager: PostProcessManager;
  104471. /**
  104472. * Gets or sets a boolean indicating if render targets are enabled on this scene
  104473. */
  104474. renderTargetsEnabled: boolean;
  104475. /**
  104476. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  104477. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  104478. */
  104479. dumpNextRenderTargets: boolean;
  104480. /**
  104481. * The list of user defined render targets added to the scene
  104482. */
  104483. customRenderTargets: RenderTargetTexture[];
  104484. /**
  104485. * Defines if texture loading must be delayed
  104486. * If true, textures will only be loaded when they need to be rendered
  104487. */
  104488. useDelayedTextureLoading: boolean;
  104489. /**
  104490. * Gets the list of meshes imported to the scene through SceneLoader
  104491. */
  104492. importedMeshesFiles: String[];
  104493. /**
  104494. * Gets or sets a boolean indicating if probes are enabled on this scene
  104495. */
  104496. probesEnabled: boolean;
  104497. /**
  104498. * Gets or sets the current offline provider to use to store scene data
  104499. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  104500. */
  104501. offlineProvider: IOfflineProvider;
  104502. /**
  104503. * Gets or sets the action manager associated with the scene
  104504. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  104505. */
  104506. actionManager: AbstractActionManager;
  104507. private _meshesForIntersections;
  104508. /**
  104509. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  104510. */
  104511. proceduralTexturesEnabled: boolean;
  104512. private _engine;
  104513. private _totalVertices;
  104514. /** @hidden */
  104515. _activeIndices: PerfCounter;
  104516. /** @hidden */
  104517. _activeParticles: PerfCounter;
  104518. /** @hidden */
  104519. _activeBones: PerfCounter;
  104520. private _animationRatio;
  104521. /** @hidden */
  104522. _animationTimeLast: number;
  104523. /** @hidden */
  104524. _animationTime: number;
  104525. /**
  104526. * Gets or sets a general scale for animation speed
  104527. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  104528. */
  104529. animationTimeScale: number;
  104530. /** @hidden */
  104531. _cachedMaterial: Nullable<Material>;
  104532. /** @hidden */
  104533. _cachedEffect: Nullable<Effect>;
  104534. /** @hidden */
  104535. _cachedVisibility: Nullable<number>;
  104536. private _renderId;
  104537. private _frameId;
  104538. private _executeWhenReadyTimeoutId;
  104539. private _intermediateRendering;
  104540. private _viewUpdateFlag;
  104541. private _projectionUpdateFlag;
  104542. /** @hidden */
  104543. _toBeDisposed: Nullable<IDisposable>[];
  104544. private _activeRequests;
  104545. /** @hidden */
  104546. _pendingData: any[];
  104547. private _isDisposed;
  104548. /**
  104549. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  104550. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  104551. */
  104552. dispatchAllSubMeshesOfActiveMeshes: boolean;
  104553. private _activeMeshes;
  104554. private _processedMaterials;
  104555. private _renderTargets;
  104556. /** @hidden */
  104557. _activeParticleSystems: SmartArray<IParticleSystem>;
  104558. private _activeSkeletons;
  104559. private _softwareSkinnedMeshes;
  104560. private _renderingManager;
  104561. /** @hidden */
  104562. _activeAnimatables: Animatable[];
  104563. private _transformMatrix;
  104564. private _sceneUbo;
  104565. /** @hidden */
  104566. _viewMatrix: Matrix;
  104567. private _projectionMatrix;
  104568. /** @hidden */
  104569. _forcedViewPosition: Nullable<Vector3>;
  104570. /** @hidden */
  104571. _frustumPlanes: Plane[];
  104572. /**
  104573. * Gets the list of frustum planes (built from the active camera)
  104574. */
  104575. readonly frustumPlanes: Plane[];
  104576. /**
  104577. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  104578. * This is useful if there are more lights that the maximum simulteanous authorized
  104579. */
  104580. requireLightSorting: boolean;
  104581. /** @hidden */
  104582. readonly useMaterialMeshMap: boolean;
  104583. /** @hidden */
  104584. readonly useClonedMeshhMap: boolean;
  104585. private _externalData;
  104586. private _uid;
  104587. /**
  104588. * @hidden
  104589. * Backing store of defined scene components.
  104590. */
  104591. _components: ISceneComponent[];
  104592. /**
  104593. * @hidden
  104594. * Backing store of defined scene components.
  104595. */
  104596. _serializableComponents: ISceneSerializableComponent[];
  104597. /**
  104598. * List of components to register on the next registration step.
  104599. */
  104600. private _transientComponents;
  104601. /**
  104602. * Registers the transient components if needed.
  104603. */
  104604. private _registerTransientComponents;
  104605. /**
  104606. * @hidden
  104607. * Add a component to the scene.
  104608. * Note that the ccomponent could be registered on th next frame if this is called after
  104609. * the register component stage.
  104610. * @param component Defines the component to add to the scene
  104611. */
  104612. _addComponent(component: ISceneComponent): void;
  104613. /**
  104614. * @hidden
  104615. * Gets a component from the scene.
  104616. * @param name defines the name of the component to retrieve
  104617. * @returns the component or null if not present
  104618. */
  104619. _getComponent(name: string): Nullable<ISceneComponent>;
  104620. /**
  104621. * @hidden
  104622. * Defines the actions happening before camera updates.
  104623. */
  104624. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  104625. /**
  104626. * @hidden
  104627. * Defines the actions happening before clear the canvas.
  104628. */
  104629. _beforeClearStage: Stage<SimpleStageAction>;
  104630. /**
  104631. * @hidden
  104632. * Defines the actions when collecting render targets for the frame.
  104633. */
  104634. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  104635. /**
  104636. * @hidden
  104637. * Defines the actions happening for one camera in the frame.
  104638. */
  104639. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  104640. /**
  104641. * @hidden
  104642. * Defines the actions happening during the per mesh ready checks.
  104643. */
  104644. _isReadyForMeshStage: Stage<MeshStageAction>;
  104645. /**
  104646. * @hidden
  104647. * Defines the actions happening before evaluate active mesh checks.
  104648. */
  104649. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  104650. /**
  104651. * @hidden
  104652. * Defines the actions happening during the evaluate sub mesh checks.
  104653. */
  104654. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  104655. /**
  104656. * @hidden
  104657. * Defines the actions happening during the active mesh stage.
  104658. */
  104659. _activeMeshStage: Stage<ActiveMeshStageAction>;
  104660. /**
  104661. * @hidden
  104662. * Defines the actions happening during the per camera render target step.
  104663. */
  104664. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  104665. /**
  104666. * @hidden
  104667. * Defines the actions happening just before the active camera is drawing.
  104668. */
  104669. _beforeCameraDrawStage: Stage<CameraStageAction>;
  104670. /**
  104671. * @hidden
  104672. * Defines the actions happening just before a render target is drawing.
  104673. */
  104674. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  104675. /**
  104676. * @hidden
  104677. * Defines the actions happening just before a rendering group is drawing.
  104678. */
  104679. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  104680. /**
  104681. * @hidden
  104682. * Defines the actions happening just before a mesh is drawing.
  104683. */
  104684. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  104685. /**
  104686. * @hidden
  104687. * Defines the actions happening just after a mesh has been drawn.
  104688. */
  104689. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  104690. /**
  104691. * @hidden
  104692. * Defines the actions happening just after a rendering group has been drawn.
  104693. */
  104694. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  104695. /**
  104696. * @hidden
  104697. * Defines the actions happening just after the active camera has been drawn.
  104698. */
  104699. _afterCameraDrawStage: Stage<CameraStageAction>;
  104700. /**
  104701. * @hidden
  104702. * Defines the actions happening just after a render target has been drawn.
  104703. */
  104704. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  104705. /**
  104706. * @hidden
  104707. * Defines the actions happening just after rendering all cameras and computing intersections.
  104708. */
  104709. _afterRenderStage: Stage<SimpleStageAction>;
  104710. /**
  104711. * @hidden
  104712. * Defines the actions happening when a pointer move event happens.
  104713. */
  104714. _pointerMoveStage: Stage<PointerMoveStageAction>;
  104715. /**
  104716. * @hidden
  104717. * Defines the actions happening when a pointer down event happens.
  104718. */
  104719. _pointerDownStage: Stage<PointerUpDownStageAction>;
  104720. /**
  104721. * @hidden
  104722. * Defines the actions happening when a pointer up event happens.
  104723. */
  104724. _pointerUpStage: Stage<PointerUpDownStageAction>;
  104725. /**
  104726. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  104727. */
  104728. private geometriesByUniqueId;
  104729. /**
  104730. * Creates a new Scene
  104731. * @param engine defines the engine to use to render this scene
  104732. * @param options defines the scene options
  104733. */
  104734. constructor(engine: Engine, options?: SceneOptions);
  104735. /**
  104736. * Gets a string idenfifying the name of the class
  104737. * @returns "Scene" string
  104738. */
  104739. getClassName(): string;
  104740. private _defaultMeshCandidates;
  104741. /**
  104742. * @hidden
  104743. */
  104744. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  104745. private _defaultSubMeshCandidates;
  104746. /**
  104747. * @hidden
  104748. */
  104749. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  104750. /**
  104751. * Sets the default candidate providers for the scene.
  104752. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  104753. * and getCollidingSubMeshCandidates to their default function
  104754. */
  104755. setDefaultCandidateProviders(): void;
  104756. /**
  104757. * Gets the mesh that is currently under the pointer
  104758. */
  104759. readonly meshUnderPointer: Nullable<AbstractMesh>;
  104760. /**
  104761. * Gets or sets the current on-screen X position of the pointer
  104762. */
  104763. pointerX: number;
  104764. /**
  104765. * Gets or sets the current on-screen Y position of the pointer
  104766. */
  104767. pointerY: number;
  104768. /**
  104769. * Gets the cached material (ie. the latest rendered one)
  104770. * @returns the cached material
  104771. */
  104772. getCachedMaterial(): Nullable<Material>;
  104773. /**
  104774. * Gets the cached effect (ie. the latest rendered one)
  104775. * @returns the cached effect
  104776. */
  104777. getCachedEffect(): Nullable<Effect>;
  104778. /**
  104779. * Gets the cached visibility state (ie. the latest rendered one)
  104780. * @returns the cached visibility state
  104781. */
  104782. getCachedVisibility(): Nullable<number>;
  104783. /**
  104784. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  104785. * @param material defines the current material
  104786. * @param effect defines the current effect
  104787. * @param visibility defines the current visibility state
  104788. * @returns true if one parameter is not cached
  104789. */
  104790. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  104791. /**
  104792. * Gets the engine associated with the scene
  104793. * @returns an Engine
  104794. */
  104795. getEngine(): Engine;
  104796. /**
  104797. * Gets the total number of vertices rendered per frame
  104798. * @returns the total number of vertices rendered per frame
  104799. */
  104800. getTotalVertices(): number;
  104801. /**
  104802. * Gets the performance counter for total vertices
  104803. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104804. */
  104805. readonly totalVerticesPerfCounter: PerfCounter;
  104806. /**
  104807. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  104808. * @returns the total number of active indices rendered per frame
  104809. */
  104810. getActiveIndices(): number;
  104811. /**
  104812. * Gets the performance counter for active indices
  104813. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104814. */
  104815. readonly totalActiveIndicesPerfCounter: PerfCounter;
  104816. /**
  104817. * Gets the total number of active particles rendered per frame
  104818. * @returns the total number of active particles rendered per frame
  104819. */
  104820. getActiveParticles(): number;
  104821. /**
  104822. * Gets the performance counter for active particles
  104823. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104824. */
  104825. readonly activeParticlesPerfCounter: PerfCounter;
  104826. /**
  104827. * Gets the total number of active bones rendered per frame
  104828. * @returns the total number of active bones rendered per frame
  104829. */
  104830. getActiveBones(): number;
  104831. /**
  104832. * Gets the performance counter for active bones
  104833. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104834. */
  104835. readonly activeBonesPerfCounter: PerfCounter;
  104836. /**
  104837. * Gets the array of active meshes
  104838. * @returns an array of AbstractMesh
  104839. */
  104840. getActiveMeshes(): SmartArray<AbstractMesh>;
  104841. /**
  104842. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  104843. * @returns a number
  104844. */
  104845. getAnimationRatio(): number;
  104846. /**
  104847. * Gets an unique Id for the current render phase
  104848. * @returns a number
  104849. */
  104850. getRenderId(): number;
  104851. /**
  104852. * Gets an unique Id for the current frame
  104853. * @returns a number
  104854. */
  104855. getFrameId(): number;
  104856. /** Call this function if you want to manually increment the render Id*/
  104857. incrementRenderId(): void;
  104858. private _createUbo;
  104859. /**
  104860. * Use this method to simulate a pointer move on a mesh
  104861. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104862. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104863. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104864. * @returns the current scene
  104865. */
  104866. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  104867. /**
  104868. * Use this method to simulate a pointer down on a mesh
  104869. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104870. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104871. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104872. * @returns the current scene
  104873. */
  104874. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  104875. /**
  104876. * Use this method to simulate a pointer up on a mesh
  104877. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104878. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104879. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104880. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  104881. * @returns the current scene
  104882. */
  104883. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  104884. /**
  104885. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  104886. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  104887. * @returns true if the pointer was captured
  104888. */
  104889. isPointerCaptured(pointerId?: number): boolean;
  104890. /**
  104891. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  104892. * @param attachUp defines if you want to attach events to pointerup
  104893. * @param attachDown defines if you want to attach events to pointerdown
  104894. * @param attachMove defines if you want to attach events to pointermove
  104895. */
  104896. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  104897. /** Detaches all event handlers*/
  104898. detachControl(): void;
  104899. /**
  104900. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  104901. * Delay loaded resources are not taking in account
  104902. * @return true if all required resources are ready
  104903. */
  104904. isReady(): boolean;
  104905. /** Resets all cached information relative to material (including effect and visibility) */
  104906. resetCachedMaterial(): void;
  104907. /**
  104908. * Registers a function to be called before every frame render
  104909. * @param func defines the function to register
  104910. */
  104911. registerBeforeRender(func: () => void): void;
  104912. /**
  104913. * Unregisters a function called before every frame render
  104914. * @param func defines the function to unregister
  104915. */
  104916. unregisterBeforeRender(func: () => void): void;
  104917. /**
  104918. * Registers a function to be called after every frame render
  104919. * @param func defines the function to register
  104920. */
  104921. registerAfterRender(func: () => void): void;
  104922. /**
  104923. * Unregisters a function called after every frame render
  104924. * @param func defines the function to unregister
  104925. */
  104926. unregisterAfterRender(func: () => void): void;
  104927. private _executeOnceBeforeRender;
  104928. /**
  104929. * The provided function will run before render once and will be disposed afterwards.
  104930. * A timeout delay can be provided so that the function will be executed in N ms.
  104931. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  104932. * @param func The function to be executed.
  104933. * @param timeout optional delay in ms
  104934. */
  104935. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  104936. /** @hidden */
  104937. _addPendingData(data: any): void;
  104938. /** @hidden */
  104939. _removePendingData(data: any): void;
  104940. /**
  104941. * Returns the number of items waiting to be loaded
  104942. * @returns the number of items waiting to be loaded
  104943. */
  104944. getWaitingItemsCount(): number;
  104945. /**
  104946. * Returns a boolean indicating if the scene is still loading data
  104947. */
  104948. readonly isLoading: boolean;
  104949. /**
  104950. * Registers a function to be executed when the scene is ready
  104951. * @param {Function} func - the function to be executed
  104952. */
  104953. executeWhenReady(func: () => void): void;
  104954. /**
  104955. * Returns a promise that resolves when the scene is ready
  104956. * @returns A promise that resolves when the scene is ready
  104957. */
  104958. whenReadyAsync(): Promise<void>;
  104959. /** @hidden */
  104960. _checkIsReady(): void;
  104961. /**
  104962. * Gets all animatable attached to the scene
  104963. */
  104964. readonly animatables: Animatable[];
  104965. /**
  104966. * Resets the last animation time frame.
  104967. * Useful to override when animations start running when loading a scene for the first time.
  104968. */
  104969. resetLastAnimationTimeFrame(): void;
  104970. /**
  104971. * Gets the current view matrix
  104972. * @returns a Matrix
  104973. */
  104974. getViewMatrix(): Matrix;
  104975. /**
  104976. * Gets the current projection matrix
  104977. * @returns a Matrix
  104978. */
  104979. getProjectionMatrix(): Matrix;
  104980. /**
  104981. * Gets the current transform matrix
  104982. * @returns a Matrix made of View * Projection
  104983. */
  104984. getTransformMatrix(): Matrix;
  104985. /**
  104986. * Sets the current transform matrix
  104987. * @param viewL defines the View matrix to use
  104988. * @param projectionL defines the Projection matrix to use
  104989. * @param viewR defines the right View matrix to use (if provided)
  104990. * @param projectionR defines the right Projection matrix to use (if provided)
  104991. */
  104992. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  104993. /**
  104994. * Gets the uniform buffer used to store scene data
  104995. * @returns a UniformBuffer
  104996. */
  104997. getSceneUniformBuffer(): UniformBuffer;
  104998. /**
  104999. * Gets an unique (relatively to the current scene) Id
  105000. * @returns an unique number for the scene
  105001. */
  105002. getUniqueId(): number;
  105003. /**
  105004. * Add a mesh to the list of scene's meshes
  105005. * @param newMesh defines the mesh to add
  105006. * @param recursive if all child meshes should also be added to the scene
  105007. */
  105008. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  105009. /**
  105010. * Remove a mesh for the list of scene's meshes
  105011. * @param toRemove defines the mesh to remove
  105012. * @param recursive if all child meshes should also be removed from the scene
  105013. * @returns the index where the mesh was in the mesh list
  105014. */
  105015. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  105016. /**
  105017. * Add a transform node to the list of scene's transform nodes
  105018. * @param newTransformNode defines the transform node to add
  105019. */
  105020. addTransformNode(newTransformNode: TransformNode): void;
  105021. /**
  105022. * Remove a transform node for the list of scene's transform nodes
  105023. * @param toRemove defines the transform node to remove
  105024. * @returns the index where the transform node was in the transform node list
  105025. */
  105026. removeTransformNode(toRemove: TransformNode): number;
  105027. /**
  105028. * Remove a skeleton for the list of scene's skeletons
  105029. * @param toRemove defines the skeleton to remove
  105030. * @returns the index where the skeleton was in the skeleton list
  105031. */
  105032. removeSkeleton(toRemove: Skeleton): number;
  105033. /**
  105034. * Remove a morph target for the list of scene's morph targets
  105035. * @param toRemove defines the morph target to remove
  105036. * @returns the index where the morph target was in the morph target list
  105037. */
  105038. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  105039. /**
  105040. * Remove a light for the list of scene's lights
  105041. * @param toRemove defines the light to remove
  105042. * @returns the index where the light was in the light list
  105043. */
  105044. removeLight(toRemove: Light): number;
  105045. /**
  105046. * Remove a camera for the list of scene's cameras
  105047. * @param toRemove defines the camera to remove
  105048. * @returns the index where the camera was in the camera list
  105049. */
  105050. removeCamera(toRemove: Camera): number;
  105051. /**
  105052. * Remove a particle system for the list of scene's particle systems
  105053. * @param toRemove defines the particle system to remove
  105054. * @returns the index where the particle system was in the particle system list
  105055. */
  105056. removeParticleSystem(toRemove: IParticleSystem): number;
  105057. /**
  105058. * Remove a animation for the list of scene's animations
  105059. * @param toRemove defines the animation to remove
  105060. * @returns the index where the animation was in the animation list
  105061. */
  105062. removeAnimation(toRemove: Animation): number;
  105063. /**
  105064. * Will stop the animation of the given target
  105065. * @param target - the target
  105066. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  105067. * @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)
  105068. */
  105069. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  105070. /**
  105071. * Removes the given animation group from this scene.
  105072. * @param toRemove The animation group to remove
  105073. * @returns The index of the removed animation group
  105074. */
  105075. removeAnimationGroup(toRemove: AnimationGroup): number;
  105076. /**
  105077. * Removes the given multi-material from this scene.
  105078. * @param toRemove The multi-material to remove
  105079. * @returns The index of the removed multi-material
  105080. */
  105081. removeMultiMaterial(toRemove: MultiMaterial): number;
  105082. /**
  105083. * Removes the given material from this scene.
  105084. * @param toRemove The material to remove
  105085. * @returns The index of the removed material
  105086. */
  105087. removeMaterial(toRemove: Material): number;
  105088. /**
  105089. * Removes the given action manager from this scene.
  105090. * @param toRemove The action manager to remove
  105091. * @returns The index of the removed action manager
  105092. */
  105093. removeActionManager(toRemove: AbstractActionManager): number;
  105094. /**
  105095. * Removes the given texture from this scene.
  105096. * @param toRemove The texture to remove
  105097. * @returns The index of the removed texture
  105098. */
  105099. removeTexture(toRemove: BaseTexture): number;
  105100. /**
  105101. * Adds the given light to this scene
  105102. * @param newLight The light to add
  105103. */
  105104. addLight(newLight: Light): void;
  105105. /**
  105106. * Sorts the list list based on light priorities
  105107. */
  105108. sortLightsByPriority(): void;
  105109. /**
  105110. * Adds the given camera to this scene
  105111. * @param newCamera The camera to add
  105112. */
  105113. addCamera(newCamera: Camera): void;
  105114. /**
  105115. * Adds the given skeleton to this scene
  105116. * @param newSkeleton The skeleton to add
  105117. */
  105118. addSkeleton(newSkeleton: Skeleton): void;
  105119. /**
  105120. * Adds the given particle system to this scene
  105121. * @param newParticleSystem The particle system to add
  105122. */
  105123. addParticleSystem(newParticleSystem: IParticleSystem): void;
  105124. /**
  105125. * Adds the given animation to this scene
  105126. * @param newAnimation The animation to add
  105127. */
  105128. addAnimation(newAnimation: Animation): void;
  105129. /**
  105130. * Adds the given animation group to this scene.
  105131. * @param newAnimationGroup The animation group to add
  105132. */
  105133. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  105134. /**
  105135. * Adds the given multi-material to this scene
  105136. * @param newMultiMaterial The multi-material to add
  105137. */
  105138. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  105139. /**
  105140. * Adds the given material to this scene
  105141. * @param newMaterial The material to add
  105142. */
  105143. addMaterial(newMaterial: Material): void;
  105144. /**
  105145. * Adds the given morph target to this scene
  105146. * @param newMorphTargetManager The morph target to add
  105147. */
  105148. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  105149. /**
  105150. * Adds the given geometry to this scene
  105151. * @param newGeometry The geometry to add
  105152. */
  105153. addGeometry(newGeometry: Geometry): void;
  105154. /**
  105155. * Adds the given action manager to this scene
  105156. * @param newActionManager The action manager to add
  105157. */
  105158. addActionManager(newActionManager: AbstractActionManager): void;
  105159. /**
  105160. * Adds the given texture to this scene.
  105161. * @param newTexture The texture to add
  105162. */
  105163. addTexture(newTexture: BaseTexture): void;
  105164. /**
  105165. * Switch active camera
  105166. * @param newCamera defines the new active camera
  105167. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  105168. */
  105169. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  105170. /**
  105171. * sets the active camera of the scene using its ID
  105172. * @param id defines the camera's ID
  105173. * @return the new active camera or null if none found.
  105174. */
  105175. setActiveCameraByID(id: string): Nullable<Camera>;
  105176. /**
  105177. * sets the active camera of the scene using its name
  105178. * @param name defines the camera's name
  105179. * @returns the new active camera or null if none found.
  105180. */
  105181. setActiveCameraByName(name: string): Nullable<Camera>;
  105182. /**
  105183. * get an animation group using its name
  105184. * @param name defines the material's name
  105185. * @return the animation group or null if none found.
  105186. */
  105187. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  105188. /**
  105189. * Get a material using its unique id
  105190. * @param uniqueId defines the material's unique id
  105191. * @return the material or null if none found.
  105192. */
  105193. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  105194. /**
  105195. * get a material using its id
  105196. * @param id defines the material's ID
  105197. * @return the material or null if none found.
  105198. */
  105199. getMaterialByID(id: string): Nullable<Material>;
  105200. /**
  105201. * Gets a the last added material using a given id
  105202. * @param id defines the material's ID
  105203. * @return the last material with the given id or null if none found.
  105204. */
  105205. getLastMaterialByID(id: string): Nullable<Material>;
  105206. /**
  105207. * Gets a material using its name
  105208. * @param name defines the material's name
  105209. * @return the material or null if none found.
  105210. */
  105211. getMaterialByName(name: string): Nullable<Material>;
  105212. /**
  105213. * Get a texture using its unique id
  105214. * @param uniqueId defines the texture's unique id
  105215. * @return the texture or null if none found.
  105216. */
  105217. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  105218. /**
  105219. * Gets a camera using its id
  105220. * @param id defines the id to look for
  105221. * @returns the camera or null if not found
  105222. */
  105223. getCameraByID(id: string): Nullable<Camera>;
  105224. /**
  105225. * Gets a camera using its unique id
  105226. * @param uniqueId defines the unique id to look for
  105227. * @returns the camera or null if not found
  105228. */
  105229. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  105230. /**
  105231. * Gets a camera using its name
  105232. * @param name defines the camera's name
  105233. * @return the camera or null if none found.
  105234. */
  105235. getCameraByName(name: string): Nullable<Camera>;
  105236. /**
  105237. * Gets a bone using its id
  105238. * @param id defines the bone's id
  105239. * @return the bone or null if not found
  105240. */
  105241. getBoneByID(id: string): Nullable<Bone>;
  105242. /**
  105243. * Gets a bone using its id
  105244. * @param name defines the bone's name
  105245. * @return the bone or null if not found
  105246. */
  105247. getBoneByName(name: string): Nullable<Bone>;
  105248. /**
  105249. * Gets a light node using its name
  105250. * @param name defines the the light's name
  105251. * @return the light or null if none found.
  105252. */
  105253. getLightByName(name: string): Nullable<Light>;
  105254. /**
  105255. * Gets a light node using its id
  105256. * @param id defines the light's id
  105257. * @return the light or null if none found.
  105258. */
  105259. getLightByID(id: string): Nullable<Light>;
  105260. /**
  105261. * Gets a light node using its scene-generated unique ID
  105262. * @param uniqueId defines the light's unique id
  105263. * @return the light or null if none found.
  105264. */
  105265. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  105266. /**
  105267. * Gets a particle system by id
  105268. * @param id defines the particle system id
  105269. * @return the corresponding system or null if none found
  105270. */
  105271. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  105272. /**
  105273. * Gets a geometry using its ID
  105274. * @param id defines the geometry's id
  105275. * @return the geometry or null if none found.
  105276. */
  105277. getGeometryByID(id: string): Nullable<Geometry>;
  105278. private _getGeometryByUniqueID;
  105279. /**
  105280. * Add a new geometry to this scene
  105281. * @param geometry defines the geometry to be added to the scene.
  105282. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  105283. * @return a boolean defining if the geometry was added or not
  105284. */
  105285. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  105286. /**
  105287. * Removes an existing geometry
  105288. * @param geometry defines the geometry to be removed from the scene
  105289. * @return a boolean defining if the geometry was removed or not
  105290. */
  105291. removeGeometry(geometry: Geometry): boolean;
  105292. /**
  105293. * Gets the list of geometries attached to the scene
  105294. * @returns an array of Geometry
  105295. */
  105296. getGeometries(): Geometry[];
  105297. /**
  105298. * Gets the first added mesh found of a given ID
  105299. * @param id defines the id to search for
  105300. * @return the mesh found or null if not found at all
  105301. */
  105302. getMeshByID(id: string): Nullable<AbstractMesh>;
  105303. /**
  105304. * Gets a list of meshes using their id
  105305. * @param id defines the id to search for
  105306. * @returns a list of meshes
  105307. */
  105308. getMeshesByID(id: string): Array<AbstractMesh>;
  105309. /**
  105310. * Gets the first added transform node found of a given ID
  105311. * @param id defines the id to search for
  105312. * @return the found transform node or null if not found at all.
  105313. */
  105314. getTransformNodeByID(id: string): Nullable<TransformNode>;
  105315. /**
  105316. * Gets a transform node with its auto-generated unique id
  105317. * @param uniqueId efines the unique id to search for
  105318. * @return the found transform node or null if not found at all.
  105319. */
  105320. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  105321. /**
  105322. * Gets a list of transform nodes using their id
  105323. * @param id defines the id to search for
  105324. * @returns a list of transform nodes
  105325. */
  105326. getTransformNodesByID(id: string): Array<TransformNode>;
  105327. /**
  105328. * Gets a mesh with its auto-generated unique id
  105329. * @param uniqueId defines the unique id to search for
  105330. * @return the found mesh or null if not found at all.
  105331. */
  105332. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  105333. /**
  105334. * Gets a the last added mesh using a given id
  105335. * @param id defines the id to search for
  105336. * @return the found mesh or null if not found at all.
  105337. */
  105338. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  105339. /**
  105340. * Gets a the last added node (Mesh, Camera, Light) using a given id
  105341. * @param id defines the id to search for
  105342. * @return the found node or null if not found at all
  105343. */
  105344. getLastEntryByID(id: string): Nullable<Node>;
  105345. /**
  105346. * Gets a node (Mesh, Camera, Light) using a given id
  105347. * @param id defines the id to search for
  105348. * @return the found node or null if not found at all
  105349. */
  105350. getNodeByID(id: string): Nullable<Node>;
  105351. /**
  105352. * Gets a node (Mesh, Camera, Light) using a given name
  105353. * @param name defines the name to search for
  105354. * @return the found node or null if not found at all.
  105355. */
  105356. getNodeByName(name: string): Nullable<Node>;
  105357. /**
  105358. * Gets a mesh using a given name
  105359. * @param name defines the name to search for
  105360. * @return the found mesh or null if not found at all.
  105361. */
  105362. getMeshByName(name: string): Nullable<AbstractMesh>;
  105363. /**
  105364. * Gets a transform node using a given name
  105365. * @param name defines the name to search for
  105366. * @return the found transform node or null if not found at all.
  105367. */
  105368. getTransformNodeByName(name: string): Nullable<TransformNode>;
  105369. /**
  105370. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  105371. * @param id defines the id to search for
  105372. * @return the found skeleton or null if not found at all.
  105373. */
  105374. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  105375. /**
  105376. * Gets a skeleton using a given auto generated unique id
  105377. * @param uniqueId defines the unique id to search for
  105378. * @return the found skeleton or null if not found at all.
  105379. */
  105380. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  105381. /**
  105382. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  105383. * @param id defines the id to search for
  105384. * @return the found skeleton or null if not found at all.
  105385. */
  105386. getSkeletonById(id: string): Nullable<Skeleton>;
  105387. /**
  105388. * Gets a skeleton using a given name
  105389. * @param name defines the name to search for
  105390. * @return the found skeleton or null if not found at all.
  105391. */
  105392. getSkeletonByName(name: string): Nullable<Skeleton>;
  105393. /**
  105394. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  105395. * @param id defines the id to search for
  105396. * @return the found morph target manager or null if not found at all.
  105397. */
  105398. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  105399. /**
  105400. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  105401. * @param id defines the id to search for
  105402. * @return the found morph target or null if not found at all.
  105403. */
  105404. getMorphTargetById(id: string): Nullable<MorphTarget>;
  105405. /**
  105406. * Gets a boolean indicating if the given mesh is active
  105407. * @param mesh defines the mesh to look for
  105408. * @returns true if the mesh is in the active list
  105409. */
  105410. isActiveMesh(mesh: AbstractMesh): boolean;
  105411. /**
  105412. * Return a unique id as a string which can serve as an identifier for the scene
  105413. */
  105414. readonly uid: string;
  105415. /**
  105416. * Add an externaly attached data from its key.
  105417. * This method call will fail and return false, if such key already exists.
  105418. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  105419. * @param key the unique key that identifies the data
  105420. * @param data the data object to associate to the key for this Engine instance
  105421. * @return true if no such key were already present and the data was added successfully, false otherwise
  105422. */
  105423. addExternalData<T>(key: string, data: T): boolean;
  105424. /**
  105425. * Get an externaly attached data from its key
  105426. * @param key the unique key that identifies the data
  105427. * @return the associated data, if present (can be null), or undefined if not present
  105428. */
  105429. getExternalData<T>(key: string): Nullable<T>;
  105430. /**
  105431. * Get an externaly attached data from its key, create it using a factory if it's not already present
  105432. * @param key the unique key that identifies the data
  105433. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  105434. * @return the associated data, can be null if the factory returned null.
  105435. */
  105436. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  105437. /**
  105438. * Remove an externaly attached data from the Engine instance
  105439. * @param key the unique key that identifies the data
  105440. * @return true if the data was successfully removed, false if it doesn't exist
  105441. */
  105442. removeExternalData(key: string): boolean;
  105443. private _evaluateSubMesh;
  105444. /**
  105445. * Clear the processed materials smart array preventing retention point in material dispose.
  105446. */
  105447. freeProcessedMaterials(): void;
  105448. private _preventFreeActiveMeshesAndRenderingGroups;
  105449. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  105450. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  105451. * when disposing several meshes in a row or a hierarchy of meshes.
  105452. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  105453. */
  105454. blockfreeActiveMeshesAndRenderingGroups: boolean;
  105455. /**
  105456. * Clear the active meshes smart array preventing retention point in mesh dispose.
  105457. */
  105458. freeActiveMeshes(): void;
  105459. /**
  105460. * Clear the info related to rendering groups preventing retention points during dispose.
  105461. */
  105462. freeRenderingGroups(): void;
  105463. /** @hidden */
  105464. _isInIntermediateRendering(): boolean;
  105465. /**
  105466. * Lambda returning the list of potentially active meshes.
  105467. */
  105468. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  105469. /**
  105470. * Lambda returning the list of potentially active sub meshes.
  105471. */
  105472. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  105473. /**
  105474. * Lambda returning the list of potentially intersecting sub meshes.
  105475. */
  105476. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  105477. /**
  105478. * Lambda returning the list of potentially colliding sub meshes.
  105479. */
  105480. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  105481. private _activeMeshesFrozen;
  105482. private _skipEvaluateActiveMeshesCompletely;
  105483. /**
  105484. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  105485. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  105486. * @returns the current scene
  105487. */
  105488. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  105489. /**
  105490. * Use this function to restart evaluating active meshes on every frame
  105491. * @returns the current scene
  105492. */
  105493. unfreezeActiveMeshes(): Scene;
  105494. private _evaluateActiveMeshes;
  105495. private _activeMesh;
  105496. /**
  105497. * Update the transform matrix to update from the current active camera
  105498. * @param force defines a boolean used to force the update even if cache is up to date
  105499. */
  105500. updateTransformMatrix(force?: boolean): void;
  105501. private _bindFrameBuffer;
  105502. /** @hidden */
  105503. _allowPostProcessClearColor: boolean;
  105504. /** @hidden */
  105505. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  105506. private _processSubCameras;
  105507. private _checkIntersections;
  105508. /** @hidden */
  105509. _advancePhysicsEngineStep(step: number): void;
  105510. /**
  105511. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  105512. */
  105513. getDeterministicFrameTime: () => number;
  105514. /** @hidden */
  105515. _animate(): void;
  105516. /** Execute all animations (for a frame) */
  105517. animate(): void;
  105518. /**
  105519. * Render the scene
  105520. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  105521. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  105522. */
  105523. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  105524. /**
  105525. * Freeze all materials
  105526. * A frozen material will not be updatable but should be faster to render
  105527. */
  105528. freezeMaterials(): void;
  105529. /**
  105530. * Unfreeze all materials
  105531. * A frozen material will not be updatable but should be faster to render
  105532. */
  105533. unfreezeMaterials(): void;
  105534. /**
  105535. * Releases all held ressources
  105536. */
  105537. dispose(): void;
  105538. /**
  105539. * Gets if the scene is already disposed
  105540. */
  105541. readonly isDisposed: boolean;
  105542. /**
  105543. * Call this function to reduce memory footprint of the scene.
  105544. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  105545. */
  105546. clearCachedVertexData(): void;
  105547. /**
  105548. * This function will remove the local cached buffer data from texture.
  105549. * It will save memory but will prevent the texture from being rebuilt
  105550. */
  105551. cleanCachedTextureBuffer(): void;
  105552. /**
  105553. * Get the world extend vectors with an optional filter
  105554. *
  105555. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  105556. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  105557. */
  105558. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  105559. min: Vector3;
  105560. max: Vector3;
  105561. };
  105562. /**
  105563. * Creates a ray that can be used to pick in the scene
  105564. * @param x defines the x coordinate of the origin (on-screen)
  105565. * @param y defines the y coordinate of the origin (on-screen)
  105566. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  105567. * @param camera defines the camera to use for the picking
  105568. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  105569. * @returns a Ray
  105570. */
  105571. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  105572. /**
  105573. * Creates a ray that can be used to pick in the scene
  105574. * @param x defines the x coordinate of the origin (on-screen)
  105575. * @param y defines the y coordinate of the origin (on-screen)
  105576. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  105577. * @param result defines the ray where to store the picking ray
  105578. * @param camera defines the camera to use for the picking
  105579. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  105580. * @returns the current scene
  105581. */
  105582. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  105583. /**
  105584. * Creates a ray that can be used to pick in the scene
  105585. * @param x defines the x coordinate of the origin (on-screen)
  105586. * @param y defines the y coordinate of the origin (on-screen)
  105587. * @param camera defines the camera to use for the picking
  105588. * @returns a Ray
  105589. */
  105590. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  105591. /**
  105592. * Creates a ray that can be used to pick in the scene
  105593. * @param x defines the x coordinate of the origin (on-screen)
  105594. * @param y defines the y coordinate of the origin (on-screen)
  105595. * @param result defines the ray where to store the picking ray
  105596. * @param camera defines the camera to use for the picking
  105597. * @returns the current scene
  105598. */
  105599. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  105600. /** Launch a ray to try to pick a mesh in the scene
  105601. * @param x position on screen
  105602. * @param y position on screen
  105603. * @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
  105604. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  105605. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  105606. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105607. * @returns a PickingInfo
  105608. */
  105609. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  105610. /** Use the given ray to pick a mesh in the scene
  105611. * @param ray The ray to use to pick meshes
  105612. * @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
  105613. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  105614. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105615. * @returns a PickingInfo
  105616. */
  105617. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  105618. /**
  105619. * Launch a ray to try to pick a mesh in the scene
  105620. * @param x X position on screen
  105621. * @param y Y position on screen
  105622. * @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
  105623. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  105624. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105625. * @returns an array of PickingInfo
  105626. */
  105627. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  105628. /**
  105629. * Launch a ray to try to pick a mesh in the scene
  105630. * @param ray Ray to use
  105631. * @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
  105632. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105633. * @returns an array of PickingInfo
  105634. */
  105635. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  105636. /**
  105637. * Force the value of meshUnderPointer
  105638. * @param mesh defines the mesh to use
  105639. */
  105640. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  105641. /**
  105642. * Gets the mesh under the pointer
  105643. * @returns a Mesh or null if no mesh is under the pointer
  105644. */
  105645. getPointerOverMesh(): Nullable<AbstractMesh>;
  105646. /** @hidden */
  105647. _rebuildGeometries(): void;
  105648. /** @hidden */
  105649. _rebuildTextures(): void;
  105650. private _getByTags;
  105651. /**
  105652. * Get a list of meshes by tags
  105653. * @param tagsQuery defines the tags query to use
  105654. * @param forEach defines a predicate used to filter results
  105655. * @returns an array of Mesh
  105656. */
  105657. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  105658. /**
  105659. * Get a list of cameras by tags
  105660. * @param tagsQuery defines the tags query to use
  105661. * @param forEach defines a predicate used to filter results
  105662. * @returns an array of Camera
  105663. */
  105664. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  105665. /**
  105666. * Get a list of lights by tags
  105667. * @param tagsQuery defines the tags query to use
  105668. * @param forEach defines a predicate used to filter results
  105669. * @returns an array of Light
  105670. */
  105671. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  105672. /**
  105673. * Get a list of materials by tags
  105674. * @param tagsQuery defines the tags query to use
  105675. * @param forEach defines a predicate used to filter results
  105676. * @returns an array of Material
  105677. */
  105678. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  105679. /**
  105680. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  105681. * This allowed control for front to back rendering or reversly depending of the special needs.
  105682. *
  105683. * @param renderingGroupId The rendering group id corresponding to its index
  105684. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  105685. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  105686. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  105687. */
  105688. 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;
  105689. /**
  105690. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  105691. *
  105692. * @param renderingGroupId The rendering group id corresponding to its index
  105693. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  105694. * @param depth Automatically clears depth between groups if true and autoClear is true.
  105695. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  105696. */
  105697. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  105698. /**
  105699. * Gets the current auto clear configuration for one rendering group of the rendering
  105700. * manager.
  105701. * @param index the rendering group index to get the information for
  105702. * @returns The auto clear setup for the requested rendering group
  105703. */
  105704. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  105705. private _blockMaterialDirtyMechanism;
  105706. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  105707. blockMaterialDirtyMechanism: boolean;
  105708. /**
  105709. * Will flag all materials as dirty to trigger new shader compilation
  105710. * @param flag defines the flag used to specify which material part must be marked as dirty
  105711. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  105712. */
  105713. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  105714. /** @hidden */
  105715. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  105716. /** @hidden */
  105717. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  105718. /** @hidden */
  105719. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  105720. /** @hidden */
  105721. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  105722. /** @hidden */
  105723. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  105724. /** @hidden */
  105725. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  105726. }
  105727. }
  105728. declare module BABYLON {
  105729. /**
  105730. * Set of assets to keep when moving a scene into an asset container.
  105731. */
  105732. export class KeepAssets extends AbstractScene {
  105733. }
  105734. /**
  105735. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  105736. */
  105737. export class InstantiatedEntries {
  105738. /**
  105739. * List of new root nodes (eg. nodes with no parent)
  105740. */
  105741. rootNodes: TransformNode[];
  105742. /**
  105743. * List of new skeletons
  105744. */
  105745. skeletons: Skeleton[];
  105746. /**
  105747. * List of new animation groups
  105748. */
  105749. animationGroups: AnimationGroup[];
  105750. }
  105751. /**
  105752. * Container with a set of assets that can be added or removed from a scene.
  105753. */
  105754. export class AssetContainer extends AbstractScene {
  105755. /**
  105756. * The scene the AssetContainer belongs to.
  105757. */
  105758. scene: Scene;
  105759. /**
  105760. * Instantiates an AssetContainer.
  105761. * @param scene The scene the AssetContainer belongs to.
  105762. */
  105763. constructor(scene: Scene);
  105764. /**
  105765. * Instantiate or clone all meshes and add the new ones to the scene.
  105766. * Skeletons and animation groups will all be cloned
  105767. * @param nameFunction defines an optional function used to get new names for clones
  105768. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  105769. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  105770. */
  105771. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  105772. /**
  105773. * Adds all the assets from the container to the scene.
  105774. */
  105775. addAllToScene(): void;
  105776. /**
  105777. * Removes all the assets in the container from the scene
  105778. */
  105779. removeAllFromScene(): void;
  105780. /**
  105781. * Disposes all the assets in the container
  105782. */
  105783. dispose(): void;
  105784. private _moveAssets;
  105785. /**
  105786. * Removes all the assets contained in the scene and adds them to the container.
  105787. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  105788. */
  105789. moveAllFromScene(keepAssets?: KeepAssets): void;
  105790. /**
  105791. * 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.
  105792. * @returns the root mesh
  105793. */
  105794. createRootMesh(): Mesh;
  105795. /**
  105796. * Merge animations from this asset container into a scene
  105797. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  105798. * @param animatables set of animatables to retarget to a node from the scene
  105799. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  105800. */
  105801. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  105802. }
  105803. }
  105804. declare module BABYLON {
  105805. /**
  105806. * Defines how the parser contract is defined.
  105807. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  105808. */
  105809. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  105810. /**
  105811. * Defines how the individual parser contract is defined.
  105812. * These parser can parse an individual asset
  105813. */
  105814. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  105815. /**
  105816. * Base class of the scene acting as a container for the different elements composing a scene.
  105817. * This class is dynamically extended by the different components of the scene increasing
  105818. * flexibility and reducing coupling
  105819. */
  105820. export abstract class AbstractScene {
  105821. /**
  105822. * Stores the list of available parsers in the application.
  105823. */
  105824. private static _BabylonFileParsers;
  105825. /**
  105826. * Stores the list of available individual parsers in the application.
  105827. */
  105828. private static _IndividualBabylonFileParsers;
  105829. /**
  105830. * Adds a parser in the list of available ones
  105831. * @param name Defines the name of the parser
  105832. * @param parser Defines the parser to add
  105833. */
  105834. static AddParser(name: string, parser: BabylonFileParser): void;
  105835. /**
  105836. * Gets a general parser from the list of avaialble ones
  105837. * @param name Defines the name of the parser
  105838. * @returns the requested parser or null
  105839. */
  105840. static GetParser(name: string): Nullable<BabylonFileParser>;
  105841. /**
  105842. * Adds n individual parser in the list of available ones
  105843. * @param name Defines the name of the parser
  105844. * @param parser Defines the parser to add
  105845. */
  105846. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  105847. /**
  105848. * Gets an individual parser from the list of avaialble ones
  105849. * @param name Defines the name of the parser
  105850. * @returns the requested parser or null
  105851. */
  105852. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  105853. /**
  105854. * Parser json data and populate both a scene and its associated container object
  105855. * @param jsonData Defines the data to parse
  105856. * @param scene Defines the scene to parse the data for
  105857. * @param container Defines the container attached to the parsing sequence
  105858. * @param rootUrl Defines the root url of the data
  105859. */
  105860. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  105861. /**
  105862. * Gets the list of root nodes (ie. nodes with no parent)
  105863. */
  105864. rootNodes: Node[];
  105865. /** All of the cameras added to this scene
  105866. * @see http://doc.babylonjs.com/babylon101/cameras
  105867. */
  105868. cameras: Camera[];
  105869. /**
  105870. * All of the lights added to this scene
  105871. * @see http://doc.babylonjs.com/babylon101/lights
  105872. */
  105873. lights: Light[];
  105874. /**
  105875. * All of the (abstract) meshes added to this scene
  105876. */
  105877. meshes: AbstractMesh[];
  105878. /**
  105879. * The list of skeletons added to the scene
  105880. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  105881. */
  105882. skeletons: Skeleton[];
  105883. /**
  105884. * All of the particle systems added to this scene
  105885. * @see http://doc.babylonjs.com/babylon101/particles
  105886. */
  105887. particleSystems: IParticleSystem[];
  105888. /**
  105889. * Gets a list of Animations associated with the scene
  105890. */
  105891. animations: Animation[];
  105892. /**
  105893. * All of the animation groups added to this scene
  105894. * @see http://doc.babylonjs.com/how_to/group
  105895. */
  105896. animationGroups: AnimationGroup[];
  105897. /**
  105898. * All of the multi-materials added to this scene
  105899. * @see http://doc.babylonjs.com/how_to/multi_materials
  105900. */
  105901. multiMaterials: MultiMaterial[];
  105902. /**
  105903. * All of the materials added to this scene
  105904. * In the context of a Scene, it is not supposed to be modified manually.
  105905. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  105906. * Note also that the order of the Material within the array is not significant and might change.
  105907. * @see http://doc.babylonjs.com/babylon101/materials
  105908. */
  105909. materials: Material[];
  105910. /**
  105911. * The list of morph target managers added to the scene
  105912. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  105913. */
  105914. morphTargetManagers: MorphTargetManager[];
  105915. /**
  105916. * The list of geometries used in the scene.
  105917. */
  105918. geometries: Geometry[];
  105919. /**
  105920. * All of the tranform nodes added to this scene
  105921. * In the context of a Scene, it is not supposed to be modified manually.
  105922. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  105923. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  105924. * @see http://doc.babylonjs.com/how_to/transformnode
  105925. */
  105926. transformNodes: TransformNode[];
  105927. /**
  105928. * ActionManagers available on the scene.
  105929. */
  105930. actionManagers: AbstractActionManager[];
  105931. /**
  105932. * Textures to keep.
  105933. */
  105934. textures: BaseTexture[];
  105935. /**
  105936. * Environment texture for the scene
  105937. */
  105938. environmentTexture: Nullable<BaseTexture>;
  105939. /**
  105940. * @returns all meshes, lights, cameras, transformNodes and bones
  105941. */
  105942. getNodes(): Array<Node>;
  105943. }
  105944. }
  105945. declare module BABYLON {
  105946. /**
  105947. * Interface used to define options for Sound class
  105948. */
  105949. export interface ISoundOptions {
  105950. /**
  105951. * Does the sound autoplay once loaded.
  105952. */
  105953. autoplay?: boolean;
  105954. /**
  105955. * Does the sound loop after it finishes playing once.
  105956. */
  105957. loop?: boolean;
  105958. /**
  105959. * Sound's volume
  105960. */
  105961. volume?: number;
  105962. /**
  105963. * Is it a spatial sound?
  105964. */
  105965. spatialSound?: boolean;
  105966. /**
  105967. * Maximum distance to hear that sound
  105968. */
  105969. maxDistance?: number;
  105970. /**
  105971. * Uses user defined attenuation function
  105972. */
  105973. useCustomAttenuation?: boolean;
  105974. /**
  105975. * Define the roll off factor of spatial sounds.
  105976. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105977. */
  105978. rolloffFactor?: number;
  105979. /**
  105980. * Define the reference distance the sound should be heard perfectly.
  105981. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105982. */
  105983. refDistance?: number;
  105984. /**
  105985. * Define the distance attenuation model the sound will follow.
  105986. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105987. */
  105988. distanceModel?: string;
  105989. /**
  105990. * Defines the playback speed (1 by default)
  105991. */
  105992. playbackRate?: number;
  105993. /**
  105994. * Defines if the sound is from a streaming source
  105995. */
  105996. streaming?: boolean;
  105997. /**
  105998. * Defines an optional length (in seconds) inside the sound file
  105999. */
  106000. length?: number;
  106001. /**
  106002. * Defines an optional offset (in seconds) inside the sound file
  106003. */
  106004. offset?: number;
  106005. /**
  106006. * If true, URLs will not be required to state the audio file codec to use.
  106007. */
  106008. skipCodecCheck?: boolean;
  106009. }
  106010. /**
  106011. * Defines a sound that can be played in the application.
  106012. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  106013. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106014. */
  106015. export class Sound {
  106016. /**
  106017. * The name of the sound in the scene.
  106018. */
  106019. name: string;
  106020. /**
  106021. * Does the sound autoplay once loaded.
  106022. */
  106023. autoplay: boolean;
  106024. /**
  106025. * Does the sound loop after it finishes playing once.
  106026. */
  106027. loop: boolean;
  106028. /**
  106029. * Does the sound use a custom attenuation curve to simulate the falloff
  106030. * happening when the source gets further away from the camera.
  106031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  106032. */
  106033. useCustomAttenuation: boolean;
  106034. /**
  106035. * The sound track id this sound belongs to.
  106036. */
  106037. soundTrackId: number;
  106038. /**
  106039. * Is this sound currently played.
  106040. */
  106041. isPlaying: boolean;
  106042. /**
  106043. * Is this sound currently paused.
  106044. */
  106045. isPaused: boolean;
  106046. /**
  106047. * Does this sound enables spatial sound.
  106048. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106049. */
  106050. spatialSound: boolean;
  106051. /**
  106052. * Define the reference distance the sound should be heard perfectly.
  106053. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106054. */
  106055. refDistance: number;
  106056. /**
  106057. * Define the roll off factor of spatial sounds.
  106058. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106059. */
  106060. rolloffFactor: number;
  106061. /**
  106062. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  106063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106064. */
  106065. maxDistance: number;
  106066. /**
  106067. * Define the distance attenuation model the sound will follow.
  106068. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106069. */
  106070. distanceModel: string;
  106071. /**
  106072. * @hidden
  106073. * Back Compat
  106074. **/
  106075. onended: () => any;
  106076. /**
  106077. * Observable event when the current playing sound finishes.
  106078. */
  106079. onEndedObservable: Observable<Sound>;
  106080. private _panningModel;
  106081. private _playbackRate;
  106082. private _streaming;
  106083. private _startTime;
  106084. private _startOffset;
  106085. private _position;
  106086. /** @hidden */
  106087. _positionInEmitterSpace: boolean;
  106088. private _localDirection;
  106089. private _volume;
  106090. private _isReadyToPlay;
  106091. private _isDirectional;
  106092. private _readyToPlayCallback;
  106093. private _audioBuffer;
  106094. private _soundSource;
  106095. private _streamingSource;
  106096. private _soundPanner;
  106097. private _soundGain;
  106098. private _inputAudioNode;
  106099. private _outputAudioNode;
  106100. private _coneInnerAngle;
  106101. private _coneOuterAngle;
  106102. private _coneOuterGain;
  106103. private _scene;
  106104. private _connectedTransformNode;
  106105. private _customAttenuationFunction;
  106106. private _registerFunc;
  106107. private _isOutputConnected;
  106108. private _htmlAudioElement;
  106109. private _urlType;
  106110. private _length?;
  106111. private _offset?;
  106112. /** @hidden */
  106113. static _SceneComponentInitialization: (scene: Scene) => void;
  106114. /**
  106115. * Create a sound and attach it to a scene
  106116. * @param name Name of your sound
  106117. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  106118. * @param scene defines the scene the sound belongs to
  106119. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  106120. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  106121. */
  106122. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  106123. /**
  106124. * Release the sound and its associated resources
  106125. */
  106126. dispose(): void;
  106127. /**
  106128. * Gets if the sounds is ready to be played or not.
  106129. * @returns true if ready, otherwise false
  106130. */
  106131. isReady(): boolean;
  106132. private _soundLoaded;
  106133. /**
  106134. * Sets the data of the sound from an audiobuffer
  106135. * @param audioBuffer The audioBuffer containing the data
  106136. */
  106137. setAudioBuffer(audioBuffer: AudioBuffer): void;
  106138. /**
  106139. * Updates the current sounds options such as maxdistance, loop...
  106140. * @param options A JSON object containing values named as the object properties
  106141. */
  106142. updateOptions(options: ISoundOptions): void;
  106143. private _createSpatialParameters;
  106144. private _updateSpatialParameters;
  106145. /**
  106146. * Switch the panning model to HRTF:
  106147. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  106148. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106149. */
  106150. switchPanningModelToHRTF(): void;
  106151. /**
  106152. * Switch the panning model to Equal Power:
  106153. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  106154. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106155. */
  106156. switchPanningModelToEqualPower(): void;
  106157. private _switchPanningModel;
  106158. /**
  106159. * Connect this sound to a sound track audio node like gain...
  106160. * @param soundTrackAudioNode the sound track audio node to connect to
  106161. */
  106162. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  106163. /**
  106164. * Transform this sound into a directional source
  106165. * @param coneInnerAngle Size of the inner cone in degree
  106166. * @param coneOuterAngle Size of the outer cone in degree
  106167. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  106168. */
  106169. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  106170. /**
  106171. * Gets or sets the inner angle for the directional cone.
  106172. */
  106173. /**
  106174. * Gets or sets the inner angle for the directional cone.
  106175. */
  106176. directionalConeInnerAngle: number;
  106177. /**
  106178. * Gets or sets the outer angle for the directional cone.
  106179. */
  106180. /**
  106181. * Gets or sets the outer angle for the directional cone.
  106182. */
  106183. directionalConeOuterAngle: number;
  106184. /**
  106185. * Sets the position of the emitter if spatial sound is enabled
  106186. * @param newPosition Defines the new posisiton
  106187. */
  106188. setPosition(newPosition: Vector3): void;
  106189. /**
  106190. * Sets the local direction of the emitter if spatial sound is enabled
  106191. * @param newLocalDirection Defines the new local direction
  106192. */
  106193. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  106194. private _updateDirection;
  106195. /** @hidden */
  106196. updateDistanceFromListener(): void;
  106197. /**
  106198. * Sets a new custom attenuation function for the sound.
  106199. * @param callback Defines the function used for the attenuation
  106200. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  106201. */
  106202. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  106203. /**
  106204. * Play the sound
  106205. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  106206. * @param offset (optional) Start the sound at a specific time in seconds
  106207. * @param length (optional) Sound duration (in seconds)
  106208. */
  106209. play(time?: number, offset?: number, length?: number): void;
  106210. private _onended;
  106211. /**
  106212. * Stop the sound
  106213. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  106214. */
  106215. stop(time?: number): void;
  106216. /**
  106217. * Put the sound in pause
  106218. */
  106219. pause(): void;
  106220. /**
  106221. * Sets a dedicated volume for this sounds
  106222. * @param newVolume Define the new volume of the sound
  106223. * @param time Define time for gradual change to new volume
  106224. */
  106225. setVolume(newVolume: number, time?: number): void;
  106226. /**
  106227. * Set the sound play back rate
  106228. * @param newPlaybackRate Define the playback rate the sound should be played at
  106229. */
  106230. setPlaybackRate(newPlaybackRate: number): void;
  106231. /**
  106232. * Gets the volume of the sound.
  106233. * @returns the volume of the sound
  106234. */
  106235. getVolume(): number;
  106236. /**
  106237. * Attach the sound to a dedicated mesh
  106238. * @param transformNode The transform node to connect the sound with
  106239. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  106240. */
  106241. attachToMesh(transformNode: TransformNode): void;
  106242. /**
  106243. * Detach the sound from the previously attached mesh
  106244. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  106245. */
  106246. detachFromMesh(): void;
  106247. private _onRegisterAfterWorldMatrixUpdate;
  106248. /**
  106249. * Clone the current sound in the scene.
  106250. * @returns the new sound clone
  106251. */
  106252. clone(): Nullable<Sound>;
  106253. /**
  106254. * Gets the current underlying audio buffer containing the data
  106255. * @returns the audio buffer
  106256. */
  106257. getAudioBuffer(): Nullable<AudioBuffer>;
  106258. /**
  106259. * Serializes the Sound in a JSON representation
  106260. * @returns the JSON representation of the sound
  106261. */
  106262. serialize(): any;
  106263. /**
  106264. * Parse a JSON representation of a sound to innstantiate in a given scene
  106265. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  106266. * @param scene Define the scene the new parsed sound should be created in
  106267. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  106268. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  106269. * @returns the newly parsed sound
  106270. */
  106271. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  106272. }
  106273. }
  106274. declare module BABYLON {
  106275. /**
  106276. * This defines an action helpful to play a defined sound on a triggered action.
  106277. */
  106278. export class PlaySoundAction extends Action {
  106279. private _sound;
  106280. /**
  106281. * Instantiate the action
  106282. * @param triggerOptions defines the trigger options
  106283. * @param sound defines the sound to play
  106284. * @param condition defines the trigger related conditions
  106285. */
  106286. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  106287. /** @hidden */
  106288. _prepare(): void;
  106289. /**
  106290. * Execute the action and play the sound.
  106291. */
  106292. execute(): void;
  106293. /**
  106294. * Serializes the actions and its related information.
  106295. * @param parent defines the object to serialize in
  106296. * @returns the serialized object
  106297. */
  106298. serialize(parent: any): any;
  106299. }
  106300. /**
  106301. * This defines an action helpful to stop a defined sound on a triggered action.
  106302. */
  106303. export class StopSoundAction extends Action {
  106304. private _sound;
  106305. /**
  106306. * Instantiate the action
  106307. * @param triggerOptions defines the trigger options
  106308. * @param sound defines the sound to stop
  106309. * @param condition defines the trigger related conditions
  106310. */
  106311. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  106312. /** @hidden */
  106313. _prepare(): void;
  106314. /**
  106315. * Execute the action and stop the sound.
  106316. */
  106317. execute(): void;
  106318. /**
  106319. * Serializes the actions and its related information.
  106320. * @param parent defines the object to serialize in
  106321. * @returns the serialized object
  106322. */
  106323. serialize(parent: any): any;
  106324. }
  106325. }
  106326. declare module BABYLON {
  106327. /**
  106328. * This defines an action responsible to change the value of a property
  106329. * by interpolating between its current value and the newly set one once triggered.
  106330. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  106331. */
  106332. export class InterpolateValueAction extends Action {
  106333. /**
  106334. * Defines the path of the property where the value should be interpolated
  106335. */
  106336. propertyPath: string;
  106337. /**
  106338. * Defines the target value at the end of the interpolation.
  106339. */
  106340. value: any;
  106341. /**
  106342. * Defines the time it will take for the property to interpolate to the value.
  106343. */
  106344. duration: number;
  106345. /**
  106346. * Defines if the other scene animations should be stopped when the action has been triggered
  106347. */
  106348. stopOtherAnimations?: boolean;
  106349. /**
  106350. * Defines a callback raised once the interpolation animation has been done.
  106351. */
  106352. onInterpolationDone?: () => void;
  106353. /**
  106354. * Observable triggered once the interpolation animation has been done.
  106355. */
  106356. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  106357. private _target;
  106358. private _effectiveTarget;
  106359. private _property;
  106360. /**
  106361. * Instantiate the action
  106362. * @param triggerOptions defines the trigger options
  106363. * @param target defines the object containing the value to interpolate
  106364. * @param propertyPath defines the path to the property in the target object
  106365. * @param value defines the target value at the end of the interpolation
  106366. * @param duration deines the time it will take for the property to interpolate to the value.
  106367. * @param condition defines the trigger related conditions
  106368. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  106369. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  106370. */
  106371. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  106372. /** @hidden */
  106373. _prepare(): void;
  106374. /**
  106375. * Execute the action starts the value interpolation.
  106376. */
  106377. execute(): void;
  106378. /**
  106379. * Serializes the actions and its related information.
  106380. * @param parent defines the object to serialize in
  106381. * @returns the serialized object
  106382. */
  106383. serialize(parent: any): any;
  106384. }
  106385. }
  106386. declare module BABYLON {
  106387. /**
  106388. * Options allowed during the creation of a sound track.
  106389. */
  106390. export interface ISoundTrackOptions {
  106391. /**
  106392. * The volume the sound track should take during creation
  106393. */
  106394. volume?: number;
  106395. /**
  106396. * Define if the sound track is the main sound track of the scene
  106397. */
  106398. mainTrack?: boolean;
  106399. }
  106400. /**
  106401. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  106402. * It will be also used in a future release to apply effects on a specific track.
  106403. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  106404. */
  106405. export class SoundTrack {
  106406. /**
  106407. * The unique identifier of the sound track in the scene.
  106408. */
  106409. id: number;
  106410. /**
  106411. * The list of sounds included in the sound track.
  106412. */
  106413. soundCollection: Array<Sound>;
  106414. private _outputAudioNode;
  106415. private _scene;
  106416. private _connectedAnalyser;
  106417. private _options;
  106418. private _isInitialized;
  106419. /**
  106420. * Creates a new sound track.
  106421. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  106422. * @param scene Define the scene the sound track belongs to
  106423. * @param options
  106424. */
  106425. constructor(scene: Scene, options?: ISoundTrackOptions);
  106426. private _initializeSoundTrackAudioGraph;
  106427. /**
  106428. * Release the sound track and its associated resources
  106429. */
  106430. dispose(): void;
  106431. /**
  106432. * Adds a sound to this sound track
  106433. * @param sound define the cound to add
  106434. * @ignoreNaming
  106435. */
  106436. AddSound(sound: Sound): void;
  106437. /**
  106438. * Removes a sound to this sound track
  106439. * @param sound define the cound to remove
  106440. * @ignoreNaming
  106441. */
  106442. RemoveSound(sound: Sound): void;
  106443. /**
  106444. * Set a global volume for the full sound track.
  106445. * @param newVolume Define the new volume of the sound track
  106446. */
  106447. setVolume(newVolume: number): void;
  106448. /**
  106449. * Switch the panning model to HRTF:
  106450. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  106451. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106452. */
  106453. switchPanningModelToHRTF(): void;
  106454. /**
  106455. * Switch the panning model to Equal Power:
  106456. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  106457. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106458. */
  106459. switchPanningModelToEqualPower(): void;
  106460. /**
  106461. * Connect the sound track to an audio analyser allowing some amazing
  106462. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  106463. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  106464. * @param analyser The analyser to connect to the engine
  106465. */
  106466. connectToAnalyser(analyser: Analyser): void;
  106467. }
  106468. }
  106469. declare module BABYLON {
  106470. interface AbstractScene {
  106471. /**
  106472. * The list of sounds used in the scene.
  106473. */
  106474. sounds: Nullable<Array<Sound>>;
  106475. }
  106476. interface Scene {
  106477. /**
  106478. * @hidden
  106479. * Backing field
  106480. */
  106481. _mainSoundTrack: SoundTrack;
  106482. /**
  106483. * The main sound track played by the scene.
  106484. * It cotains your primary collection of sounds.
  106485. */
  106486. mainSoundTrack: SoundTrack;
  106487. /**
  106488. * The list of sound tracks added to the scene
  106489. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106490. */
  106491. soundTracks: Nullable<Array<SoundTrack>>;
  106492. /**
  106493. * Gets a sound using a given name
  106494. * @param name defines the name to search for
  106495. * @return the found sound or null if not found at all.
  106496. */
  106497. getSoundByName(name: string): Nullable<Sound>;
  106498. /**
  106499. * Gets or sets if audio support is enabled
  106500. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106501. */
  106502. audioEnabled: boolean;
  106503. /**
  106504. * Gets or sets if audio will be output to headphones
  106505. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106506. */
  106507. headphone: boolean;
  106508. /**
  106509. * Gets or sets custom audio listener position provider
  106510. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106511. */
  106512. audioListenerPositionProvider: Nullable<() => Vector3>;
  106513. /**
  106514. * Gets or sets a refresh rate when using 3D audio positioning
  106515. */
  106516. audioPositioningRefreshRate: number;
  106517. }
  106518. /**
  106519. * Defines the sound scene component responsible to manage any sounds
  106520. * in a given scene.
  106521. */
  106522. export class AudioSceneComponent implements ISceneSerializableComponent {
  106523. /**
  106524. * The component name helpfull to identify the component in the list of scene components.
  106525. */
  106526. readonly name: string;
  106527. /**
  106528. * The scene the component belongs to.
  106529. */
  106530. scene: Scene;
  106531. private _audioEnabled;
  106532. /**
  106533. * Gets whether audio is enabled or not.
  106534. * Please use related enable/disable method to switch state.
  106535. */
  106536. readonly audioEnabled: boolean;
  106537. private _headphone;
  106538. /**
  106539. * Gets whether audio is outputing to headphone or not.
  106540. * Please use the according Switch methods to change output.
  106541. */
  106542. readonly headphone: boolean;
  106543. /**
  106544. * Gets or sets a refresh rate when using 3D audio positioning
  106545. */
  106546. audioPositioningRefreshRate: number;
  106547. private _audioListenerPositionProvider;
  106548. /**
  106549. * Gets the current audio listener position provider
  106550. */
  106551. /**
  106552. * Sets a custom listener position for all sounds in the scene
  106553. * By default, this is the position of the first active camera
  106554. */
  106555. audioListenerPositionProvider: Nullable<() => Vector3>;
  106556. /**
  106557. * Creates a new instance of the component for the given scene
  106558. * @param scene Defines the scene to register the component in
  106559. */
  106560. constructor(scene: Scene);
  106561. /**
  106562. * Registers the component in a given scene
  106563. */
  106564. register(): void;
  106565. /**
  106566. * Rebuilds the elements related to this component in case of
  106567. * context lost for instance.
  106568. */
  106569. rebuild(): void;
  106570. /**
  106571. * Serializes the component data to the specified json object
  106572. * @param serializationObject The object to serialize to
  106573. */
  106574. serialize(serializationObject: any): void;
  106575. /**
  106576. * Adds all the elements from the container to the scene
  106577. * @param container the container holding the elements
  106578. */
  106579. addFromContainer(container: AbstractScene): void;
  106580. /**
  106581. * Removes all the elements in the container from the scene
  106582. * @param container contains the elements to remove
  106583. * @param dispose if the removed element should be disposed (default: false)
  106584. */
  106585. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106586. /**
  106587. * Disposes the component and the associated ressources.
  106588. */
  106589. dispose(): void;
  106590. /**
  106591. * Disables audio in the associated scene.
  106592. */
  106593. disableAudio(): void;
  106594. /**
  106595. * Enables audio in the associated scene.
  106596. */
  106597. enableAudio(): void;
  106598. /**
  106599. * Switch audio to headphone output.
  106600. */
  106601. switchAudioModeForHeadphones(): void;
  106602. /**
  106603. * Switch audio to normal speakers.
  106604. */
  106605. switchAudioModeForNormalSpeakers(): void;
  106606. private _cachedCameraDirection;
  106607. private _cachedCameraPosition;
  106608. private _lastCheck;
  106609. private _afterRender;
  106610. }
  106611. }
  106612. declare module BABYLON {
  106613. /**
  106614. * Wraps one or more Sound objects and selects one with random weight for playback.
  106615. */
  106616. export class WeightedSound {
  106617. /** When true a Sound will be selected and played when the current playing Sound completes. */
  106618. loop: boolean;
  106619. private _coneInnerAngle;
  106620. private _coneOuterAngle;
  106621. private _volume;
  106622. /** A Sound is currently playing. */
  106623. isPlaying: boolean;
  106624. /** A Sound is currently paused. */
  106625. isPaused: boolean;
  106626. private _sounds;
  106627. private _weights;
  106628. private _currentIndex?;
  106629. /**
  106630. * Creates a new WeightedSound from the list of sounds given.
  106631. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  106632. * @param sounds Array of Sounds that will be selected from.
  106633. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  106634. */
  106635. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  106636. /**
  106637. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  106638. */
  106639. /**
  106640. * The size of cone in degress for a directional sound in which there will be no attenuation.
  106641. */
  106642. directionalConeInnerAngle: number;
  106643. /**
  106644. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  106645. * Listener angles between innerAngle and outerAngle will falloff linearly.
  106646. */
  106647. /**
  106648. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  106649. * Listener angles between innerAngle and outerAngle will falloff linearly.
  106650. */
  106651. directionalConeOuterAngle: number;
  106652. /**
  106653. * Playback volume.
  106654. */
  106655. /**
  106656. * Playback volume.
  106657. */
  106658. volume: number;
  106659. private _onended;
  106660. /**
  106661. * Suspend playback
  106662. */
  106663. pause(): void;
  106664. /**
  106665. * Stop playback
  106666. */
  106667. stop(): void;
  106668. /**
  106669. * Start playback.
  106670. * @param startOffset Position the clip head at a specific time in seconds.
  106671. */
  106672. play(startOffset?: number): void;
  106673. }
  106674. }
  106675. declare module BABYLON {
  106676. /**
  106677. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  106678. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  106679. */
  106680. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  106681. /**
  106682. * Gets the name of the behavior.
  106683. */
  106684. readonly name: string;
  106685. /**
  106686. * The easing function used by animations
  106687. */
  106688. static EasingFunction: BackEase;
  106689. /**
  106690. * The easing mode used by animations
  106691. */
  106692. static EasingMode: number;
  106693. /**
  106694. * The duration of the animation, in milliseconds
  106695. */
  106696. transitionDuration: number;
  106697. /**
  106698. * Length of the distance animated by the transition when lower radius is reached
  106699. */
  106700. lowerRadiusTransitionRange: number;
  106701. /**
  106702. * Length of the distance animated by the transition when upper radius is reached
  106703. */
  106704. upperRadiusTransitionRange: number;
  106705. private _autoTransitionRange;
  106706. /**
  106707. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  106708. */
  106709. /**
  106710. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  106711. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  106712. */
  106713. autoTransitionRange: boolean;
  106714. private _attachedCamera;
  106715. private _onAfterCheckInputsObserver;
  106716. private _onMeshTargetChangedObserver;
  106717. /**
  106718. * Initializes the behavior.
  106719. */
  106720. init(): void;
  106721. /**
  106722. * Attaches the behavior to its arc rotate camera.
  106723. * @param camera Defines the camera to attach the behavior to
  106724. */
  106725. attach(camera: ArcRotateCamera): void;
  106726. /**
  106727. * Detaches the behavior from its current arc rotate camera.
  106728. */
  106729. detach(): void;
  106730. private _radiusIsAnimating;
  106731. private _radiusBounceTransition;
  106732. private _animatables;
  106733. private _cachedWheelPrecision;
  106734. /**
  106735. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  106736. * @param radiusLimit The limit to check against.
  106737. * @return Bool to indicate if at limit.
  106738. */
  106739. private _isRadiusAtLimit;
  106740. /**
  106741. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  106742. * @param radiusDelta The delta by which to animate to. Can be negative.
  106743. */
  106744. private _applyBoundRadiusAnimation;
  106745. /**
  106746. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  106747. */
  106748. protected _clearAnimationLocks(): void;
  106749. /**
  106750. * Stops and removes all animations that have been applied to the camera
  106751. */
  106752. stopAllAnimations(): void;
  106753. }
  106754. }
  106755. declare module BABYLON {
  106756. /**
  106757. * 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.
  106758. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  106759. */
  106760. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  106761. /**
  106762. * Gets the name of the behavior.
  106763. */
  106764. readonly name: string;
  106765. private _mode;
  106766. private _radiusScale;
  106767. private _positionScale;
  106768. private _defaultElevation;
  106769. private _elevationReturnTime;
  106770. private _elevationReturnWaitTime;
  106771. private _zoomStopsAnimation;
  106772. private _framingTime;
  106773. /**
  106774. * The easing function used by animations
  106775. */
  106776. static EasingFunction: ExponentialEase;
  106777. /**
  106778. * The easing mode used by animations
  106779. */
  106780. static EasingMode: number;
  106781. /**
  106782. * Sets the current mode used by the behavior
  106783. */
  106784. /**
  106785. * Gets current mode used by the behavior.
  106786. */
  106787. mode: number;
  106788. /**
  106789. * Sets the scale applied to the radius (1 by default)
  106790. */
  106791. /**
  106792. * Gets the scale applied to the radius
  106793. */
  106794. radiusScale: number;
  106795. /**
  106796. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  106797. */
  106798. /**
  106799. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  106800. */
  106801. positionScale: number;
  106802. /**
  106803. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  106804. * behaviour is triggered, in radians.
  106805. */
  106806. /**
  106807. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  106808. * behaviour is triggered, in radians.
  106809. */
  106810. defaultElevation: number;
  106811. /**
  106812. * Sets the time (in milliseconds) taken to return to the default beta position.
  106813. * Negative value indicates camera should not return to default.
  106814. */
  106815. /**
  106816. * Gets the time (in milliseconds) taken to return to the default beta position.
  106817. * Negative value indicates camera should not return to default.
  106818. */
  106819. elevationReturnTime: number;
  106820. /**
  106821. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  106822. */
  106823. /**
  106824. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  106825. */
  106826. elevationReturnWaitTime: number;
  106827. /**
  106828. * Sets the flag that indicates if user zooming should stop animation.
  106829. */
  106830. /**
  106831. * Gets the flag that indicates if user zooming should stop animation.
  106832. */
  106833. zoomStopsAnimation: boolean;
  106834. /**
  106835. * Sets the transition time when framing the mesh, in milliseconds
  106836. */
  106837. /**
  106838. * Gets the transition time when framing the mesh, in milliseconds
  106839. */
  106840. framingTime: number;
  106841. /**
  106842. * Define if the behavior should automatically change the configured
  106843. * camera limits and sensibilities.
  106844. */
  106845. autoCorrectCameraLimitsAndSensibility: boolean;
  106846. private _onPrePointerObservableObserver;
  106847. private _onAfterCheckInputsObserver;
  106848. private _onMeshTargetChangedObserver;
  106849. private _attachedCamera;
  106850. private _isPointerDown;
  106851. private _lastInteractionTime;
  106852. /**
  106853. * Initializes the behavior.
  106854. */
  106855. init(): void;
  106856. /**
  106857. * Attaches the behavior to its arc rotate camera.
  106858. * @param camera Defines the camera to attach the behavior to
  106859. */
  106860. attach(camera: ArcRotateCamera): void;
  106861. /**
  106862. * Detaches the behavior from its current arc rotate camera.
  106863. */
  106864. detach(): void;
  106865. private _animatables;
  106866. private _betaIsAnimating;
  106867. private _betaTransition;
  106868. private _radiusTransition;
  106869. private _vectorTransition;
  106870. /**
  106871. * Targets the given mesh and updates zoom level accordingly.
  106872. * @param mesh The mesh to target.
  106873. * @param radius Optional. If a cached radius position already exists, overrides default.
  106874. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  106875. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106876. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106877. */
  106878. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106879. /**
  106880. * Targets the given mesh with its children and updates zoom level accordingly.
  106881. * @param mesh The mesh to target.
  106882. * @param radius Optional. If a cached radius position already exists, overrides default.
  106883. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  106884. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106885. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106886. */
  106887. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106888. /**
  106889. * Targets the given meshes with their children and updates zoom level accordingly.
  106890. * @param meshes The mesh to target.
  106891. * @param radius Optional. If a cached radius position already exists, overrides default.
  106892. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  106893. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106894. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106895. */
  106896. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106897. /**
  106898. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  106899. * @param minimumWorld Determines the smaller position of the bounding box extend
  106900. * @param maximumWorld Determines the bigger position of the bounding box extend
  106901. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106902. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106903. */
  106904. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106905. /**
  106906. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  106907. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  106908. * frustum width.
  106909. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  106910. * to fully enclose the mesh in the viewing frustum.
  106911. */
  106912. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  106913. /**
  106914. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  106915. * is automatically returned to its default position (expected to be above ground plane).
  106916. */
  106917. private _maintainCameraAboveGround;
  106918. /**
  106919. * Returns the frustum slope based on the canvas ratio and camera FOV
  106920. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  106921. */
  106922. private _getFrustumSlope;
  106923. /**
  106924. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  106925. */
  106926. private _clearAnimationLocks;
  106927. /**
  106928. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  106929. */
  106930. private _applyUserInteraction;
  106931. /**
  106932. * Stops and removes all animations that have been applied to the camera
  106933. */
  106934. stopAllAnimations(): void;
  106935. /**
  106936. * Gets a value indicating if the user is moving the camera
  106937. */
  106938. readonly isUserIsMoving: boolean;
  106939. /**
  106940. * The camera can move all the way towards the mesh.
  106941. */
  106942. static IgnoreBoundsSizeMode: number;
  106943. /**
  106944. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  106945. */
  106946. static FitFrustumSidesMode: number;
  106947. }
  106948. }
  106949. declare module BABYLON {
  106950. /**
  106951. * Base class for Camera Pointer Inputs.
  106952. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  106953. * for example usage.
  106954. */
  106955. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  106956. /**
  106957. * Defines the camera the input is attached to.
  106958. */
  106959. abstract camera: Camera;
  106960. /**
  106961. * Whether keyboard modifier keys are pressed at time of last mouse event.
  106962. */
  106963. protected _altKey: boolean;
  106964. protected _ctrlKey: boolean;
  106965. protected _metaKey: boolean;
  106966. protected _shiftKey: boolean;
  106967. /**
  106968. * Which mouse buttons were pressed at time of last mouse event.
  106969. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  106970. */
  106971. protected _buttonsPressed: number;
  106972. /**
  106973. * Defines the buttons associated with the input to handle camera move.
  106974. */
  106975. buttons: number[];
  106976. /**
  106977. * Attach the input controls to a specific dom element to get the input from.
  106978. * @param element Defines the element the controls should be listened from
  106979. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106980. */
  106981. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106982. /**
  106983. * Detach the current controls from the specified dom element.
  106984. * @param element Defines the element to stop listening the inputs from
  106985. */
  106986. detachControl(element: Nullable<HTMLElement>): void;
  106987. /**
  106988. * Gets the class name of the current input.
  106989. * @returns the class name
  106990. */
  106991. getClassName(): string;
  106992. /**
  106993. * Get the friendly name associated with the input class.
  106994. * @returns the input friendly name
  106995. */
  106996. getSimpleName(): string;
  106997. /**
  106998. * Called on pointer POINTERDOUBLETAP event.
  106999. * Override this method to provide functionality on POINTERDOUBLETAP event.
  107000. */
  107001. protected onDoubleTap(type: string): void;
  107002. /**
  107003. * Called on pointer POINTERMOVE event if only a single touch is active.
  107004. * Override this method to provide functionality.
  107005. */
  107006. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  107007. /**
  107008. * Called on pointer POINTERMOVE event if multiple touches are active.
  107009. * Override this method to provide functionality.
  107010. */
  107011. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  107012. /**
  107013. * Called on JS contextmenu event.
  107014. * Override this method to provide functionality.
  107015. */
  107016. protected onContextMenu(evt: PointerEvent): void;
  107017. /**
  107018. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  107019. * press.
  107020. * Override this method to provide functionality.
  107021. */
  107022. protected onButtonDown(evt: PointerEvent): void;
  107023. /**
  107024. * Called each time a new POINTERUP event occurs. Ie, for each button
  107025. * release.
  107026. * Override this method to provide functionality.
  107027. */
  107028. protected onButtonUp(evt: PointerEvent): void;
  107029. /**
  107030. * Called when window becomes inactive.
  107031. * Override this method to provide functionality.
  107032. */
  107033. protected onLostFocus(): void;
  107034. private _pointerInput;
  107035. private _observer;
  107036. private _onLostFocus;
  107037. private pointA;
  107038. private pointB;
  107039. }
  107040. }
  107041. declare module BABYLON {
  107042. /**
  107043. * Manage the pointers inputs to control an arc rotate camera.
  107044. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107045. */
  107046. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  107047. /**
  107048. * Defines the camera the input is attached to.
  107049. */
  107050. camera: ArcRotateCamera;
  107051. /**
  107052. * Gets the class name of the current input.
  107053. * @returns the class name
  107054. */
  107055. getClassName(): string;
  107056. /**
  107057. * Defines the buttons associated with the input to handle camera move.
  107058. */
  107059. buttons: number[];
  107060. /**
  107061. * Defines the pointer angular sensibility along the X axis or how fast is
  107062. * the camera rotating.
  107063. */
  107064. angularSensibilityX: number;
  107065. /**
  107066. * Defines the pointer angular sensibility along the Y axis or how fast is
  107067. * the camera rotating.
  107068. */
  107069. angularSensibilityY: number;
  107070. /**
  107071. * Defines the pointer pinch precision or how fast is the camera zooming.
  107072. */
  107073. pinchPrecision: number;
  107074. /**
  107075. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  107076. * from 0.
  107077. * It defines the percentage of current camera.radius to use as delta when
  107078. * pinch zoom is used.
  107079. */
  107080. pinchDeltaPercentage: number;
  107081. /**
  107082. * Defines the pointer panning sensibility or how fast is the camera moving.
  107083. */
  107084. panningSensibility: number;
  107085. /**
  107086. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  107087. */
  107088. multiTouchPanning: boolean;
  107089. /**
  107090. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  107091. * zoom (pinch) through multitouch.
  107092. */
  107093. multiTouchPanAndZoom: boolean;
  107094. /**
  107095. * Revers pinch action direction.
  107096. */
  107097. pinchInwards: boolean;
  107098. private _isPanClick;
  107099. private _twoFingerActivityCount;
  107100. private _isPinching;
  107101. /**
  107102. * Called on pointer POINTERMOVE event if only a single touch is active.
  107103. */
  107104. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  107105. /**
  107106. * Called on pointer POINTERDOUBLETAP event.
  107107. */
  107108. protected onDoubleTap(type: string): void;
  107109. /**
  107110. * Called on pointer POINTERMOVE event if multiple touches are active.
  107111. */
  107112. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  107113. /**
  107114. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  107115. * press.
  107116. */
  107117. protected onButtonDown(evt: PointerEvent): void;
  107118. /**
  107119. * Called each time a new POINTERUP event occurs. Ie, for each button
  107120. * release.
  107121. */
  107122. protected onButtonUp(evt: PointerEvent): void;
  107123. /**
  107124. * Called when window becomes inactive.
  107125. */
  107126. protected onLostFocus(): void;
  107127. }
  107128. }
  107129. declare module BABYLON {
  107130. /**
  107131. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  107132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107133. */
  107134. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  107135. /**
  107136. * Defines the camera the input is attached to.
  107137. */
  107138. camera: ArcRotateCamera;
  107139. /**
  107140. * Defines the list of key codes associated with the up action (increase alpha)
  107141. */
  107142. keysUp: number[];
  107143. /**
  107144. * Defines the list of key codes associated with the down action (decrease alpha)
  107145. */
  107146. keysDown: number[];
  107147. /**
  107148. * Defines the list of key codes associated with the left action (increase beta)
  107149. */
  107150. keysLeft: number[];
  107151. /**
  107152. * Defines the list of key codes associated with the right action (decrease beta)
  107153. */
  107154. keysRight: number[];
  107155. /**
  107156. * Defines the list of key codes associated with the reset action.
  107157. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  107158. */
  107159. keysReset: number[];
  107160. /**
  107161. * Defines the panning sensibility of the inputs.
  107162. * (How fast is the camera paning)
  107163. */
  107164. panningSensibility: number;
  107165. /**
  107166. * Defines the zooming sensibility of the inputs.
  107167. * (How fast is the camera zooming)
  107168. */
  107169. zoomingSensibility: number;
  107170. /**
  107171. * Defines wether maintaining the alt key down switch the movement mode from
  107172. * orientation to zoom.
  107173. */
  107174. useAltToZoom: boolean;
  107175. /**
  107176. * Rotation speed of the camera
  107177. */
  107178. angularSpeed: number;
  107179. private _keys;
  107180. private _ctrlPressed;
  107181. private _altPressed;
  107182. private _onCanvasBlurObserver;
  107183. private _onKeyboardObserver;
  107184. private _engine;
  107185. private _scene;
  107186. /**
  107187. * Attach the input controls to a specific dom element to get the input from.
  107188. * @param element Defines the element the controls should be listened from
  107189. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107190. */
  107191. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107192. /**
  107193. * Detach the current controls from the specified dom element.
  107194. * @param element Defines the element to stop listening the inputs from
  107195. */
  107196. detachControl(element: Nullable<HTMLElement>): void;
  107197. /**
  107198. * Update the current camera state depending on the inputs that have been used this frame.
  107199. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107200. */
  107201. checkInputs(): void;
  107202. /**
  107203. * Gets the class name of the current intput.
  107204. * @returns the class name
  107205. */
  107206. getClassName(): string;
  107207. /**
  107208. * Get the friendly name associated with the input class.
  107209. * @returns the input friendly name
  107210. */
  107211. getSimpleName(): string;
  107212. }
  107213. }
  107214. declare module BABYLON {
  107215. /**
  107216. * Manage the mouse wheel inputs to control an arc rotate camera.
  107217. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107218. */
  107219. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  107220. /**
  107221. * Defines the camera the input is attached to.
  107222. */
  107223. camera: ArcRotateCamera;
  107224. /**
  107225. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  107226. */
  107227. wheelPrecision: number;
  107228. /**
  107229. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  107230. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  107231. */
  107232. wheelDeltaPercentage: number;
  107233. private _wheel;
  107234. private _observer;
  107235. private computeDeltaFromMouseWheelLegacyEvent;
  107236. /**
  107237. * Attach the input controls to a specific dom element to get the input from.
  107238. * @param element Defines the element the controls should be listened from
  107239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107240. */
  107241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107242. /**
  107243. * Detach the current controls from the specified dom element.
  107244. * @param element Defines the element to stop listening the inputs from
  107245. */
  107246. detachControl(element: Nullable<HTMLElement>): void;
  107247. /**
  107248. * Gets the class name of the current intput.
  107249. * @returns the class name
  107250. */
  107251. getClassName(): string;
  107252. /**
  107253. * Get the friendly name associated with the input class.
  107254. * @returns the input friendly name
  107255. */
  107256. getSimpleName(): string;
  107257. }
  107258. }
  107259. declare module BABYLON {
  107260. /**
  107261. * Default Inputs manager for the ArcRotateCamera.
  107262. * It groups all the default supported inputs for ease of use.
  107263. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107264. */
  107265. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  107266. /**
  107267. * Instantiates a new ArcRotateCameraInputsManager.
  107268. * @param camera Defines the camera the inputs belong to
  107269. */
  107270. constructor(camera: ArcRotateCamera);
  107271. /**
  107272. * Add mouse wheel input support to the input manager.
  107273. * @returns the current input manager
  107274. */
  107275. addMouseWheel(): ArcRotateCameraInputsManager;
  107276. /**
  107277. * Add pointers input support to the input manager.
  107278. * @returns the current input manager
  107279. */
  107280. addPointers(): ArcRotateCameraInputsManager;
  107281. /**
  107282. * Add keyboard input support to the input manager.
  107283. * @returns the current input manager
  107284. */
  107285. addKeyboard(): ArcRotateCameraInputsManager;
  107286. }
  107287. }
  107288. declare module BABYLON {
  107289. /**
  107290. * This represents an orbital type of camera.
  107291. *
  107292. * 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.
  107293. * 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.
  107294. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  107295. */
  107296. export class ArcRotateCamera extends TargetCamera {
  107297. /**
  107298. * Defines the rotation angle of the camera along the longitudinal axis.
  107299. */
  107300. alpha: number;
  107301. /**
  107302. * Defines the rotation angle of the camera along the latitudinal axis.
  107303. */
  107304. beta: number;
  107305. /**
  107306. * Defines the radius of the camera from it s target point.
  107307. */
  107308. radius: number;
  107309. protected _target: Vector3;
  107310. protected _targetHost: Nullable<AbstractMesh>;
  107311. /**
  107312. * Defines the target point of the camera.
  107313. * The camera looks towards it form the radius distance.
  107314. */
  107315. target: Vector3;
  107316. /**
  107317. * Define the current local position of the camera in the scene
  107318. */
  107319. position: Vector3;
  107320. protected _upVector: Vector3;
  107321. protected _upToYMatrix: Matrix;
  107322. protected _YToUpMatrix: Matrix;
  107323. /**
  107324. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  107325. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  107326. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  107327. */
  107328. upVector: Vector3;
  107329. /**
  107330. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  107331. */
  107332. setMatUp(): void;
  107333. /**
  107334. * Current inertia value on the longitudinal axis.
  107335. * The bigger this number the longer it will take for the camera to stop.
  107336. */
  107337. inertialAlphaOffset: number;
  107338. /**
  107339. * Current inertia value on the latitudinal axis.
  107340. * The bigger this number the longer it will take for the camera to stop.
  107341. */
  107342. inertialBetaOffset: number;
  107343. /**
  107344. * Current inertia value on the radius axis.
  107345. * The bigger this number the longer it will take for the camera to stop.
  107346. */
  107347. inertialRadiusOffset: number;
  107348. /**
  107349. * Minimum allowed angle on the longitudinal axis.
  107350. * This can help limiting how the Camera is able to move in the scene.
  107351. */
  107352. lowerAlphaLimit: Nullable<number>;
  107353. /**
  107354. * Maximum allowed angle on the longitudinal axis.
  107355. * This can help limiting how the Camera is able to move in the scene.
  107356. */
  107357. upperAlphaLimit: Nullable<number>;
  107358. /**
  107359. * Minimum allowed angle on the latitudinal axis.
  107360. * This can help limiting how the Camera is able to move in the scene.
  107361. */
  107362. lowerBetaLimit: number;
  107363. /**
  107364. * Maximum allowed angle on the latitudinal axis.
  107365. * This can help limiting how the Camera is able to move in the scene.
  107366. */
  107367. upperBetaLimit: number;
  107368. /**
  107369. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  107370. * This can help limiting how the Camera is able to move in the scene.
  107371. */
  107372. lowerRadiusLimit: Nullable<number>;
  107373. /**
  107374. * Maximum allowed distance of the camera to the target (The camera can not get further).
  107375. * This can help limiting how the Camera is able to move in the scene.
  107376. */
  107377. upperRadiusLimit: Nullable<number>;
  107378. /**
  107379. * Defines the current inertia value used during panning of the camera along the X axis.
  107380. */
  107381. inertialPanningX: number;
  107382. /**
  107383. * Defines the current inertia value used during panning of the camera along the Y axis.
  107384. */
  107385. inertialPanningY: number;
  107386. /**
  107387. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  107388. * Basically if your fingers moves away from more than this distance you will be considered
  107389. * in pinch mode.
  107390. */
  107391. pinchToPanMaxDistance: number;
  107392. /**
  107393. * Defines the maximum distance the camera can pan.
  107394. * This could help keeping the cammera always in your scene.
  107395. */
  107396. panningDistanceLimit: Nullable<number>;
  107397. /**
  107398. * Defines the target of the camera before paning.
  107399. */
  107400. panningOriginTarget: Vector3;
  107401. /**
  107402. * Defines the value of the inertia used during panning.
  107403. * 0 would mean stop inertia and one would mean no decelleration at all.
  107404. */
  107405. panningInertia: number;
  107406. /**
  107407. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  107408. */
  107409. angularSensibilityX: number;
  107410. /**
  107411. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  107412. */
  107413. angularSensibilityY: number;
  107414. /**
  107415. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  107416. */
  107417. pinchPrecision: number;
  107418. /**
  107419. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  107420. * It will be used instead of pinchDeltaPrecision if different from 0.
  107421. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  107422. */
  107423. pinchDeltaPercentage: number;
  107424. /**
  107425. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  107426. */
  107427. panningSensibility: number;
  107428. /**
  107429. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  107430. */
  107431. keysUp: number[];
  107432. /**
  107433. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  107434. */
  107435. keysDown: number[];
  107436. /**
  107437. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  107438. */
  107439. keysLeft: number[];
  107440. /**
  107441. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  107442. */
  107443. keysRight: number[];
  107444. /**
  107445. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  107446. */
  107447. wheelPrecision: number;
  107448. /**
  107449. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  107450. * It will be used instead of pinchDeltaPrecision if different from 0.
  107451. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  107452. */
  107453. wheelDeltaPercentage: number;
  107454. /**
  107455. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  107456. */
  107457. zoomOnFactor: number;
  107458. /**
  107459. * Defines a screen offset for the camera position.
  107460. */
  107461. targetScreenOffset: Vector2;
  107462. /**
  107463. * Allows the camera to be completely reversed.
  107464. * If false the camera can not arrive upside down.
  107465. */
  107466. allowUpsideDown: boolean;
  107467. /**
  107468. * Define if double tap/click is used to restore the previously saved state of the camera.
  107469. */
  107470. useInputToRestoreState: boolean;
  107471. /** @hidden */
  107472. _viewMatrix: Matrix;
  107473. /** @hidden */
  107474. _useCtrlForPanning: boolean;
  107475. /** @hidden */
  107476. _panningMouseButton: number;
  107477. /**
  107478. * Defines the input associated to the camera.
  107479. */
  107480. inputs: ArcRotateCameraInputsManager;
  107481. /** @hidden */
  107482. _reset: () => void;
  107483. /**
  107484. * Defines the allowed panning axis.
  107485. */
  107486. panningAxis: Vector3;
  107487. protected _localDirection: Vector3;
  107488. protected _transformedDirection: Vector3;
  107489. private _bouncingBehavior;
  107490. /**
  107491. * Gets the bouncing behavior of the camera if it has been enabled.
  107492. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  107493. */
  107494. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  107495. /**
  107496. * Defines if the bouncing behavior of the camera is enabled on the camera.
  107497. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  107498. */
  107499. useBouncingBehavior: boolean;
  107500. private _framingBehavior;
  107501. /**
  107502. * Gets the framing behavior of the camera if it has been enabled.
  107503. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  107504. */
  107505. readonly framingBehavior: Nullable<FramingBehavior>;
  107506. /**
  107507. * Defines if the framing behavior of the camera is enabled on the camera.
  107508. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  107509. */
  107510. useFramingBehavior: boolean;
  107511. private _autoRotationBehavior;
  107512. /**
  107513. * Gets the auto rotation behavior of the camera if it has been enabled.
  107514. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  107515. */
  107516. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  107517. /**
  107518. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  107519. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  107520. */
  107521. useAutoRotationBehavior: boolean;
  107522. /**
  107523. * Observable triggered when the mesh target has been changed on the camera.
  107524. */
  107525. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  107526. /**
  107527. * Event raised when the camera is colliding with a mesh.
  107528. */
  107529. onCollide: (collidedMesh: AbstractMesh) => void;
  107530. /**
  107531. * Defines whether the camera should check collision with the objects oh the scene.
  107532. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  107533. */
  107534. checkCollisions: boolean;
  107535. /**
  107536. * Defines the collision radius of the camera.
  107537. * This simulates a sphere around the camera.
  107538. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  107539. */
  107540. collisionRadius: Vector3;
  107541. protected _collider: Collider;
  107542. protected _previousPosition: Vector3;
  107543. protected _collisionVelocity: Vector3;
  107544. protected _newPosition: Vector3;
  107545. protected _previousAlpha: number;
  107546. protected _previousBeta: number;
  107547. protected _previousRadius: number;
  107548. protected _collisionTriggered: boolean;
  107549. protected _targetBoundingCenter: Nullable<Vector3>;
  107550. private _computationVector;
  107551. /**
  107552. * Instantiates a new ArcRotateCamera in a given scene
  107553. * @param name Defines the name of the camera
  107554. * @param alpha Defines the camera rotation along the logitudinal axis
  107555. * @param beta Defines the camera rotation along the latitudinal axis
  107556. * @param radius Defines the camera distance from its target
  107557. * @param target Defines the camera target
  107558. * @param scene Defines the scene the camera belongs to
  107559. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  107560. */
  107561. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  107562. /** @hidden */
  107563. _initCache(): void;
  107564. /** @hidden */
  107565. _updateCache(ignoreParentClass?: boolean): void;
  107566. protected _getTargetPosition(): Vector3;
  107567. private _storedAlpha;
  107568. private _storedBeta;
  107569. private _storedRadius;
  107570. private _storedTarget;
  107571. private _storedTargetScreenOffset;
  107572. /**
  107573. * Stores the current state of the camera (alpha, beta, radius and target)
  107574. * @returns the camera itself
  107575. */
  107576. storeState(): Camera;
  107577. /**
  107578. * @hidden
  107579. * Restored camera state. You must call storeState() first
  107580. */
  107581. _restoreStateValues(): boolean;
  107582. /** @hidden */
  107583. _isSynchronizedViewMatrix(): boolean;
  107584. /**
  107585. * Attached controls to the current camera.
  107586. * @param element Defines the element the controls should be listened from
  107587. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107588. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  107589. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  107590. */
  107591. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  107592. /**
  107593. * Detach the current controls from the camera.
  107594. * The camera will stop reacting to inputs.
  107595. * @param element Defines the element to stop listening the inputs from
  107596. */
  107597. detachControl(element: HTMLElement): void;
  107598. /** @hidden */
  107599. _checkInputs(): void;
  107600. protected _checkLimits(): void;
  107601. /**
  107602. * Rebuilds angles (alpha, beta) and radius from the give position and target
  107603. */
  107604. rebuildAnglesAndRadius(): void;
  107605. /**
  107606. * Use a position to define the current camera related information like alpha, beta and radius
  107607. * @param position Defines the position to set the camera at
  107608. */
  107609. setPosition(position: Vector3): void;
  107610. /**
  107611. * Defines the target the camera should look at.
  107612. * This will automatically adapt alpha beta and radius to fit within the new target.
  107613. * @param target Defines the new target as a Vector or a mesh
  107614. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  107615. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  107616. */
  107617. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  107618. /** @hidden */
  107619. _getViewMatrix(): Matrix;
  107620. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  107621. /**
  107622. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  107623. * @param meshes Defines the mesh to zoom on
  107624. * @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)
  107625. */
  107626. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  107627. /**
  107628. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  107629. * The target will be changed but the radius
  107630. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  107631. * @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)
  107632. */
  107633. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  107634. min: Vector3;
  107635. max: Vector3;
  107636. distance: number;
  107637. }, doNotUpdateMaxZ?: boolean): void;
  107638. /**
  107639. * @override
  107640. * Override Camera.createRigCamera
  107641. */
  107642. createRigCamera(name: string, cameraIndex: number): Camera;
  107643. /**
  107644. * @hidden
  107645. * @override
  107646. * Override Camera._updateRigCameras
  107647. */
  107648. _updateRigCameras(): void;
  107649. /**
  107650. * Destroy the camera and release the current resources hold by it.
  107651. */
  107652. dispose(): void;
  107653. /**
  107654. * Gets the current object class name.
  107655. * @return the class name
  107656. */
  107657. getClassName(): string;
  107658. }
  107659. }
  107660. declare module BABYLON {
  107661. /**
  107662. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  107663. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  107664. */
  107665. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  107666. /**
  107667. * Gets the name of the behavior.
  107668. */
  107669. readonly name: string;
  107670. private _zoomStopsAnimation;
  107671. private _idleRotationSpeed;
  107672. private _idleRotationWaitTime;
  107673. private _idleRotationSpinupTime;
  107674. /**
  107675. * Sets the flag that indicates if user zooming should stop animation.
  107676. */
  107677. /**
  107678. * Gets the flag that indicates if user zooming should stop animation.
  107679. */
  107680. zoomStopsAnimation: boolean;
  107681. /**
  107682. * Sets the default speed at which the camera rotates around the model.
  107683. */
  107684. /**
  107685. * Gets the default speed at which the camera rotates around the model.
  107686. */
  107687. idleRotationSpeed: number;
  107688. /**
  107689. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  107690. */
  107691. /**
  107692. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  107693. */
  107694. idleRotationWaitTime: number;
  107695. /**
  107696. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  107697. */
  107698. /**
  107699. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  107700. */
  107701. idleRotationSpinupTime: number;
  107702. /**
  107703. * Gets a value indicating if the camera is currently rotating because of this behavior
  107704. */
  107705. readonly rotationInProgress: boolean;
  107706. private _onPrePointerObservableObserver;
  107707. private _onAfterCheckInputsObserver;
  107708. private _attachedCamera;
  107709. private _isPointerDown;
  107710. private _lastFrameTime;
  107711. private _lastInteractionTime;
  107712. private _cameraRotationSpeed;
  107713. /**
  107714. * Initializes the behavior.
  107715. */
  107716. init(): void;
  107717. /**
  107718. * Attaches the behavior to its arc rotate camera.
  107719. * @param camera Defines the camera to attach the behavior to
  107720. */
  107721. attach(camera: ArcRotateCamera): void;
  107722. /**
  107723. * Detaches the behavior from its current arc rotate camera.
  107724. */
  107725. detach(): void;
  107726. /**
  107727. * Returns true if user is scrolling.
  107728. * @return true if user is scrolling.
  107729. */
  107730. private _userIsZooming;
  107731. private _lastFrameRadius;
  107732. private _shouldAnimationStopForInteraction;
  107733. /**
  107734. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  107735. */
  107736. private _applyUserInteraction;
  107737. private _userIsMoving;
  107738. }
  107739. }
  107740. declare module BABYLON {
  107741. /**
  107742. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  107743. */
  107744. export class AttachToBoxBehavior implements Behavior<Mesh> {
  107745. private ui;
  107746. /**
  107747. * The name of the behavior
  107748. */
  107749. name: string;
  107750. /**
  107751. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  107752. */
  107753. distanceAwayFromFace: number;
  107754. /**
  107755. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  107756. */
  107757. distanceAwayFromBottomOfFace: number;
  107758. private _faceVectors;
  107759. private _target;
  107760. private _scene;
  107761. private _onRenderObserver;
  107762. private _tmpMatrix;
  107763. private _tmpVector;
  107764. /**
  107765. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  107766. * @param ui The transform node that should be attched to the mesh
  107767. */
  107768. constructor(ui: TransformNode);
  107769. /**
  107770. * Initializes the behavior
  107771. */
  107772. init(): void;
  107773. private _closestFace;
  107774. private _zeroVector;
  107775. private _lookAtTmpMatrix;
  107776. private _lookAtToRef;
  107777. /**
  107778. * Attaches the AttachToBoxBehavior to the passed in mesh
  107779. * @param target The mesh that the specified node will be attached to
  107780. */
  107781. attach(target: Mesh): void;
  107782. /**
  107783. * Detaches the behavior from the mesh
  107784. */
  107785. detach(): void;
  107786. }
  107787. }
  107788. declare module BABYLON {
  107789. /**
  107790. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  107791. */
  107792. export class FadeInOutBehavior implements Behavior<Mesh> {
  107793. /**
  107794. * Time in milliseconds to delay before fading in (Default: 0)
  107795. */
  107796. delay: number;
  107797. /**
  107798. * Time in milliseconds for the mesh to fade in (Default: 300)
  107799. */
  107800. fadeInTime: number;
  107801. private _millisecondsPerFrame;
  107802. private _hovered;
  107803. private _hoverValue;
  107804. private _ownerNode;
  107805. /**
  107806. * Instatiates the FadeInOutBehavior
  107807. */
  107808. constructor();
  107809. /**
  107810. * The name of the behavior
  107811. */
  107812. readonly name: string;
  107813. /**
  107814. * Initializes the behavior
  107815. */
  107816. init(): void;
  107817. /**
  107818. * Attaches the fade behavior on the passed in mesh
  107819. * @param ownerNode The mesh that will be faded in/out once attached
  107820. */
  107821. attach(ownerNode: Mesh): void;
  107822. /**
  107823. * Detaches the behavior from the mesh
  107824. */
  107825. detach(): void;
  107826. /**
  107827. * Triggers the mesh to begin fading in or out
  107828. * @param value if the object should fade in or out (true to fade in)
  107829. */
  107830. fadeIn(value: boolean): void;
  107831. private _update;
  107832. private _setAllVisibility;
  107833. }
  107834. }
  107835. declare module BABYLON {
  107836. /**
  107837. * Class containing a set of static utilities functions for managing Pivots
  107838. * @hidden
  107839. */
  107840. export class PivotTools {
  107841. private static _PivotCached;
  107842. private static _OldPivotPoint;
  107843. private static _PivotTranslation;
  107844. private static _PivotTmpVector;
  107845. /** @hidden */
  107846. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  107847. /** @hidden */
  107848. static _RestorePivotPoint(mesh: AbstractMesh): void;
  107849. }
  107850. }
  107851. declare module BABYLON {
  107852. /**
  107853. * Class containing static functions to help procedurally build meshes
  107854. */
  107855. export class PlaneBuilder {
  107856. /**
  107857. * Creates a plane mesh
  107858. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  107859. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  107860. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  107861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107862. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107864. * @param name defines the name of the mesh
  107865. * @param options defines the options used to create the mesh
  107866. * @param scene defines the hosting scene
  107867. * @returns the plane mesh
  107868. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  107869. */
  107870. static CreatePlane(name: string, options: {
  107871. size?: number;
  107872. width?: number;
  107873. height?: number;
  107874. sideOrientation?: number;
  107875. frontUVs?: Vector4;
  107876. backUVs?: Vector4;
  107877. updatable?: boolean;
  107878. sourcePlane?: Plane;
  107879. }, scene?: Nullable<Scene>): Mesh;
  107880. }
  107881. }
  107882. declare module BABYLON {
  107883. /**
  107884. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  107885. */
  107886. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  107887. private static _AnyMouseID;
  107888. /**
  107889. * Abstract mesh the behavior is set on
  107890. */
  107891. attachedNode: AbstractMesh;
  107892. private _dragPlane;
  107893. private _scene;
  107894. private _pointerObserver;
  107895. private _beforeRenderObserver;
  107896. private static _planeScene;
  107897. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  107898. /**
  107899. * 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)
  107900. */
  107901. maxDragAngle: number;
  107902. /**
  107903. * @hidden
  107904. */
  107905. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  107906. /**
  107907. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  107908. */
  107909. currentDraggingPointerID: number;
  107910. /**
  107911. * The last position where the pointer hit the drag plane in world space
  107912. */
  107913. lastDragPosition: Vector3;
  107914. /**
  107915. * If the behavior is currently in a dragging state
  107916. */
  107917. dragging: boolean;
  107918. /**
  107919. * 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)
  107920. */
  107921. dragDeltaRatio: number;
  107922. /**
  107923. * If the drag plane orientation should be updated during the dragging (Default: true)
  107924. */
  107925. updateDragPlane: boolean;
  107926. private _debugMode;
  107927. private _moving;
  107928. /**
  107929. * Fires each time the attached mesh is dragged with the pointer
  107930. * * delta between last drag position and current drag position in world space
  107931. * * dragDistance along the drag axis
  107932. * * dragPlaneNormal normal of the current drag plane used during the drag
  107933. * * dragPlanePoint in world space where the drag intersects the drag plane
  107934. */
  107935. onDragObservable: Observable<{
  107936. delta: Vector3;
  107937. dragPlanePoint: Vector3;
  107938. dragPlaneNormal: Vector3;
  107939. dragDistance: number;
  107940. pointerId: number;
  107941. }>;
  107942. /**
  107943. * Fires each time a drag begins (eg. mouse down on mesh)
  107944. */
  107945. onDragStartObservable: Observable<{
  107946. dragPlanePoint: Vector3;
  107947. pointerId: number;
  107948. }>;
  107949. /**
  107950. * Fires each time a drag ends (eg. mouse release after drag)
  107951. */
  107952. onDragEndObservable: Observable<{
  107953. dragPlanePoint: Vector3;
  107954. pointerId: number;
  107955. }>;
  107956. /**
  107957. * If the attached mesh should be moved when dragged
  107958. */
  107959. moveAttached: boolean;
  107960. /**
  107961. * If the drag behavior will react to drag events (Default: true)
  107962. */
  107963. enabled: boolean;
  107964. /**
  107965. * If pointer events should start and release the drag (Default: true)
  107966. */
  107967. startAndReleaseDragOnPointerEvents: boolean;
  107968. /**
  107969. * If camera controls should be detached during the drag
  107970. */
  107971. detachCameraControls: boolean;
  107972. /**
  107973. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  107974. */
  107975. useObjectOrienationForDragging: boolean;
  107976. private _options;
  107977. /**
  107978. * Gets the options used by the behavior
  107979. */
  107980. /**
  107981. * Sets the options used by the behavior
  107982. */
  107983. options: {
  107984. dragAxis?: Vector3;
  107985. dragPlaneNormal?: Vector3;
  107986. };
  107987. /**
  107988. * Creates a pointer drag behavior that can be attached to a mesh
  107989. * @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)
  107990. */
  107991. constructor(options?: {
  107992. dragAxis?: Vector3;
  107993. dragPlaneNormal?: Vector3;
  107994. });
  107995. /**
  107996. * Predicate to determine if it is valid to move the object to a new position when it is moved
  107997. */
  107998. validateDrag: (targetPosition: Vector3) => boolean;
  107999. /**
  108000. * The name of the behavior
  108001. */
  108002. readonly name: string;
  108003. /**
  108004. * Initializes the behavior
  108005. */
  108006. init(): void;
  108007. private _tmpVector;
  108008. private _alternatePickedPoint;
  108009. private _worldDragAxis;
  108010. private _targetPosition;
  108011. private _attachedElement;
  108012. /**
  108013. * Attaches the drag behavior the passed in mesh
  108014. * @param ownerNode The mesh that will be dragged around once attached
  108015. * @param predicate Predicate to use for pick filtering
  108016. */
  108017. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  108018. /**
  108019. * Force relase the drag action by code.
  108020. */
  108021. releaseDrag(): void;
  108022. private _startDragRay;
  108023. private _lastPointerRay;
  108024. /**
  108025. * Simulates the start of a pointer drag event on the behavior
  108026. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  108027. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  108028. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  108029. */
  108030. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  108031. private _startDrag;
  108032. private _dragDelta;
  108033. private _moveDrag;
  108034. private _pickWithRayOnDragPlane;
  108035. private _pointA;
  108036. private _pointB;
  108037. private _pointC;
  108038. private _lineA;
  108039. private _lineB;
  108040. private _localAxis;
  108041. private _lookAt;
  108042. private _updateDragPlanePosition;
  108043. /**
  108044. * Detaches the behavior from the mesh
  108045. */
  108046. detach(): void;
  108047. }
  108048. }
  108049. declare module BABYLON {
  108050. /**
  108051. * A behavior that when attached to a mesh will allow the mesh to be scaled
  108052. */
  108053. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  108054. private _dragBehaviorA;
  108055. private _dragBehaviorB;
  108056. private _startDistance;
  108057. private _initialScale;
  108058. private _targetScale;
  108059. private _ownerNode;
  108060. private _sceneRenderObserver;
  108061. /**
  108062. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  108063. */
  108064. constructor();
  108065. /**
  108066. * The name of the behavior
  108067. */
  108068. readonly name: string;
  108069. /**
  108070. * Initializes the behavior
  108071. */
  108072. init(): void;
  108073. private _getCurrentDistance;
  108074. /**
  108075. * Attaches the scale behavior the passed in mesh
  108076. * @param ownerNode The mesh that will be scaled around once attached
  108077. */
  108078. attach(ownerNode: Mesh): void;
  108079. /**
  108080. * Detaches the behavior from the mesh
  108081. */
  108082. detach(): void;
  108083. }
  108084. }
  108085. declare module BABYLON {
  108086. /**
  108087. * 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
  108088. */
  108089. export class SixDofDragBehavior implements Behavior<Mesh> {
  108090. private static _virtualScene;
  108091. private _ownerNode;
  108092. private _sceneRenderObserver;
  108093. private _scene;
  108094. private _targetPosition;
  108095. private _virtualOriginMesh;
  108096. private _virtualDragMesh;
  108097. private _pointerObserver;
  108098. private _moving;
  108099. private _startingOrientation;
  108100. /**
  108101. * 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)
  108102. */
  108103. private zDragFactor;
  108104. /**
  108105. * If the object should rotate to face the drag origin
  108106. */
  108107. rotateDraggedObject: boolean;
  108108. /**
  108109. * If the behavior is currently in a dragging state
  108110. */
  108111. dragging: boolean;
  108112. /**
  108113. * 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)
  108114. */
  108115. dragDeltaRatio: number;
  108116. /**
  108117. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  108118. */
  108119. currentDraggingPointerID: number;
  108120. /**
  108121. * If camera controls should be detached during the drag
  108122. */
  108123. detachCameraControls: boolean;
  108124. /**
  108125. * Fires each time a drag starts
  108126. */
  108127. onDragStartObservable: Observable<{}>;
  108128. /**
  108129. * Fires each time a drag ends (eg. mouse release after drag)
  108130. */
  108131. onDragEndObservable: Observable<{}>;
  108132. /**
  108133. * 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
  108134. */
  108135. constructor();
  108136. /**
  108137. * The name of the behavior
  108138. */
  108139. readonly name: string;
  108140. /**
  108141. * Initializes the behavior
  108142. */
  108143. init(): void;
  108144. /**
  108145. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  108146. */
  108147. private readonly _pointerCamera;
  108148. /**
  108149. * Attaches the scale behavior the passed in mesh
  108150. * @param ownerNode The mesh that will be scaled around once attached
  108151. */
  108152. attach(ownerNode: Mesh): void;
  108153. /**
  108154. * Detaches the behavior from the mesh
  108155. */
  108156. detach(): void;
  108157. }
  108158. }
  108159. declare module BABYLON {
  108160. /**
  108161. * Class used to apply inverse kinematics to bones
  108162. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  108163. */
  108164. export class BoneIKController {
  108165. private static _tmpVecs;
  108166. private static _tmpQuat;
  108167. private static _tmpMats;
  108168. /**
  108169. * Gets or sets the target mesh
  108170. */
  108171. targetMesh: AbstractMesh;
  108172. /** Gets or sets the mesh used as pole */
  108173. poleTargetMesh: AbstractMesh;
  108174. /**
  108175. * Gets or sets the bone used as pole
  108176. */
  108177. poleTargetBone: Nullable<Bone>;
  108178. /**
  108179. * Gets or sets the target position
  108180. */
  108181. targetPosition: Vector3;
  108182. /**
  108183. * Gets or sets the pole target position
  108184. */
  108185. poleTargetPosition: Vector3;
  108186. /**
  108187. * Gets or sets the pole target local offset
  108188. */
  108189. poleTargetLocalOffset: Vector3;
  108190. /**
  108191. * Gets or sets the pole angle
  108192. */
  108193. poleAngle: number;
  108194. /**
  108195. * Gets or sets the mesh associated with the controller
  108196. */
  108197. mesh: AbstractMesh;
  108198. /**
  108199. * 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)
  108200. */
  108201. slerpAmount: number;
  108202. private _bone1Quat;
  108203. private _bone1Mat;
  108204. private _bone2Ang;
  108205. private _bone1;
  108206. private _bone2;
  108207. private _bone1Length;
  108208. private _bone2Length;
  108209. private _maxAngle;
  108210. private _maxReach;
  108211. private _rightHandedSystem;
  108212. private _bendAxis;
  108213. private _slerping;
  108214. private _adjustRoll;
  108215. /**
  108216. * Gets or sets maximum allowed angle
  108217. */
  108218. maxAngle: number;
  108219. /**
  108220. * Creates a new BoneIKController
  108221. * @param mesh defines the mesh to control
  108222. * @param bone defines the bone to control
  108223. * @param options defines options to set up the controller
  108224. */
  108225. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  108226. targetMesh?: AbstractMesh;
  108227. poleTargetMesh?: AbstractMesh;
  108228. poleTargetBone?: Bone;
  108229. poleTargetLocalOffset?: Vector3;
  108230. poleAngle?: number;
  108231. bendAxis?: Vector3;
  108232. maxAngle?: number;
  108233. slerpAmount?: number;
  108234. });
  108235. private _setMaxAngle;
  108236. /**
  108237. * Force the controller to update the bones
  108238. */
  108239. update(): void;
  108240. }
  108241. }
  108242. declare module BABYLON {
  108243. /**
  108244. * Class used to make a bone look toward a point in space
  108245. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  108246. */
  108247. export class BoneLookController {
  108248. private static _tmpVecs;
  108249. private static _tmpQuat;
  108250. private static _tmpMats;
  108251. /**
  108252. * The target Vector3 that the bone will look at
  108253. */
  108254. target: Vector3;
  108255. /**
  108256. * The mesh that the bone is attached to
  108257. */
  108258. mesh: AbstractMesh;
  108259. /**
  108260. * The bone that will be looking to the target
  108261. */
  108262. bone: Bone;
  108263. /**
  108264. * The up axis of the coordinate system that is used when the bone is rotated
  108265. */
  108266. upAxis: Vector3;
  108267. /**
  108268. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  108269. */
  108270. upAxisSpace: Space;
  108271. /**
  108272. * Used to make an adjustment to the yaw of the bone
  108273. */
  108274. adjustYaw: number;
  108275. /**
  108276. * Used to make an adjustment to the pitch of the bone
  108277. */
  108278. adjustPitch: number;
  108279. /**
  108280. * Used to make an adjustment to the roll of the bone
  108281. */
  108282. adjustRoll: number;
  108283. /**
  108284. * 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)
  108285. */
  108286. slerpAmount: number;
  108287. private _minYaw;
  108288. private _maxYaw;
  108289. private _minPitch;
  108290. private _maxPitch;
  108291. private _minYawSin;
  108292. private _minYawCos;
  108293. private _maxYawSin;
  108294. private _maxYawCos;
  108295. private _midYawConstraint;
  108296. private _minPitchTan;
  108297. private _maxPitchTan;
  108298. private _boneQuat;
  108299. private _slerping;
  108300. private _transformYawPitch;
  108301. private _transformYawPitchInv;
  108302. private _firstFrameSkipped;
  108303. private _yawRange;
  108304. private _fowardAxis;
  108305. /**
  108306. * Gets or sets the minimum yaw angle that the bone can look to
  108307. */
  108308. minYaw: number;
  108309. /**
  108310. * Gets or sets the maximum yaw angle that the bone can look to
  108311. */
  108312. maxYaw: number;
  108313. /**
  108314. * Gets or sets the minimum pitch angle that the bone can look to
  108315. */
  108316. minPitch: number;
  108317. /**
  108318. * Gets or sets the maximum pitch angle that the bone can look to
  108319. */
  108320. maxPitch: number;
  108321. /**
  108322. * Create a BoneLookController
  108323. * @param mesh the mesh that the bone belongs to
  108324. * @param bone the bone that will be looking to the target
  108325. * @param target the target Vector3 to look at
  108326. * @param options optional settings:
  108327. * * maxYaw: the maximum angle the bone will yaw to
  108328. * * minYaw: the minimum angle the bone will yaw to
  108329. * * maxPitch: the maximum angle the bone will pitch to
  108330. * * minPitch: the minimum angle the bone will yaw to
  108331. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  108332. * * upAxis: the up axis of the coordinate system
  108333. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  108334. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  108335. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  108336. * * adjustYaw: used to make an adjustment to the yaw of the bone
  108337. * * adjustPitch: used to make an adjustment to the pitch of the bone
  108338. * * adjustRoll: used to make an adjustment to the roll of the bone
  108339. **/
  108340. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  108341. maxYaw?: number;
  108342. minYaw?: number;
  108343. maxPitch?: number;
  108344. minPitch?: number;
  108345. slerpAmount?: number;
  108346. upAxis?: Vector3;
  108347. upAxisSpace?: Space;
  108348. yawAxis?: Vector3;
  108349. pitchAxis?: Vector3;
  108350. adjustYaw?: number;
  108351. adjustPitch?: number;
  108352. adjustRoll?: number;
  108353. });
  108354. /**
  108355. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  108356. */
  108357. update(): void;
  108358. private _getAngleDiff;
  108359. private _getAngleBetween;
  108360. private _isAngleBetween;
  108361. }
  108362. }
  108363. declare module BABYLON {
  108364. /**
  108365. * Manage the gamepad inputs to control an arc rotate camera.
  108366. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108367. */
  108368. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  108369. /**
  108370. * Defines the camera the input is attached to.
  108371. */
  108372. camera: ArcRotateCamera;
  108373. /**
  108374. * Defines the gamepad the input is gathering event from.
  108375. */
  108376. gamepad: Nullable<Gamepad>;
  108377. /**
  108378. * Defines the gamepad rotation sensiblity.
  108379. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  108380. */
  108381. gamepadRotationSensibility: number;
  108382. /**
  108383. * Defines the gamepad move sensiblity.
  108384. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  108385. */
  108386. gamepadMoveSensibility: number;
  108387. private _yAxisScale;
  108388. /**
  108389. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  108390. */
  108391. invertYAxis: boolean;
  108392. private _onGamepadConnectedObserver;
  108393. private _onGamepadDisconnectedObserver;
  108394. /**
  108395. * Attach the input controls to a specific dom element to get the input from.
  108396. * @param element Defines the element the controls should be listened from
  108397. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108398. */
  108399. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108400. /**
  108401. * Detach the current controls from the specified dom element.
  108402. * @param element Defines the element to stop listening the inputs from
  108403. */
  108404. detachControl(element: Nullable<HTMLElement>): void;
  108405. /**
  108406. * Update the current camera state depending on the inputs that have been used this frame.
  108407. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108408. */
  108409. checkInputs(): void;
  108410. /**
  108411. * Gets the class name of the current intput.
  108412. * @returns the class name
  108413. */
  108414. getClassName(): string;
  108415. /**
  108416. * Get the friendly name associated with the input class.
  108417. * @returns the input friendly name
  108418. */
  108419. getSimpleName(): string;
  108420. }
  108421. }
  108422. declare module BABYLON {
  108423. interface ArcRotateCameraInputsManager {
  108424. /**
  108425. * Add orientation input support to the input manager.
  108426. * @returns the current input manager
  108427. */
  108428. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  108429. }
  108430. /**
  108431. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  108432. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108433. */
  108434. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  108435. /**
  108436. * Defines the camera the input is attached to.
  108437. */
  108438. camera: ArcRotateCamera;
  108439. /**
  108440. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  108441. */
  108442. alphaCorrection: number;
  108443. /**
  108444. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  108445. */
  108446. gammaCorrection: number;
  108447. private _alpha;
  108448. private _gamma;
  108449. private _dirty;
  108450. private _deviceOrientationHandler;
  108451. /**
  108452. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  108453. */
  108454. constructor();
  108455. /**
  108456. * Attach the input controls to a specific dom element to get the input from.
  108457. * @param element Defines the element the controls should be listened from
  108458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108459. */
  108460. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108461. /** @hidden */
  108462. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  108463. /**
  108464. * Update the current camera state depending on the inputs that have been used this frame.
  108465. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108466. */
  108467. checkInputs(): void;
  108468. /**
  108469. * Detach the current controls from the specified dom element.
  108470. * @param element Defines the element to stop listening the inputs from
  108471. */
  108472. detachControl(element: Nullable<HTMLElement>): void;
  108473. /**
  108474. * Gets the class name of the current intput.
  108475. * @returns the class name
  108476. */
  108477. getClassName(): string;
  108478. /**
  108479. * Get the friendly name associated with the input class.
  108480. * @returns the input friendly name
  108481. */
  108482. getSimpleName(): string;
  108483. }
  108484. }
  108485. declare module BABYLON {
  108486. /**
  108487. * Listen to mouse events to control the camera.
  108488. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108489. */
  108490. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  108491. /**
  108492. * Defines the camera the input is attached to.
  108493. */
  108494. camera: FlyCamera;
  108495. /**
  108496. * Defines if touch is enabled. (Default is true.)
  108497. */
  108498. touchEnabled: boolean;
  108499. /**
  108500. * Defines the buttons associated with the input to handle camera rotation.
  108501. */
  108502. buttons: number[];
  108503. /**
  108504. * Assign buttons for Yaw control.
  108505. */
  108506. buttonsYaw: number[];
  108507. /**
  108508. * Assign buttons for Pitch control.
  108509. */
  108510. buttonsPitch: number[];
  108511. /**
  108512. * Assign buttons for Roll control.
  108513. */
  108514. buttonsRoll: number[];
  108515. /**
  108516. * Detect if any button is being pressed while mouse is moved.
  108517. * -1 = Mouse locked.
  108518. * 0 = Left button.
  108519. * 1 = Middle Button.
  108520. * 2 = Right Button.
  108521. */
  108522. activeButton: number;
  108523. /**
  108524. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  108525. * Higher values reduce its sensitivity.
  108526. */
  108527. angularSensibility: number;
  108528. private _mousemoveCallback;
  108529. private _observer;
  108530. private _rollObserver;
  108531. private previousPosition;
  108532. private noPreventDefault;
  108533. private element;
  108534. /**
  108535. * Listen to mouse events to control the camera.
  108536. * @param touchEnabled Define if touch is enabled. (Default is true.)
  108537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108538. */
  108539. constructor(touchEnabled?: boolean);
  108540. /**
  108541. * Attach the mouse control to the HTML DOM element.
  108542. * @param element Defines the element that listens to the input events.
  108543. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  108544. */
  108545. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108546. /**
  108547. * Detach the current controls from the specified dom element.
  108548. * @param element Defines the element to stop listening the inputs from
  108549. */
  108550. detachControl(element: Nullable<HTMLElement>): void;
  108551. /**
  108552. * Gets the class name of the current input.
  108553. * @returns the class name.
  108554. */
  108555. getClassName(): string;
  108556. /**
  108557. * Get the friendly name associated with the input class.
  108558. * @returns the input's friendly name.
  108559. */
  108560. getSimpleName(): string;
  108561. private _pointerInput;
  108562. private _onMouseMove;
  108563. /**
  108564. * Rotate camera by mouse offset.
  108565. */
  108566. private rotateCamera;
  108567. }
  108568. }
  108569. declare module BABYLON {
  108570. /**
  108571. * Default Inputs manager for the FlyCamera.
  108572. * It groups all the default supported inputs for ease of use.
  108573. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108574. */
  108575. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  108576. /**
  108577. * Instantiates a new FlyCameraInputsManager.
  108578. * @param camera Defines the camera the inputs belong to.
  108579. */
  108580. constructor(camera: FlyCamera);
  108581. /**
  108582. * Add keyboard input support to the input manager.
  108583. * @returns the new FlyCameraKeyboardMoveInput().
  108584. */
  108585. addKeyboard(): FlyCameraInputsManager;
  108586. /**
  108587. * Add mouse input support to the input manager.
  108588. * @param touchEnabled Enable touch screen support.
  108589. * @returns the new FlyCameraMouseInput().
  108590. */
  108591. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  108592. }
  108593. }
  108594. declare module BABYLON {
  108595. /**
  108596. * This is a flying camera, designed for 3D movement and rotation in all directions,
  108597. * such as in a 3D Space Shooter or a Flight Simulator.
  108598. */
  108599. export class FlyCamera extends TargetCamera {
  108600. /**
  108601. * Define the collision ellipsoid of the camera.
  108602. * This is helpful for simulating a camera body, like a player's body.
  108603. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  108604. */
  108605. ellipsoid: Vector3;
  108606. /**
  108607. * Define an offset for the position of the ellipsoid around the camera.
  108608. * This can be helpful if the camera is attached away from the player's body center,
  108609. * such as at its head.
  108610. */
  108611. ellipsoidOffset: Vector3;
  108612. /**
  108613. * Enable or disable collisions of the camera with the rest of the scene objects.
  108614. */
  108615. checkCollisions: boolean;
  108616. /**
  108617. * Enable or disable gravity on the camera.
  108618. */
  108619. applyGravity: boolean;
  108620. /**
  108621. * Define the current direction the camera is moving to.
  108622. */
  108623. cameraDirection: Vector3;
  108624. /**
  108625. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  108626. * This overrides and empties cameraRotation.
  108627. */
  108628. rotationQuaternion: Quaternion;
  108629. /**
  108630. * Track Roll to maintain the wanted Rolling when looking around.
  108631. */
  108632. _trackRoll: number;
  108633. /**
  108634. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  108635. */
  108636. rollCorrect: number;
  108637. /**
  108638. * Mimic a banked turn, Rolling the camera when Yawing.
  108639. * It's recommended to use rollCorrect = 10 for faster banking correction.
  108640. */
  108641. bankedTurn: boolean;
  108642. /**
  108643. * Limit in radians for how much Roll banking will add. (Default: 90°)
  108644. */
  108645. bankedTurnLimit: number;
  108646. /**
  108647. * Value of 0 disables the banked Roll.
  108648. * Value of 1 is equal to the Yaw angle in radians.
  108649. */
  108650. bankedTurnMultiplier: number;
  108651. /**
  108652. * The inputs manager loads all the input sources, such as keyboard and mouse.
  108653. */
  108654. inputs: FlyCameraInputsManager;
  108655. /**
  108656. * Gets the input sensibility for mouse input.
  108657. * Higher values reduce sensitivity.
  108658. */
  108659. /**
  108660. * Sets the input sensibility for a mouse input.
  108661. * Higher values reduce sensitivity.
  108662. */
  108663. angularSensibility: number;
  108664. /**
  108665. * Get the keys for camera movement forward.
  108666. */
  108667. /**
  108668. * Set the keys for camera movement forward.
  108669. */
  108670. keysForward: number[];
  108671. /**
  108672. * Get the keys for camera movement backward.
  108673. */
  108674. keysBackward: number[];
  108675. /**
  108676. * Get the keys for camera movement up.
  108677. */
  108678. /**
  108679. * Set the keys for camera movement up.
  108680. */
  108681. keysUp: number[];
  108682. /**
  108683. * Get the keys for camera movement down.
  108684. */
  108685. /**
  108686. * Set the keys for camera movement down.
  108687. */
  108688. keysDown: number[];
  108689. /**
  108690. * Get the keys for camera movement left.
  108691. */
  108692. /**
  108693. * Set the keys for camera movement left.
  108694. */
  108695. keysLeft: number[];
  108696. /**
  108697. * Set the keys for camera movement right.
  108698. */
  108699. /**
  108700. * Set the keys for camera movement right.
  108701. */
  108702. keysRight: number[];
  108703. /**
  108704. * Event raised when the camera collides with a mesh in the scene.
  108705. */
  108706. onCollide: (collidedMesh: AbstractMesh) => void;
  108707. private _collider;
  108708. private _needMoveForGravity;
  108709. private _oldPosition;
  108710. private _diffPosition;
  108711. private _newPosition;
  108712. /** @hidden */
  108713. _localDirection: Vector3;
  108714. /** @hidden */
  108715. _transformedDirection: Vector3;
  108716. /**
  108717. * Instantiates a FlyCamera.
  108718. * This is a flying camera, designed for 3D movement and rotation in all directions,
  108719. * such as in a 3D Space Shooter or a Flight Simulator.
  108720. * @param name Define the name of the camera in the scene.
  108721. * @param position Define the starting position of the camera in the scene.
  108722. * @param scene Define the scene the camera belongs to.
  108723. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  108724. */
  108725. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  108726. /**
  108727. * Attach a control to the HTML DOM element.
  108728. * @param element Defines the element that listens to the input events.
  108729. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  108730. */
  108731. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108732. /**
  108733. * Detach a control from the HTML DOM element.
  108734. * The camera will stop reacting to that input.
  108735. * @param element Defines the element that listens to the input events.
  108736. */
  108737. detachControl(element: HTMLElement): void;
  108738. private _collisionMask;
  108739. /**
  108740. * Get the mask that the camera ignores in collision events.
  108741. */
  108742. /**
  108743. * Set the mask that the camera ignores in collision events.
  108744. */
  108745. collisionMask: number;
  108746. /** @hidden */
  108747. _collideWithWorld(displacement: Vector3): void;
  108748. /** @hidden */
  108749. private _onCollisionPositionChange;
  108750. /** @hidden */
  108751. _checkInputs(): void;
  108752. /** @hidden */
  108753. _decideIfNeedsToMove(): boolean;
  108754. /** @hidden */
  108755. _updatePosition(): void;
  108756. /**
  108757. * Restore the Roll to its target value at the rate specified.
  108758. * @param rate - Higher means slower restoring.
  108759. * @hidden
  108760. */
  108761. restoreRoll(rate: number): void;
  108762. /**
  108763. * Destroy the camera and release the current resources held by it.
  108764. */
  108765. dispose(): void;
  108766. /**
  108767. * Get the current object class name.
  108768. * @returns the class name.
  108769. */
  108770. getClassName(): string;
  108771. }
  108772. }
  108773. declare module BABYLON {
  108774. /**
  108775. * Listen to keyboard events to control the camera.
  108776. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108777. */
  108778. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  108779. /**
  108780. * Defines the camera the input is attached to.
  108781. */
  108782. camera: FlyCamera;
  108783. /**
  108784. * The list of keyboard keys used to control the forward move of the camera.
  108785. */
  108786. keysForward: number[];
  108787. /**
  108788. * The list of keyboard keys used to control the backward move of the camera.
  108789. */
  108790. keysBackward: number[];
  108791. /**
  108792. * The list of keyboard keys used to control the forward move of the camera.
  108793. */
  108794. keysUp: number[];
  108795. /**
  108796. * The list of keyboard keys used to control the backward move of the camera.
  108797. */
  108798. keysDown: number[];
  108799. /**
  108800. * The list of keyboard keys used to control the right strafe move of the camera.
  108801. */
  108802. keysRight: number[];
  108803. /**
  108804. * The list of keyboard keys used to control the left strafe move of the camera.
  108805. */
  108806. keysLeft: number[];
  108807. private _keys;
  108808. private _onCanvasBlurObserver;
  108809. private _onKeyboardObserver;
  108810. private _engine;
  108811. private _scene;
  108812. /**
  108813. * Attach the input controls to a specific dom element to get the input from.
  108814. * @param element Defines the element the controls should be listened from
  108815. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108816. */
  108817. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108818. /**
  108819. * Detach the current controls from the specified dom element.
  108820. * @param element Defines the element to stop listening the inputs from
  108821. */
  108822. detachControl(element: Nullable<HTMLElement>): void;
  108823. /**
  108824. * Gets the class name of the current intput.
  108825. * @returns the class name
  108826. */
  108827. getClassName(): string;
  108828. /** @hidden */
  108829. _onLostFocus(e: FocusEvent): void;
  108830. /**
  108831. * Get the friendly name associated with the input class.
  108832. * @returns the input friendly name
  108833. */
  108834. getSimpleName(): string;
  108835. /**
  108836. * Update the current camera state depending on the inputs that have been used this frame.
  108837. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108838. */
  108839. checkInputs(): void;
  108840. }
  108841. }
  108842. declare module BABYLON {
  108843. /**
  108844. * Manage the mouse wheel inputs to control a follow camera.
  108845. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108846. */
  108847. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  108848. /**
  108849. * Defines the camera the input is attached to.
  108850. */
  108851. camera: FollowCamera;
  108852. /**
  108853. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  108854. */
  108855. axisControlRadius: boolean;
  108856. /**
  108857. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  108858. */
  108859. axisControlHeight: boolean;
  108860. /**
  108861. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  108862. */
  108863. axisControlRotation: boolean;
  108864. /**
  108865. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  108866. * relation to mouseWheel events.
  108867. */
  108868. wheelPrecision: number;
  108869. /**
  108870. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  108871. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  108872. */
  108873. wheelDeltaPercentage: number;
  108874. private _wheel;
  108875. private _observer;
  108876. /**
  108877. * Attach the input controls to a specific dom element to get the input from.
  108878. * @param element Defines the element the controls should be listened from
  108879. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108880. */
  108881. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108882. /**
  108883. * Detach the current controls from the specified dom element.
  108884. * @param element Defines the element to stop listening the inputs from
  108885. */
  108886. detachControl(element: Nullable<HTMLElement>): void;
  108887. /**
  108888. * Gets the class name of the current intput.
  108889. * @returns the class name
  108890. */
  108891. getClassName(): string;
  108892. /**
  108893. * Get the friendly name associated with the input class.
  108894. * @returns the input friendly name
  108895. */
  108896. getSimpleName(): string;
  108897. }
  108898. }
  108899. declare module BABYLON {
  108900. /**
  108901. * Manage the pointers inputs to control an follow camera.
  108902. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108903. */
  108904. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  108905. /**
  108906. * Defines the camera the input is attached to.
  108907. */
  108908. camera: FollowCamera;
  108909. /**
  108910. * Gets the class name of the current input.
  108911. * @returns the class name
  108912. */
  108913. getClassName(): string;
  108914. /**
  108915. * Defines the pointer angular sensibility along the X axis or how fast is
  108916. * the camera rotating.
  108917. * A negative number will reverse the axis direction.
  108918. */
  108919. angularSensibilityX: number;
  108920. /**
  108921. * Defines the pointer angular sensibility along the Y axis or how fast is
  108922. * the camera rotating.
  108923. * A negative number will reverse the axis direction.
  108924. */
  108925. angularSensibilityY: number;
  108926. /**
  108927. * Defines the pointer pinch precision or how fast is the camera zooming.
  108928. * A negative number will reverse the axis direction.
  108929. */
  108930. pinchPrecision: number;
  108931. /**
  108932. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  108933. * from 0.
  108934. * It defines the percentage of current camera.radius to use as delta when
  108935. * pinch zoom is used.
  108936. */
  108937. pinchDeltaPercentage: number;
  108938. /**
  108939. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  108940. */
  108941. axisXControlRadius: boolean;
  108942. /**
  108943. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  108944. */
  108945. axisXControlHeight: boolean;
  108946. /**
  108947. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  108948. */
  108949. axisXControlRotation: boolean;
  108950. /**
  108951. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  108952. */
  108953. axisYControlRadius: boolean;
  108954. /**
  108955. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  108956. */
  108957. axisYControlHeight: boolean;
  108958. /**
  108959. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  108960. */
  108961. axisYControlRotation: boolean;
  108962. /**
  108963. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  108964. */
  108965. axisPinchControlRadius: boolean;
  108966. /**
  108967. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  108968. */
  108969. axisPinchControlHeight: boolean;
  108970. /**
  108971. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  108972. */
  108973. axisPinchControlRotation: boolean;
  108974. /**
  108975. * Log error messages if basic misconfiguration has occurred.
  108976. */
  108977. warningEnable: boolean;
  108978. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  108979. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  108980. private _warningCounter;
  108981. private _warning;
  108982. }
  108983. }
  108984. declare module BABYLON {
  108985. /**
  108986. * Default Inputs manager for the FollowCamera.
  108987. * It groups all the default supported inputs for ease of use.
  108988. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108989. */
  108990. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  108991. /**
  108992. * Instantiates a new FollowCameraInputsManager.
  108993. * @param camera Defines the camera the inputs belong to
  108994. */
  108995. constructor(camera: FollowCamera);
  108996. /**
  108997. * Add keyboard input support to the input manager.
  108998. * @returns the current input manager
  108999. */
  109000. addKeyboard(): FollowCameraInputsManager;
  109001. /**
  109002. * Add mouse wheel input support to the input manager.
  109003. * @returns the current input manager
  109004. */
  109005. addMouseWheel(): FollowCameraInputsManager;
  109006. /**
  109007. * Add pointers input support to the input manager.
  109008. * @returns the current input manager
  109009. */
  109010. addPointers(): FollowCameraInputsManager;
  109011. /**
  109012. * Add orientation input support to the input manager.
  109013. * @returns the current input manager
  109014. */
  109015. addVRDeviceOrientation(): FollowCameraInputsManager;
  109016. }
  109017. }
  109018. declare module BABYLON {
  109019. /**
  109020. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  109021. * an arc rotate version arcFollowCamera are available.
  109022. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  109023. */
  109024. export class FollowCamera extends TargetCamera {
  109025. /**
  109026. * Distance the follow camera should follow an object at
  109027. */
  109028. radius: number;
  109029. /**
  109030. * Minimum allowed distance of the camera to the axis of rotation
  109031. * (The camera can not get closer).
  109032. * This can help limiting how the Camera is able to move in the scene.
  109033. */
  109034. lowerRadiusLimit: Nullable<number>;
  109035. /**
  109036. * Maximum allowed distance of the camera to the axis of rotation
  109037. * (The camera can not get further).
  109038. * This can help limiting how the Camera is able to move in the scene.
  109039. */
  109040. upperRadiusLimit: Nullable<number>;
  109041. /**
  109042. * Define a rotation offset between the camera and the object it follows
  109043. */
  109044. rotationOffset: number;
  109045. /**
  109046. * Minimum allowed angle to camera position relative to target object.
  109047. * This can help limiting how the Camera is able to move in the scene.
  109048. */
  109049. lowerRotationOffsetLimit: Nullable<number>;
  109050. /**
  109051. * Maximum allowed angle to camera position relative to target object.
  109052. * This can help limiting how the Camera is able to move in the scene.
  109053. */
  109054. upperRotationOffsetLimit: Nullable<number>;
  109055. /**
  109056. * Define a height offset between the camera and the object it follows.
  109057. * It can help following an object from the top (like a car chaing a plane)
  109058. */
  109059. heightOffset: number;
  109060. /**
  109061. * Minimum allowed height of camera position relative to target object.
  109062. * This can help limiting how the Camera is able to move in the scene.
  109063. */
  109064. lowerHeightOffsetLimit: Nullable<number>;
  109065. /**
  109066. * Maximum allowed height of camera position relative to target object.
  109067. * This can help limiting how the Camera is able to move in the scene.
  109068. */
  109069. upperHeightOffsetLimit: Nullable<number>;
  109070. /**
  109071. * Define how fast the camera can accelerate to follow it s target.
  109072. */
  109073. cameraAcceleration: number;
  109074. /**
  109075. * Define the speed limit of the camera following an object.
  109076. */
  109077. maxCameraSpeed: number;
  109078. /**
  109079. * Define the target of the camera.
  109080. */
  109081. lockedTarget: Nullable<AbstractMesh>;
  109082. /**
  109083. * Defines the input associated with the camera.
  109084. */
  109085. inputs: FollowCameraInputsManager;
  109086. /**
  109087. * Instantiates the follow camera.
  109088. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  109089. * @param name Define the name of the camera in the scene
  109090. * @param position Define the position of the camera
  109091. * @param scene Define the scene the camera belong to
  109092. * @param lockedTarget Define the target of the camera
  109093. */
  109094. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  109095. private _follow;
  109096. /**
  109097. * Attached controls to the current camera.
  109098. * @param element Defines the element the controls should be listened from
  109099. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109100. */
  109101. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109102. /**
  109103. * Detach the current controls from the camera.
  109104. * The camera will stop reacting to inputs.
  109105. * @param element Defines the element to stop listening the inputs from
  109106. */
  109107. detachControl(element: HTMLElement): void;
  109108. /** @hidden */
  109109. _checkInputs(): void;
  109110. private _checkLimits;
  109111. /**
  109112. * Gets the camera class name.
  109113. * @returns the class name
  109114. */
  109115. getClassName(): string;
  109116. }
  109117. /**
  109118. * Arc Rotate version of the follow camera.
  109119. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  109120. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  109121. */
  109122. export class ArcFollowCamera extends TargetCamera {
  109123. /** The longitudinal angle of the camera */
  109124. alpha: number;
  109125. /** The latitudinal angle of the camera */
  109126. beta: number;
  109127. /** The radius of the camera from its target */
  109128. radius: number;
  109129. /** Define the camera target (the messh it should follow) */
  109130. target: Nullable<AbstractMesh>;
  109131. private _cartesianCoordinates;
  109132. /**
  109133. * Instantiates a new ArcFollowCamera
  109134. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  109135. * @param name Define the name of the camera
  109136. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  109137. * @param beta Define the rotation angle of the camera around the elevation axis
  109138. * @param radius Define the radius of the camera from its target point
  109139. * @param target Define the target of the camera
  109140. * @param scene Define the scene the camera belongs to
  109141. */
  109142. constructor(name: string,
  109143. /** The longitudinal angle of the camera */
  109144. alpha: number,
  109145. /** The latitudinal angle of the camera */
  109146. beta: number,
  109147. /** The radius of the camera from its target */
  109148. radius: number,
  109149. /** Define the camera target (the messh it should follow) */
  109150. target: Nullable<AbstractMesh>, scene: Scene);
  109151. private _follow;
  109152. /** @hidden */
  109153. _checkInputs(): void;
  109154. /**
  109155. * Returns the class name of the object.
  109156. * It is mostly used internally for serialization purposes.
  109157. */
  109158. getClassName(): string;
  109159. }
  109160. }
  109161. declare module BABYLON {
  109162. /**
  109163. * Manage the keyboard inputs to control the movement of a follow camera.
  109164. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109165. */
  109166. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  109167. /**
  109168. * Defines the camera the input is attached to.
  109169. */
  109170. camera: FollowCamera;
  109171. /**
  109172. * Defines the list of key codes associated with the up action (increase heightOffset)
  109173. */
  109174. keysHeightOffsetIncr: number[];
  109175. /**
  109176. * Defines the list of key codes associated with the down action (decrease heightOffset)
  109177. */
  109178. keysHeightOffsetDecr: number[];
  109179. /**
  109180. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  109181. */
  109182. keysHeightOffsetModifierAlt: boolean;
  109183. /**
  109184. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  109185. */
  109186. keysHeightOffsetModifierCtrl: boolean;
  109187. /**
  109188. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  109189. */
  109190. keysHeightOffsetModifierShift: boolean;
  109191. /**
  109192. * Defines the list of key codes associated with the left action (increase rotationOffset)
  109193. */
  109194. keysRotationOffsetIncr: number[];
  109195. /**
  109196. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  109197. */
  109198. keysRotationOffsetDecr: number[];
  109199. /**
  109200. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  109201. */
  109202. keysRotationOffsetModifierAlt: boolean;
  109203. /**
  109204. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  109205. */
  109206. keysRotationOffsetModifierCtrl: boolean;
  109207. /**
  109208. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  109209. */
  109210. keysRotationOffsetModifierShift: boolean;
  109211. /**
  109212. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  109213. */
  109214. keysRadiusIncr: number[];
  109215. /**
  109216. * Defines the list of key codes associated with the zoom-out action (increase radius)
  109217. */
  109218. keysRadiusDecr: number[];
  109219. /**
  109220. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  109221. */
  109222. keysRadiusModifierAlt: boolean;
  109223. /**
  109224. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  109225. */
  109226. keysRadiusModifierCtrl: boolean;
  109227. /**
  109228. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  109229. */
  109230. keysRadiusModifierShift: boolean;
  109231. /**
  109232. * Defines the rate of change of heightOffset.
  109233. */
  109234. heightSensibility: number;
  109235. /**
  109236. * Defines the rate of change of rotationOffset.
  109237. */
  109238. rotationSensibility: number;
  109239. /**
  109240. * Defines the rate of change of radius.
  109241. */
  109242. radiusSensibility: number;
  109243. private _keys;
  109244. private _ctrlPressed;
  109245. private _altPressed;
  109246. private _shiftPressed;
  109247. private _onCanvasBlurObserver;
  109248. private _onKeyboardObserver;
  109249. private _engine;
  109250. private _scene;
  109251. /**
  109252. * Attach the input controls to a specific dom element to get the input from.
  109253. * @param element Defines the element the controls should be listened from
  109254. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109255. */
  109256. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109257. /**
  109258. * Detach the current controls from the specified dom element.
  109259. * @param element Defines the element to stop listening the inputs from
  109260. */
  109261. detachControl(element: Nullable<HTMLElement>): void;
  109262. /**
  109263. * Update the current camera state depending on the inputs that have been used this frame.
  109264. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109265. */
  109266. checkInputs(): void;
  109267. /**
  109268. * Gets the class name of the current input.
  109269. * @returns the class name
  109270. */
  109271. getClassName(): string;
  109272. /**
  109273. * Get the friendly name associated with the input class.
  109274. * @returns the input friendly name
  109275. */
  109276. getSimpleName(): string;
  109277. /**
  109278. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  109279. * allow modification of the heightOffset value.
  109280. */
  109281. private _modifierHeightOffset;
  109282. /**
  109283. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  109284. * allow modification of the rotationOffset value.
  109285. */
  109286. private _modifierRotationOffset;
  109287. /**
  109288. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  109289. * allow modification of the radius value.
  109290. */
  109291. private _modifierRadius;
  109292. }
  109293. }
  109294. declare module BABYLON {
  109295. interface FreeCameraInputsManager {
  109296. /**
  109297. * @hidden
  109298. */
  109299. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  109300. /**
  109301. * Add orientation input support to the input manager.
  109302. * @returns the current input manager
  109303. */
  109304. addDeviceOrientation(): FreeCameraInputsManager;
  109305. }
  109306. /**
  109307. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  109308. * Screen rotation is taken into account.
  109309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109310. */
  109311. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  109312. private _camera;
  109313. private _screenOrientationAngle;
  109314. private _constantTranform;
  109315. private _screenQuaternion;
  109316. private _alpha;
  109317. private _beta;
  109318. private _gamma;
  109319. /**
  109320. * Can be used to detect if a device orientation sensor is available on a device
  109321. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  109322. * @returns a promise that will resolve on orientation change
  109323. */
  109324. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  109325. /**
  109326. * @hidden
  109327. */
  109328. _onDeviceOrientationChangedObservable: Observable<void>;
  109329. /**
  109330. * Instantiates a new input
  109331. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109332. */
  109333. constructor();
  109334. /**
  109335. * Define the camera controlled by the input.
  109336. */
  109337. camera: FreeCamera;
  109338. /**
  109339. * Attach the input controls to a specific dom element to get the input from.
  109340. * @param element Defines the element the controls should be listened from
  109341. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109342. */
  109343. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109344. private _orientationChanged;
  109345. private _deviceOrientation;
  109346. /**
  109347. * Detach the current controls from the specified dom element.
  109348. * @param element Defines the element to stop listening the inputs from
  109349. */
  109350. detachControl(element: Nullable<HTMLElement>): void;
  109351. /**
  109352. * Update the current camera state depending on the inputs that have been used this frame.
  109353. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109354. */
  109355. checkInputs(): void;
  109356. /**
  109357. * Gets the class name of the current intput.
  109358. * @returns the class name
  109359. */
  109360. getClassName(): string;
  109361. /**
  109362. * Get the friendly name associated with the input class.
  109363. * @returns the input friendly name
  109364. */
  109365. getSimpleName(): string;
  109366. }
  109367. }
  109368. declare module BABYLON {
  109369. /**
  109370. * Manage the gamepad inputs to control a free camera.
  109371. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109372. */
  109373. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  109374. /**
  109375. * Define the camera the input is attached to.
  109376. */
  109377. camera: FreeCamera;
  109378. /**
  109379. * Define the Gamepad controlling the input
  109380. */
  109381. gamepad: Nullable<Gamepad>;
  109382. /**
  109383. * Defines the gamepad rotation sensiblity.
  109384. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  109385. */
  109386. gamepadAngularSensibility: number;
  109387. /**
  109388. * Defines the gamepad move sensiblity.
  109389. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  109390. */
  109391. gamepadMoveSensibility: number;
  109392. private _yAxisScale;
  109393. /**
  109394. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  109395. */
  109396. invertYAxis: boolean;
  109397. private _onGamepadConnectedObserver;
  109398. private _onGamepadDisconnectedObserver;
  109399. private _cameraTransform;
  109400. private _deltaTransform;
  109401. private _vector3;
  109402. private _vector2;
  109403. /**
  109404. * Attach the input controls to a specific dom element to get the input from.
  109405. * @param element Defines the element the controls should be listened from
  109406. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109407. */
  109408. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109409. /**
  109410. * Detach the current controls from the specified dom element.
  109411. * @param element Defines the element to stop listening the inputs from
  109412. */
  109413. detachControl(element: Nullable<HTMLElement>): void;
  109414. /**
  109415. * Update the current camera state depending on the inputs that have been used this frame.
  109416. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109417. */
  109418. checkInputs(): void;
  109419. /**
  109420. * Gets the class name of the current intput.
  109421. * @returns the class name
  109422. */
  109423. getClassName(): string;
  109424. /**
  109425. * Get the friendly name associated with the input class.
  109426. * @returns the input friendly name
  109427. */
  109428. getSimpleName(): string;
  109429. }
  109430. }
  109431. declare module BABYLON {
  109432. /**
  109433. * Defines the potential axis of a Joystick
  109434. */
  109435. export enum JoystickAxis {
  109436. /** X axis */
  109437. X = 0,
  109438. /** Y axis */
  109439. Y = 1,
  109440. /** Z axis */
  109441. Z = 2
  109442. }
  109443. /**
  109444. * Class used to define virtual joystick (used in touch mode)
  109445. */
  109446. export class VirtualJoystick {
  109447. /**
  109448. * Gets or sets a boolean indicating that left and right values must be inverted
  109449. */
  109450. reverseLeftRight: boolean;
  109451. /**
  109452. * Gets or sets a boolean indicating that up and down values must be inverted
  109453. */
  109454. reverseUpDown: boolean;
  109455. /**
  109456. * Gets the offset value for the position (ie. the change of the position value)
  109457. */
  109458. deltaPosition: Vector3;
  109459. /**
  109460. * Gets a boolean indicating if the virtual joystick was pressed
  109461. */
  109462. pressed: boolean;
  109463. /**
  109464. * Canvas the virtual joystick will render onto, default z-index of this is 5
  109465. */
  109466. static Canvas: Nullable<HTMLCanvasElement>;
  109467. private static _globalJoystickIndex;
  109468. private static vjCanvasContext;
  109469. private static vjCanvasWidth;
  109470. private static vjCanvasHeight;
  109471. private static halfWidth;
  109472. private _action;
  109473. private _axisTargetedByLeftAndRight;
  109474. private _axisTargetedByUpAndDown;
  109475. private _joystickSensibility;
  109476. private _inversedSensibility;
  109477. private _joystickPointerID;
  109478. private _joystickColor;
  109479. private _joystickPointerPos;
  109480. private _joystickPreviousPointerPos;
  109481. private _joystickPointerStartPos;
  109482. private _deltaJoystickVector;
  109483. private _leftJoystick;
  109484. private _touches;
  109485. private _onPointerDownHandlerRef;
  109486. private _onPointerMoveHandlerRef;
  109487. private _onPointerUpHandlerRef;
  109488. private _onResize;
  109489. /**
  109490. * Creates a new virtual joystick
  109491. * @param leftJoystick defines that the joystick is for left hand (false by default)
  109492. */
  109493. constructor(leftJoystick?: boolean);
  109494. /**
  109495. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  109496. * @param newJoystickSensibility defines the new sensibility
  109497. */
  109498. setJoystickSensibility(newJoystickSensibility: number): void;
  109499. private _onPointerDown;
  109500. private _onPointerMove;
  109501. private _onPointerUp;
  109502. /**
  109503. * Change the color of the virtual joystick
  109504. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  109505. */
  109506. setJoystickColor(newColor: string): void;
  109507. /**
  109508. * Defines a callback to call when the joystick is touched
  109509. * @param action defines the callback
  109510. */
  109511. setActionOnTouch(action: () => any): void;
  109512. /**
  109513. * Defines which axis you'd like to control for left & right
  109514. * @param axis defines the axis to use
  109515. */
  109516. setAxisForLeftRight(axis: JoystickAxis): void;
  109517. /**
  109518. * Defines which axis you'd like to control for up & down
  109519. * @param axis defines the axis to use
  109520. */
  109521. setAxisForUpDown(axis: JoystickAxis): void;
  109522. private _drawVirtualJoystick;
  109523. /**
  109524. * Release internal HTML canvas
  109525. */
  109526. releaseCanvas(): void;
  109527. }
  109528. }
  109529. declare module BABYLON {
  109530. interface FreeCameraInputsManager {
  109531. /**
  109532. * Add virtual joystick input support to the input manager.
  109533. * @returns the current input manager
  109534. */
  109535. addVirtualJoystick(): FreeCameraInputsManager;
  109536. }
  109537. /**
  109538. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  109539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109540. */
  109541. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  109542. /**
  109543. * Defines the camera the input is attached to.
  109544. */
  109545. camera: FreeCamera;
  109546. private _leftjoystick;
  109547. private _rightjoystick;
  109548. /**
  109549. * Gets the left stick of the virtual joystick.
  109550. * @returns The virtual Joystick
  109551. */
  109552. getLeftJoystick(): VirtualJoystick;
  109553. /**
  109554. * Gets the right stick of the virtual joystick.
  109555. * @returns The virtual Joystick
  109556. */
  109557. getRightJoystick(): VirtualJoystick;
  109558. /**
  109559. * Update the current camera state depending on the inputs that have been used this frame.
  109560. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109561. */
  109562. checkInputs(): void;
  109563. /**
  109564. * Attach the input controls to a specific dom element to get the input from.
  109565. * @param element Defines the element the controls should be listened from
  109566. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109567. */
  109568. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109569. /**
  109570. * Detach the current controls from the specified dom element.
  109571. * @param element Defines the element to stop listening the inputs from
  109572. */
  109573. detachControl(element: Nullable<HTMLElement>): void;
  109574. /**
  109575. * Gets the class name of the current intput.
  109576. * @returns the class name
  109577. */
  109578. getClassName(): string;
  109579. /**
  109580. * Get the friendly name associated with the input class.
  109581. * @returns the input friendly name
  109582. */
  109583. getSimpleName(): string;
  109584. }
  109585. }
  109586. declare module BABYLON {
  109587. /**
  109588. * This represents a FPS type of camera controlled by touch.
  109589. * This is like a universal camera minus the Gamepad controls.
  109590. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109591. */
  109592. export class TouchCamera extends FreeCamera {
  109593. /**
  109594. * Defines the touch sensibility for rotation.
  109595. * The higher the faster.
  109596. */
  109597. touchAngularSensibility: number;
  109598. /**
  109599. * Defines the touch sensibility for move.
  109600. * The higher the faster.
  109601. */
  109602. touchMoveSensibility: number;
  109603. /**
  109604. * Instantiates a new touch camera.
  109605. * This represents a FPS type of camera controlled by touch.
  109606. * This is like a universal camera minus the Gamepad controls.
  109607. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109608. * @param name Define the name of the camera in the scene
  109609. * @param position Define the start position of the camera in the scene
  109610. * @param scene Define the scene the camera belongs to
  109611. */
  109612. constructor(name: string, position: Vector3, scene: Scene);
  109613. /**
  109614. * Gets the current object class name.
  109615. * @return the class name
  109616. */
  109617. getClassName(): string;
  109618. /** @hidden */
  109619. _setupInputs(): void;
  109620. }
  109621. }
  109622. declare module BABYLON {
  109623. /**
  109624. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  109625. * being tilted forward or back and left or right.
  109626. */
  109627. export class DeviceOrientationCamera extends FreeCamera {
  109628. private _initialQuaternion;
  109629. private _quaternionCache;
  109630. private _tmpDragQuaternion;
  109631. private _disablePointerInputWhenUsingDeviceOrientation;
  109632. /**
  109633. * Creates a new device orientation camera
  109634. * @param name The name of the camera
  109635. * @param position The start position camera
  109636. * @param scene The scene the camera belongs to
  109637. */
  109638. constructor(name: string, position: Vector3, scene: Scene);
  109639. /**
  109640. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  109641. */
  109642. disablePointerInputWhenUsingDeviceOrientation: boolean;
  109643. private _dragFactor;
  109644. /**
  109645. * Enabled turning on the y axis when the orientation sensor is active
  109646. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  109647. */
  109648. enableHorizontalDragging(dragFactor?: number): void;
  109649. /**
  109650. * Gets the current instance class name ("DeviceOrientationCamera").
  109651. * This helps avoiding instanceof at run time.
  109652. * @returns the class name
  109653. */
  109654. getClassName(): string;
  109655. /**
  109656. * @hidden
  109657. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  109658. */
  109659. _checkInputs(): void;
  109660. /**
  109661. * Reset the camera to its default orientation on the specified axis only.
  109662. * @param axis The axis to reset
  109663. */
  109664. resetToCurrentRotation(axis?: Axis): void;
  109665. }
  109666. }
  109667. declare module BABYLON {
  109668. /**
  109669. * Defines supported buttons for XBox360 compatible gamepads
  109670. */
  109671. export enum Xbox360Button {
  109672. /** A */
  109673. A = 0,
  109674. /** B */
  109675. B = 1,
  109676. /** X */
  109677. X = 2,
  109678. /** Y */
  109679. Y = 3,
  109680. /** Start */
  109681. Start = 4,
  109682. /** Back */
  109683. Back = 5,
  109684. /** Left button */
  109685. LB = 6,
  109686. /** Right button */
  109687. RB = 7,
  109688. /** Left stick */
  109689. LeftStick = 8,
  109690. /** Right stick */
  109691. RightStick = 9
  109692. }
  109693. /** Defines values for XBox360 DPad */
  109694. export enum Xbox360Dpad {
  109695. /** Up */
  109696. Up = 0,
  109697. /** Down */
  109698. Down = 1,
  109699. /** Left */
  109700. Left = 2,
  109701. /** Right */
  109702. Right = 3
  109703. }
  109704. /**
  109705. * Defines a XBox360 gamepad
  109706. */
  109707. export class Xbox360Pad extends Gamepad {
  109708. private _leftTrigger;
  109709. private _rightTrigger;
  109710. private _onlefttriggerchanged;
  109711. private _onrighttriggerchanged;
  109712. private _onbuttondown;
  109713. private _onbuttonup;
  109714. private _ondpaddown;
  109715. private _ondpadup;
  109716. /** Observable raised when a button is pressed */
  109717. onButtonDownObservable: Observable<Xbox360Button>;
  109718. /** Observable raised when a button is released */
  109719. onButtonUpObservable: Observable<Xbox360Button>;
  109720. /** Observable raised when a pad is pressed */
  109721. onPadDownObservable: Observable<Xbox360Dpad>;
  109722. /** Observable raised when a pad is released */
  109723. onPadUpObservable: Observable<Xbox360Dpad>;
  109724. private _buttonA;
  109725. private _buttonB;
  109726. private _buttonX;
  109727. private _buttonY;
  109728. private _buttonBack;
  109729. private _buttonStart;
  109730. private _buttonLB;
  109731. private _buttonRB;
  109732. private _buttonLeftStick;
  109733. private _buttonRightStick;
  109734. private _dPadUp;
  109735. private _dPadDown;
  109736. private _dPadLeft;
  109737. private _dPadRight;
  109738. private _isXboxOnePad;
  109739. /**
  109740. * Creates a new XBox360 gamepad object
  109741. * @param id defines the id of this gamepad
  109742. * @param index defines its index
  109743. * @param gamepad defines the internal HTML gamepad object
  109744. * @param xboxOne defines if it is a XBox One gamepad
  109745. */
  109746. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  109747. /**
  109748. * Defines the callback to call when left trigger is pressed
  109749. * @param callback defines the callback to use
  109750. */
  109751. onlefttriggerchanged(callback: (value: number) => void): void;
  109752. /**
  109753. * Defines the callback to call when right trigger is pressed
  109754. * @param callback defines the callback to use
  109755. */
  109756. onrighttriggerchanged(callback: (value: number) => void): void;
  109757. /**
  109758. * Gets the left trigger value
  109759. */
  109760. /**
  109761. * Sets the left trigger value
  109762. */
  109763. leftTrigger: number;
  109764. /**
  109765. * Gets the right trigger value
  109766. */
  109767. /**
  109768. * Sets the right trigger value
  109769. */
  109770. rightTrigger: number;
  109771. /**
  109772. * Defines the callback to call when a button is pressed
  109773. * @param callback defines the callback to use
  109774. */
  109775. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  109776. /**
  109777. * Defines the callback to call when a button is released
  109778. * @param callback defines the callback to use
  109779. */
  109780. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  109781. /**
  109782. * Defines the callback to call when a pad is pressed
  109783. * @param callback defines the callback to use
  109784. */
  109785. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  109786. /**
  109787. * Defines the callback to call when a pad is released
  109788. * @param callback defines the callback to use
  109789. */
  109790. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  109791. private _setButtonValue;
  109792. private _setDPadValue;
  109793. /**
  109794. * Gets the value of the `A` button
  109795. */
  109796. /**
  109797. * Sets the value of the `A` button
  109798. */
  109799. buttonA: number;
  109800. /**
  109801. * Gets the value of the `B` button
  109802. */
  109803. /**
  109804. * Sets the value of the `B` button
  109805. */
  109806. buttonB: number;
  109807. /**
  109808. * Gets the value of the `X` button
  109809. */
  109810. /**
  109811. * Sets the value of the `X` button
  109812. */
  109813. buttonX: number;
  109814. /**
  109815. * Gets the value of the `Y` button
  109816. */
  109817. /**
  109818. * Sets the value of the `Y` button
  109819. */
  109820. buttonY: number;
  109821. /**
  109822. * Gets the value of the `Start` button
  109823. */
  109824. /**
  109825. * Sets the value of the `Start` button
  109826. */
  109827. buttonStart: number;
  109828. /**
  109829. * Gets the value of the `Back` button
  109830. */
  109831. /**
  109832. * Sets the value of the `Back` button
  109833. */
  109834. buttonBack: number;
  109835. /**
  109836. * Gets the value of the `Left` button
  109837. */
  109838. /**
  109839. * Sets the value of the `Left` button
  109840. */
  109841. buttonLB: number;
  109842. /**
  109843. * Gets the value of the `Right` button
  109844. */
  109845. /**
  109846. * Sets the value of the `Right` button
  109847. */
  109848. buttonRB: number;
  109849. /**
  109850. * Gets the value of the Left joystick
  109851. */
  109852. /**
  109853. * Sets the value of the Left joystick
  109854. */
  109855. buttonLeftStick: number;
  109856. /**
  109857. * Gets the value of the Right joystick
  109858. */
  109859. /**
  109860. * Sets the value of the Right joystick
  109861. */
  109862. buttonRightStick: number;
  109863. /**
  109864. * Gets the value of D-pad up
  109865. */
  109866. /**
  109867. * Sets the value of D-pad up
  109868. */
  109869. dPadUp: number;
  109870. /**
  109871. * Gets the value of D-pad down
  109872. */
  109873. /**
  109874. * Sets the value of D-pad down
  109875. */
  109876. dPadDown: number;
  109877. /**
  109878. * Gets the value of D-pad left
  109879. */
  109880. /**
  109881. * Sets the value of D-pad left
  109882. */
  109883. dPadLeft: number;
  109884. /**
  109885. * Gets the value of D-pad right
  109886. */
  109887. /**
  109888. * Sets the value of D-pad right
  109889. */
  109890. dPadRight: number;
  109891. /**
  109892. * Force the gamepad to synchronize with device values
  109893. */
  109894. update(): void;
  109895. /**
  109896. * Disposes the gamepad
  109897. */
  109898. dispose(): void;
  109899. }
  109900. }
  109901. declare module BABYLON {
  109902. /**
  109903. * Defines supported buttons for DualShock compatible gamepads
  109904. */
  109905. export enum DualShockButton {
  109906. /** Cross */
  109907. Cross = 0,
  109908. /** Circle */
  109909. Circle = 1,
  109910. /** Square */
  109911. Square = 2,
  109912. /** Triangle */
  109913. Triangle = 3,
  109914. /** Options */
  109915. Options = 4,
  109916. /** Share */
  109917. Share = 5,
  109918. /** L1 */
  109919. L1 = 6,
  109920. /** R1 */
  109921. R1 = 7,
  109922. /** Left stick */
  109923. LeftStick = 8,
  109924. /** Right stick */
  109925. RightStick = 9
  109926. }
  109927. /** Defines values for DualShock DPad */
  109928. export enum DualShockDpad {
  109929. /** Up */
  109930. Up = 0,
  109931. /** Down */
  109932. Down = 1,
  109933. /** Left */
  109934. Left = 2,
  109935. /** Right */
  109936. Right = 3
  109937. }
  109938. /**
  109939. * Defines a DualShock gamepad
  109940. */
  109941. export class DualShockPad extends Gamepad {
  109942. private _leftTrigger;
  109943. private _rightTrigger;
  109944. private _onlefttriggerchanged;
  109945. private _onrighttriggerchanged;
  109946. private _onbuttondown;
  109947. private _onbuttonup;
  109948. private _ondpaddown;
  109949. private _ondpadup;
  109950. /** Observable raised when a button is pressed */
  109951. onButtonDownObservable: Observable<DualShockButton>;
  109952. /** Observable raised when a button is released */
  109953. onButtonUpObservable: Observable<DualShockButton>;
  109954. /** Observable raised when a pad is pressed */
  109955. onPadDownObservable: Observable<DualShockDpad>;
  109956. /** Observable raised when a pad is released */
  109957. onPadUpObservable: Observable<DualShockDpad>;
  109958. private _buttonCross;
  109959. private _buttonCircle;
  109960. private _buttonSquare;
  109961. private _buttonTriangle;
  109962. private _buttonShare;
  109963. private _buttonOptions;
  109964. private _buttonL1;
  109965. private _buttonR1;
  109966. private _buttonLeftStick;
  109967. private _buttonRightStick;
  109968. private _dPadUp;
  109969. private _dPadDown;
  109970. private _dPadLeft;
  109971. private _dPadRight;
  109972. /**
  109973. * Creates a new DualShock gamepad object
  109974. * @param id defines the id of this gamepad
  109975. * @param index defines its index
  109976. * @param gamepad defines the internal HTML gamepad object
  109977. */
  109978. constructor(id: string, index: number, gamepad: any);
  109979. /**
  109980. * Defines the callback to call when left trigger is pressed
  109981. * @param callback defines the callback to use
  109982. */
  109983. onlefttriggerchanged(callback: (value: number) => void): void;
  109984. /**
  109985. * Defines the callback to call when right trigger is pressed
  109986. * @param callback defines the callback to use
  109987. */
  109988. onrighttriggerchanged(callback: (value: number) => void): void;
  109989. /**
  109990. * Gets the left trigger value
  109991. */
  109992. /**
  109993. * Sets the left trigger value
  109994. */
  109995. leftTrigger: number;
  109996. /**
  109997. * Gets the right trigger value
  109998. */
  109999. /**
  110000. * Sets the right trigger value
  110001. */
  110002. rightTrigger: number;
  110003. /**
  110004. * Defines the callback to call when a button is pressed
  110005. * @param callback defines the callback to use
  110006. */
  110007. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  110008. /**
  110009. * Defines the callback to call when a button is released
  110010. * @param callback defines the callback to use
  110011. */
  110012. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  110013. /**
  110014. * Defines the callback to call when a pad is pressed
  110015. * @param callback defines the callback to use
  110016. */
  110017. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  110018. /**
  110019. * Defines the callback to call when a pad is released
  110020. * @param callback defines the callback to use
  110021. */
  110022. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  110023. private _setButtonValue;
  110024. private _setDPadValue;
  110025. /**
  110026. * Gets the value of the `Cross` button
  110027. */
  110028. /**
  110029. * Sets the value of the `Cross` button
  110030. */
  110031. buttonCross: number;
  110032. /**
  110033. * Gets the value of the `Circle` button
  110034. */
  110035. /**
  110036. * Sets the value of the `Circle` button
  110037. */
  110038. buttonCircle: number;
  110039. /**
  110040. * Gets the value of the `Square` button
  110041. */
  110042. /**
  110043. * Sets the value of the `Square` button
  110044. */
  110045. buttonSquare: number;
  110046. /**
  110047. * Gets the value of the `Triangle` button
  110048. */
  110049. /**
  110050. * Sets the value of the `Triangle` button
  110051. */
  110052. buttonTriangle: number;
  110053. /**
  110054. * Gets the value of the `Options` button
  110055. */
  110056. /**
  110057. * Sets the value of the `Options` button
  110058. */
  110059. buttonOptions: number;
  110060. /**
  110061. * Gets the value of the `Share` button
  110062. */
  110063. /**
  110064. * Sets the value of the `Share` button
  110065. */
  110066. buttonShare: number;
  110067. /**
  110068. * Gets the value of the `L1` button
  110069. */
  110070. /**
  110071. * Sets the value of the `L1` button
  110072. */
  110073. buttonL1: number;
  110074. /**
  110075. * Gets the value of the `R1` button
  110076. */
  110077. /**
  110078. * Sets the value of the `R1` button
  110079. */
  110080. buttonR1: number;
  110081. /**
  110082. * Gets the value of the Left joystick
  110083. */
  110084. /**
  110085. * Sets the value of the Left joystick
  110086. */
  110087. buttonLeftStick: number;
  110088. /**
  110089. * Gets the value of the Right joystick
  110090. */
  110091. /**
  110092. * Sets the value of the Right joystick
  110093. */
  110094. buttonRightStick: number;
  110095. /**
  110096. * Gets the value of D-pad up
  110097. */
  110098. /**
  110099. * Sets the value of D-pad up
  110100. */
  110101. dPadUp: number;
  110102. /**
  110103. * Gets the value of D-pad down
  110104. */
  110105. /**
  110106. * Sets the value of D-pad down
  110107. */
  110108. dPadDown: number;
  110109. /**
  110110. * Gets the value of D-pad left
  110111. */
  110112. /**
  110113. * Sets the value of D-pad left
  110114. */
  110115. dPadLeft: number;
  110116. /**
  110117. * Gets the value of D-pad right
  110118. */
  110119. /**
  110120. * Sets the value of D-pad right
  110121. */
  110122. dPadRight: number;
  110123. /**
  110124. * Force the gamepad to synchronize with device values
  110125. */
  110126. update(): void;
  110127. /**
  110128. * Disposes the gamepad
  110129. */
  110130. dispose(): void;
  110131. }
  110132. }
  110133. declare module BABYLON {
  110134. /**
  110135. * Manager for handling gamepads
  110136. */
  110137. export class GamepadManager {
  110138. private _scene?;
  110139. private _babylonGamepads;
  110140. private _oneGamepadConnected;
  110141. /** @hidden */
  110142. _isMonitoring: boolean;
  110143. private _gamepadEventSupported;
  110144. private _gamepadSupport;
  110145. /**
  110146. * observable to be triggered when the gamepad controller has been connected
  110147. */
  110148. onGamepadConnectedObservable: Observable<Gamepad>;
  110149. /**
  110150. * observable to be triggered when the gamepad controller has been disconnected
  110151. */
  110152. onGamepadDisconnectedObservable: Observable<Gamepad>;
  110153. private _onGamepadConnectedEvent;
  110154. private _onGamepadDisconnectedEvent;
  110155. /**
  110156. * Initializes the gamepad manager
  110157. * @param _scene BabylonJS scene
  110158. */
  110159. constructor(_scene?: Scene | undefined);
  110160. /**
  110161. * The gamepads in the game pad manager
  110162. */
  110163. readonly gamepads: Gamepad[];
  110164. /**
  110165. * Get the gamepad controllers based on type
  110166. * @param type The type of gamepad controller
  110167. * @returns Nullable gamepad
  110168. */
  110169. getGamepadByType(type?: number): Nullable<Gamepad>;
  110170. /**
  110171. * Disposes the gamepad manager
  110172. */
  110173. dispose(): void;
  110174. private _addNewGamepad;
  110175. private _startMonitoringGamepads;
  110176. private _stopMonitoringGamepads;
  110177. /** @hidden */
  110178. _checkGamepadsStatus(): void;
  110179. private _updateGamepadObjects;
  110180. }
  110181. }
  110182. declare module BABYLON {
  110183. interface Scene {
  110184. /** @hidden */
  110185. _gamepadManager: Nullable<GamepadManager>;
  110186. /**
  110187. * Gets the gamepad manager associated with the scene
  110188. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  110189. */
  110190. gamepadManager: GamepadManager;
  110191. }
  110192. /**
  110193. * Interface representing a free camera inputs manager
  110194. */
  110195. interface FreeCameraInputsManager {
  110196. /**
  110197. * Adds gamepad input support to the FreeCameraInputsManager.
  110198. * @returns the FreeCameraInputsManager
  110199. */
  110200. addGamepad(): FreeCameraInputsManager;
  110201. }
  110202. /**
  110203. * Interface representing an arc rotate camera inputs manager
  110204. */
  110205. interface ArcRotateCameraInputsManager {
  110206. /**
  110207. * Adds gamepad input support to the ArcRotateCamera InputManager.
  110208. * @returns the camera inputs manager
  110209. */
  110210. addGamepad(): ArcRotateCameraInputsManager;
  110211. }
  110212. /**
  110213. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  110214. */
  110215. export class GamepadSystemSceneComponent implements ISceneComponent {
  110216. /**
  110217. * The component name helpfull to identify the component in the list of scene components.
  110218. */
  110219. readonly name: string;
  110220. /**
  110221. * The scene the component belongs to.
  110222. */
  110223. scene: Scene;
  110224. /**
  110225. * Creates a new instance of the component for the given scene
  110226. * @param scene Defines the scene to register the component in
  110227. */
  110228. constructor(scene: Scene);
  110229. /**
  110230. * Registers the component in a given scene
  110231. */
  110232. register(): void;
  110233. /**
  110234. * Rebuilds the elements related to this component in case of
  110235. * context lost for instance.
  110236. */
  110237. rebuild(): void;
  110238. /**
  110239. * Disposes the component and the associated ressources
  110240. */
  110241. dispose(): void;
  110242. private _beforeCameraUpdate;
  110243. }
  110244. }
  110245. declare module BABYLON {
  110246. /**
  110247. * 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,
  110248. * which still works and will still be found in many Playgrounds.
  110249. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  110250. */
  110251. export class UniversalCamera extends TouchCamera {
  110252. /**
  110253. * Defines the gamepad rotation sensiblity.
  110254. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  110255. */
  110256. gamepadAngularSensibility: number;
  110257. /**
  110258. * Defines the gamepad move sensiblity.
  110259. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  110260. */
  110261. gamepadMoveSensibility: number;
  110262. /**
  110263. * 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,
  110264. * which still works and will still be found in many Playgrounds.
  110265. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  110266. * @param name Define the name of the camera in the scene
  110267. * @param position Define the start position of the camera in the scene
  110268. * @param scene Define the scene the camera belongs to
  110269. */
  110270. constructor(name: string, position: Vector3, scene: Scene);
  110271. /**
  110272. * Gets the current object class name.
  110273. * @return the class name
  110274. */
  110275. getClassName(): string;
  110276. }
  110277. }
  110278. declare module BABYLON {
  110279. /**
  110280. * This represents a FPS type of camera. This is only here for back compat purpose.
  110281. * Please use the UniversalCamera instead as both are identical.
  110282. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  110283. */
  110284. export class GamepadCamera extends UniversalCamera {
  110285. /**
  110286. * Instantiates a new Gamepad Camera
  110287. * This represents a FPS type of camera. This is only here for back compat purpose.
  110288. * Please use the UniversalCamera instead as both are identical.
  110289. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  110290. * @param name Define the name of the camera in the scene
  110291. * @param position Define the start position of the camera in the scene
  110292. * @param scene Define the scene the camera belongs to
  110293. */
  110294. constructor(name: string, position: Vector3, scene: Scene);
  110295. /**
  110296. * Gets the current object class name.
  110297. * @return the class name
  110298. */
  110299. getClassName(): string;
  110300. }
  110301. }
  110302. declare module BABYLON {
  110303. /** @hidden */
  110304. export var passPixelShader: {
  110305. name: string;
  110306. shader: string;
  110307. };
  110308. }
  110309. declare module BABYLON {
  110310. /** @hidden */
  110311. export var passCubePixelShader: {
  110312. name: string;
  110313. shader: string;
  110314. };
  110315. }
  110316. declare module BABYLON {
  110317. /**
  110318. * PassPostProcess which produces an output the same as it's input
  110319. */
  110320. export class PassPostProcess extends PostProcess {
  110321. /**
  110322. * Creates the PassPostProcess
  110323. * @param name The name of the effect.
  110324. * @param options The required width/height ratio to downsize to before computing the render pass.
  110325. * @param camera The camera to apply the render pass to.
  110326. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110327. * @param engine The engine which the post process will be applied. (default: current engine)
  110328. * @param reusable If the post process can be reused on the same frame. (default: false)
  110329. * @param textureType The type of texture to be used when performing the post processing.
  110330. * @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)
  110331. */
  110332. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110333. }
  110334. /**
  110335. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  110336. */
  110337. export class PassCubePostProcess extends PostProcess {
  110338. private _face;
  110339. /**
  110340. * Gets or sets the cube face to display.
  110341. * * 0 is +X
  110342. * * 1 is -X
  110343. * * 2 is +Y
  110344. * * 3 is -Y
  110345. * * 4 is +Z
  110346. * * 5 is -Z
  110347. */
  110348. face: number;
  110349. /**
  110350. * Creates the PassCubePostProcess
  110351. * @param name The name of the effect.
  110352. * @param options The required width/height ratio to downsize to before computing the render pass.
  110353. * @param camera The camera to apply the render pass to.
  110354. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110355. * @param engine The engine which the post process will be applied. (default: current engine)
  110356. * @param reusable If the post process can be reused on the same frame. (default: false)
  110357. * @param textureType The type of texture to be used when performing the post processing.
  110358. * @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)
  110359. */
  110360. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110361. }
  110362. }
  110363. declare module BABYLON {
  110364. /** @hidden */
  110365. export var anaglyphPixelShader: {
  110366. name: string;
  110367. shader: string;
  110368. };
  110369. }
  110370. declare module BABYLON {
  110371. /**
  110372. * Postprocess used to generate anaglyphic rendering
  110373. */
  110374. export class AnaglyphPostProcess extends PostProcess {
  110375. private _passedProcess;
  110376. /**
  110377. * Creates a new AnaglyphPostProcess
  110378. * @param name defines postprocess name
  110379. * @param options defines creation options or target ratio scale
  110380. * @param rigCameras defines cameras using this postprocess
  110381. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  110382. * @param engine defines hosting engine
  110383. * @param reusable defines if the postprocess will be reused multiple times per frame
  110384. */
  110385. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  110386. }
  110387. }
  110388. declare module BABYLON {
  110389. /**
  110390. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  110391. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  110392. */
  110393. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  110394. /**
  110395. * Creates a new AnaglyphArcRotateCamera
  110396. * @param name defines camera name
  110397. * @param alpha defines alpha angle (in radians)
  110398. * @param beta defines beta angle (in radians)
  110399. * @param radius defines radius
  110400. * @param target defines camera target
  110401. * @param interaxialDistance defines distance between each color axis
  110402. * @param scene defines the hosting scene
  110403. */
  110404. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  110405. /**
  110406. * Gets camera class name
  110407. * @returns AnaglyphArcRotateCamera
  110408. */
  110409. getClassName(): string;
  110410. }
  110411. }
  110412. declare module BABYLON {
  110413. /**
  110414. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  110415. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  110416. */
  110417. export class AnaglyphFreeCamera extends FreeCamera {
  110418. /**
  110419. * Creates a new AnaglyphFreeCamera
  110420. * @param name defines camera name
  110421. * @param position defines initial position
  110422. * @param interaxialDistance defines distance between each color axis
  110423. * @param scene defines the hosting scene
  110424. */
  110425. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  110426. /**
  110427. * Gets camera class name
  110428. * @returns AnaglyphFreeCamera
  110429. */
  110430. getClassName(): string;
  110431. }
  110432. }
  110433. declare module BABYLON {
  110434. /**
  110435. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  110436. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  110437. */
  110438. export class AnaglyphGamepadCamera extends GamepadCamera {
  110439. /**
  110440. * Creates a new AnaglyphGamepadCamera
  110441. * @param name defines camera name
  110442. * @param position defines initial position
  110443. * @param interaxialDistance defines distance between each color axis
  110444. * @param scene defines the hosting scene
  110445. */
  110446. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  110447. /**
  110448. * Gets camera class name
  110449. * @returns AnaglyphGamepadCamera
  110450. */
  110451. getClassName(): string;
  110452. }
  110453. }
  110454. declare module BABYLON {
  110455. /**
  110456. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  110457. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  110458. */
  110459. export class AnaglyphUniversalCamera extends UniversalCamera {
  110460. /**
  110461. * Creates a new AnaglyphUniversalCamera
  110462. * @param name defines camera name
  110463. * @param position defines initial position
  110464. * @param interaxialDistance defines distance between each color axis
  110465. * @param scene defines the hosting scene
  110466. */
  110467. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  110468. /**
  110469. * Gets camera class name
  110470. * @returns AnaglyphUniversalCamera
  110471. */
  110472. getClassName(): string;
  110473. }
  110474. }
  110475. declare module BABYLON {
  110476. /** @hidden */
  110477. export var stereoscopicInterlacePixelShader: {
  110478. name: string;
  110479. shader: string;
  110480. };
  110481. }
  110482. declare module BABYLON {
  110483. /**
  110484. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  110485. */
  110486. export class StereoscopicInterlacePostProcess extends PostProcess {
  110487. private _stepSize;
  110488. private _passedProcess;
  110489. /**
  110490. * Initializes a StereoscopicInterlacePostProcess
  110491. * @param name The name of the effect.
  110492. * @param rigCameras The rig cameras to be appled to the post process
  110493. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  110494. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110495. * @param engine The engine which the post process will be applied. (default: current engine)
  110496. * @param reusable If the post process can be reused on the same frame. (default: false)
  110497. */
  110498. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110499. }
  110500. }
  110501. declare module BABYLON {
  110502. /**
  110503. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  110504. * @see http://doc.babylonjs.com/features/cameras
  110505. */
  110506. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  110507. /**
  110508. * Creates a new StereoscopicArcRotateCamera
  110509. * @param name defines camera name
  110510. * @param alpha defines alpha angle (in radians)
  110511. * @param beta defines beta angle (in radians)
  110512. * @param radius defines radius
  110513. * @param target defines camera target
  110514. * @param interaxialDistance defines distance between each color axis
  110515. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  110516. * @param scene defines the hosting scene
  110517. */
  110518. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  110519. /**
  110520. * Gets camera class name
  110521. * @returns StereoscopicArcRotateCamera
  110522. */
  110523. getClassName(): string;
  110524. }
  110525. }
  110526. declare module BABYLON {
  110527. /**
  110528. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  110529. * @see http://doc.babylonjs.com/features/cameras
  110530. */
  110531. export class StereoscopicFreeCamera extends FreeCamera {
  110532. /**
  110533. * Creates a new StereoscopicFreeCamera
  110534. * @param name defines camera name
  110535. * @param position defines initial position
  110536. * @param interaxialDistance defines distance between each color axis
  110537. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  110538. * @param scene defines the hosting scene
  110539. */
  110540. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  110541. /**
  110542. * Gets camera class name
  110543. * @returns StereoscopicFreeCamera
  110544. */
  110545. getClassName(): string;
  110546. }
  110547. }
  110548. declare module BABYLON {
  110549. /**
  110550. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  110551. * @see http://doc.babylonjs.com/features/cameras
  110552. */
  110553. export class StereoscopicGamepadCamera extends GamepadCamera {
  110554. /**
  110555. * Creates a new StereoscopicGamepadCamera
  110556. * @param name defines camera name
  110557. * @param position defines initial position
  110558. * @param interaxialDistance defines distance between each color axis
  110559. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  110560. * @param scene defines the hosting scene
  110561. */
  110562. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  110563. /**
  110564. * Gets camera class name
  110565. * @returns StereoscopicGamepadCamera
  110566. */
  110567. getClassName(): string;
  110568. }
  110569. }
  110570. declare module BABYLON {
  110571. /**
  110572. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  110573. * @see http://doc.babylonjs.com/features/cameras
  110574. */
  110575. export class StereoscopicUniversalCamera extends UniversalCamera {
  110576. /**
  110577. * Creates a new StereoscopicUniversalCamera
  110578. * @param name defines camera name
  110579. * @param position defines initial position
  110580. * @param interaxialDistance defines distance between each color axis
  110581. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  110582. * @param scene defines the hosting scene
  110583. */
  110584. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  110585. /**
  110586. * Gets camera class name
  110587. * @returns StereoscopicUniversalCamera
  110588. */
  110589. getClassName(): string;
  110590. }
  110591. }
  110592. declare module BABYLON {
  110593. /**
  110594. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  110595. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  110596. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  110597. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  110598. */
  110599. export class VirtualJoysticksCamera extends FreeCamera {
  110600. /**
  110601. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  110602. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  110603. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  110604. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  110605. * @param name Define the name of the camera in the scene
  110606. * @param position Define the start position of the camera in the scene
  110607. * @param scene Define the scene the camera belongs to
  110608. */
  110609. constructor(name: string, position: Vector3, scene: Scene);
  110610. /**
  110611. * Gets the current object class name.
  110612. * @return the class name
  110613. */
  110614. getClassName(): string;
  110615. }
  110616. }
  110617. declare module BABYLON {
  110618. /**
  110619. * This represents all the required metrics to create a VR camera.
  110620. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  110621. */
  110622. export class VRCameraMetrics {
  110623. /**
  110624. * Define the horizontal resolution off the screen.
  110625. */
  110626. hResolution: number;
  110627. /**
  110628. * Define the vertical resolution off the screen.
  110629. */
  110630. vResolution: number;
  110631. /**
  110632. * Define the horizontal screen size.
  110633. */
  110634. hScreenSize: number;
  110635. /**
  110636. * Define the vertical screen size.
  110637. */
  110638. vScreenSize: number;
  110639. /**
  110640. * Define the vertical screen center position.
  110641. */
  110642. vScreenCenter: number;
  110643. /**
  110644. * Define the distance of the eyes to the screen.
  110645. */
  110646. eyeToScreenDistance: number;
  110647. /**
  110648. * Define the distance between both lenses
  110649. */
  110650. lensSeparationDistance: number;
  110651. /**
  110652. * Define the distance between both viewer's eyes.
  110653. */
  110654. interpupillaryDistance: number;
  110655. /**
  110656. * Define the distortion factor of the VR postprocess.
  110657. * Please, touch with care.
  110658. */
  110659. distortionK: number[];
  110660. /**
  110661. * Define the chromatic aberration correction factors for the VR post process.
  110662. */
  110663. chromaAbCorrection: number[];
  110664. /**
  110665. * Define the scale factor of the post process.
  110666. * The smaller the better but the slower.
  110667. */
  110668. postProcessScaleFactor: number;
  110669. /**
  110670. * Define an offset for the lens center.
  110671. */
  110672. lensCenterOffset: number;
  110673. /**
  110674. * Define if the current vr camera should compensate the distortion of the lense or not.
  110675. */
  110676. compensateDistortion: boolean;
  110677. /**
  110678. * Defines if multiview should be enabled when rendering (Default: false)
  110679. */
  110680. multiviewEnabled: boolean;
  110681. /**
  110682. * Gets the rendering aspect ratio based on the provided resolutions.
  110683. */
  110684. readonly aspectRatio: number;
  110685. /**
  110686. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  110687. */
  110688. readonly aspectRatioFov: number;
  110689. /**
  110690. * @hidden
  110691. */
  110692. readonly leftHMatrix: Matrix;
  110693. /**
  110694. * @hidden
  110695. */
  110696. readonly rightHMatrix: Matrix;
  110697. /**
  110698. * @hidden
  110699. */
  110700. readonly leftPreViewMatrix: Matrix;
  110701. /**
  110702. * @hidden
  110703. */
  110704. readonly rightPreViewMatrix: Matrix;
  110705. /**
  110706. * Get the default VRMetrics based on the most generic setup.
  110707. * @returns the default vr metrics
  110708. */
  110709. static GetDefault(): VRCameraMetrics;
  110710. }
  110711. }
  110712. declare module BABYLON {
  110713. /** @hidden */
  110714. export var vrDistortionCorrectionPixelShader: {
  110715. name: string;
  110716. shader: string;
  110717. };
  110718. }
  110719. declare module BABYLON {
  110720. /**
  110721. * VRDistortionCorrectionPostProcess used for mobile VR
  110722. */
  110723. export class VRDistortionCorrectionPostProcess extends PostProcess {
  110724. private _isRightEye;
  110725. private _distortionFactors;
  110726. private _postProcessScaleFactor;
  110727. private _lensCenterOffset;
  110728. private _scaleIn;
  110729. private _scaleFactor;
  110730. private _lensCenter;
  110731. /**
  110732. * Initializes the VRDistortionCorrectionPostProcess
  110733. * @param name The name of the effect.
  110734. * @param camera The camera to apply the render pass to.
  110735. * @param isRightEye If this is for the right eye distortion
  110736. * @param vrMetrics All the required metrics for the VR camera
  110737. */
  110738. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  110739. }
  110740. }
  110741. declare module BABYLON {
  110742. /**
  110743. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  110744. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  110745. */
  110746. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  110747. /**
  110748. * Creates a new VRDeviceOrientationArcRotateCamera
  110749. * @param name defines camera name
  110750. * @param alpha defines the camera rotation along the logitudinal axis
  110751. * @param beta defines the camera rotation along the latitudinal axis
  110752. * @param radius defines the camera distance from its target
  110753. * @param target defines the camera target
  110754. * @param scene defines the scene the camera belongs to
  110755. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  110756. * @param vrCameraMetrics defines the vr metrics associated to the camera
  110757. */
  110758. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  110759. /**
  110760. * Gets camera class name
  110761. * @returns VRDeviceOrientationArcRotateCamera
  110762. */
  110763. getClassName(): string;
  110764. }
  110765. }
  110766. declare module BABYLON {
  110767. /**
  110768. * Camera used to simulate VR rendering (based on FreeCamera)
  110769. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  110770. */
  110771. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  110772. /**
  110773. * Creates a new VRDeviceOrientationFreeCamera
  110774. * @param name defines camera name
  110775. * @param position defines the start position of the camera
  110776. * @param scene defines the scene the camera belongs to
  110777. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  110778. * @param vrCameraMetrics defines the vr metrics associated to the camera
  110779. */
  110780. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  110781. /**
  110782. * Gets camera class name
  110783. * @returns VRDeviceOrientationFreeCamera
  110784. */
  110785. getClassName(): string;
  110786. }
  110787. }
  110788. declare module BABYLON {
  110789. /**
  110790. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  110791. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  110792. */
  110793. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  110794. /**
  110795. * Creates a new VRDeviceOrientationGamepadCamera
  110796. * @param name defines camera name
  110797. * @param position defines the start position of the camera
  110798. * @param scene defines the scene the camera belongs to
  110799. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  110800. * @param vrCameraMetrics defines the vr metrics associated to the camera
  110801. */
  110802. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  110803. /**
  110804. * Gets camera class name
  110805. * @returns VRDeviceOrientationGamepadCamera
  110806. */
  110807. getClassName(): string;
  110808. }
  110809. }
  110810. declare module BABYLON {
  110811. /** @hidden */
  110812. export var imageProcessingPixelShader: {
  110813. name: string;
  110814. shader: string;
  110815. };
  110816. }
  110817. declare module BABYLON {
  110818. /**
  110819. * ImageProcessingPostProcess
  110820. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  110821. */
  110822. export class ImageProcessingPostProcess extends PostProcess {
  110823. /**
  110824. * Default configuration related to image processing available in the PBR Material.
  110825. */
  110826. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110827. /**
  110828. * Gets the image processing configuration used either in this material.
  110829. */
  110830. /**
  110831. * Sets the Default image processing configuration used either in the this material.
  110832. *
  110833. * If sets to null, the scene one is in use.
  110834. */
  110835. imageProcessingConfiguration: ImageProcessingConfiguration;
  110836. /**
  110837. * Keep track of the image processing observer to allow dispose and replace.
  110838. */
  110839. private _imageProcessingObserver;
  110840. /**
  110841. * Attaches a new image processing configuration to the PBR Material.
  110842. * @param configuration
  110843. */
  110844. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  110845. /**
  110846. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  110847. */
  110848. /**
  110849. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  110850. */
  110851. colorCurves: Nullable<ColorCurves>;
  110852. /**
  110853. * Gets wether the color curves effect is enabled.
  110854. */
  110855. /**
  110856. * Sets wether the color curves effect is enabled.
  110857. */
  110858. colorCurvesEnabled: boolean;
  110859. /**
  110860. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  110861. */
  110862. /**
  110863. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  110864. */
  110865. colorGradingTexture: Nullable<BaseTexture>;
  110866. /**
  110867. * Gets wether the color grading effect is enabled.
  110868. */
  110869. /**
  110870. * Gets wether the color grading effect is enabled.
  110871. */
  110872. colorGradingEnabled: boolean;
  110873. /**
  110874. * Gets exposure used in the effect.
  110875. */
  110876. /**
  110877. * Sets exposure used in the effect.
  110878. */
  110879. exposure: number;
  110880. /**
  110881. * Gets wether tonemapping is enabled or not.
  110882. */
  110883. /**
  110884. * Sets wether tonemapping is enabled or not
  110885. */
  110886. toneMappingEnabled: boolean;
  110887. /**
  110888. * Gets the type of tone mapping effect.
  110889. */
  110890. /**
  110891. * Sets the type of tone mapping effect.
  110892. */
  110893. toneMappingType: number;
  110894. /**
  110895. * Gets contrast used in the effect.
  110896. */
  110897. /**
  110898. * Sets contrast used in the effect.
  110899. */
  110900. contrast: number;
  110901. /**
  110902. * Gets Vignette stretch size.
  110903. */
  110904. /**
  110905. * Sets Vignette stretch size.
  110906. */
  110907. vignetteStretch: number;
  110908. /**
  110909. * Gets Vignette centre X Offset.
  110910. */
  110911. /**
  110912. * Sets Vignette centre X Offset.
  110913. */
  110914. vignetteCentreX: number;
  110915. /**
  110916. * Gets Vignette centre Y Offset.
  110917. */
  110918. /**
  110919. * Sets Vignette centre Y Offset.
  110920. */
  110921. vignetteCentreY: number;
  110922. /**
  110923. * Gets Vignette weight or intensity of the vignette effect.
  110924. */
  110925. /**
  110926. * Sets Vignette weight or intensity of the vignette effect.
  110927. */
  110928. vignetteWeight: number;
  110929. /**
  110930. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  110931. * if vignetteEnabled is set to true.
  110932. */
  110933. /**
  110934. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  110935. * if vignetteEnabled is set to true.
  110936. */
  110937. vignetteColor: Color4;
  110938. /**
  110939. * Gets Camera field of view used by the Vignette effect.
  110940. */
  110941. /**
  110942. * Sets Camera field of view used by the Vignette effect.
  110943. */
  110944. vignetteCameraFov: number;
  110945. /**
  110946. * Gets the vignette blend mode allowing different kind of effect.
  110947. */
  110948. /**
  110949. * Sets the vignette blend mode allowing different kind of effect.
  110950. */
  110951. vignetteBlendMode: number;
  110952. /**
  110953. * Gets wether the vignette effect is enabled.
  110954. */
  110955. /**
  110956. * Sets wether the vignette effect is enabled.
  110957. */
  110958. vignetteEnabled: boolean;
  110959. private _fromLinearSpace;
  110960. /**
  110961. * Gets wether the input of the processing is in Gamma or Linear Space.
  110962. */
  110963. /**
  110964. * Sets wether the input of the processing is in Gamma or Linear Space.
  110965. */
  110966. fromLinearSpace: boolean;
  110967. /**
  110968. * Defines cache preventing GC.
  110969. */
  110970. private _defines;
  110971. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  110972. /**
  110973. * "ImageProcessingPostProcess"
  110974. * @returns "ImageProcessingPostProcess"
  110975. */
  110976. getClassName(): string;
  110977. protected _updateParameters(): void;
  110978. dispose(camera?: Camera): void;
  110979. }
  110980. }
  110981. declare module BABYLON {
  110982. /**
  110983. * Class containing static functions to help procedurally build meshes
  110984. */
  110985. export class GroundBuilder {
  110986. /**
  110987. * Creates a ground mesh
  110988. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  110989. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  110990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110991. * @param name defines the name of the mesh
  110992. * @param options defines the options used to create the mesh
  110993. * @param scene defines the hosting scene
  110994. * @returns the ground mesh
  110995. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  110996. */
  110997. static CreateGround(name: string, options: {
  110998. width?: number;
  110999. height?: number;
  111000. subdivisions?: number;
  111001. subdivisionsX?: number;
  111002. subdivisionsY?: number;
  111003. updatable?: boolean;
  111004. }, scene: any): Mesh;
  111005. /**
  111006. * Creates a tiled ground mesh
  111007. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  111008. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  111009. * * 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
  111010. * * 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
  111011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  111012. * @param name defines the name of the mesh
  111013. * @param options defines the options used to create the mesh
  111014. * @param scene defines the hosting scene
  111015. * @returns the tiled ground mesh
  111016. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  111017. */
  111018. static CreateTiledGround(name: string, options: {
  111019. xmin: number;
  111020. zmin: number;
  111021. xmax: number;
  111022. zmax: number;
  111023. subdivisions?: {
  111024. w: number;
  111025. h: number;
  111026. };
  111027. precision?: {
  111028. w: number;
  111029. h: number;
  111030. };
  111031. updatable?: boolean;
  111032. }, scene?: Nullable<Scene>): Mesh;
  111033. /**
  111034. * Creates a ground mesh from a height map
  111035. * * The parameter `url` sets the URL of the height map image resource.
  111036. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  111037. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  111038. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  111039. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  111040. * * 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.
  111041. * * 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).
  111042. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  111043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  111044. * @param name defines the name of the mesh
  111045. * @param url defines the url to the height map
  111046. * @param options defines the options used to create the mesh
  111047. * @param scene defines the hosting scene
  111048. * @returns the ground mesh
  111049. * @see https://doc.babylonjs.com/babylon101/height_map
  111050. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  111051. */
  111052. static CreateGroundFromHeightMap(name: string, url: string, options: {
  111053. width?: number;
  111054. height?: number;
  111055. subdivisions?: number;
  111056. minHeight?: number;
  111057. maxHeight?: number;
  111058. colorFilter?: Color3;
  111059. alphaFilter?: number;
  111060. updatable?: boolean;
  111061. onReady?: (mesh: GroundMesh) => void;
  111062. }, scene?: Nullable<Scene>): GroundMesh;
  111063. }
  111064. }
  111065. declare module BABYLON {
  111066. /**
  111067. * Class containing static functions to help procedurally build meshes
  111068. */
  111069. export class TorusBuilder {
  111070. /**
  111071. * Creates a torus mesh
  111072. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  111073. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  111074. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  111075. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111076. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  111078. * @param name defines the name of the mesh
  111079. * @param options defines the options used to create the mesh
  111080. * @param scene defines the hosting scene
  111081. * @returns the torus mesh
  111082. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  111083. */
  111084. static CreateTorus(name: string, options: {
  111085. diameter?: number;
  111086. thickness?: number;
  111087. tessellation?: number;
  111088. updatable?: boolean;
  111089. sideOrientation?: number;
  111090. frontUVs?: Vector4;
  111091. backUVs?: Vector4;
  111092. }, scene: any): Mesh;
  111093. }
  111094. }
  111095. declare module BABYLON {
  111096. /**
  111097. * Class containing static functions to help procedurally build meshes
  111098. */
  111099. export class CylinderBuilder {
  111100. /**
  111101. * Creates a cylinder or a cone mesh
  111102. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  111103. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  111104. * * 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.
  111105. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  111106. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  111107. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  111108. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  111109. * * 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).
  111110. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  111111. * * 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).
  111112. * * 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
  111113. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  111114. * * 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
  111115. * * 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.
  111116. * * If `enclose` is false, a ring surface is one element.
  111117. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  111118. * * 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
  111119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111120. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  111122. * @param name defines the name of the mesh
  111123. * @param options defines the options used to create the mesh
  111124. * @param scene defines the hosting scene
  111125. * @returns the cylinder mesh
  111126. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  111127. */
  111128. static CreateCylinder(name: string, options: {
  111129. height?: number;
  111130. diameterTop?: number;
  111131. diameterBottom?: number;
  111132. diameter?: number;
  111133. tessellation?: number;
  111134. subdivisions?: number;
  111135. arc?: number;
  111136. faceColors?: Color4[];
  111137. faceUV?: Vector4[];
  111138. updatable?: boolean;
  111139. hasRings?: boolean;
  111140. enclose?: boolean;
  111141. cap?: number;
  111142. sideOrientation?: number;
  111143. frontUVs?: Vector4;
  111144. backUVs?: Vector4;
  111145. }, scene: any): Mesh;
  111146. }
  111147. }
  111148. declare module BABYLON {
  111149. /**
  111150. * States of the webXR experience
  111151. */
  111152. export enum WebXRState {
  111153. /**
  111154. * Transitioning to being in XR mode
  111155. */
  111156. ENTERING_XR = 0,
  111157. /**
  111158. * Transitioning to non XR mode
  111159. */
  111160. EXITING_XR = 1,
  111161. /**
  111162. * In XR mode and presenting
  111163. */
  111164. IN_XR = 2,
  111165. /**
  111166. * Not entered XR mode
  111167. */
  111168. NOT_IN_XR = 3
  111169. }
  111170. /**
  111171. * Abstraction of the XR render target
  111172. */
  111173. export interface WebXRRenderTarget extends IDisposable {
  111174. /**
  111175. * xrpresent context of the canvas which can be used to display/mirror xr content
  111176. */
  111177. canvasContext: WebGLRenderingContext;
  111178. /**
  111179. * xr layer for the canvas
  111180. */
  111181. xrLayer: Nullable<XRWebGLLayer>;
  111182. /**
  111183. * Initializes the xr layer for the session
  111184. * @param xrSession xr session
  111185. * @returns a promise that will resolve once the XR Layer has been created
  111186. */
  111187. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  111188. }
  111189. }
  111190. declare module BABYLON {
  111191. /**
  111192. * COnfiguration object for WebXR output canvas
  111193. */
  111194. export class WebXRManagedOutputCanvasOptions {
  111195. /**
  111196. * Options for this XR Layer output
  111197. */
  111198. canvasOptions: XRWebGLLayerOptions;
  111199. /**
  111200. * CSS styling for a newly created canvas (if not provided)
  111201. */
  111202. newCanvasCssStyle?: string;
  111203. /**
  111204. * Get the default values of the configuration object
  111205. * @returns default values of this configuration object
  111206. */
  111207. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  111208. }
  111209. /**
  111210. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  111211. */
  111212. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  111213. private configuration;
  111214. private _engine;
  111215. private _canvas;
  111216. /**
  111217. * xrpresent context of the canvas which can be used to display/mirror xr content
  111218. */
  111219. canvasContext: WebGLRenderingContext;
  111220. /**
  111221. * xr layer for the canvas
  111222. */
  111223. xrLayer: Nullable<XRWebGLLayer>;
  111224. /**
  111225. * Initializes the xr layer for the session
  111226. * @param xrSession xr session
  111227. * @returns a promise that will resolve once the XR Layer has been created
  111228. */
  111229. initializeXRLayerAsync(xrSession: any): any;
  111230. /**
  111231. * Initializes the canvas to be added/removed upon entering/exiting xr
  111232. * @param engine the Babylon engine
  111233. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  111234. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  111235. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  111236. */
  111237. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  111238. /**
  111239. * Disposes of the object
  111240. */
  111241. dispose(): void;
  111242. private _setManagedOutputCanvas;
  111243. private _addCanvas;
  111244. private _removeCanvas;
  111245. }
  111246. }
  111247. declare module BABYLON {
  111248. /**
  111249. * Manages an XRSession to work with Babylon's engine
  111250. * @see https://doc.babylonjs.com/how_to/webxr
  111251. */
  111252. export class WebXRSessionManager implements IDisposable {
  111253. /** The scene which the session should be created for */
  111254. scene: Scene;
  111255. /**
  111256. * Fires every time a new xrFrame arrives which can be used to update the camera
  111257. */
  111258. onXRFrameObservable: Observable<XRFrame>;
  111259. /**
  111260. * Fires when the xr session is ended either by the device or manually done
  111261. */
  111262. onXRSessionEnded: Observable<any>;
  111263. /**
  111264. * Fires when the xr session is ended either by the device or manually done
  111265. */
  111266. onXRSessionInit: Observable<XRSession>;
  111267. /**
  111268. * Underlying xr session
  111269. */
  111270. session: XRSession;
  111271. /**
  111272. * Type of reference space used when creating the session
  111273. */
  111274. referenceSpace: XRReferenceSpace;
  111275. /**
  111276. * Current XR frame
  111277. */
  111278. currentFrame: Nullable<XRFrame>;
  111279. private _xrNavigator;
  111280. private baseLayer;
  111281. private _rttProvider;
  111282. private _sessionEnded;
  111283. /**
  111284. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  111285. * @param scene The scene which the session should be created for
  111286. */
  111287. constructor(
  111288. /** The scene which the session should be created for */
  111289. scene: Scene);
  111290. /**
  111291. * Initializes the manager
  111292. * After initialization enterXR can be called to start an XR session
  111293. * @returns Promise which resolves after it is initialized
  111294. */
  111295. initializeAsync(): Promise<void>;
  111296. /**
  111297. * Initializes an xr session
  111298. * @param xrSessionMode mode to initialize
  111299. * @param optionalFeatures defines optional values to pass to the session builder
  111300. * @returns a promise which will resolve once the session has been initialized
  111301. */
  111302. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  111303. /**
  111304. * Sets the reference space on the xr session
  111305. * @param referenceSpace space to set
  111306. * @returns a promise that will resolve once the reference space has been set
  111307. */
  111308. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  111309. /**
  111310. * Updates the render state of the session
  111311. * @param state state to set
  111312. * @returns a promise that resolves once the render state has been updated
  111313. */
  111314. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  111315. /**
  111316. * Starts rendering to the xr layer
  111317. * @returns a promise that will resolve once rendering has started
  111318. */
  111319. startRenderingToXRAsync(): Promise<void>;
  111320. /**
  111321. * Gets the correct render target texture to be rendered this frame for this eye
  111322. * @param eye the eye for which to get the render target
  111323. * @returns the render target for the specified eye
  111324. */
  111325. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  111326. /**
  111327. * Stops the xrSession and restores the renderloop
  111328. * @returns Promise which resolves after it exits XR
  111329. */
  111330. exitXRAsync(): Promise<void>;
  111331. /**
  111332. * Checks if a session would be supported for the creation options specified
  111333. * @param sessionMode session mode to check if supported eg. immersive-vr
  111334. * @returns true if supported
  111335. */
  111336. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  111337. /**
  111338. * Creates a WebXRRenderTarget object for the XR session
  111339. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  111340. * @param options optional options to provide when creating a new render target
  111341. * @returns a WebXR render target to which the session can render
  111342. */
  111343. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  111344. /**
  111345. * @hidden
  111346. * Converts the render layer of xrSession to a render target
  111347. * @param session session to create render target for
  111348. * @param scene scene the new render target should be created for
  111349. * @param baseLayer the webgl layer to create the render target for
  111350. */
  111351. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  111352. /**
  111353. * Disposes of the session manager
  111354. */
  111355. dispose(): void;
  111356. /**
  111357. * Gets a promise returning true when fullfiled if the given session mode is supported
  111358. * @param sessionMode defines the session to test
  111359. * @returns a promise
  111360. */
  111361. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  111362. }
  111363. }
  111364. declare module BABYLON {
  111365. /**
  111366. * WebXR Camera which holds the views for the xrSession
  111367. * @see https://doc.babylonjs.com/how_to/webxr
  111368. */
  111369. export class WebXRCamera extends FreeCamera {
  111370. /**
  111371. * Is the camera in debug mode. Used when using an emulator
  111372. */
  111373. debugMode: boolean;
  111374. /**
  111375. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  111376. * @param name the name of the camera
  111377. * @param scene the scene to add the camera to
  111378. */
  111379. constructor(name: string, scene: Scene);
  111380. private _updateNumberOfRigCameras;
  111381. /** @hidden */
  111382. _updateForDualEyeDebugging(): void;
  111383. /**
  111384. * Updates the cameras position from the current pose information of the XR session
  111385. * @param xrSessionManager the session containing pose information
  111386. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  111387. */
  111388. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  111389. }
  111390. }
  111391. declare module BABYLON {
  111392. /**
  111393. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  111394. * @see https://doc.babylonjs.com/how_to/webxr
  111395. */
  111396. export class WebXRExperienceHelper implements IDisposable {
  111397. private scene;
  111398. /**
  111399. * 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
  111400. */
  111401. container: AbstractMesh;
  111402. /**
  111403. * Camera used to render xr content
  111404. */
  111405. camera: WebXRCamera;
  111406. /**
  111407. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  111408. */
  111409. state: WebXRState;
  111410. private _setState;
  111411. private static _TmpVector;
  111412. /**
  111413. * Fires when the state of the experience helper has changed
  111414. */
  111415. onStateChangedObservable: Observable<WebXRState>;
  111416. /** Session manager used to keep track of xr session */
  111417. sessionManager: WebXRSessionManager;
  111418. private _nonVRCamera;
  111419. private _originalSceneAutoClear;
  111420. private _supported;
  111421. /**
  111422. * Creates the experience helper
  111423. * @param scene the scene to attach the experience helper to
  111424. * @returns a promise for the experience helper
  111425. */
  111426. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  111427. /**
  111428. * Creates a WebXRExperienceHelper
  111429. * @param scene The scene the helper should be created in
  111430. */
  111431. private constructor();
  111432. /**
  111433. * Exits XR mode and returns the scene to its original state
  111434. * @returns promise that resolves after xr mode has exited
  111435. */
  111436. exitXRAsync(): Promise<void>;
  111437. /**
  111438. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  111439. * @param sessionMode options for the XR session
  111440. * @param referenceSpaceType frame of reference of the XR session
  111441. * @param renderTarget the output canvas that will be used to enter XR mode
  111442. * @returns promise that resolves after xr mode has entered
  111443. */
  111444. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  111445. /**
  111446. * Updates the global position of the camera by moving the camera's container
  111447. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  111448. * @param position The desired global position of the camera
  111449. */
  111450. setPositionOfCameraUsingContainer(position: Vector3): void;
  111451. /**
  111452. * Rotates the xr camera by rotating the camera's container around the camera's position
  111453. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  111454. * @param rotation the desired quaternion rotation to apply to the camera
  111455. */
  111456. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  111457. /**
  111458. * Disposes of the experience helper
  111459. */
  111460. dispose(): void;
  111461. }
  111462. }
  111463. declare module BABYLON {
  111464. /**
  111465. * Represents an XR input
  111466. */
  111467. export class WebXRController {
  111468. private scene;
  111469. /** The underlying input source for the controller */
  111470. inputSource: XRInputSource;
  111471. private parentContainer;
  111472. /**
  111473. * 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
  111474. */
  111475. grip?: AbstractMesh;
  111476. /**
  111477. * Pointer which can be used to select objects or attach a visible laser to
  111478. */
  111479. pointer: AbstractMesh;
  111480. private _gamepadMode;
  111481. /**
  111482. * If available, this is the gamepad object related to this controller.
  111483. * Using this object it is possible to get click events and trackpad changes of the
  111484. * webxr controller that is currently being used.
  111485. */
  111486. gamepadController?: WebVRController;
  111487. /**
  111488. * Event that fires when the controller is removed/disposed
  111489. */
  111490. onDisposeObservable: Observable<{}>;
  111491. private _tmpQuaternion;
  111492. private _tmpVector;
  111493. /**
  111494. * Creates the controller
  111495. * @see https://doc.babylonjs.com/how_to/webxr
  111496. * @param scene the scene which the controller should be associated to
  111497. * @param inputSource the underlying input source for the controller
  111498. * @param parentContainer parent that the controller meshes should be children of
  111499. */
  111500. constructor(scene: Scene,
  111501. /** The underlying input source for the controller */
  111502. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  111503. /**
  111504. * Updates the controller pose based on the given XRFrame
  111505. * @param xrFrame xr frame to update the pose with
  111506. * @param referenceSpace reference space to use
  111507. */
  111508. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  111509. /**
  111510. * Gets a world space ray coming from the controller
  111511. * @param result the resulting ray
  111512. */
  111513. getWorldPointerRayToRef(result: Ray): void;
  111514. /**
  111515. * Get the scene associated with this controller
  111516. * @returns the scene object
  111517. */
  111518. getScene(): Scene;
  111519. /**
  111520. * Disposes of the object
  111521. */
  111522. dispose(): void;
  111523. }
  111524. }
  111525. declare module BABYLON {
  111526. /**
  111527. * XR input used to track XR inputs such as controllers/rays
  111528. */
  111529. export class WebXRInput implements IDisposable {
  111530. /**
  111531. * Base experience the input listens to
  111532. */
  111533. baseExperience: WebXRExperienceHelper;
  111534. /**
  111535. * XR controllers being tracked
  111536. */
  111537. controllers: Array<WebXRController>;
  111538. private _frameObserver;
  111539. private _stateObserver;
  111540. /**
  111541. * Event when a controller has been connected/added
  111542. */
  111543. onControllerAddedObservable: Observable<WebXRController>;
  111544. /**
  111545. * Event when a controller has been removed/disconnected
  111546. */
  111547. onControllerRemovedObservable: Observable<WebXRController>;
  111548. /**
  111549. * Initializes the WebXRInput
  111550. * @param baseExperience experience helper which the input should be created for
  111551. */
  111552. constructor(
  111553. /**
  111554. * Base experience the input listens to
  111555. */
  111556. baseExperience: WebXRExperienceHelper);
  111557. private _onInputSourcesChange;
  111558. private _addAndRemoveControllers;
  111559. /**
  111560. * Disposes of the object
  111561. */
  111562. dispose(): void;
  111563. }
  111564. }
  111565. declare module BABYLON {
  111566. /**
  111567. * Class used to represent data loading progression
  111568. */
  111569. export class SceneLoaderProgressEvent {
  111570. /** defines if data length to load can be evaluated */
  111571. readonly lengthComputable: boolean;
  111572. /** defines the loaded data length */
  111573. readonly loaded: number;
  111574. /** defines the data length to load */
  111575. readonly total: number;
  111576. /**
  111577. * Create a new progress event
  111578. * @param lengthComputable defines if data length to load can be evaluated
  111579. * @param loaded defines the loaded data length
  111580. * @param total defines the data length to load
  111581. */
  111582. constructor(
  111583. /** defines if data length to load can be evaluated */
  111584. lengthComputable: boolean,
  111585. /** defines the loaded data length */
  111586. loaded: number,
  111587. /** defines the data length to load */
  111588. total: number);
  111589. /**
  111590. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  111591. * @param event defines the source event
  111592. * @returns a new SceneLoaderProgressEvent
  111593. */
  111594. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  111595. }
  111596. /**
  111597. * Interface used by SceneLoader plugins to define supported file extensions
  111598. */
  111599. export interface ISceneLoaderPluginExtensions {
  111600. /**
  111601. * Defines the list of supported extensions
  111602. */
  111603. [extension: string]: {
  111604. isBinary: boolean;
  111605. };
  111606. }
  111607. /**
  111608. * Interface used by SceneLoader plugin factory
  111609. */
  111610. export interface ISceneLoaderPluginFactory {
  111611. /**
  111612. * Defines the name of the factory
  111613. */
  111614. name: string;
  111615. /**
  111616. * Function called to create a new plugin
  111617. * @return the new plugin
  111618. */
  111619. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  111620. /**
  111621. * The callback that returns true if the data can be directly loaded.
  111622. * @param data string containing the file data
  111623. * @returns if the data can be loaded directly
  111624. */
  111625. canDirectLoad?(data: string): boolean;
  111626. }
  111627. /**
  111628. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  111629. */
  111630. export interface ISceneLoaderPluginBase {
  111631. /**
  111632. * The friendly name of this plugin.
  111633. */
  111634. name: string;
  111635. /**
  111636. * The file extensions supported by this plugin.
  111637. */
  111638. extensions: string | ISceneLoaderPluginExtensions;
  111639. /**
  111640. * The callback called when loading from a url.
  111641. * @param scene scene loading this url
  111642. * @param url url to load
  111643. * @param onSuccess callback called when the file successfully loads
  111644. * @param onProgress callback called while file is loading (if the server supports this mode)
  111645. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  111646. * @param onError callback called when the file fails to load
  111647. * @returns a file request object
  111648. */
  111649. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  111650. /**
  111651. * The callback called when loading from a file object.
  111652. * @param scene scene loading this file
  111653. * @param file defines the file to load
  111654. * @param onSuccess defines the callback to call when data is loaded
  111655. * @param onProgress defines the callback to call during loading process
  111656. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  111657. * @param onError defines the callback to call when an error occurs
  111658. * @returns a file request object
  111659. */
  111660. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  111661. /**
  111662. * The callback that returns true if the data can be directly loaded.
  111663. * @param data string containing the file data
  111664. * @returns if the data can be loaded directly
  111665. */
  111666. canDirectLoad?(data: string): boolean;
  111667. /**
  111668. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  111669. * @param scene scene loading this data
  111670. * @param data string containing the data
  111671. * @returns data to pass to the plugin
  111672. */
  111673. directLoad?(scene: Scene, data: string): any;
  111674. /**
  111675. * The callback that allows custom handling of the root url based on the response url.
  111676. * @param rootUrl the original root url
  111677. * @param responseURL the response url if available
  111678. * @returns the new root url
  111679. */
  111680. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  111681. }
  111682. /**
  111683. * Interface used to define a SceneLoader plugin
  111684. */
  111685. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  111686. /**
  111687. * Import meshes into a scene.
  111688. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111689. * @param scene The scene to import into
  111690. * @param data The data to import
  111691. * @param rootUrl The root url for scene and resources
  111692. * @param meshes The meshes array to import into
  111693. * @param particleSystems The particle systems array to import into
  111694. * @param skeletons The skeletons array to import into
  111695. * @param onError The callback when import fails
  111696. * @returns True if successful or false otherwise
  111697. */
  111698. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  111699. /**
  111700. * Load into a scene.
  111701. * @param scene The scene to load into
  111702. * @param data The data to import
  111703. * @param rootUrl The root url for scene and resources
  111704. * @param onError The callback when import fails
  111705. * @returns True if successful or false otherwise
  111706. */
  111707. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  111708. /**
  111709. * Load into an asset container.
  111710. * @param scene The scene to load into
  111711. * @param data The data to import
  111712. * @param rootUrl The root url for scene and resources
  111713. * @param onError The callback when import fails
  111714. * @returns The loaded asset container
  111715. */
  111716. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  111717. }
  111718. /**
  111719. * Interface used to define an async SceneLoader plugin
  111720. */
  111721. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  111722. /**
  111723. * Import meshes into a scene.
  111724. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111725. * @param scene The scene to import into
  111726. * @param data The data to import
  111727. * @param rootUrl The root url for scene and resources
  111728. * @param onProgress The callback when the load progresses
  111729. * @param fileName Defines the name of the file to load
  111730. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  111731. */
  111732. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  111733. meshes: AbstractMesh[];
  111734. particleSystems: IParticleSystem[];
  111735. skeletons: Skeleton[];
  111736. animationGroups: AnimationGroup[];
  111737. }>;
  111738. /**
  111739. * Load into a scene.
  111740. * @param scene The scene to load into
  111741. * @param data The data to import
  111742. * @param rootUrl The root url for scene and resources
  111743. * @param onProgress The callback when the load progresses
  111744. * @param fileName Defines the name of the file to load
  111745. * @returns Nothing
  111746. */
  111747. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  111748. /**
  111749. * Load into an asset container.
  111750. * @param scene The scene to load into
  111751. * @param data The data to import
  111752. * @param rootUrl The root url for scene and resources
  111753. * @param onProgress The callback when the load progresses
  111754. * @param fileName Defines the name of the file to load
  111755. * @returns The loaded asset container
  111756. */
  111757. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  111758. }
  111759. /**
  111760. * Mode that determines how to handle old animation groups before loading new ones.
  111761. */
  111762. export enum SceneLoaderAnimationGroupLoadingMode {
  111763. /**
  111764. * Reset all old animations to initial state then dispose them.
  111765. */
  111766. Clean = 0,
  111767. /**
  111768. * Stop all old animations.
  111769. */
  111770. Stop = 1,
  111771. /**
  111772. * Restart old animations from first frame.
  111773. */
  111774. Sync = 2,
  111775. /**
  111776. * Old animations remains untouched.
  111777. */
  111778. NoSync = 3
  111779. }
  111780. /**
  111781. * Class used to load scene from various file formats using registered plugins
  111782. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  111783. */
  111784. export class SceneLoader {
  111785. /**
  111786. * No logging while loading
  111787. */
  111788. static readonly NO_LOGGING: number;
  111789. /**
  111790. * Minimal logging while loading
  111791. */
  111792. static readonly MINIMAL_LOGGING: number;
  111793. /**
  111794. * Summary logging while loading
  111795. */
  111796. static readonly SUMMARY_LOGGING: number;
  111797. /**
  111798. * Detailled logging while loading
  111799. */
  111800. static readonly DETAILED_LOGGING: number;
  111801. /**
  111802. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  111803. */
  111804. static ForceFullSceneLoadingForIncremental: boolean;
  111805. /**
  111806. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  111807. */
  111808. static ShowLoadingScreen: boolean;
  111809. /**
  111810. * Defines the current logging level (while loading the scene)
  111811. * @ignorenaming
  111812. */
  111813. static loggingLevel: number;
  111814. /**
  111815. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  111816. */
  111817. static CleanBoneMatrixWeights: boolean;
  111818. /**
  111819. * Event raised when a plugin is used to load a scene
  111820. */
  111821. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  111822. private static _registeredPlugins;
  111823. private static _getDefaultPlugin;
  111824. private static _getPluginForExtension;
  111825. private static _getPluginForDirectLoad;
  111826. private static _getPluginForFilename;
  111827. private static _getDirectLoad;
  111828. private static _loadData;
  111829. private static _getFileInfo;
  111830. /**
  111831. * Gets a plugin that can load the given extension
  111832. * @param extension defines the extension to load
  111833. * @returns a plugin or null if none works
  111834. */
  111835. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  111836. /**
  111837. * Gets a boolean indicating that the given extension can be loaded
  111838. * @param extension defines the extension to load
  111839. * @returns true if the extension is supported
  111840. */
  111841. static IsPluginForExtensionAvailable(extension: string): boolean;
  111842. /**
  111843. * Adds a new plugin to the list of registered plugins
  111844. * @param plugin defines the plugin to add
  111845. */
  111846. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  111847. /**
  111848. * Import meshes into a scene
  111849. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111850. * @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)
  111851. * @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)
  111852. * @param scene the instance of BABYLON.Scene to append to
  111853. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  111854. * @param onProgress a callback with a progress event for each file being loaded
  111855. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111856. * @param pluginExtension the extension used to determine the plugin
  111857. * @returns The loaded plugin
  111858. */
  111859. 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>;
  111860. /**
  111861. * Import meshes into a scene
  111862. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111863. * @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)
  111864. * @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)
  111865. * @param scene the instance of BABYLON.Scene to append to
  111866. * @param onProgress a callback with a progress event for each file being loaded
  111867. * @param pluginExtension the extension used to determine the plugin
  111868. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  111869. */
  111870. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  111871. meshes: AbstractMesh[];
  111872. particleSystems: IParticleSystem[];
  111873. skeletons: Skeleton[];
  111874. animationGroups: AnimationGroup[];
  111875. }>;
  111876. /**
  111877. * Load a scene
  111878. * @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)
  111879. * @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)
  111880. * @param engine is the instance of BABYLON.Engine to use to create the scene
  111881. * @param onSuccess a callback with the scene when import succeeds
  111882. * @param onProgress a callback with a progress event for each file being loaded
  111883. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111884. * @param pluginExtension the extension used to determine the plugin
  111885. * @returns The loaded plugin
  111886. */
  111887. 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>;
  111888. /**
  111889. * Load a scene
  111890. * @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)
  111891. * @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)
  111892. * @param engine is the instance of BABYLON.Engine to use to create the scene
  111893. * @param onProgress a callback with a progress event for each file being loaded
  111894. * @param pluginExtension the extension used to determine the plugin
  111895. * @returns The loaded scene
  111896. */
  111897. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  111898. /**
  111899. * Append a scene
  111900. * @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)
  111901. * @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)
  111902. * @param scene is the instance of BABYLON.Scene to append to
  111903. * @param onSuccess a callback with the scene when import succeeds
  111904. * @param onProgress a callback with a progress event for each file being loaded
  111905. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111906. * @param pluginExtension the extension used to determine the plugin
  111907. * @returns The loaded plugin
  111908. */
  111909. 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>;
  111910. /**
  111911. * Append a scene
  111912. * @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)
  111913. * @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)
  111914. * @param scene is the instance of BABYLON.Scene to append to
  111915. * @param onProgress a callback with a progress event for each file being loaded
  111916. * @param pluginExtension the extension used to determine the plugin
  111917. * @returns The given scene
  111918. */
  111919. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  111920. /**
  111921. * Load a scene into an asset container
  111922. * @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)
  111923. * @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)
  111924. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  111925. * @param onSuccess a callback with the scene when import succeeds
  111926. * @param onProgress a callback with a progress event for each file being loaded
  111927. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111928. * @param pluginExtension the extension used to determine the plugin
  111929. * @returns The loaded plugin
  111930. */
  111931. 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>;
  111932. /**
  111933. * Load a scene into an asset container
  111934. * @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)
  111935. * @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)
  111936. * @param scene is the instance of Scene to append to
  111937. * @param onProgress a callback with a progress event for each file being loaded
  111938. * @param pluginExtension the extension used to determine the plugin
  111939. * @returns The loaded asset container
  111940. */
  111941. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  111942. /**
  111943. * Import animations from a file into a scene
  111944. * @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)
  111945. * @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)
  111946. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  111947. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  111948. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  111949. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  111950. * @param onSuccess a callback with the scene when import succeeds
  111951. * @param onProgress a callback with a progress event for each file being loaded
  111952. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111953. */
  111954. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  111955. /**
  111956. * Import animations from a file into a scene
  111957. * @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)
  111958. * @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)
  111959. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  111960. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  111961. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  111962. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  111963. * @param onSuccess a callback with the scene when import succeeds
  111964. * @param onProgress a callback with a progress event for each file being loaded
  111965. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111966. * @returns the updated scene with imported animations
  111967. */
  111968. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  111969. }
  111970. }
  111971. declare module BABYLON {
  111972. /**
  111973. * Generic Controller
  111974. */
  111975. export class GenericController extends WebVRController {
  111976. /**
  111977. * Base Url for the controller model.
  111978. */
  111979. static readonly MODEL_BASE_URL: string;
  111980. /**
  111981. * File name for the controller model.
  111982. */
  111983. static readonly MODEL_FILENAME: string;
  111984. /**
  111985. * Creates a new GenericController from a gamepad
  111986. * @param vrGamepad the gamepad that the controller should be created from
  111987. */
  111988. constructor(vrGamepad: any);
  111989. /**
  111990. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111991. * @param scene scene in which to add meshes
  111992. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111993. */
  111994. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111995. /**
  111996. * Called once for each button that changed state since the last frame
  111997. * @param buttonIdx Which button index changed
  111998. * @param state New state of the button
  111999. * @param changes Which properties on the state changed since last frame
  112000. */
  112001. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112002. }
  112003. }
  112004. declare module BABYLON {
  112005. /**
  112006. * Defines the WindowsMotionController object that the state of the windows motion controller
  112007. */
  112008. export class WindowsMotionController extends WebVRController {
  112009. /**
  112010. * The base url used to load the left and right controller models
  112011. */
  112012. static MODEL_BASE_URL: string;
  112013. /**
  112014. * The name of the left controller model file
  112015. */
  112016. static MODEL_LEFT_FILENAME: string;
  112017. /**
  112018. * The name of the right controller model file
  112019. */
  112020. static MODEL_RIGHT_FILENAME: string;
  112021. /**
  112022. * The controller name prefix for this controller type
  112023. */
  112024. static readonly GAMEPAD_ID_PREFIX: string;
  112025. /**
  112026. * The controller id pattern for this controller type
  112027. */
  112028. private static readonly GAMEPAD_ID_PATTERN;
  112029. private _loadedMeshInfo;
  112030. protected readonly _mapping: {
  112031. buttons: string[];
  112032. buttonMeshNames: {
  112033. 'trigger': string;
  112034. 'menu': string;
  112035. 'grip': string;
  112036. 'thumbstick': string;
  112037. 'trackpad': string;
  112038. };
  112039. buttonObservableNames: {
  112040. 'trigger': string;
  112041. 'menu': string;
  112042. 'grip': string;
  112043. 'thumbstick': string;
  112044. 'trackpad': string;
  112045. };
  112046. axisMeshNames: string[];
  112047. pointingPoseMeshName: string;
  112048. };
  112049. /**
  112050. * Fired when the trackpad on this controller is clicked
  112051. */
  112052. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  112053. /**
  112054. * Fired when the trackpad on this controller is modified
  112055. */
  112056. onTrackpadValuesChangedObservable: Observable<StickValues>;
  112057. /**
  112058. * The current x and y values of this controller's trackpad
  112059. */
  112060. trackpad: StickValues;
  112061. /**
  112062. * Creates a new WindowsMotionController from a gamepad
  112063. * @param vrGamepad the gamepad that the controller should be created from
  112064. */
  112065. constructor(vrGamepad: any);
  112066. /**
  112067. * Fired when the trigger on this controller is modified
  112068. */
  112069. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112070. /**
  112071. * Fired when the menu button on this controller is modified
  112072. */
  112073. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112074. /**
  112075. * Fired when the grip button on this controller is modified
  112076. */
  112077. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112078. /**
  112079. * Fired when the thumbstick button on this controller is modified
  112080. */
  112081. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112082. /**
  112083. * Fired when the touchpad button on this controller is modified
  112084. */
  112085. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112086. /**
  112087. * Fired when the touchpad values on this controller are modified
  112088. */
  112089. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  112090. protected _updateTrackpad(): void;
  112091. /**
  112092. * Called once per frame by the engine.
  112093. */
  112094. update(): void;
  112095. /**
  112096. * Called once for each button that changed state since the last frame
  112097. * @param buttonIdx Which button index changed
  112098. * @param state New state of the button
  112099. * @param changes Which properties on the state changed since last frame
  112100. */
  112101. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112102. /**
  112103. * Moves the buttons on the controller mesh based on their current state
  112104. * @param buttonName the name of the button to move
  112105. * @param buttonValue the value of the button which determines the buttons new position
  112106. */
  112107. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  112108. /**
  112109. * Moves the axis on the controller mesh based on its current state
  112110. * @param axis the index of the axis
  112111. * @param axisValue the value of the axis which determines the meshes new position
  112112. * @hidden
  112113. */
  112114. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  112115. /**
  112116. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112117. * @param scene scene in which to add meshes
  112118. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112119. */
  112120. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  112121. /**
  112122. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  112123. * can be transformed by button presses and axes values, based on this._mapping.
  112124. *
  112125. * @param scene scene in which the meshes exist
  112126. * @param meshes list of meshes that make up the controller model to process
  112127. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  112128. */
  112129. private processModel;
  112130. private createMeshInfo;
  112131. /**
  112132. * Gets the ray of the controller in the direction the controller is pointing
  112133. * @param length the length the resulting ray should be
  112134. * @returns a ray in the direction the controller is pointing
  112135. */
  112136. getForwardRay(length?: number): Ray;
  112137. /**
  112138. * Disposes of the controller
  112139. */
  112140. dispose(): void;
  112141. }
  112142. /**
  112143. * This class represents a new windows motion controller in XR.
  112144. */
  112145. export class XRWindowsMotionController extends WindowsMotionController {
  112146. /**
  112147. * Changing the original WIndowsMotionController mapping to fir the new mapping
  112148. */
  112149. protected readonly _mapping: {
  112150. buttons: string[];
  112151. buttonMeshNames: {
  112152. 'trigger': string;
  112153. 'menu': string;
  112154. 'grip': string;
  112155. 'thumbstick': string;
  112156. 'trackpad': string;
  112157. };
  112158. buttonObservableNames: {
  112159. 'trigger': string;
  112160. 'menu': string;
  112161. 'grip': string;
  112162. 'thumbstick': string;
  112163. 'trackpad': string;
  112164. };
  112165. axisMeshNames: string[];
  112166. pointingPoseMeshName: string;
  112167. };
  112168. /**
  112169. * Construct a new XR-Based windows motion controller
  112170. *
  112171. * @param gamepadInfo the gamepad object from the browser
  112172. */
  112173. constructor(gamepadInfo: any);
  112174. /**
  112175. * holds the thumbstick values (X,Y)
  112176. */
  112177. thumbstickValues: StickValues;
  112178. /**
  112179. * Fired when the thumbstick on this controller is clicked
  112180. */
  112181. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  112182. /**
  112183. * Fired when the thumbstick on this controller is modified
  112184. */
  112185. onThumbstickValuesChangedObservable: Observable<StickValues>;
  112186. /**
  112187. * Fired when the touchpad button on this controller is modified
  112188. */
  112189. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  112190. /**
  112191. * Fired when the touchpad values on this controller are modified
  112192. */
  112193. onTrackpadValuesChangedObservable: Observable<StickValues>;
  112194. /**
  112195. * Fired when the thumbstick button on this controller is modified
  112196. * here to prevent breaking changes
  112197. */
  112198. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112199. /**
  112200. * updating the thumbstick(!) and not the trackpad.
  112201. * This is named this way due to the difference between WebVR and XR and to avoid
  112202. * changing the parent class.
  112203. */
  112204. protected _updateTrackpad(): void;
  112205. /**
  112206. * Disposes the class with joy
  112207. */
  112208. dispose(): void;
  112209. }
  112210. }
  112211. declare module BABYLON {
  112212. /**
  112213. * Oculus Touch Controller
  112214. */
  112215. export class OculusTouchController extends WebVRController {
  112216. /**
  112217. * Base Url for the controller model.
  112218. */
  112219. static MODEL_BASE_URL: string;
  112220. /**
  112221. * File name for the left controller model.
  112222. */
  112223. static MODEL_LEFT_FILENAME: string;
  112224. /**
  112225. * File name for the right controller model.
  112226. */
  112227. static MODEL_RIGHT_FILENAME: string;
  112228. /**
  112229. * Base Url for the Quest controller model.
  112230. */
  112231. static QUEST_MODEL_BASE_URL: string;
  112232. /**
  112233. * @hidden
  112234. * If the controllers are running on a device that needs the updated Quest controller models
  112235. */
  112236. static _IsQuest: boolean;
  112237. /**
  112238. * Fired when the secondary trigger on this controller is modified
  112239. */
  112240. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  112241. /**
  112242. * Fired when the thumb rest on this controller is modified
  112243. */
  112244. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  112245. /**
  112246. * Creates a new OculusTouchController from a gamepad
  112247. * @param vrGamepad the gamepad that the controller should be created from
  112248. */
  112249. constructor(vrGamepad: any);
  112250. /**
  112251. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112252. * @param scene scene in which to add meshes
  112253. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112254. */
  112255. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112256. /**
  112257. * Fired when the A button on this controller is modified
  112258. */
  112259. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112260. /**
  112261. * Fired when the B button on this controller is modified
  112262. */
  112263. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112264. /**
  112265. * Fired when the X button on this controller is modified
  112266. */
  112267. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112268. /**
  112269. * Fired when the Y button on this controller is modified
  112270. */
  112271. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112272. /**
  112273. * Called once for each button that changed state since the last frame
  112274. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  112275. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  112276. * 2) secondary trigger (same)
  112277. * 3) A (right) X (left), touch, pressed = value
  112278. * 4) B / Y
  112279. * 5) thumb rest
  112280. * @param buttonIdx Which button index changed
  112281. * @param state New state of the button
  112282. * @param changes Which properties on the state changed since last frame
  112283. */
  112284. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112285. }
  112286. }
  112287. declare module BABYLON {
  112288. /**
  112289. * Vive Controller
  112290. */
  112291. export class ViveController extends WebVRController {
  112292. /**
  112293. * Base Url for the controller model.
  112294. */
  112295. static MODEL_BASE_URL: string;
  112296. /**
  112297. * File name for the controller model.
  112298. */
  112299. static MODEL_FILENAME: string;
  112300. /**
  112301. * Creates a new ViveController from a gamepad
  112302. * @param vrGamepad the gamepad that the controller should be created from
  112303. */
  112304. constructor(vrGamepad: any);
  112305. /**
  112306. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112307. * @param scene scene in which to add meshes
  112308. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112309. */
  112310. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112311. /**
  112312. * Fired when the left button on this controller is modified
  112313. */
  112314. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112315. /**
  112316. * Fired when the right button on this controller is modified
  112317. */
  112318. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112319. /**
  112320. * Fired when the menu button on this controller is modified
  112321. */
  112322. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112323. /**
  112324. * Called once for each button that changed state since the last frame
  112325. * Vive mapping:
  112326. * 0: touchpad
  112327. * 1: trigger
  112328. * 2: left AND right buttons
  112329. * 3: menu button
  112330. * @param buttonIdx Which button index changed
  112331. * @param state New state of the button
  112332. * @param changes Which properties on the state changed since last frame
  112333. */
  112334. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112335. }
  112336. }
  112337. declare module BABYLON {
  112338. /**
  112339. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  112340. */
  112341. export class WebXRControllerModelLoader {
  112342. /**
  112343. * an observable that triggers when a new model (the mesh itself) was initialized.
  112344. * To know when the mesh was loaded use the controller's own modelLoaded() method
  112345. */
  112346. onControllerModelLoaded: Observable<WebXRController>;
  112347. /**
  112348. * Creates the WebXRControllerModelLoader
  112349. * @param input xr input that creates the controllers
  112350. */
  112351. constructor(input: WebXRInput);
  112352. }
  112353. }
  112354. declare module BABYLON {
  112355. /**
  112356. * Handles pointer input automatically for the pointer of XR controllers
  112357. */
  112358. export class WebXRControllerPointerSelection {
  112359. private static _idCounter;
  112360. private _tmpRay;
  112361. /**
  112362. * Creates a WebXRControllerPointerSelection
  112363. * @param input input manager to setup pointer selection
  112364. */
  112365. constructor(input: WebXRInput);
  112366. private _convertNormalToDirectionOfRay;
  112367. private _updatePointerDistance;
  112368. }
  112369. }
  112370. declare module BABYLON {
  112371. /**
  112372. * Enables teleportation
  112373. */
  112374. export class WebXRControllerTeleportation {
  112375. private _teleportationFillColor;
  112376. private _teleportationBorderColor;
  112377. private _tmpRay;
  112378. private _tmpVector;
  112379. /**
  112380. * when set to true (default) teleportation will wait for thumbstick changes.
  112381. * When set to false teleportation will be disabled.
  112382. *
  112383. * If set to false while teleporting results can be unexpected.
  112384. */
  112385. enabled: boolean;
  112386. /**
  112387. * Creates a WebXRControllerTeleportation
  112388. * @param input input manager to add teleportation to
  112389. * @param floorMeshes floormeshes which can be teleported to
  112390. */
  112391. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  112392. }
  112393. }
  112394. declare module BABYLON {
  112395. /**
  112396. * Button which can be used to enter a different mode of XR
  112397. */
  112398. export class WebXREnterExitUIButton {
  112399. /** button element */
  112400. element: HTMLElement;
  112401. /** XR initialization options for the button */
  112402. sessionMode: XRSessionMode;
  112403. /** Reference space type */
  112404. referenceSpaceType: XRReferenceSpaceType;
  112405. /**
  112406. * Creates a WebXREnterExitUIButton
  112407. * @param element button element
  112408. * @param sessionMode XR initialization session mode
  112409. * @param referenceSpaceType the type of reference space to be used
  112410. */
  112411. constructor(
  112412. /** button element */
  112413. element: HTMLElement,
  112414. /** XR initialization options for the button */
  112415. sessionMode: XRSessionMode,
  112416. /** Reference space type */
  112417. referenceSpaceType: XRReferenceSpaceType);
  112418. /**
  112419. * Overwritable function which can be used to update the button's visuals when the state changes
  112420. * @param activeButton the current active button in the UI
  112421. */
  112422. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  112423. }
  112424. /**
  112425. * Options to create the webXR UI
  112426. */
  112427. export class WebXREnterExitUIOptions {
  112428. /**
  112429. * Context to enter xr with
  112430. */
  112431. renderTarget?: Nullable<WebXRRenderTarget>;
  112432. /**
  112433. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  112434. */
  112435. customButtons?: Array<WebXREnterExitUIButton>;
  112436. /**
  112437. * A session mode to use when creating the default button.
  112438. * Default is immersive-vr
  112439. */
  112440. sessionMode?: XRSessionMode;
  112441. /**
  112442. * A reference space type to use when creating the default button.
  112443. * Default is local-floor
  112444. */
  112445. referenceSpaceType?: XRReferenceSpaceType;
  112446. }
  112447. /**
  112448. * UI to allow the user to enter/exit XR mode
  112449. */
  112450. export class WebXREnterExitUI implements IDisposable {
  112451. private scene;
  112452. /** version of the options passed to this UI */
  112453. options: WebXREnterExitUIOptions;
  112454. private _overlay;
  112455. private _buttons;
  112456. private _activeButton;
  112457. /**
  112458. * Fired every time the active button is changed.
  112459. *
  112460. * When xr is entered via a button that launches xr that button will be the callback parameter
  112461. *
  112462. * When exiting xr the callback parameter will be null)
  112463. */
  112464. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  112465. /**
  112466. * Creates UI to allow the user to enter/exit XR mode
  112467. * @param scene the scene to add the ui to
  112468. * @param helper the xr experience helper to enter/exit xr with
  112469. * @param options options to configure the UI
  112470. * @returns the created ui
  112471. */
  112472. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  112473. /**
  112474. *
  112475. * @param scene babylon scene object to use
  112476. * @param options (read-only) version of the options passed to this UI
  112477. */
  112478. private constructor();
  112479. private _updateButtons;
  112480. /**
  112481. * Disposes of the object
  112482. */
  112483. dispose(): void;
  112484. }
  112485. }
  112486. declare module BABYLON {
  112487. /**
  112488. * Options for the default xr helper
  112489. */
  112490. export class WebXRDefaultExperienceOptions {
  112491. /**
  112492. * Floor meshes that should be used for teleporting
  112493. */
  112494. floorMeshes: Array<AbstractMesh>;
  112495. /**
  112496. * Enable or disable default UI to enter XR
  112497. */
  112498. disableDefaultUI?: boolean;
  112499. /**
  112500. * optional configuration for the output canvas
  112501. */
  112502. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  112503. /**
  112504. * optional UI options. This can be used among other to change session mode and reference space type
  112505. */
  112506. uiOptions?: WebXREnterExitUIOptions;
  112507. }
  112508. /**
  112509. * Default experience which provides a similar setup to the previous webVRExperience
  112510. */
  112511. export class WebXRDefaultExperience {
  112512. /**
  112513. * Base experience
  112514. */
  112515. baseExperience: WebXRExperienceHelper;
  112516. /**
  112517. * Input experience extension
  112518. */
  112519. input: WebXRInput;
  112520. /**
  112521. * Loads the controller models
  112522. */
  112523. controllerModelLoader: WebXRControllerModelLoader;
  112524. /**
  112525. * Enables laser pointer and selection
  112526. */
  112527. pointerSelection: WebXRControllerPointerSelection;
  112528. /**
  112529. * Enables teleportation
  112530. */
  112531. teleportation: WebXRControllerTeleportation;
  112532. /**
  112533. * Enables ui for entering/exiting xr
  112534. */
  112535. enterExitUI: WebXREnterExitUI;
  112536. /**
  112537. * Default target xr should render to
  112538. */
  112539. renderTarget: WebXRRenderTarget;
  112540. /**
  112541. * Creates the default xr experience
  112542. * @param scene scene
  112543. * @param options options for basic configuration
  112544. * @returns resulting WebXRDefaultExperience
  112545. */
  112546. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  112547. private constructor();
  112548. /**
  112549. * DIsposes of the experience helper
  112550. */
  112551. dispose(): void;
  112552. }
  112553. }
  112554. declare module BABYLON {
  112555. /**
  112556. * Options to modify the vr teleportation behavior.
  112557. */
  112558. export interface VRTeleportationOptions {
  112559. /**
  112560. * The name of the mesh which should be used as the teleportation floor. (default: null)
  112561. */
  112562. floorMeshName?: string;
  112563. /**
  112564. * A list of meshes to be used as the teleportation floor. (default: empty)
  112565. */
  112566. floorMeshes?: Mesh[];
  112567. /**
  112568. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  112569. */
  112570. teleportationMode?: number;
  112571. /**
  112572. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  112573. */
  112574. teleportationTime?: number;
  112575. /**
  112576. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  112577. */
  112578. teleportationSpeed?: number;
  112579. /**
  112580. * The easing function used in the animation or null for Linear. (default CircleEase)
  112581. */
  112582. easingFunction?: EasingFunction;
  112583. }
  112584. /**
  112585. * Options to modify the vr experience helper's behavior.
  112586. */
  112587. export interface VRExperienceHelperOptions extends WebVROptions {
  112588. /**
  112589. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  112590. */
  112591. createDeviceOrientationCamera?: boolean;
  112592. /**
  112593. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  112594. */
  112595. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  112596. /**
  112597. * Uses the main button on the controller to toggle the laser casted. (default: true)
  112598. */
  112599. laserToggle?: boolean;
  112600. /**
  112601. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  112602. */
  112603. floorMeshes?: Mesh[];
  112604. /**
  112605. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  112606. */
  112607. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  112608. /**
  112609. * Defines if WebXR should be used instead of WebVR (if available)
  112610. */
  112611. useXR?: boolean;
  112612. }
  112613. /**
  112614. * Event containing information after VR has been entered
  112615. */
  112616. export class OnAfterEnteringVRObservableEvent {
  112617. /**
  112618. * If entering vr was successful
  112619. */
  112620. success: boolean;
  112621. }
  112622. /**
  112623. * Helps to quickly add VR support to an existing scene.
  112624. * See http://doc.babylonjs.com/how_to/webvr_helper
  112625. */
  112626. export class VRExperienceHelper {
  112627. /** Options to modify the vr experience helper's behavior. */
  112628. webVROptions: VRExperienceHelperOptions;
  112629. private _scene;
  112630. private _position;
  112631. private _btnVR;
  112632. private _btnVRDisplayed;
  112633. private _webVRsupported;
  112634. private _webVRready;
  112635. private _webVRrequesting;
  112636. private _webVRpresenting;
  112637. private _hasEnteredVR;
  112638. private _fullscreenVRpresenting;
  112639. private _inputElement;
  112640. private _webVRCamera;
  112641. private _vrDeviceOrientationCamera;
  112642. private _deviceOrientationCamera;
  112643. private _existingCamera;
  112644. private _onKeyDown;
  112645. private _onVrDisplayPresentChange;
  112646. private _onVRDisplayChanged;
  112647. private _onVRRequestPresentStart;
  112648. private _onVRRequestPresentComplete;
  112649. /**
  112650. * 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)
  112651. */
  112652. enableGazeEvenWhenNoPointerLock: boolean;
  112653. /**
  112654. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  112655. */
  112656. exitVROnDoubleTap: boolean;
  112657. /**
  112658. * Observable raised right before entering VR.
  112659. */
  112660. onEnteringVRObservable: Observable<VRExperienceHelper>;
  112661. /**
  112662. * Observable raised when entering VR has completed.
  112663. */
  112664. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  112665. /**
  112666. * Observable raised when exiting VR.
  112667. */
  112668. onExitingVRObservable: Observable<VRExperienceHelper>;
  112669. /**
  112670. * Observable raised when controller mesh is loaded.
  112671. */
  112672. onControllerMeshLoadedObservable: Observable<WebVRController>;
  112673. /** Return this.onEnteringVRObservable
  112674. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  112675. */
  112676. readonly onEnteringVR: Observable<VRExperienceHelper>;
  112677. /** Return this.onExitingVRObservable
  112678. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  112679. */
  112680. readonly onExitingVR: Observable<VRExperienceHelper>;
  112681. /** Return this.onControllerMeshLoadedObservable
  112682. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  112683. */
  112684. readonly onControllerMeshLoaded: Observable<WebVRController>;
  112685. private _rayLength;
  112686. private _useCustomVRButton;
  112687. private _teleportationRequested;
  112688. private _teleportActive;
  112689. private _floorMeshName;
  112690. private _floorMeshesCollection;
  112691. private _teleportationMode;
  112692. private _teleportationTime;
  112693. private _teleportationSpeed;
  112694. private _teleportationEasing;
  112695. private _rotationAllowed;
  112696. private _teleportBackwardsVector;
  112697. private _teleportationTarget;
  112698. private _isDefaultTeleportationTarget;
  112699. private _postProcessMove;
  112700. private _teleportationFillColor;
  112701. private _teleportationBorderColor;
  112702. private _rotationAngle;
  112703. private _haloCenter;
  112704. private _cameraGazer;
  112705. private _padSensibilityUp;
  112706. private _padSensibilityDown;
  112707. private _leftController;
  112708. private _rightController;
  112709. /**
  112710. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  112711. */
  112712. onNewMeshSelected: Observable<AbstractMesh>;
  112713. /**
  112714. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  112715. * This observable will provide the mesh and the controller used to select the mesh
  112716. */
  112717. onMeshSelectedWithController: Observable<{
  112718. mesh: AbstractMesh;
  112719. controller: WebVRController;
  112720. }>;
  112721. /**
  112722. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  112723. */
  112724. onNewMeshPicked: Observable<PickingInfo>;
  112725. private _circleEase;
  112726. /**
  112727. * Observable raised before camera teleportation
  112728. */
  112729. onBeforeCameraTeleport: Observable<Vector3>;
  112730. /**
  112731. * Observable raised after camera teleportation
  112732. */
  112733. onAfterCameraTeleport: Observable<Vector3>;
  112734. /**
  112735. * Observable raised when current selected mesh gets unselected
  112736. */
  112737. onSelectedMeshUnselected: Observable<AbstractMesh>;
  112738. private _raySelectionPredicate;
  112739. /**
  112740. * To be optionaly changed by user to define custom ray selection
  112741. */
  112742. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  112743. /**
  112744. * To be optionaly changed by user to define custom selection logic (after ray selection)
  112745. */
  112746. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  112747. /**
  112748. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  112749. */
  112750. teleportationEnabled: boolean;
  112751. private _defaultHeight;
  112752. private _teleportationInitialized;
  112753. private _interactionsEnabled;
  112754. private _interactionsRequested;
  112755. private _displayGaze;
  112756. private _displayLaserPointer;
  112757. /**
  112758. * The mesh used to display where the user is going to teleport.
  112759. */
  112760. /**
  112761. * Sets the mesh to be used to display where the user is going to teleport.
  112762. */
  112763. teleportationTarget: Mesh;
  112764. /**
  112765. * 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
  112766. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  112767. * See http://doc.babylonjs.com/resources/baking_transformations
  112768. */
  112769. gazeTrackerMesh: Mesh;
  112770. /**
  112771. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  112772. */
  112773. updateGazeTrackerScale: boolean;
  112774. /**
  112775. * If the gaze trackers color should be updated when selecting meshes
  112776. */
  112777. updateGazeTrackerColor: boolean;
  112778. /**
  112779. * If the controller laser color should be updated when selecting meshes
  112780. */
  112781. updateControllerLaserColor: boolean;
  112782. /**
  112783. * The gaze tracking mesh corresponding to the left controller
  112784. */
  112785. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  112786. /**
  112787. * The gaze tracking mesh corresponding to the right controller
  112788. */
  112789. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  112790. /**
  112791. * If the ray of the gaze should be displayed.
  112792. */
  112793. /**
  112794. * Sets if the ray of the gaze should be displayed.
  112795. */
  112796. displayGaze: boolean;
  112797. /**
  112798. * If the ray of the LaserPointer should be displayed.
  112799. */
  112800. /**
  112801. * Sets if the ray of the LaserPointer should be displayed.
  112802. */
  112803. displayLaserPointer: boolean;
  112804. /**
  112805. * The deviceOrientationCamera used as the camera when not in VR.
  112806. */
  112807. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  112808. /**
  112809. * Based on the current WebVR support, returns the current VR camera used.
  112810. */
  112811. readonly currentVRCamera: Nullable<Camera>;
  112812. /**
  112813. * The webVRCamera which is used when in VR.
  112814. */
  112815. readonly webVRCamera: WebVRFreeCamera;
  112816. /**
  112817. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  112818. */
  112819. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  112820. /**
  112821. * The html button that is used to trigger entering into VR.
  112822. */
  112823. readonly vrButton: Nullable<HTMLButtonElement>;
  112824. private readonly _teleportationRequestInitiated;
  112825. /**
  112826. * Defines wether or not Pointer lock should be requested when switching to
  112827. * full screen.
  112828. */
  112829. requestPointerLockOnFullScreen: boolean;
  112830. /**
  112831. * If asking to force XR, this will be populated with the default xr experience
  112832. */
  112833. xr: WebXRDefaultExperience;
  112834. /**
  112835. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  112836. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  112837. */
  112838. xrTestDone: boolean;
  112839. /**
  112840. * Instantiates a VRExperienceHelper.
  112841. * Helps to quickly add VR support to an existing scene.
  112842. * @param scene The scene the VRExperienceHelper belongs to.
  112843. * @param webVROptions Options to modify the vr experience helper's behavior.
  112844. */
  112845. constructor(scene: Scene,
  112846. /** Options to modify the vr experience helper's behavior. */
  112847. webVROptions?: VRExperienceHelperOptions);
  112848. private completeVRInit;
  112849. private _onDefaultMeshLoaded;
  112850. private _onResize;
  112851. private _onFullscreenChange;
  112852. /**
  112853. * Gets a value indicating if we are currently in VR mode.
  112854. */
  112855. readonly isInVRMode: boolean;
  112856. private onVrDisplayPresentChange;
  112857. private onVRDisplayChanged;
  112858. private moveButtonToBottomRight;
  112859. private displayVRButton;
  112860. private updateButtonVisibility;
  112861. private _cachedAngularSensibility;
  112862. /**
  112863. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  112864. * Otherwise, will use the fullscreen API.
  112865. */
  112866. enterVR(): void;
  112867. /**
  112868. * Attempt to exit VR, or fullscreen.
  112869. */
  112870. exitVR(): void;
  112871. /**
  112872. * The position of the vr experience helper.
  112873. */
  112874. /**
  112875. * Sets the position of the vr experience helper.
  112876. */
  112877. position: Vector3;
  112878. /**
  112879. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  112880. */
  112881. enableInteractions(): void;
  112882. private readonly _noControllerIsActive;
  112883. private beforeRender;
  112884. private _isTeleportationFloor;
  112885. /**
  112886. * Adds a floor mesh to be used for teleportation.
  112887. * @param floorMesh the mesh to be used for teleportation.
  112888. */
  112889. addFloorMesh(floorMesh: Mesh): void;
  112890. /**
  112891. * Removes a floor mesh from being used for teleportation.
  112892. * @param floorMesh the mesh to be removed.
  112893. */
  112894. removeFloorMesh(floorMesh: Mesh): void;
  112895. /**
  112896. * Enables interactions and teleportation using the VR controllers and gaze.
  112897. * @param vrTeleportationOptions options to modify teleportation behavior.
  112898. */
  112899. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  112900. private _onNewGamepadConnected;
  112901. private _tryEnableInteractionOnController;
  112902. private _onNewGamepadDisconnected;
  112903. private _enableInteractionOnController;
  112904. private _checkTeleportWithRay;
  112905. private _checkRotate;
  112906. private _checkTeleportBackwards;
  112907. private _enableTeleportationOnController;
  112908. private _createTeleportationCircles;
  112909. private _displayTeleportationTarget;
  112910. private _hideTeleportationTarget;
  112911. private _rotateCamera;
  112912. private _moveTeleportationSelectorTo;
  112913. private _workingVector;
  112914. private _workingQuaternion;
  112915. private _workingMatrix;
  112916. /**
  112917. * Time Constant Teleportation Mode
  112918. */
  112919. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  112920. /**
  112921. * Speed Constant Teleportation Mode
  112922. */
  112923. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  112924. /**
  112925. * Teleports the users feet to the desired location
  112926. * @param location The location where the user's feet should be placed
  112927. */
  112928. teleportCamera(location: Vector3): void;
  112929. private _convertNormalToDirectionOfRay;
  112930. private _castRayAndSelectObject;
  112931. private _notifySelectedMeshUnselected;
  112932. /**
  112933. * Sets the color of the laser ray from the vr controllers.
  112934. * @param color new color for the ray.
  112935. */
  112936. changeLaserColor(color: Color3): void;
  112937. /**
  112938. * Sets the color of the ray from the vr headsets gaze.
  112939. * @param color new color for the ray.
  112940. */
  112941. changeGazeColor(color: Color3): void;
  112942. /**
  112943. * Exits VR and disposes of the vr experience helper
  112944. */
  112945. dispose(): void;
  112946. /**
  112947. * Gets the name of the VRExperienceHelper class
  112948. * @returns "VRExperienceHelper"
  112949. */
  112950. getClassName(): string;
  112951. }
  112952. }
  112953. declare module BABYLON {
  112954. /**
  112955. * Contains an array of blocks representing the octree
  112956. */
  112957. export interface IOctreeContainer<T> {
  112958. /**
  112959. * Blocks within the octree
  112960. */
  112961. blocks: Array<OctreeBlock<T>>;
  112962. }
  112963. /**
  112964. * Class used to store a cell in an octree
  112965. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112966. */
  112967. export class OctreeBlock<T> {
  112968. /**
  112969. * Gets the content of the current block
  112970. */
  112971. entries: T[];
  112972. /**
  112973. * Gets the list of block children
  112974. */
  112975. blocks: Array<OctreeBlock<T>>;
  112976. private _depth;
  112977. private _maxDepth;
  112978. private _capacity;
  112979. private _minPoint;
  112980. private _maxPoint;
  112981. private _boundingVectors;
  112982. private _creationFunc;
  112983. /**
  112984. * Creates a new block
  112985. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  112986. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  112987. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  112988. * @param depth defines the current depth of this block in the octree
  112989. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  112990. * @param creationFunc defines a callback to call when an element is added to the block
  112991. */
  112992. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  112993. /**
  112994. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  112995. */
  112996. readonly capacity: number;
  112997. /**
  112998. * Gets the minimum vector (in world space) of the block's bounding box
  112999. */
  113000. readonly minPoint: Vector3;
  113001. /**
  113002. * Gets the maximum vector (in world space) of the block's bounding box
  113003. */
  113004. readonly maxPoint: Vector3;
  113005. /**
  113006. * Add a new element to this block
  113007. * @param entry defines the element to add
  113008. */
  113009. addEntry(entry: T): void;
  113010. /**
  113011. * Remove an element from this block
  113012. * @param entry defines the element to remove
  113013. */
  113014. removeEntry(entry: T): void;
  113015. /**
  113016. * Add an array of elements to this block
  113017. * @param entries defines the array of elements to add
  113018. */
  113019. addEntries(entries: T[]): void;
  113020. /**
  113021. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  113022. * @param frustumPlanes defines the frustum planes to test
  113023. * @param selection defines the array to store current content if selection is positive
  113024. * @param allowDuplicate defines if the selection array can contains duplicated entries
  113025. */
  113026. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  113027. /**
  113028. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  113029. * @param sphereCenter defines the bounding sphere center
  113030. * @param sphereRadius defines the bounding sphere radius
  113031. * @param selection defines the array to store current content if selection is positive
  113032. * @param allowDuplicate defines if the selection array can contains duplicated entries
  113033. */
  113034. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  113035. /**
  113036. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  113037. * @param ray defines the ray to test with
  113038. * @param selection defines the array to store current content if selection is positive
  113039. */
  113040. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  113041. /**
  113042. * Subdivide the content into child blocks (this block will then be empty)
  113043. */
  113044. createInnerBlocks(): void;
  113045. /**
  113046. * @hidden
  113047. */
  113048. 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;
  113049. }
  113050. }
  113051. declare module BABYLON {
  113052. /**
  113053. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  113054. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  113055. */
  113056. export class Octree<T> {
  113057. /** 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.) */
  113058. maxDepth: number;
  113059. /**
  113060. * Blocks within the octree containing objects
  113061. */
  113062. blocks: Array<OctreeBlock<T>>;
  113063. /**
  113064. * Content stored in the octree
  113065. */
  113066. dynamicContent: T[];
  113067. private _maxBlockCapacity;
  113068. private _selectionContent;
  113069. private _creationFunc;
  113070. /**
  113071. * Creates a octree
  113072. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  113073. * @param creationFunc function to be used to instatiate the octree
  113074. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  113075. * @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.)
  113076. */
  113077. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  113078. /** 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.) */
  113079. maxDepth?: number);
  113080. /**
  113081. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  113082. * @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);
  113083. * @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);
  113084. * @param entries meshes to be added to the octree blocks
  113085. */
  113086. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  113087. /**
  113088. * Adds a mesh to the octree
  113089. * @param entry Mesh to add to the octree
  113090. */
  113091. addMesh(entry: T): void;
  113092. /**
  113093. * Remove an element from the octree
  113094. * @param entry defines the element to remove
  113095. */
  113096. removeMesh(entry: T): void;
  113097. /**
  113098. * Selects an array of meshes within the frustum
  113099. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  113100. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  113101. * @returns array of meshes within the frustum
  113102. */
  113103. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  113104. /**
  113105. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  113106. * @param sphereCenter defines the bounding sphere center
  113107. * @param sphereRadius defines the bounding sphere radius
  113108. * @param allowDuplicate defines if the selection array can contains duplicated entries
  113109. * @returns an array of objects that intersect the sphere
  113110. */
  113111. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  113112. /**
  113113. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  113114. * @param ray defines the ray to test with
  113115. * @returns array of intersected objects
  113116. */
  113117. intersectsRay(ray: Ray): SmartArray<T>;
  113118. /**
  113119. * Adds a mesh into the octree block if it intersects the block
  113120. */
  113121. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  113122. /**
  113123. * Adds a submesh into the octree block if it intersects the block
  113124. */
  113125. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  113126. }
  113127. }
  113128. declare module BABYLON {
  113129. interface Scene {
  113130. /**
  113131. * @hidden
  113132. * Backing Filed
  113133. */
  113134. _selectionOctree: Octree<AbstractMesh>;
  113135. /**
  113136. * Gets the octree used to boost mesh selection (picking)
  113137. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  113138. */
  113139. selectionOctree: Octree<AbstractMesh>;
  113140. /**
  113141. * Creates or updates the octree used to boost selection (picking)
  113142. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  113143. * @param maxCapacity defines the maximum capacity per leaf
  113144. * @param maxDepth defines the maximum depth of the octree
  113145. * @returns an octree of AbstractMesh
  113146. */
  113147. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  113148. }
  113149. interface AbstractMesh {
  113150. /**
  113151. * @hidden
  113152. * Backing Field
  113153. */
  113154. _submeshesOctree: Octree<SubMesh>;
  113155. /**
  113156. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  113157. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  113158. * @param maxCapacity defines the maximum size of each block (64 by default)
  113159. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  113160. * @returns the new octree
  113161. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  113162. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  113163. */
  113164. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  113165. }
  113166. /**
  113167. * Defines the octree scene component responsible to manage any octrees
  113168. * in a given scene.
  113169. */
  113170. export class OctreeSceneComponent {
  113171. /**
  113172. * The component name help to identify the component in the list of scene components.
  113173. */
  113174. readonly name: string;
  113175. /**
  113176. * The scene the component belongs to.
  113177. */
  113178. scene: Scene;
  113179. /**
  113180. * Indicates if the meshes have been checked to make sure they are isEnabled()
  113181. */
  113182. readonly checksIsEnabled: boolean;
  113183. /**
  113184. * Creates a new instance of the component for the given scene
  113185. * @param scene Defines the scene to register the component in
  113186. */
  113187. constructor(scene: Scene);
  113188. /**
  113189. * Registers the component in a given scene
  113190. */
  113191. register(): void;
  113192. /**
  113193. * Return the list of active meshes
  113194. * @returns the list of active meshes
  113195. */
  113196. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  113197. /**
  113198. * Return the list of active sub meshes
  113199. * @param mesh The mesh to get the candidates sub meshes from
  113200. * @returns the list of active sub meshes
  113201. */
  113202. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  113203. private _tempRay;
  113204. /**
  113205. * Return the list of sub meshes intersecting with a given local ray
  113206. * @param mesh defines the mesh to find the submesh for
  113207. * @param localRay defines the ray in local space
  113208. * @returns the list of intersecting sub meshes
  113209. */
  113210. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  113211. /**
  113212. * Return the list of sub meshes colliding with a collider
  113213. * @param mesh defines the mesh to find the submesh for
  113214. * @param collider defines the collider to evaluate the collision against
  113215. * @returns the list of colliding sub meshes
  113216. */
  113217. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  113218. /**
  113219. * Rebuilds the elements related to this component in case of
  113220. * context lost for instance.
  113221. */
  113222. rebuild(): void;
  113223. /**
  113224. * Disposes the component and the associated ressources.
  113225. */
  113226. dispose(): void;
  113227. }
  113228. }
  113229. declare module BABYLON {
  113230. /**
  113231. * Renders a layer on top of an existing scene
  113232. */
  113233. export class UtilityLayerRenderer implements IDisposable {
  113234. /** the original scene that will be rendered on top of */
  113235. originalScene: Scene;
  113236. private _pointerCaptures;
  113237. private _lastPointerEvents;
  113238. private static _DefaultUtilityLayer;
  113239. private static _DefaultKeepDepthUtilityLayer;
  113240. private _sharedGizmoLight;
  113241. private _renderCamera;
  113242. /**
  113243. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  113244. * @returns the camera that is used when rendering the utility layer
  113245. */
  113246. getRenderCamera(): Nullable<Camera>;
  113247. /**
  113248. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  113249. * @param cam the camera that should be used when rendering the utility layer
  113250. */
  113251. setRenderCamera(cam: Nullable<Camera>): void;
  113252. /**
  113253. * @hidden
  113254. * Light which used by gizmos to get light shading
  113255. */
  113256. _getSharedGizmoLight(): HemisphericLight;
  113257. /**
  113258. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  113259. */
  113260. pickUtilitySceneFirst: boolean;
  113261. /**
  113262. * 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)
  113263. */
  113264. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  113265. /**
  113266. * 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)
  113267. */
  113268. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  113269. /**
  113270. * The scene that is rendered on top of the original scene
  113271. */
  113272. utilityLayerScene: Scene;
  113273. /**
  113274. * If the utility layer should automatically be rendered on top of existing scene
  113275. */
  113276. shouldRender: boolean;
  113277. /**
  113278. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  113279. */
  113280. onlyCheckPointerDownEvents: boolean;
  113281. /**
  113282. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  113283. */
  113284. processAllEvents: boolean;
  113285. /**
  113286. * Observable raised when the pointer move from the utility layer scene to the main scene
  113287. */
  113288. onPointerOutObservable: Observable<number>;
  113289. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  113290. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  113291. private _afterRenderObserver;
  113292. private _sceneDisposeObserver;
  113293. private _originalPointerObserver;
  113294. /**
  113295. * Instantiates a UtilityLayerRenderer
  113296. * @param originalScene the original scene that will be rendered on top of
  113297. * @param handleEvents boolean indicating if the utility layer should handle events
  113298. */
  113299. constructor(
  113300. /** the original scene that will be rendered on top of */
  113301. originalScene: Scene, handleEvents?: boolean);
  113302. private _notifyObservers;
  113303. /**
  113304. * Renders the utility layers scene on top of the original scene
  113305. */
  113306. render(): void;
  113307. /**
  113308. * Disposes of the renderer
  113309. */
  113310. dispose(): void;
  113311. private _updateCamera;
  113312. }
  113313. }
  113314. declare module BABYLON {
  113315. /**
  113316. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  113317. */
  113318. export class Gizmo implements IDisposable {
  113319. /** The utility layer the gizmo will be added to */
  113320. gizmoLayer: UtilityLayerRenderer;
  113321. /**
  113322. * The root mesh of the gizmo
  113323. */
  113324. _rootMesh: Mesh;
  113325. private _attachedMesh;
  113326. /**
  113327. * Ratio for the scale of the gizmo (Default: 1)
  113328. */
  113329. scaleRatio: number;
  113330. /**
  113331. * If a custom mesh has been set (Default: false)
  113332. */
  113333. protected _customMeshSet: boolean;
  113334. /**
  113335. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  113336. * * When set, interactions will be enabled
  113337. */
  113338. attachedMesh: Nullable<AbstractMesh>;
  113339. /**
  113340. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  113341. * @param mesh The mesh to replace the default mesh of the gizmo
  113342. */
  113343. setCustomMesh(mesh: Mesh): void;
  113344. /**
  113345. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  113346. */
  113347. updateGizmoRotationToMatchAttachedMesh: boolean;
  113348. /**
  113349. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  113350. */
  113351. updateGizmoPositionToMatchAttachedMesh: boolean;
  113352. /**
  113353. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  113354. */
  113355. updateScale: boolean;
  113356. protected _interactionsEnabled: boolean;
  113357. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113358. private _beforeRenderObserver;
  113359. private _tempVector;
  113360. /**
  113361. * Creates a gizmo
  113362. * @param gizmoLayer The utility layer the gizmo will be added to
  113363. */
  113364. constructor(
  113365. /** The utility layer the gizmo will be added to */
  113366. gizmoLayer?: UtilityLayerRenderer);
  113367. /**
  113368. * Updates the gizmo to match the attached mesh's position/rotation
  113369. */
  113370. protected _update(): void;
  113371. /**
  113372. * Disposes of the gizmo
  113373. */
  113374. dispose(): void;
  113375. }
  113376. }
  113377. declare module BABYLON {
  113378. /**
  113379. * Single plane drag gizmo
  113380. */
  113381. export class PlaneDragGizmo extends Gizmo {
  113382. /**
  113383. * Drag behavior responsible for the gizmos dragging interactions
  113384. */
  113385. dragBehavior: PointerDragBehavior;
  113386. private _pointerObserver;
  113387. /**
  113388. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113389. */
  113390. snapDistance: number;
  113391. /**
  113392. * Event that fires each time the gizmo snaps to a new location.
  113393. * * snapDistance is the the change in distance
  113394. */
  113395. onSnapObservable: Observable<{
  113396. snapDistance: number;
  113397. }>;
  113398. private _plane;
  113399. private _coloredMaterial;
  113400. private _hoverMaterial;
  113401. private _isEnabled;
  113402. private _parent;
  113403. /** @hidden */
  113404. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  113405. /** @hidden */
  113406. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  113407. /**
  113408. * Creates a PlaneDragGizmo
  113409. * @param gizmoLayer The utility layer the gizmo will be added to
  113410. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  113411. * @param color The color of the gizmo
  113412. */
  113413. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  113414. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113415. /**
  113416. * If the gizmo is enabled
  113417. */
  113418. isEnabled: boolean;
  113419. /**
  113420. * Disposes of the gizmo
  113421. */
  113422. dispose(): void;
  113423. }
  113424. }
  113425. declare module BABYLON {
  113426. /**
  113427. * Gizmo that enables dragging a mesh along 3 axis
  113428. */
  113429. export class PositionGizmo extends Gizmo {
  113430. /**
  113431. * Internal gizmo used for interactions on the x axis
  113432. */
  113433. xGizmo: AxisDragGizmo;
  113434. /**
  113435. * Internal gizmo used for interactions on the y axis
  113436. */
  113437. yGizmo: AxisDragGizmo;
  113438. /**
  113439. * Internal gizmo used for interactions on the z axis
  113440. */
  113441. zGizmo: AxisDragGizmo;
  113442. /**
  113443. * Internal gizmo used for interactions on the yz plane
  113444. */
  113445. xPlaneGizmo: PlaneDragGizmo;
  113446. /**
  113447. * Internal gizmo used for interactions on the xz plane
  113448. */
  113449. yPlaneGizmo: PlaneDragGizmo;
  113450. /**
  113451. * Internal gizmo used for interactions on the xy plane
  113452. */
  113453. zPlaneGizmo: PlaneDragGizmo;
  113454. /**
  113455. * private variables
  113456. */
  113457. private _meshAttached;
  113458. private _updateGizmoRotationToMatchAttachedMesh;
  113459. private _snapDistance;
  113460. private _scaleRatio;
  113461. /** Fires an event when any of it's sub gizmos are dragged */
  113462. onDragStartObservable: Observable<unknown>;
  113463. /** Fires an event when any of it's sub gizmos are released from dragging */
  113464. onDragEndObservable: Observable<unknown>;
  113465. /**
  113466. * If set to true, planar drag is enabled
  113467. */
  113468. private _planarGizmoEnabled;
  113469. attachedMesh: Nullable<AbstractMesh>;
  113470. /**
  113471. * Creates a PositionGizmo
  113472. * @param gizmoLayer The utility layer the gizmo will be added to
  113473. */
  113474. constructor(gizmoLayer?: UtilityLayerRenderer);
  113475. /**
  113476. * If the planar drag gizmo is enabled
  113477. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  113478. */
  113479. planarGizmoEnabled: boolean;
  113480. updateGizmoRotationToMatchAttachedMesh: boolean;
  113481. /**
  113482. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113483. */
  113484. snapDistance: number;
  113485. /**
  113486. * Ratio for the scale of the gizmo (Default: 1)
  113487. */
  113488. scaleRatio: number;
  113489. /**
  113490. * Disposes of the gizmo
  113491. */
  113492. dispose(): void;
  113493. /**
  113494. * CustomMeshes are not supported by this gizmo
  113495. * @param mesh The mesh to replace the default mesh of the gizmo
  113496. */
  113497. setCustomMesh(mesh: Mesh): void;
  113498. }
  113499. }
  113500. declare module BABYLON {
  113501. /**
  113502. * Single axis drag gizmo
  113503. */
  113504. export class AxisDragGizmo extends Gizmo {
  113505. /**
  113506. * Drag behavior responsible for the gizmos dragging interactions
  113507. */
  113508. dragBehavior: PointerDragBehavior;
  113509. private _pointerObserver;
  113510. /**
  113511. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113512. */
  113513. snapDistance: number;
  113514. /**
  113515. * Event that fires each time the gizmo snaps to a new location.
  113516. * * snapDistance is the the change in distance
  113517. */
  113518. onSnapObservable: Observable<{
  113519. snapDistance: number;
  113520. }>;
  113521. private _isEnabled;
  113522. private _parent;
  113523. private _arrow;
  113524. private _coloredMaterial;
  113525. private _hoverMaterial;
  113526. /** @hidden */
  113527. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  113528. /** @hidden */
  113529. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  113530. /**
  113531. * Creates an AxisDragGizmo
  113532. * @param gizmoLayer The utility layer the gizmo will be added to
  113533. * @param dragAxis The axis which the gizmo will be able to drag on
  113534. * @param color The color of the gizmo
  113535. */
  113536. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  113537. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113538. /**
  113539. * If the gizmo is enabled
  113540. */
  113541. isEnabled: boolean;
  113542. /**
  113543. * Disposes of the gizmo
  113544. */
  113545. dispose(): void;
  113546. }
  113547. }
  113548. declare module BABYLON.Debug {
  113549. /**
  113550. * The Axes viewer will show 3 axes in a specific point in space
  113551. */
  113552. export class AxesViewer {
  113553. private _xAxis;
  113554. private _yAxis;
  113555. private _zAxis;
  113556. private _scaleLinesFactor;
  113557. private _instanced;
  113558. /**
  113559. * Gets the hosting scene
  113560. */
  113561. scene: Scene;
  113562. /**
  113563. * Gets or sets a number used to scale line length
  113564. */
  113565. scaleLines: number;
  113566. /** Gets the node hierarchy used to render x-axis */
  113567. readonly xAxis: TransformNode;
  113568. /** Gets the node hierarchy used to render y-axis */
  113569. readonly yAxis: TransformNode;
  113570. /** Gets the node hierarchy used to render z-axis */
  113571. readonly zAxis: TransformNode;
  113572. /**
  113573. * Creates a new AxesViewer
  113574. * @param scene defines the hosting scene
  113575. * @param scaleLines defines a number used to scale line length (1 by default)
  113576. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  113577. * @param xAxis defines the node hierarchy used to render the x-axis
  113578. * @param yAxis defines the node hierarchy used to render the y-axis
  113579. * @param zAxis defines the node hierarchy used to render the z-axis
  113580. */
  113581. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  113582. /**
  113583. * Force the viewer to update
  113584. * @param position defines the position of the viewer
  113585. * @param xaxis defines the x axis of the viewer
  113586. * @param yaxis defines the y axis of the viewer
  113587. * @param zaxis defines the z axis of the viewer
  113588. */
  113589. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  113590. /**
  113591. * Creates an instance of this axes viewer.
  113592. * @returns a new axes viewer with instanced meshes
  113593. */
  113594. createInstance(): AxesViewer;
  113595. /** Releases resources */
  113596. dispose(): void;
  113597. private static _SetRenderingGroupId;
  113598. }
  113599. }
  113600. declare module BABYLON.Debug {
  113601. /**
  113602. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  113603. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  113604. */
  113605. export class BoneAxesViewer extends AxesViewer {
  113606. /**
  113607. * Gets or sets the target mesh where to display the axes viewer
  113608. */
  113609. mesh: Nullable<Mesh>;
  113610. /**
  113611. * Gets or sets the target bone where to display the axes viewer
  113612. */
  113613. bone: Nullable<Bone>;
  113614. /** Gets current position */
  113615. pos: Vector3;
  113616. /** Gets direction of X axis */
  113617. xaxis: Vector3;
  113618. /** Gets direction of Y axis */
  113619. yaxis: Vector3;
  113620. /** Gets direction of Z axis */
  113621. zaxis: Vector3;
  113622. /**
  113623. * Creates a new BoneAxesViewer
  113624. * @param scene defines the hosting scene
  113625. * @param bone defines the target bone
  113626. * @param mesh defines the target mesh
  113627. * @param scaleLines defines a scaling factor for line length (1 by default)
  113628. */
  113629. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  113630. /**
  113631. * Force the viewer to update
  113632. */
  113633. update(): void;
  113634. /** Releases resources */
  113635. dispose(): void;
  113636. }
  113637. }
  113638. declare module BABYLON {
  113639. /**
  113640. * Interface used to define scene explorer extensibility option
  113641. */
  113642. export interface IExplorerExtensibilityOption {
  113643. /**
  113644. * Define the option label
  113645. */
  113646. label: string;
  113647. /**
  113648. * Defines the action to execute on click
  113649. */
  113650. action: (entity: any) => void;
  113651. }
  113652. /**
  113653. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  113654. */
  113655. export interface IExplorerExtensibilityGroup {
  113656. /**
  113657. * Defines a predicate to test if a given type mut be extended
  113658. */
  113659. predicate: (entity: any) => boolean;
  113660. /**
  113661. * Gets the list of options added to a type
  113662. */
  113663. entries: IExplorerExtensibilityOption[];
  113664. }
  113665. /**
  113666. * Interface used to define the options to use to create the Inspector
  113667. */
  113668. export interface IInspectorOptions {
  113669. /**
  113670. * Display in overlay mode (default: false)
  113671. */
  113672. overlay?: boolean;
  113673. /**
  113674. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  113675. */
  113676. globalRoot?: HTMLElement;
  113677. /**
  113678. * Display the Scene explorer
  113679. */
  113680. showExplorer?: boolean;
  113681. /**
  113682. * Display the property inspector
  113683. */
  113684. showInspector?: boolean;
  113685. /**
  113686. * Display in embed mode (both panes on the right)
  113687. */
  113688. embedMode?: boolean;
  113689. /**
  113690. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  113691. */
  113692. handleResize?: boolean;
  113693. /**
  113694. * Allow the panes to popup (default: true)
  113695. */
  113696. enablePopup?: boolean;
  113697. /**
  113698. * Allow the panes to be closed by users (default: true)
  113699. */
  113700. enableClose?: boolean;
  113701. /**
  113702. * Optional list of extensibility entries
  113703. */
  113704. explorerExtensibility?: IExplorerExtensibilityGroup[];
  113705. /**
  113706. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  113707. */
  113708. inspectorURL?: string;
  113709. /**
  113710. * Optional initial tab (default to DebugLayerTab.Properties)
  113711. */
  113712. initialTab?: DebugLayerTab;
  113713. }
  113714. interface Scene {
  113715. /**
  113716. * @hidden
  113717. * Backing field
  113718. */
  113719. _debugLayer: DebugLayer;
  113720. /**
  113721. * Gets the debug layer (aka Inspector) associated with the scene
  113722. * @see http://doc.babylonjs.com/features/playground_debuglayer
  113723. */
  113724. debugLayer: DebugLayer;
  113725. }
  113726. /**
  113727. * Enum of inspector action tab
  113728. */
  113729. export enum DebugLayerTab {
  113730. /**
  113731. * Properties tag (default)
  113732. */
  113733. Properties = 0,
  113734. /**
  113735. * Debug tab
  113736. */
  113737. Debug = 1,
  113738. /**
  113739. * Statistics tab
  113740. */
  113741. Statistics = 2,
  113742. /**
  113743. * Tools tab
  113744. */
  113745. Tools = 3,
  113746. /**
  113747. * Settings tab
  113748. */
  113749. Settings = 4
  113750. }
  113751. /**
  113752. * The debug layer (aka Inspector) is the go to tool in order to better understand
  113753. * what is happening in your scene
  113754. * @see http://doc.babylonjs.com/features/playground_debuglayer
  113755. */
  113756. export class DebugLayer {
  113757. /**
  113758. * Define the url to get the inspector script from.
  113759. * By default it uses the babylonjs CDN.
  113760. * @ignoreNaming
  113761. */
  113762. static InspectorURL: string;
  113763. private _scene;
  113764. private BJSINSPECTOR;
  113765. private _onPropertyChangedObservable?;
  113766. /**
  113767. * Observable triggered when a property is changed through the inspector.
  113768. */
  113769. readonly onPropertyChangedObservable: any;
  113770. /**
  113771. * Instantiates a new debug layer.
  113772. * The debug layer (aka Inspector) is the go to tool in order to better understand
  113773. * what is happening in your scene
  113774. * @see http://doc.babylonjs.com/features/playground_debuglayer
  113775. * @param scene Defines the scene to inspect
  113776. */
  113777. constructor(scene: Scene);
  113778. /** Creates the inspector window. */
  113779. private _createInspector;
  113780. /**
  113781. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  113782. * @param entity defines the entity to select
  113783. * @param lineContainerTitle defines the specific block to highlight
  113784. */
  113785. select(entity: any, lineContainerTitle?: string): void;
  113786. /** Get the inspector from bundle or global */
  113787. private _getGlobalInspector;
  113788. /**
  113789. * Get if the inspector is visible or not.
  113790. * @returns true if visible otherwise, false
  113791. */
  113792. isVisible(): boolean;
  113793. /**
  113794. * Hide the inspector and close its window.
  113795. */
  113796. hide(): void;
  113797. /**
  113798. * Launch the debugLayer.
  113799. * @param config Define the configuration of the inspector
  113800. * @return a promise fulfilled when the debug layer is visible
  113801. */
  113802. show(config?: IInspectorOptions): Promise<DebugLayer>;
  113803. }
  113804. }
  113805. declare module BABYLON {
  113806. /**
  113807. * Class containing static functions to help procedurally build meshes
  113808. */
  113809. export class BoxBuilder {
  113810. /**
  113811. * Creates a box mesh
  113812. * * The parameter `size` sets the size (float) of each box side (default 1)
  113813. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  113814. * * 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)
  113815. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  113816. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113817. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113819. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  113820. * @param name defines the name of the mesh
  113821. * @param options defines the options used to create the mesh
  113822. * @param scene defines the hosting scene
  113823. * @returns the box mesh
  113824. */
  113825. static CreateBox(name: string, options: {
  113826. size?: number;
  113827. width?: number;
  113828. height?: number;
  113829. depth?: number;
  113830. faceUV?: Vector4[];
  113831. faceColors?: Color4[];
  113832. sideOrientation?: number;
  113833. frontUVs?: Vector4;
  113834. backUVs?: Vector4;
  113835. wrap?: boolean;
  113836. topBaseAt?: number;
  113837. bottomBaseAt?: number;
  113838. updatable?: boolean;
  113839. }, scene?: Nullable<Scene>): Mesh;
  113840. }
  113841. }
  113842. declare module BABYLON {
  113843. /**
  113844. * Class containing static functions to help procedurally build meshes
  113845. */
  113846. export class SphereBuilder {
  113847. /**
  113848. * Creates a sphere mesh
  113849. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  113850. * * 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`)
  113851. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  113852. * * 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
  113853. * * 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)
  113854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113855. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113857. * @param name defines the name of the mesh
  113858. * @param options defines the options used to create the mesh
  113859. * @param scene defines the hosting scene
  113860. * @returns the sphere mesh
  113861. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  113862. */
  113863. static CreateSphere(name: string, options: {
  113864. segments?: number;
  113865. diameter?: number;
  113866. diameterX?: number;
  113867. diameterY?: number;
  113868. diameterZ?: number;
  113869. arc?: number;
  113870. slice?: number;
  113871. sideOrientation?: number;
  113872. frontUVs?: Vector4;
  113873. backUVs?: Vector4;
  113874. updatable?: boolean;
  113875. }, scene?: Nullable<Scene>): Mesh;
  113876. }
  113877. }
  113878. declare module BABYLON.Debug {
  113879. /**
  113880. * Used to show the physics impostor around the specific mesh
  113881. */
  113882. export class PhysicsViewer {
  113883. /** @hidden */
  113884. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  113885. /** @hidden */
  113886. protected _meshes: Array<Nullable<AbstractMesh>>;
  113887. /** @hidden */
  113888. protected _scene: Nullable<Scene>;
  113889. /** @hidden */
  113890. protected _numMeshes: number;
  113891. /** @hidden */
  113892. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  113893. private _renderFunction;
  113894. private _utilityLayer;
  113895. private _debugBoxMesh;
  113896. private _debugSphereMesh;
  113897. private _debugCylinderMesh;
  113898. private _debugMaterial;
  113899. private _debugMeshMeshes;
  113900. /**
  113901. * Creates a new PhysicsViewer
  113902. * @param scene defines the hosting scene
  113903. */
  113904. constructor(scene: Scene);
  113905. /** @hidden */
  113906. protected _updateDebugMeshes(): void;
  113907. /**
  113908. * Renders a specified physic impostor
  113909. * @param impostor defines the impostor to render
  113910. * @param targetMesh defines the mesh represented by the impostor
  113911. * @returns the new debug mesh used to render the impostor
  113912. */
  113913. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  113914. /**
  113915. * Hides a specified physic impostor
  113916. * @param impostor defines the impostor to hide
  113917. */
  113918. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  113919. private _getDebugMaterial;
  113920. private _getDebugBoxMesh;
  113921. private _getDebugSphereMesh;
  113922. private _getDebugCylinderMesh;
  113923. private _getDebugMeshMesh;
  113924. private _getDebugMesh;
  113925. /** Releases all resources */
  113926. dispose(): void;
  113927. }
  113928. }
  113929. declare module BABYLON {
  113930. /**
  113931. * Class containing static functions to help procedurally build meshes
  113932. */
  113933. export class LinesBuilder {
  113934. /**
  113935. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  113936. * * 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
  113937. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  113938. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  113939. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  113940. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  113941. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  113942. * * 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
  113943. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  113944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113945. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  113946. * @param name defines the name of the new line system
  113947. * @param options defines the options used to create the line system
  113948. * @param scene defines the hosting scene
  113949. * @returns a new line system mesh
  113950. */
  113951. static CreateLineSystem(name: string, options: {
  113952. lines: Vector3[][];
  113953. updatable?: boolean;
  113954. instance?: Nullable<LinesMesh>;
  113955. colors?: Nullable<Color4[][]>;
  113956. useVertexAlpha?: boolean;
  113957. }, scene: Nullable<Scene>): LinesMesh;
  113958. /**
  113959. * Creates a line mesh
  113960. * 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
  113961. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  113962. * * The parameter `points` is an array successive Vector3
  113963. * * 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
  113964. * * The optional parameter `colors` is an array of successive Color4, one per line point
  113965. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  113966. * * When updating an instance, remember that only point positions can change, not the number of points
  113967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113968. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  113969. * @param name defines the name of the new line system
  113970. * @param options defines the options used to create the line system
  113971. * @param scene defines the hosting scene
  113972. * @returns a new line mesh
  113973. */
  113974. static CreateLines(name: string, options: {
  113975. points: Vector3[];
  113976. updatable?: boolean;
  113977. instance?: Nullable<LinesMesh>;
  113978. colors?: Color4[];
  113979. useVertexAlpha?: boolean;
  113980. }, scene?: Nullable<Scene>): LinesMesh;
  113981. /**
  113982. * Creates a dashed line mesh
  113983. * * 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
  113984. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  113985. * * The parameter `points` is an array successive Vector3
  113986. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  113987. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  113988. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  113989. * * 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
  113990. * * When updating an instance, remember that only point positions can change, not the number of points
  113991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113992. * @param name defines the name of the mesh
  113993. * @param options defines the options used to create the mesh
  113994. * @param scene defines the hosting scene
  113995. * @returns the dashed line mesh
  113996. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  113997. */
  113998. static CreateDashedLines(name: string, options: {
  113999. points: Vector3[];
  114000. dashSize?: number;
  114001. gapSize?: number;
  114002. dashNb?: number;
  114003. updatable?: boolean;
  114004. instance?: LinesMesh;
  114005. }, scene?: Nullable<Scene>): LinesMesh;
  114006. }
  114007. }
  114008. declare module BABYLON {
  114009. /**
  114010. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  114011. * in order to better appreciate the issue one might have.
  114012. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  114013. */
  114014. export class RayHelper {
  114015. /**
  114016. * Defines the ray we are currently tryin to visualize.
  114017. */
  114018. ray: Nullable<Ray>;
  114019. private _renderPoints;
  114020. private _renderLine;
  114021. private _renderFunction;
  114022. private _scene;
  114023. private _updateToMeshFunction;
  114024. private _attachedToMesh;
  114025. private _meshSpaceDirection;
  114026. private _meshSpaceOrigin;
  114027. /**
  114028. * Helper function to create a colored helper in a scene in one line.
  114029. * @param ray Defines the ray we are currently tryin to visualize
  114030. * @param scene Defines the scene the ray is used in
  114031. * @param color Defines the color we want to see the ray in
  114032. * @returns The newly created ray helper.
  114033. */
  114034. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  114035. /**
  114036. * Instantiate a new ray helper.
  114037. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  114038. * in order to better appreciate the issue one might have.
  114039. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  114040. * @param ray Defines the ray we are currently tryin to visualize
  114041. */
  114042. constructor(ray: Ray);
  114043. /**
  114044. * Shows the ray we are willing to debug.
  114045. * @param scene Defines the scene the ray needs to be rendered in
  114046. * @param color Defines the color the ray needs to be rendered in
  114047. */
  114048. show(scene: Scene, color?: Color3): void;
  114049. /**
  114050. * Hides the ray we are debugging.
  114051. */
  114052. hide(): void;
  114053. private _render;
  114054. /**
  114055. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  114056. * @param mesh Defines the mesh we want the helper attached to
  114057. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  114058. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  114059. * @param length Defines the length of the ray
  114060. */
  114061. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  114062. /**
  114063. * Detach the ray helper from the mesh it has previously been attached to.
  114064. */
  114065. detachFromMesh(): void;
  114066. private _updateToMesh;
  114067. /**
  114068. * Dispose the helper and release its associated resources.
  114069. */
  114070. dispose(): void;
  114071. }
  114072. }
  114073. declare module BABYLON.Debug {
  114074. /**
  114075. * Class used to render a debug view of a given skeleton
  114076. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  114077. */
  114078. export class SkeletonViewer {
  114079. /** defines the skeleton to render */
  114080. skeleton: Skeleton;
  114081. /** defines the mesh attached to the skeleton */
  114082. mesh: AbstractMesh;
  114083. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  114084. autoUpdateBonesMatrices: boolean;
  114085. /** defines the rendering group id to use with the viewer */
  114086. renderingGroupId: number;
  114087. /** Gets or sets the color used to render the skeleton */
  114088. color: Color3;
  114089. private _scene;
  114090. private _debugLines;
  114091. private _debugMesh;
  114092. private _isEnabled;
  114093. private _renderFunction;
  114094. private _utilityLayer;
  114095. /**
  114096. * Returns the mesh used to render the bones
  114097. */
  114098. readonly debugMesh: Nullable<LinesMesh>;
  114099. /**
  114100. * Creates a new SkeletonViewer
  114101. * @param skeleton defines the skeleton to render
  114102. * @param mesh defines the mesh attached to the skeleton
  114103. * @param scene defines the hosting scene
  114104. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  114105. * @param renderingGroupId defines the rendering group id to use with the viewer
  114106. */
  114107. constructor(
  114108. /** defines the skeleton to render */
  114109. skeleton: Skeleton,
  114110. /** defines the mesh attached to the skeleton */
  114111. mesh: AbstractMesh, scene: Scene,
  114112. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  114113. autoUpdateBonesMatrices?: boolean,
  114114. /** defines the rendering group id to use with the viewer */
  114115. renderingGroupId?: number);
  114116. /** Gets or sets a boolean indicating if the viewer is enabled */
  114117. isEnabled: boolean;
  114118. private _getBonePosition;
  114119. private _getLinesForBonesWithLength;
  114120. private _getLinesForBonesNoLength;
  114121. /** Update the viewer to sync with current skeleton state */
  114122. update(): void;
  114123. /** Release associated resources */
  114124. dispose(): void;
  114125. }
  114126. }
  114127. declare module BABYLON {
  114128. /**
  114129. * Options to create the null engine
  114130. */
  114131. export class NullEngineOptions {
  114132. /**
  114133. * Render width (Default: 512)
  114134. */
  114135. renderWidth: number;
  114136. /**
  114137. * Render height (Default: 256)
  114138. */
  114139. renderHeight: number;
  114140. /**
  114141. * Texture size (Default: 512)
  114142. */
  114143. textureSize: number;
  114144. /**
  114145. * If delta time between frames should be constant
  114146. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114147. */
  114148. deterministicLockstep: boolean;
  114149. /**
  114150. * Maximum about of steps between frames (Default: 4)
  114151. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114152. */
  114153. lockstepMaxSteps: number;
  114154. }
  114155. /**
  114156. * The null engine class provides support for headless version of babylon.js.
  114157. * This can be used in server side scenario or for testing purposes
  114158. */
  114159. export class NullEngine extends Engine {
  114160. private _options;
  114161. /**
  114162. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  114163. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114164. * @returns true if engine is in deterministic lock step mode
  114165. */
  114166. isDeterministicLockStep(): boolean;
  114167. /**
  114168. * Gets the max steps when engine is running in deterministic lock step
  114169. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114170. * @returns the max steps
  114171. */
  114172. getLockstepMaxSteps(): number;
  114173. /**
  114174. * Gets the current hardware scaling level.
  114175. * By default the hardware scaling level is computed from the window device ratio.
  114176. * 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.
  114177. * @returns a number indicating the current hardware scaling level
  114178. */
  114179. getHardwareScalingLevel(): number;
  114180. constructor(options?: NullEngineOptions);
  114181. /**
  114182. * Creates a vertex buffer
  114183. * @param vertices the data for the vertex buffer
  114184. * @returns the new WebGL static buffer
  114185. */
  114186. createVertexBuffer(vertices: FloatArray): DataBuffer;
  114187. /**
  114188. * Creates a new index buffer
  114189. * @param indices defines the content of the index buffer
  114190. * @param updatable defines if the index buffer must be updatable
  114191. * @returns a new webGL buffer
  114192. */
  114193. createIndexBuffer(indices: IndicesArray): DataBuffer;
  114194. /**
  114195. * Clear the current render buffer or the current render target (if any is set up)
  114196. * @param color defines the color to use
  114197. * @param backBuffer defines if the back buffer must be cleared
  114198. * @param depth defines if the depth buffer must be cleared
  114199. * @param stencil defines if the stencil buffer must be cleared
  114200. */
  114201. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  114202. /**
  114203. * Gets the current render width
  114204. * @param useScreen defines if screen size must be used (or the current render target if any)
  114205. * @returns a number defining the current render width
  114206. */
  114207. getRenderWidth(useScreen?: boolean): number;
  114208. /**
  114209. * Gets the current render height
  114210. * @param useScreen defines if screen size must be used (or the current render target if any)
  114211. * @returns a number defining the current render height
  114212. */
  114213. getRenderHeight(useScreen?: boolean): number;
  114214. /**
  114215. * Set the WebGL's viewport
  114216. * @param viewport defines the viewport element to be used
  114217. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  114218. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  114219. */
  114220. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  114221. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  114222. /**
  114223. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  114224. * @param pipelineContext defines the pipeline context to use
  114225. * @param uniformsNames defines the list of uniform names
  114226. * @returns an array of webGL uniform locations
  114227. */
  114228. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  114229. /**
  114230. * Gets the lsit of active attributes for a given webGL program
  114231. * @param pipelineContext defines the pipeline context to use
  114232. * @param attributesNames defines the list of attribute names to get
  114233. * @returns an array of indices indicating the offset of each attribute
  114234. */
  114235. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  114236. /**
  114237. * Binds an effect to the webGL context
  114238. * @param effect defines the effect to bind
  114239. */
  114240. bindSamplers(effect: Effect): void;
  114241. /**
  114242. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  114243. * @param effect defines the effect to activate
  114244. */
  114245. enableEffect(effect: Effect): void;
  114246. /**
  114247. * Set various states to the webGL context
  114248. * @param culling defines backface culling state
  114249. * @param zOffset defines the value to apply to zOffset (0 by default)
  114250. * @param force defines if states must be applied even if cache is up to date
  114251. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  114252. */
  114253. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  114254. /**
  114255. * Set the value of an uniform to an array of int32
  114256. * @param uniform defines the webGL uniform location where to store the value
  114257. * @param array defines the array of int32 to store
  114258. */
  114259. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  114260. /**
  114261. * Set the value of an uniform to an array of int32 (stored as vec2)
  114262. * @param uniform defines the webGL uniform location where to store the value
  114263. * @param array defines the array of int32 to store
  114264. */
  114265. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  114266. /**
  114267. * Set the value of an uniform to an array of int32 (stored as vec3)
  114268. * @param uniform defines the webGL uniform location where to store the value
  114269. * @param array defines the array of int32 to store
  114270. */
  114271. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  114272. /**
  114273. * Set the value of an uniform to an array of int32 (stored as vec4)
  114274. * @param uniform defines the webGL uniform location where to store the value
  114275. * @param array defines the array of int32 to store
  114276. */
  114277. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  114278. /**
  114279. * Set the value of an uniform to an array of float32
  114280. * @param uniform defines the webGL uniform location where to store the value
  114281. * @param array defines the array of float32 to store
  114282. */
  114283. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  114284. /**
  114285. * Set the value of an uniform to an array of float32 (stored as vec2)
  114286. * @param uniform defines the webGL uniform location where to store the value
  114287. * @param array defines the array of float32 to store
  114288. */
  114289. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  114290. /**
  114291. * Set the value of an uniform to an array of float32 (stored as vec3)
  114292. * @param uniform defines the webGL uniform location where to store the value
  114293. * @param array defines the array of float32 to store
  114294. */
  114295. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  114296. /**
  114297. * Set the value of an uniform to an array of float32 (stored as vec4)
  114298. * @param uniform defines the webGL uniform location where to store the value
  114299. * @param array defines the array of float32 to store
  114300. */
  114301. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  114302. /**
  114303. * Set the value of an uniform to an array of number
  114304. * @param uniform defines the webGL uniform location where to store the value
  114305. * @param array defines the array of number to store
  114306. */
  114307. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  114308. /**
  114309. * Set the value of an uniform to an array of number (stored as vec2)
  114310. * @param uniform defines the webGL uniform location where to store the value
  114311. * @param array defines the array of number to store
  114312. */
  114313. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  114314. /**
  114315. * Set the value of an uniform to an array of number (stored as vec3)
  114316. * @param uniform defines the webGL uniform location where to store the value
  114317. * @param array defines the array of number to store
  114318. */
  114319. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  114320. /**
  114321. * Set the value of an uniform to an array of number (stored as vec4)
  114322. * @param uniform defines the webGL uniform location where to store the value
  114323. * @param array defines the array of number to store
  114324. */
  114325. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  114326. /**
  114327. * Set the value of an uniform to an array of float32 (stored as matrices)
  114328. * @param uniform defines the webGL uniform location where to store the value
  114329. * @param matrices defines the array of float32 to store
  114330. */
  114331. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  114332. /**
  114333. * Set the value of an uniform to a matrix (3x3)
  114334. * @param uniform defines the webGL uniform location where to store the value
  114335. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  114336. */
  114337. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  114338. /**
  114339. * Set the value of an uniform to a matrix (2x2)
  114340. * @param uniform defines the webGL uniform location where to store the value
  114341. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  114342. */
  114343. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  114344. /**
  114345. * Set the value of an uniform to a number (float)
  114346. * @param uniform defines the webGL uniform location where to store the value
  114347. * @param value defines the float number to store
  114348. */
  114349. setFloat(uniform: WebGLUniformLocation, value: number): void;
  114350. /**
  114351. * Set the value of an uniform to a vec2
  114352. * @param uniform defines the webGL uniform location where to store the value
  114353. * @param x defines the 1st component of the value
  114354. * @param y defines the 2nd component of the value
  114355. */
  114356. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  114357. /**
  114358. * Set the value of an uniform to a vec3
  114359. * @param uniform defines the webGL uniform location where to store the value
  114360. * @param x defines the 1st component of the value
  114361. * @param y defines the 2nd component of the value
  114362. * @param z defines the 3rd component of the value
  114363. */
  114364. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  114365. /**
  114366. * Set the value of an uniform to a boolean
  114367. * @param uniform defines the webGL uniform location where to store the value
  114368. * @param bool defines the boolean to store
  114369. */
  114370. setBool(uniform: WebGLUniformLocation, bool: number): void;
  114371. /**
  114372. * Set the value of an uniform to a vec4
  114373. * @param uniform defines the webGL uniform location where to store the value
  114374. * @param x defines the 1st component of the value
  114375. * @param y defines the 2nd component of the value
  114376. * @param z defines the 3rd component of the value
  114377. * @param w defines the 4th component of the value
  114378. */
  114379. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  114380. /**
  114381. * Sets the current alpha mode
  114382. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  114383. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  114384. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114385. */
  114386. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  114387. /**
  114388. * Bind webGl buffers directly to the webGL context
  114389. * @param vertexBuffers defines the vertex buffer to bind
  114390. * @param indexBuffer defines the index buffer to bind
  114391. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  114392. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  114393. * @param effect defines the effect associated with the vertex buffer
  114394. */
  114395. bindBuffers(vertexBuffers: {
  114396. [key: string]: VertexBuffer;
  114397. }, indexBuffer: DataBuffer, effect: Effect): void;
  114398. /**
  114399. * Force the entire cache to be cleared
  114400. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  114401. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  114402. */
  114403. wipeCaches(bruteForce?: boolean): void;
  114404. /**
  114405. * Send a draw order
  114406. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  114407. * @param indexStart defines the starting index
  114408. * @param indexCount defines the number of index to draw
  114409. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114410. */
  114411. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  114412. /**
  114413. * Draw a list of indexed primitives
  114414. * @param fillMode defines the primitive to use
  114415. * @param indexStart defines the starting index
  114416. * @param indexCount defines the number of index to draw
  114417. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114418. */
  114419. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  114420. /**
  114421. * Draw a list of unindexed primitives
  114422. * @param fillMode defines the primitive to use
  114423. * @param verticesStart defines the index of first vertex to draw
  114424. * @param verticesCount defines the count of vertices to draw
  114425. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114426. */
  114427. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114428. /** @hidden */
  114429. _createTexture(): WebGLTexture;
  114430. /** @hidden */
  114431. _releaseTexture(texture: InternalTexture): void;
  114432. /**
  114433. * Usually called from Texture.ts.
  114434. * Passed information to create a WebGLTexture
  114435. * @param urlArg defines a value which contains one of the following:
  114436. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  114437. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  114438. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  114439. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  114440. * @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)
  114441. * @param scene needed for loading to the correct scene
  114442. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  114443. * @param onLoad optional callback to be called upon successful completion
  114444. * @param onError optional callback to be called upon failure
  114445. * @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
  114446. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  114447. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  114448. * @param forcedExtension defines the extension to use to pick the right loader
  114449. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  114450. * @returns a InternalTexture for assignment back into BABYLON.Texture
  114451. */
  114452. 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;
  114453. /**
  114454. * Creates a new render target texture
  114455. * @param size defines the size of the texture
  114456. * @param options defines the options used to create the texture
  114457. * @returns a new render target texture stored in an InternalTexture
  114458. */
  114459. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  114460. /**
  114461. * Update the sampling mode of a given texture
  114462. * @param samplingMode defines the required sampling mode
  114463. * @param texture defines the texture to update
  114464. */
  114465. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  114466. /**
  114467. * Binds the frame buffer to the specified texture.
  114468. * @param texture The texture to render to or null for the default canvas
  114469. * @param faceIndex The face of the texture to render to in case of cube texture
  114470. * @param requiredWidth The width of the target to render to
  114471. * @param requiredHeight The height of the target to render to
  114472. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  114473. * @param depthStencilTexture The depth stencil texture to use to render
  114474. * @param lodLevel defines le lod level to bind to the frame buffer
  114475. */
  114476. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  114477. /**
  114478. * Unbind the current render target texture from the webGL context
  114479. * @param texture defines the render target texture to unbind
  114480. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  114481. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  114482. */
  114483. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  114484. /**
  114485. * Creates a dynamic vertex buffer
  114486. * @param vertices the data for the dynamic vertex buffer
  114487. * @returns the new WebGL dynamic buffer
  114488. */
  114489. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  114490. /**
  114491. * Update the content of a dynamic texture
  114492. * @param texture defines the texture to update
  114493. * @param canvas defines the canvas containing the source
  114494. * @param invertY defines if data must be stored with Y axis inverted
  114495. * @param premulAlpha defines if alpha is stored as premultiplied
  114496. * @param format defines the format of the data
  114497. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  114498. */
  114499. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  114500. /**
  114501. * Gets a boolean indicating if all created effects are ready
  114502. * @returns true if all effects are ready
  114503. */
  114504. areAllEffectsReady(): boolean;
  114505. /**
  114506. * @hidden
  114507. * Get the current error code of the webGL context
  114508. * @returns the error code
  114509. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  114510. */
  114511. getError(): number;
  114512. /** @hidden */
  114513. _getUnpackAlignement(): number;
  114514. /** @hidden */
  114515. _unpackFlipY(value: boolean): void;
  114516. /**
  114517. * Update a dynamic index buffer
  114518. * @param indexBuffer defines the target index buffer
  114519. * @param indices defines the data to update
  114520. * @param offset defines the offset in the target index buffer where update should start
  114521. */
  114522. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  114523. /**
  114524. * Updates a dynamic vertex buffer.
  114525. * @param vertexBuffer the vertex buffer to update
  114526. * @param vertices the data used to update the vertex buffer
  114527. * @param byteOffset the byte offset of the data (optional)
  114528. * @param byteLength the byte length of the data (optional)
  114529. */
  114530. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  114531. /** @hidden */
  114532. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  114533. /** @hidden */
  114534. _bindTexture(channel: number, texture: InternalTexture): void;
  114535. protected _deleteBuffer(buffer: WebGLBuffer): void;
  114536. /**
  114537. * 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
  114538. */
  114539. releaseEffects(): void;
  114540. displayLoadingUI(): void;
  114541. hideLoadingUI(): void;
  114542. /** @hidden */
  114543. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114544. /** @hidden */
  114545. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114546. /** @hidden */
  114547. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114548. /** @hidden */
  114549. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  114550. }
  114551. }
  114552. declare module BABYLON {
  114553. /** @hidden */
  114554. export class _OcclusionDataStorage {
  114555. /** @hidden */
  114556. occlusionInternalRetryCounter: number;
  114557. /** @hidden */
  114558. isOcclusionQueryInProgress: boolean;
  114559. /** @hidden */
  114560. isOccluded: boolean;
  114561. /** @hidden */
  114562. occlusionRetryCount: number;
  114563. /** @hidden */
  114564. occlusionType: number;
  114565. /** @hidden */
  114566. occlusionQueryAlgorithmType: number;
  114567. }
  114568. interface Engine {
  114569. /**
  114570. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  114571. * @return the new query
  114572. */
  114573. createQuery(): WebGLQuery;
  114574. /**
  114575. * Delete and release a webGL query
  114576. * @param query defines the query to delete
  114577. * @return the current engine
  114578. */
  114579. deleteQuery(query: WebGLQuery): Engine;
  114580. /**
  114581. * Check if a given query has resolved and got its value
  114582. * @param query defines the query to check
  114583. * @returns true if the query got its value
  114584. */
  114585. isQueryResultAvailable(query: WebGLQuery): boolean;
  114586. /**
  114587. * Gets the value of a given query
  114588. * @param query defines the query to check
  114589. * @returns the value of the query
  114590. */
  114591. getQueryResult(query: WebGLQuery): number;
  114592. /**
  114593. * Initiates an occlusion query
  114594. * @param algorithmType defines the algorithm to use
  114595. * @param query defines the query to use
  114596. * @returns the current engine
  114597. * @see http://doc.babylonjs.com/features/occlusionquery
  114598. */
  114599. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  114600. /**
  114601. * Ends an occlusion query
  114602. * @see http://doc.babylonjs.com/features/occlusionquery
  114603. * @param algorithmType defines the algorithm to use
  114604. * @returns the current engine
  114605. */
  114606. endOcclusionQuery(algorithmType: number): Engine;
  114607. /**
  114608. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  114609. * Please note that only one query can be issued at a time
  114610. * @returns a time token used to track the time span
  114611. */
  114612. startTimeQuery(): Nullable<_TimeToken>;
  114613. /**
  114614. * Ends a time query
  114615. * @param token defines the token used to measure the time span
  114616. * @returns the time spent (in ns)
  114617. */
  114618. endTimeQuery(token: _TimeToken): int;
  114619. /** @hidden */
  114620. _currentNonTimestampToken: Nullable<_TimeToken>;
  114621. /** @hidden */
  114622. _createTimeQuery(): WebGLQuery;
  114623. /** @hidden */
  114624. _deleteTimeQuery(query: WebGLQuery): void;
  114625. /** @hidden */
  114626. _getGlAlgorithmType(algorithmType: number): number;
  114627. /** @hidden */
  114628. _getTimeQueryResult(query: WebGLQuery): any;
  114629. /** @hidden */
  114630. _getTimeQueryAvailability(query: WebGLQuery): any;
  114631. }
  114632. interface AbstractMesh {
  114633. /**
  114634. * Backing filed
  114635. * @hidden
  114636. */
  114637. __occlusionDataStorage: _OcclusionDataStorage;
  114638. /**
  114639. * Access property
  114640. * @hidden
  114641. */
  114642. _occlusionDataStorage: _OcclusionDataStorage;
  114643. /**
  114644. * 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.
  114645. * The default value is -1 which means don't break the query and wait till the result
  114646. * @see http://doc.babylonjs.com/features/occlusionquery
  114647. */
  114648. occlusionRetryCount: number;
  114649. /**
  114650. * 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:
  114651. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  114652. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  114653. * * 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.
  114654. * @see http://doc.babylonjs.com/features/occlusionquery
  114655. */
  114656. occlusionType: number;
  114657. /**
  114658. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  114659. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  114660. * * 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.
  114661. * @see http://doc.babylonjs.com/features/occlusionquery
  114662. */
  114663. occlusionQueryAlgorithmType: number;
  114664. /**
  114665. * 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
  114666. * @see http://doc.babylonjs.com/features/occlusionquery
  114667. */
  114668. isOccluded: boolean;
  114669. /**
  114670. * Flag to check the progress status of the query
  114671. * @see http://doc.babylonjs.com/features/occlusionquery
  114672. */
  114673. isOcclusionQueryInProgress: boolean;
  114674. }
  114675. }
  114676. declare module BABYLON {
  114677. /** @hidden */
  114678. export var _forceTransformFeedbackToBundle: boolean;
  114679. interface Engine {
  114680. /**
  114681. * Creates a webGL transform feedback object
  114682. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  114683. * @returns the webGL transform feedback object
  114684. */
  114685. createTransformFeedback(): WebGLTransformFeedback;
  114686. /**
  114687. * Delete a webGL transform feedback object
  114688. * @param value defines the webGL transform feedback object to delete
  114689. */
  114690. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  114691. /**
  114692. * Bind a webGL transform feedback object to the webgl context
  114693. * @param value defines the webGL transform feedback object to bind
  114694. */
  114695. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  114696. /**
  114697. * Begins a transform feedback operation
  114698. * @param usePoints defines if points or triangles must be used
  114699. */
  114700. beginTransformFeedback(usePoints: boolean): void;
  114701. /**
  114702. * Ends a transform feedback operation
  114703. */
  114704. endTransformFeedback(): void;
  114705. /**
  114706. * Specify the varyings to use with transform feedback
  114707. * @param program defines the associated webGL program
  114708. * @param value defines the list of strings representing the varying names
  114709. */
  114710. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  114711. /**
  114712. * Bind a webGL buffer for a transform feedback operation
  114713. * @param value defines the webGL buffer to bind
  114714. */
  114715. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  114716. }
  114717. }
  114718. declare module BABYLON {
  114719. /**
  114720. * Creation options of the multi render target texture.
  114721. */
  114722. export interface IMultiRenderTargetOptions {
  114723. /**
  114724. * Define if the texture needs to create mip maps after render.
  114725. */
  114726. generateMipMaps?: boolean;
  114727. /**
  114728. * Define the types of all the draw buffers we want to create
  114729. */
  114730. types?: number[];
  114731. /**
  114732. * Define the sampling modes of all the draw buffers we want to create
  114733. */
  114734. samplingModes?: number[];
  114735. /**
  114736. * Define if a depth buffer is required
  114737. */
  114738. generateDepthBuffer?: boolean;
  114739. /**
  114740. * Define if a stencil buffer is required
  114741. */
  114742. generateStencilBuffer?: boolean;
  114743. /**
  114744. * Define if a depth texture is required instead of a depth buffer
  114745. */
  114746. generateDepthTexture?: boolean;
  114747. /**
  114748. * Define the number of desired draw buffers
  114749. */
  114750. textureCount?: number;
  114751. /**
  114752. * Define if aspect ratio should be adapted to the texture or stay the scene one
  114753. */
  114754. doNotChangeAspectRatio?: boolean;
  114755. /**
  114756. * Define the default type of the buffers we are creating
  114757. */
  114758. defaultType?: number;
  114759. }
  114760. /**
  114761. * A multi render target, like a render target provides the ability to render to a texture.
  114762. * Unlike the render target, it can render to several draw buffers in one draw.
  114763. * This is specially interesting in deferred rendering or for any effects requiring more than
  114764. * just one color from a single pass.
  114765. */
  114766. export class MultiRenderTarget extends RenderTargetTexture {
  114767. private _internalTextures;
  114768. private _textures;
  114769. private _multiRenderTargetOptions;
  114770. /**
  114771. * Get if draw buffers are currently supported by the used hardware and browser.
  114772. */
  114773. readonly isSupported: boolean;
  114774. /**
  114775. * Get the list of textures generated by the multi render target.
  114776. */
  114777. readonly textures: Texture[];
  114778. /**
  114779. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  114780. */
  114781. readonly depthTexture: Texture;
  114782. /**
  114783. * Set the wrapping mode on U of all the textures we are rendering to.
  114784. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  114785. */
  114786. wrapU: number;
  114787. /**
  114788. * Set the wrapping mode on V of all the textures we are rendering to.
  114789. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  114790. */
  114791. wrapV: number;
  114792. /**
  114793. * Instantiate a new multi render target texture.
  114794. * A multi render target, like a render target provides the ability to render to a texture.
  114795. * Unlike the render target, it can render to several draw buffers in one draw.
  114796. * This is specially interesting in deferred rendering or for any effects requiring more than
  114797. * just one color from a single pass.
  114798. * @param name Define the name of the texture
  114799. * @param size Define the size of the buffers to render to
  114800. * @param count Define the number of target we are rendering into
  114801. * @param scene Define the scene the texture belongs to
  114802. * @param options Define the options used to create the multi render target
  114803. */
  114804. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  114805. /** @hidden */
  114806. _rebuild(): void;
  114807. private _createInternalTextures;
  114808. private _createTextures;
  114809. /**
  114810. * Define the number of samples used if MSAA is enabled.
  114811. */
  114812. samples: number;
  114813. /**
  114814. * Resize all the textures in the multi render target.
  114815. * Be carrefull as it will recreate all the data in the new texture.
  114816. * @param size Define the new size
  114817. */
  114818. resize(size: any): void;
  114819. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  114820. /**
  114821. * Dispose the render targets and their associated resources
  114822. */
  114823. dispose(): void;
  114824. /**
  114825. * Release all the underlying texture used as draw buffers.
  114826. */
  114827. releaseInternalTextures(): void;
  114828. }
  114829. }
  114830. declare module BABYLON {
  114831. interface ThinEngine {
  114832. /**
  114833. * Unbind a list of render target textures from the webGL context
  114834. * This is used only when drawBuffer extension or webGL2 are active
  114835. * @param textures defines the render target textures to unbind
  114836. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  114837. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  114838. */
  114839. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  114840. /**
  114841. * Create a multi render target texture
  114842. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  114843. * @param size defines the size of the texture
  114844. * @param options defines the creation options
  114845. * @returns the cube texture as an InternalTexture
  114846. */
  114847. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  114848. /**
  114849. * Update the sample count for a given multiple render target texture
  114850. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  114851. * @param textures defines the textures to update
  114852. * @param samples defines the sample count to set
  114853. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  114854. */
  114855. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  114856. }
  114857. }
  114858. declare module BABYLON {
  114859. /**
  114860. * Class used to define an additional view for the engine
  114861. * @see https://doc.babylonjs.com/how_to/multi_canvases
  114862. */
  114863. export class EngineView {
  114864. /** Defines the canvas where to render the view */
  114865. target: HTMLCanvasElement;
  114866. /** Defines an optional camera used to render the view (will use active camera else) */
  114867. camera?: Camera;
  114868. }
  114869. interface Engine {
  114870. /**
  114871. * Gets or sets the HTML element to use for attaching events
  114872. */
  114873. inputElement: Nullable<HTMLElement>;
  114874. /**
  114875. * Gets the current engine view
  114876. * @see https://doc.babylonjs.com/how_to/multi_canvases
  114877. */
  114878. activeView: Nullable<EngineView>;
  114879. /** Gets or sets the list of views */
  114880. views: EngineView[];
  114881. /**
  114882. * Register a new child canvas
  114883. * @param canvas defines the canvas to register
  114884. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  114885. * @returns the associated view
  114886. */
  114887. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  114888. /**
  114889. * Remove a registered child canvas
  114890. * @param canvas defines the canvas to remove
  114891. * @returns the current engine
  114892. */
  114893. unRegisterView(canvas: HTMLCanvasElement): Engine;
  114894. }
  114895. }
  114896. declare module BABYLON {
  114897. /**
  114898. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  114899. */
  114900. export interface CubeMapInfo {
  114901. /**
  114902. * The pixel array for the front face.
  114903. * This is stored in format, left to right, up to down format.
  114904. */
  114905. front: Nullable<ArrayBufferView>;
  114906. /**
  114907. * The pixel array for the back face.
  114908. * This is stored in format, left to right, up to down format.
  114909. */
  114910. back: Nullable<ArrayBufferView>;
  114911. /**
  114912. * The pixel array for the left face.
  114913. * This is stored in format, left to right, up to down format.
  114914. */
  114915. left: Nullable<ArrayBufferView>;
  114916. /**
  114917. * The pixel array for the right face.
  114918. * This is stored in format, left to right, up to down format.
  114919. */
  114920. right: Nullable<ArrayBufferView>;
  114921. /**
  114922. * The pixel array for the up face.
  114923. * This is stored in format, left to right, up to down format.
  114924. */
  114925. up: Nullable<ArrayBufferView>;
  114926. /**
  114927. * The pixel array for the down face.
  114928. * This is stored in format, left to right, up to down format.
  114929. */
  114930. down: Nullable<ArrayBufferView>;
  114931. /**
  114932. * The size of the cubemap stored.
  114933. *
  114934. * Each faces will be size * size pixels.
  114935. */
  114936. size: number;
  114937. /**
  114938. * The format of the texture.
  114939. *
  114940. * RGBA, RGB.
  114941. */
  114942. format: number;
  114943. /**
  114944. * The type of the texture data.
  114945. *
  114946. * UNSIGNED_INT, FLOAT.
  114947. */
  114948. type: number;
  114949. /**
  114950. * Specifies whether the texture is in gamma space.
  114951. */
  114952. gammaSpace: boolean;
  114953. }
  114954. /**
  114955. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  114956. */
  114957. export class PanoramaToCubeMapTools {
  114958. private static FACE_FRONT;
  114959. private static FACE_BACK;
  114960. private static FACE_RIGHT;
  114961. private static FACE_LEFT;
  114962. private static FACE_DOWN;
  114963. private static FACE_UP;
  114964. /**
  114965. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  114966. *
  114967. * @param float32Array The source data.
  114968. * @param inputWidth The width of the input panorama.
  114969. * @param inputHeight The height of the input panorama.
  114970. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  114971. * @return The cubemap data
  114972. */
  114973. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  114974. private static CreateCubemapTexture;
  114975. private static CalcProjectionSpherical;
  114976. }
  114977. }
  114978. declare module BABYLON {
  114979. /**
  114980. * Helper class dealing with the extraction of spherical polynomial dataArray
  114981. * from a cube map.
  114982. */
  114983. export class CubeMapToSphericalPolynomialTools {
  114984. private static FileFaces;
  114985. /**
  114986. * Converts a texture to the according Spherical Polynomial data.
  114987. * This extracts the first 3 orders only as they are the only one used in the lighting.
  114988. *
  114989. * @param texture The texture to extract the information from.
  114990. * @return The Spherical Polynomial data.
  114991. */
  114992. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  114993. /**
  114994. * Converts a cubemap to the according Spherical Polynomial data.
  114995. * This extracts the first 3 orders only as they are the only one used in the lighting.
  114996. *
  114997. * @param cubeInfo The Cube map to extract the information from.
  114998. * @return The Spherical Polynomial data.
  114999. */
  115000. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  115001. }
  115002. }
  115003. declare module BABYLON {
  115004. interface BaseTexture {
  115005. /**
  115006. * Get the polynomial representation of the texture data.
  115007. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  115008. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  115009. */
  115010. sphericalPolynomial: Nullable<SphericalPolynomial>;
  115011. }
  115012. }
  115013. declare module BABYLON {
  115014. /** @hidden */
  115015. export var rgbdEncodePixelShader: {
  115016. name: string;
  115017. shader: string;
  115018. };
  115019. }
  115020. declare module BABYLON {
  115021. /** @hidden */
  115022. export var rgbdDecodePixelShader: {
  115023. name: string;
  115024. shader: string;
  115025. };
  115026. }
  115027. declare module BABYLON {
  115028. /**
  115029. * Raw texture data and descriptor sufficient for WebGL texture upload
  115030. */
  115031. export interface EnvironmentTextureInfo {
  115032. /**
  115033. * Version of the environment map
  115034. */
  115035. version: number;
  115036. /**
  115037. * Width of image
  115038. */
  115039. width: number;
  115040. /**
  115041. * Irradiance information stored in the file.
  115042. */
  115043. irradiance: any;
  115044. /**
  115045. * Specular information stored in the file.
  115046. */
  115047. specular: any;
  115048. }
  115049. /**
  115050. * Defines One Image in the file. It requires only the position in the file
  115051. * as well as the length.
  115052. */
  115053. interface BufferImageData {
  115054. /**
  115055. * Length of the image data.
  115056. */
  115057. length: number;
  115058. /**
  115059. * Position of the data from the null terminator delimiting the end of the JSON.
  115060. */
  115061. position: number;
  115062. }
  115063. /**
  115064. * Defines the specular data enclosed in the file.
  115065. * This corresponds to the version 1 of the data.
  115066. */
  115067. export interface EnvironmentTextureSpecularInfoV1 {
  115068. /**
  115069. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  115070. */
  115071. specularDataPosition?: number;
  115072. /**
  115073. * This contains all the images data needed to reconstruct the cubemap.
  115074. */
  115075. mipmaps: Array<BufferImageData>;
  115076. /**
  115077. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  115078. */
  115079. lodGenerationScale: number;
  115080. }
  115081. /**
  115082. * Sets of helpers addressing the serialization and deserialization of environment texture
  115083. * stored in a BabylonJS env file.
  115084. * Those files are usually stored as .env files.
  115085. */
  115086. export class EnvironmentTextureTools {
  115087. /**
  115088. * Magic number identifying the env file.
  115089. */
  115090. private static _MagicBytes;
  115091. /**
  115092. * Gets the environment info from an env file.
  115093. * @param data The array buffer containing the .env bytes.
  115094. * @returns the environment file info (the json header) if successfully parsed.
  115095. */
  115096. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  115097. /**
  115098. * Creates an environment texture from a loaded cube texture.
  115099. * @param texture defines the cube texture to convert in env file
  115100. * @return a promise containing the environment data if succesfull.
  115101. */
  115102. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  115103. /**
  115104. * Creates a JSON representation of the spherical data.
  115105. * @param texture defines the texture containing the polynomials
  115106. * @return the JSON representation of the spherical info
  115107. */
  115108. private static _CreateEnvTextureIrradiance;
  115109. /**
  115110. * Creates the ArrayBufferViews used for initializing environment texture image data.
  115111. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  115112. * @param info parameters that determine what views will be created for accessing the underlying buffer
  115113. * @return the views described by info providing access to the underlying buffer
  115114. */
  115115. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  115116. /**
  115117. * Uploads the texture info contained in the env file to the GPU.
  115118. * @param texture defines the internal texture to upload to
  115119. * @param arrayBuffer defines the buffer cotaining the data to load
  115120. * @param info defines the texture info retrieved through the GetEnvInfo method
  115121. * @returns a promise
  115122. */
  115123. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  115124. private static _OnImageReadyAsync;
  115125. /**
  115126. * Uploads the levels of image data to the GPU.
  115127. * @param texture defines the internal texture to upload to
  115128. * @param imageData defines the array buffer views of image data [mipmap][face]
  115129. * @returns a promise
  115130. */
  115131. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  115132. /**
  115133. * Uploads spherical polynomials information to the texture.
  115134. * @param texture defines the texture we are trying to upload the information to
  115135. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  115136. */
  115137. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  115138. /** @hidden */
  115139. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  115140. }
  115141. }
  115142. declare module BABYLON {
  115143. /**
  115144. * Contains position and normal vectors for a vertex
  115145. */
  115146. export class PositionNormalVertex {
  115147. /** the position of the vertex (defaut: 0,0,0) */
  115148. position: Vector3;
  115149. /** the normal of the vertex (defaut: 0,1,0) */
  115150. normal: Vector3;
  115151. /**
  115152. * Creates a PositionNormalVertex
  115153. * @param position the position of the vertex (defaut: 0,0,0)
  115154. * @param normal the normal of the vertex (defaut: 0,1,0)
  115155. */
  115156. constructor(
  115157. /** the position of the vertex (defaut: 0,0,0) */
  115158. position?: Vector3,
  115159. /** the normal of the vertex (defaut: 0,1,0) */
  115160. normal?: Vector3);
  115161. /**
  115162. * Clones the PositionNormalVertex
  115163. * @returns the cloned PositionNormalVertex
  115164. */
  115165. clone(): PositionNormalVertex;
  115166. }
  115167. /**
  115168. * Contains position, normal and uv vectors for a vertex
  115169. */
  115170. export class PositionNormalTextureVertex {
  115171. /** the position of the vertex (defaut: 0,0,0) */
  115172. position: Vector3;
  115173. /** the normal of the vertex (defaut: 0,1,0) */
  115174. normal: Vector3;
  115175. /** the uv of the vertex (default: 0,0) */
  115176. uv: Vector2;
  115177. /**
  115178. * Creates a PositionNormalTextureVertex
  115179. * @param position the position of the vertex (defaut: 0,0,0)
  115180. * @param normal the normal of the vertex (defaut: 0,1,0)
  115181. * @param uv the uv of the vertex (default: 0,0)
  115182. */
  115183. constructor(
  115184. /** the position of the vertex (defaut: 0,0,0) */
  115185. position?: Vector3,
  115186. /** the normal of the vertex (defaut: 0,1,0) */
  115187. normal?: Vector3,
  115188. /** the uv of the vertex (default: 0,0) */
  115189. uv?: Vector2);
  115190. /**
  115191. * Clones the PositionNormalTextureVertex
  115192. * @returns the cloned PositionNormalTextureVertex
  115193. */
  115194. clone(): PositionNormalTextureVertex;
  115195. }
  115196. }
  115197. declare module BABYLON {
  115198. /** @hidden */
  115199. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  115200. private _genericAttributeLocation;
  115201. private _varyingLocationCount;
  115202. private _varyingLocationMap;
  115203. private _replacements;
  115204. private _textureCount;
  115205. private _uniforms;
  115206. lineProcessor(line: string): string;
  115207. attributeProcessor(attribute: string): string;
  115208. varyingProcessor(varying: string, isFragment: boolean): string;
  115209. uniformProcessor(uniform: string): string;
  115210. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  115211. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  115212. }
  115213. }
  115214. declare module BABYLON {
  115215. /**
  115216. * Container for accessors for natively-stored mesh data buffers.
  115217. */
  115218. class NativeDataBuffer extends DataBuffer {
  115219. /**
  115220. * Accessor value used to identify/retrieve a natively-stored index buffer.
  115221. */
  115222. nativeIndexBuffer?: any;
  115223. /**
  115224. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  115225. */
  115226. nativeVertexBuffer?: any;
  115227. }
  115228. /** @hidden */
  115229. class NativeTexture extends InternalTexture {
  115230. getInternalTexture(): InternalTexture;
  115231. getViewCount(): number;
  115232. }
  115233. /** @hidden */
  115234. export class NativeEngine extends Engine {
  115235. private readonly _native;
  115236. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  115237. private readonly INVALID_HANDLE;
  115238. getHardwareScalingLevel(): number;
  115239. constructor();
  115240. /**
  115241. * Can be used to override the current requestAnimationFrame requester.
  115242. * @hidden
  115243. */
  115244. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  115245. /**
  115246. * Override default engine behavior.
  115247. * @param color
  115248. * @param backBuffer
  115249. * @param depth
  115250. * @param stencil
  115251. */
  115252. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  115253. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  115254. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  115255. createVertexBuffer(data: DataArray): NativeDataBuffer;
  115256. recordVertexArrayObject(vertexBuffers: {
  115257. [key: string]: VertexBuffer;
  115258. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  115259. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  115260. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  115261. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  115262. /**
  115263. * Draw a list of indexed primitives
  115264. * @param fillMode defines the primitive to use
  115265. * @param indexStart defines the starting index
  115266. * @param indexCount defines the number of index to draw
  115267. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115268. */
  115269. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  115270. /**
  115271. * Draw a list of unindexed primitives
  115272. * @param fillMode defines the primitive to use
  115273. * @param verticesStart defines the index of first vertex to draw
  115274. * @param verticesCount defines the count of vertices to draw
  115275. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115276. */
  115277. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115278. createPipelineContext(): IPipelineContext;
  115279. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  115280. /** @hidden */
  115281. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  115282. /** @hidden */
  115283. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  115284. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  115285. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  115286. protected _setProgram(program: WebGLProgram): void;
  115287. _releaseEffect(effect: Effect): void;
  115288. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  115289. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  115290. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  115291. bindSamplers(effect: Effect): void;
  115292. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  115293. getRenderWidth(useScreen?: boolean): number;
  115294. getRenderHeight(useScreen?: boolean): number;
  115295. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  115296. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  115297. /**
  115298. * Set the z offset to apply to current rendering
  115299. * @param value defines the offset to apply
  115300. */
  115301. setZOffset(value: number): void;
  115302. /**
  115303. * Gets the current value of the zOffset
  115304. * @returns the current zOffset state
  115305. */
  115306. getZOffset(): number;
  115307. /**
  115308. * Enable or disable depth buffering
  115309. * @param enable defines the state to set
  115310. */
  115311. setDepthBuffer(enable: boolean): void;
  115312. /**
  115313. * Gets a boolean indicating if depth writing is enabled
  115314. * @returns the current depth writing state
  115315. */
  115316. getDepthWrite(): boolean;
  115317. /**
  115318. * Enable or disable depth writing
  115319. * @param enable defines the state to set
  115320. */
  115321. setDepthWrite(enable: boolean): void;
  115322. /**
  115323. * Enable or disable color writing
  115324. * @param enable defines the state to set
  115325. */
  115326. setColorWrite(enable: boolean): void;
  115327. /**
  115328. * Gets a boolean indicating if color writing is enabled
  115329. * @returns the current color writing state
  115330. */
  115331. getColorWrite(): boolean;
  115332. /**
  115333. * Sets alpha constants used by some alpha blending modes
  115334. * @param r defines the red component
  115335. * @param g defines the green component
  115336. * @param b defines the blue component
  115337. * @param a defines the alpha component
  115338. */
  115339. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  115340. /**
  115341. * Sets the current alpha mode
  115342. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  115343. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  115344. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  115345. */
  115346. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  115347. /**
  115348. * Gets the current alpha mode
  115349. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  115350. * @returns the current alpha mode
  115351. */
  115352. getAlphaMode(): number;
  115353. setInt(uniform: WebGLUniformLocation, int: number): void;
  115354. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  115355. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  115356. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  115357. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  115358. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  115359. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  115360. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  115361. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  115362. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  115363. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  115364. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  115365. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  115366. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  115367. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  115368. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  115369. setFloat(uniform: WebGLUniformLocation, value: number): void;
  115370. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  115371. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  115372. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  115373. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  115374. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  115375. wipeCaches(bruteForce?: boolean): void;
  115376. _createTexture(): WebGLTexture;
  115377. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  115378. /**
  115379. * Usually called from BABYLON.Texture.ts.
  115380. * Passed information to create a WebGLTexture
  115381. * @param urlArg defines a value which contains one of the following:
  115382. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  115383. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  115384. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  115385. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  115386. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  115387. * @param scene needed for loading to the correct scene
  115388. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  115389. * @param onLoad optional callback to be called upon successful completion
  115390. * @param onError optional callback to be called upon failure
  115391. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  115392. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  115393. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  115394. * @param forcedExtension defines the extension to use to pick the right loader
  115395. * @returns a InternalTexture for assignment back into BABYLON.Texture
  115396. */
  115397. 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;
  115398. /**
  115399. * Creates a cube texture
  115400. * @param rootUrl defines the url where the files to load is located
  115401. * @param scene defines the current scene
  115402. * @param files defines the list of files to load (1 per face)
  115403. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  115404. * @param onLoad defines an optional callback raised when the texture is loaded
  115405. * @param onError defines an optional callback raised if there is an issue to load the texture
  115406. * @param format defines the format of the data
  115407. * @param forcedExtension defines the extension to use to pick the right loader
  115408. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  115409. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  115410. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  115411. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  115412. * @returns the cube texture as an InternalTexture
  115413. */
  115414. 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;
  115415. private _getSamplingFilter;
  115416. private static _GetNativeTextureFormat;
  115417. createRenderTargetTexture(size: number | {
  115418. width: number;
  115419. height: number;
  115420. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  115421. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  115422. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  115423. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  115424. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  115425. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  115426. /**
  115427. * Updates a dynamic vertex buffer.
  115428. * @param vertexBuffer the vertex buffer to update
  115429. * @param data the data used to update the vertex buffer
  115430. * @param byteOffset the byte offset of the data (optional)
  115431. * @param byteLength the byte length of the data (optional)
  115432. */
  115433. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  115434. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  115435. private _updateAnisotropicLevel;
  115436. private _getAddressMode;
  115437. /** @hidden */
  115438. _bindTexture(channel: number, texture: InternalTexture): void;
  115439. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  115440. releaseEffects(): void;
  115441. /** @hidden */
  115442. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115443. /** @hidden */
  115444. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115445. /** @hidden */
  115446. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115447. /** @hidden */
  115448. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  115449. }
  115450. }
  115451. declare module BABYLON {
  115452. /**
  115453. * Gather the list of clipboard event types as constants.
  115454. */
  115455. export class ClipboardEventTypes {
  115456. /**
  115457. * The clipboard event is fired when a copy command is active (pressed).
  115458. */
  115459. static readonly COPY: number;
  115460. /**
  115461. * The clipboard event is fired when a cut command is active (pressed).
  115462. */
  115463. static readonly CUT: number;
  115464. /**
  115465. * The clipboard event is fired when a paste command is active (pressed).
  115466. */
  115467. static readonly PASTE: number;
  115468. }
  115469. /**
  115470. * This class is used to store clipboard related info for the onClipboardObservable event.
  115471. */
  115472. export class ClipboardInfo {
  115473. /**
  115474. * Defines the type of event (BABYLON.ClipboardEventTypes)
  115475. */
  115476. type: number;
  115477. /**
  115478. * Defines the related dom event
  115479. */
  115480. event: ClipboardEvent;
  115481. /**
  115482. *Creates an instance of ClipboardInfo.
  115483. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  115484. * @param event Defines the related dom event
  115485. */
  115486. constructor(
  115487. /**
  115488. * Defines the type of event (BABYLON.ClipboardEventTypes)
  115489. */
  115490. type: number,
  115491. /**
  115492. * Defines the related dom event
  115493. */
  115494. event: ClipboardEvent);
  115495. /**
  115496. * Get the clipboard event's type from the keycode.
  115497. * @param keyCode Defines the keyCode for the current keyboard event.
  115498. * @return {number}
  115499. */
  115500. static GetTypeFromCharacter(keyCode: number): number;
  115501. }
  115502. }
  115503. declare module BABYLON {
  115504. /**
  115505. * Google Daydream controller
  115506. */
  115507. export class DaydreamController extends WebVRController {
  115508. /**
  115509. * Base Url for the controller model.
  115510. */
  115511. static MODEL_BASE_URL: string;
  115512. /**
  115513. * File name for the controller model.
  115514. */
  115515. static MODEL_FILENAME: string;
  115516. /**
  115517. * Gamepad Id prefix used to identify Daydream Controller.
  115518. */
  115519. static readonly GAMEPAD_ID_PREFIX: string;
  115520. /**
  115521. * Creates a new DaydreamController from a gamepad
  115522. * @param vrGamepad the gamepad that the controller should be created from
  115523. */
  115524. constructor(vrGamepad: any);
  115525. /**
  115526. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  115527. * @param scene scene in which to add meshes
  115528. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  115529. */
  115530. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  115531. /**
  115532. * Called once for each button that changed state since the last frame
  115533. * @param buttonIdx Which button index changed
  115534. * @param state New state of the button
  115535. * @param changes Which properties on the state changed since last frame
  115536. */
  115537. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  115538. }
  115539. }
  115540. declare module BABYLON {
  115541. /**
  115542. * Gear VR Controller
  115543. */
  115544. export class GearVRController extends WebVRController {
  115545. /**
  115546. * Base Url for the controller model.
  115547. */
  115548. static MODEL_BASE_URL: string;
  115549. /**
  115550. * File name for the controller model.
  115551. */
  115552. static MODEL_FILENAME: string;
  115553. /**
  115554. * Gamepad Id prefix used to identify this controller.
  115555. */
  115556. static readonly GAMEPAD_ID_PREFIX: string;
  115557. private readonly _buttonIndexToObservableNameMap;
  115558. /**
  115559. * Creates a new GearVRController from a gamepad
  115560. * @param vrGamepad the gamepad that the controller should be created from
  115561. */
  115562. constructor(vrGamepad: any);
  115563. /**
  115564. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  115565. * @param scene scene in which to add meshes
  115566. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  115567. */
  115568. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  115569. /**
  115570. * Called once for each button that changed state since the last frame
  115571. * @param buttonIdx Which button index changed
  115572. * @param state New state of the button
  115573. * @param changes Which properties on the state changed since last frame
  115574. */
  115575. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  115576. }
  115577. }
  115578. declare module BABYLON {
  115579. /**
  115580. * Class containing static functions to help procedurally build meshes
  115581. */
  115582. export class PolyhedronBuilder {
  115583. /**
  115584. * Creates a polyhedron mesh
  115585. * * 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
  115586. * * The parameter `size` (positive float, default 1) sets the polygon size
  115587. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  115588. * * 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`
  115589. * * 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
  115590. * * 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)`)
  115591. * * 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
  115592. * * 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
  115593. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115594. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115596. * @param name defines the name of the mesh
  115597. * @param options defines the options used to create the mesh
  115598. * @param scene defines the hosting scene
  115599. * @returns the polyhedron mesh
  115600. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  115601. */
  115602. static CreatePolyhedron(name: string, options: {
  115603. type?: number;
  115604. size?: number;
  115605. sizeX?: number;
  115606. sizeY?: number;
  115607. sizeZ?: number;
  115608. custom?: any;
  115609. faceUV?: Vector4[];
  115610. faceColors?: Color4[];
  115611. flat?: boolean;
  115612. updatable?: boolean;
  115613. sideOrientation?: number;
  115614. frontUVs?: Vector4;
  115615. backUVs?: Vector4;
  115616. }, scene?: Nullable<Scene>): Mesh;
  115617. }
  115618. }
  115619. declare module BABYLON {
  115620. /**
  115621. * Gizmo that enables scaling a mesh along 3 axis
  115622. */
  115623. export class ScaleGizmo extends Gizmo {
  115624. /**
  115625. * Internal gizmo used for interactions on the x axis
  115626. */
  115627. xGizmo: AxisScaleGizmo;
  115628. /**
  115629. * Internal gizmo used for interactions on the y axis
  115630. */
  115631. yGizmo: AxisScaleGizmo;
  115632. /**
  115633. * Internal gizmo used for interactions on the z axis
  115634. */
  115635. zGizmo: AxisScaleGizmo;
  115636. /**
  115637. * Internal gizmo used to scale all axis equally
  115638. */
  115639. uniformScaleGizmo: AxisScaleGizmo;
  115640. private _meshAttached;
  115641. private _updateGizmoRotationToMatchAttachedMesh;
  115642. private _snapDistance;
  115643. private _scaleRatio;
  115644. private _uniformScalingMesh;
  115645. private _octahedron;
  115646. private _sensitivity;
  115647. /** Fires an event when any of it's sub gizmos are dragged */
  115648. onDragStartObservable: Observable<unknown>;
  115649. /** Fires an event when any of it's sub gizmos are released from dragging */
  115650. onDragEndObservable: Observable<unknown>;
  115651. attachedMesh: Nullable<AbstractMesh>;
  115652. /**
  115653. * Creates a ScaleGizmo
  115654. * @param gizmoLayer The utility layer the gizmo will be added to
  115655. */
  115656. constructor(gizmoLayer?: UtilityLayerRenderer);
  115657. updateGizmoRotationToMatchAttachedMesh: boolean;
  115658. /**
  115659. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115660. */
  115661. snapDistance: number;
  115662. /**
  115663. * Ratio for the scale of the gizmo (Default: 1)
  115664. */
  115665. scaleRatio: number;
  115666. /**
  115667. * Sensitivity factor for dragging (Default: 1)
  115668. */
  115669. sensitivity: number;
  115670. /**
  115671. * Disposes of the gizmo
  115672. */
  115673. dispose(): void;
  115674. }
  115675. }
  115676. declare module BABYLON {
  115677. /**
  115678. * Single axis scale gizmo
  115679. */
  115680. export class AxisScaleGizmo extends Gizmo {
  115681. /**
  115682. * Drag behavior responsible for the gizmos dragging interactions
  115683. */
  115684. dragBehavior: PointerDragBehavior;
  115685. private _pointerObserver;
  115686. /**
  115687. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115688. */
  115689. snapDistance: number;
  115690. /**
  115691. * Event that fires each time the gizmo snaps to a new location.
  115692. * * snapDistance is the the change in distance
  115693. */
  115694. onSnapObservable: Observable<{
  115695. snapDistance: number;
  115696. }>;
  115697. /**
  115698. * If the scaling operation should be done on all axis (default: false)
  115699. */
  115700. uniformScaling: boolean;
  115701. /**
  115702. * Custom sensitivity value for the drag strength
  115703. */
  115704. sensitivity: number;
  115705. private _isEnabled;
  115706. private _parent;
  115707. private _arrow;
  115708. private _coloredMaterial;
  115709. private _hoverMaterial;
  115710. /**
  115711. * Creates an AxisScaleGizmo
  115712. * @param gizmoLayer The utility layer the gizmo will be added to
  115713. * @param dragAxis The axis which the gizmo will be able to scale on
  115714. * @param color The color of the gizmo
  115715. */
  115716. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  115717. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115718. /**
  115719. * If the gizmo is enabled
  115720. */
  115721. isEnabled: boolean;
  115722. /**
  115723. * Disposes of the gizmo
  115724. */
  115725. dispose(): void;
  115726. /**
  115727. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  115728. * @param mesh The mesh to replace the default mesh of the gizmo
  115729. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  115730. */
  115731. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  115732. }
  115733. }
  115734. declare module BABYLON {
  115735. /**
  115736. * Bounding box gizmo
  115737. */
  115738. export class BoundingBoxGizmo extends Gizmo {
  115739. private _lineBoundingBox;
  115740. private _rotateSpheresParent;
  115741. private _scaleBoxesParent;
  115742. private _boundingDimensions;
  115743. private _renderObserver;
  115744. private _pointerObserver;
  115745. private _scaleDragSpeed;
  115746. private _tmpQuaternion;
  115747. private _tmpVector;
  115748. private _tmpRotationMatrix;
  115749. /**
  115750. * 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)
  115751. */
  115752. ignoreChildren: boolean;
  115753. /**
  115754. * 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)
  115755. */
  115756. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  115757. /**
  115758. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  115759. */
  115760. rotationSphereSize: number;
  115761. /**
  115762. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  115763. */
  115764. scaleBoxSize: number;
  115765. /**
  115766. * 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)
  115767. */
  115768. fixedDragMeshScreenSize: boolean;
  115769. /**
  115770. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  115771. */
  115772. fixedDragMeshScreenSizeDistanceFactor: number;
  115773. /**
  115774. * Fired when a rotation sphere or scale box is dragged
  115775. */
  115776. onDragStartObservable: Observable<{}>;
  115777. /**
  115778. * Fired when a scale box is dragged
  115779. */
  115780. onScaleBoxDragObservable: Observable<{}>;
  115781. /**
  115782. * Fired when a scale box drag is ended
  115783. */
  115784. onScaleBoxDragEndObservable: Observable<{}>;
  115785. /**
  115786. * Fired when a rotation sphere is dragged
  115787. */
  115788. onRotationSphereDragObservable: Observable<{}>;
  115789. /**
  115790. * Fired when a rotation sphere drag is ended
  115791. */
  115792. onRotationSphereDragEndObservable: Observable<{}>;
  115793. /**
  115794. * 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)
  115795. */
  115796. scalePivot: Nullable<Vector3>;
  115797. /**
  115798. * Mesh used as a pivot to rotate the attached mesh
  115799. */
  115800. private _anchorMesh;
  115801. private _existingMeshScale;
  115802. private _dragMesh;
  115803. private pointerDragBehavior;
  115804. private coloredMaterial;
  115805. private hoverColoredMaterial;
  115806. /**
  115807. * Sets the color of the bounding box gizmo
  115808. * @param color the color to set
  115809. */
  115810. setColor(color: Color3): void;
  115811. /**
  115812. * Creates an BoundingBoxGizmo
  115813. * @param gizmoLayer The utility layer the gizmo will be added to
  115814. * @param color The color of the gizmo
  115815. */
  115816. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  115817. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115818. private _selectNode;
  115819. /**
  115820. * Updates the bounding box information for the Gizmo
  115821. */
  115822. updateBoundingBox(): void;
  115823. private _updateRotationSpheres;
  115824. private _updateScaleBoxes;
  115825. /**
  115826. * Enables rotation on the specified axis and disables rotation on the others
  115827. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  115828. */
  115829. setEnabledRotationAxis(axis: string): void;
  115830. /**
  115831. * Enables/disables scaling
  115832. * @param enable if scaling should be enabled
  115833. */
  115834. setEnabledScaling(enable: boolean): void;
  115835. private _updateDummy;
  115836. /**
  115837. * Enables a pointer drag behavior on the bounding box of the gizmo
  115838. */
  115839. enableDragBehavior(): void;
  115840. /**
  115841. * Disposes of the gizmo
  115842. */
  115843. dispose(): void;
  115844. /**
  115845. * 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)
  115846. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  115847. * @returns the bounding box mesh with the passed in mesh as a child
  115848. */
  115849. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  115850. /**
  115851. * CustomMeshes are not supported by this gizmo
  115852. * @param mesh The mesh to replace the default mesh of the gizmo
  115853. */
  115854. setCustomMesh(mesh: Mesh): void;
  115855. }
  115856. }
  115857. declare module BABYLON {
  115858. /**
  115859. * Single plane rotation gizmo
  115860. */
  115861. export class PlaneRotationGizmo extends Gizmo {
  115862. /**
  115863. * Drag behavior responsible for the gizmos dragging interactions
  115864. */
  115865. dragBehavior: PointerDragBehavior;
  115866. private _pointerObserver;
  115867. /**
  115868. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  115869. */
  115870. snapDistance: number;
  115871. /**
  115872. * Event that fires each time the gizmo snaps to a new location.
  115873. * * snapDistance is the the change in distance
  115874. */
  115875. onSnapObservable: Observable<{
  115876. snapDistance: number;
  115877. }>;
  115878. private _isEnabled;
  115879. private _parent;
  115880. /**
  115881. * Creates a PlaneRotationGizmo
  115882. * @param gizmoLayer The utility layer the gizmo will be added to
  115883. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  115884. * @param color The color of the gizmo
  115885. * @param tessellation Amount of tessellation to be used when creating rotation circles
  115886. * @param useEulerRotation Use and update Euler angle instead of quaternion
  115887. */
  115888. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  115889. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115890. /**
  115891. * If the gizmo is enabled
  115892. */
  115893. isEnabled: boolean;
  115894. /**
  115895. * Disposes of the gizmo
  115896. */
  115897. dispose(): void;
  115898. }
  115899. }
  115900. declare module BABYLON {
  115901. /**
  115902. * Gizmo that enables rotating a mesh along 3 axis
  115903. */
  115904. export class RotationGizmo extends Gizmo {
  115905. /**
  115906. * Internal gizmo used for interactions on the x axis
  115907. */
  115908. xGizmo: PlaneRotationGizmo;
  115909. /**
  115910. * Internal gizmo used for interactions on the y axis
  115911. */
  115912. yGizmo: PlaneRotationGizmo;
  115913. /**
  115914. * Internal gizmo used for interactions on the z axis
  115915. */
  115916. zGizmo: PlaneRotationGizmo;
  115917. /** Fires an event when any of it's sub gizmos are dragged */
  115918. onDragStartObservable: Observable<unknown>;
  115919. /** Fires an event when any of it's sub gizmos are released from dragging */
  115920. onDragEndObservable: Observable<unknown>;
  115921. private _meshAttached;
  115922. attachedMesh: Nullable<AbstractMesh>;
  115923. /**
  115924. * Creates a RotationGizmo
  115925. * @param gizmoLayer The utility layer the gizmo will be added to
  115926. * @param tessellation Amount of tessellation to be used when creating rotation circles
  115927. * @param useEulerRotation Use and update Euler angle instead of quaternion
  115928. */
  115929. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  115930. updateGizmoRotationToMatchAttachedMesh: boolean;
  115931. /**
  115932. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115933. */
  115934. snapDistance: number;
  115935. /**
  115936. * Ratio for the scale of the gizmo (Default: 1)
  115937. */
  115938. scaleRatio: number;
  115939. /**
  115940. * Disposes of the gizmo
  115941. */
  115942. dispose(): void;
  115943. /**
  115944. * CustomMeshes are not supported by this gizmo
  115945. * @param mesh The mesh to replace the default mesh of the gizmo
  115946. */
  115947. setCustomMesh(mesh: Mesh): void;
  115948. }
  115949. }
  115950. declare module BABYLON {
  115951. /**
  115952. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  115953. */
  115954. export class GizmoManager implements IDisposable {
  115955. private scene;
  115956. /**
  115957. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  115958. */
  115959. gizmos: {
  115960. positionGizmo: Nullable<PositionGizmo>;
  115961. rotationGizmo: Nullable<RotationGizmo>;
  115962. scaleGizmo: Nullable<ScaleGizmo>;
  115963. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  115964. };
  115965. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  115966. clearGizmoOnEmptyPointerEvent: boolean;
  115967. /** Fires an event when the manager is attached to a mesh */
  115968. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  115969. private _gizmosEnabled;
  115970. private _pointerObserver;
  115971. private _attachedMesh;
  115972. private _boundingBoxColor;
  115973. private _defaultUtilityLayer;
  115974. private _defaultKeepDepthUtilityLayer;
  115975. /**
  115976. * When bounding box gizmo is enabled, this can be used to track drag/end events
  115977. */
  115978. boundingBoxDragBehavior: SixDofDragBehavior;
  115979. /**
  115980. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  115981. */
  115982. attachableMeshes: Nullable<Array<AbstractMesh>>;
  115983. /**
  115984. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  115985. */
  115986. usePointerToAttachGizmos: boolean;
  115987. /**
  115988. * Utility layer that the bounding box gizmo belongs to
  115989. */
  115990. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  115991. /**
  115992. * Utility layer that all gizmos besides bounding box belong to
  115993. */
  115994. readonly utilityLayer: UtilityLayerRenderer;
  115995. /**
  115996. * Instatiates a gizmo manager
  115997. * @param scene the scene to overlay the gizmos on top of
  115998. */
  115999. constructor(scene: Scene);
  116000. /**
  116001. * Attaches a set of gizmos to the specified mesh
  116002. * @param mesh The mesh the gizmo's should be attached to
  116003. */
  116004. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  116005. /**
  116006. * If the position gizmo is enabled
  116007. */
  116008. positionGizmoEnabled: boolean;
  116009. /**
  116010. * If the rotation gizmo is enabled
  116011. */
  116012. rotationGizmoEnabled: boolean;
  116013. /**
  116014. * If the scale gizmo is enabled
  116015. */
  116016. scaleGizmoEnabled: boolean;
  116017. /**
  116018. * If the boundingBox gizmo is enabled
  116019. */
  116020. boundingBoxGizmoEnabled: boolean;
  116021. /**
  116022. * Disposes of the gizmo manager
  116023. */
  116024. dispose(): void;
  116025. }
  116026. }
  116027. declare module BABYLON {
  116028. /**
  116029. * A directional light is defined by a direction (what a surprise!).
  116030. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  116031. * 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.
  116032. * Documentation: https://doc.babylonjs.com/babylon101/lights
  116033. */
  116034. export class DirectionalLight extends ShadowLight {
  116035. private _shadowFrustumSize;
  116036. /**
  116037. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  116038. */
  116039. /**
  116040. * Specifies a fix frustum size for the shadow generation.
  116041. */
  116042. shadowFrustumSize: number;
  116043. private _shadowOrthoScale;
  116044. /**
  116045. * Gets the shadow projection scale against the optimal computed one.
  116046. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  116047. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  116048. */
  116049. /**
  116050. * Sets the shadow projection scale against the optimal computed one.
  116051. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  116052. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  116053. */
  116054. shadowOrthoScale: number;
  116055. /**
  116056. * Automatically compute the projection matrix to best fit (including all the casters)
  116057. * on each frame.
  116058. */
  116059. autoUpdateExtends: boolean;
  116060. private _orthoLeft;
  116061. private _orthoRight;
  116062. private _orthoTop;
  116063. private _orthoBottom;
  116064. /**
  116065. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  116066. * The directional light is emitted from everywhere in the given direction.
  116067. * It can cast shadows.
  116068. * Documentation : https://doc.babylonjs.com/babylon101/lights
  116069. * @param name The friendly name of the light
  116070. * @param direction The direction of the light
  116071. * @param scene The scene the light belongs to
  116072. */
  116073. constructor(name: string, direction: Vector3, scene: Scene);
  116074. /**
  116075. * Returns the string "DirectionalLight".
  116076. * @return The class name
  116077. */
  116078. getClassName(): string;
  116079. /**
  116080. * Returns the integer 1.
  116081. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  116082. */
  116083. getTypeID(): number;
  116084. /**
  116085. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  116086. * Returns the DirectionalLight Shadow projection matrix.
  116087. */
  116088. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  116089. /**
  116090. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  116091. * Returns the DirectionalLight Shadow projection matrix.
  116092. */
  116093. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  116094. /**
  116095. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  116096. * Returns the DirectionalLight Shadow projection matrix.
  116097. */
  116098. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  116099. protected _buildUniformLayout(): void;
  116100. /**
  116101. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  116102. * @param effect The effect to update
  116103. * @param lightIndex The index of the light in the effect to update
  116104. * @returns The directional light
  116105. */
  116106. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  116107. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  116108. /**
  116109. * Gets the minZ used for shadow according to both the scene and the light.
  116110. *
  116111. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  116112. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  116113. * @param activeCamera The camera we are returning the min for
  116114. * @returns the depth min z
  116115. */
  116116. getDepthMinZ(activeCamera: Camera): number;
  116117. /**
  116118. * Gets the maxZ used for shadow according to both the scene and the light.
  116119. *
  116120. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  116121. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  116122. * @param activeCamera The camera we are returning the max for
  116123. * @returns the depth max z
  116124. */
  116125. getDepthMaxZ(activeCamera: Camera): number;
  116126. /**
  116127. * Prepares the list of defines specific to the light type.
  116128. * @param defines the list of defines
  116129. * @param lightIndex defines the index of the light for the effect
  116130. */
  116131. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  116132. }
  116133. }
  116134. declare module BABYLON {
  116135. /**
  116136. * Class containing static functions to help procedurally build meshes
  116137. */
  116138. export class HemisphereBuilder {
  116139. /**
  116140. * Creates a hemisphere mesh
  116141. * @param name defines the name of the mesh
  116142. * @param options defines the options used to create the mesh
  116143. * @param scene defines the hosting scene
  116144. * @returns the hemisphere mesh
  116145. */
  116146. static CreateHemisphere(name: string, options: {
  116147. segments?: number;
  116148. diameter?: number;
  116149. sideOrientation?: number;
  116150. }, scene: any): Mesh;
  116151. }
  116152. }
  116153. declare module BABYLON {
  116154. /**
  116155. * A spot light is defined by a position, a direction, an angle, and an exponent.
  116156. * These values define a cone of light starting from the position, emitting toward the direction.
  116157. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  116158. * and the exponent defines the speed of the decay of the light with distance (reach).
  116159. * Documentation: https://doc.babylonjs.com/babylon101/lights
  116160. */
  116161. export class SpotLight extends ShadowLight {
  116162. private _angle;
  116163. private _innerAngle;
  116164. private _cosHalfAngle;
  116165. private _lightAngleScale;
  116166. private _lightAngleOffset;
  116167. /**
  116168. * Gets the cone angle of the spot light in Radians.
  116169. */
  116170. /**
  116171. * Sets the cone angle of the spot light in Radians.
  116172. */
  116173. angle: number;
  116174. /**
  116175. * Only used in gltf falloff mode, this defines the angle where
  116176. * the directional falloff will start before cutting at angle which could be seen
  116177. * as outer angle.
  116178. */
  116179. /**
  116180. * Only used in gltf falloff mode, this defines the angle where
  116181. * the directional falloff will start before cutting at angle which could be seen
  116182. * as outer angle.
  116183. */
  116184. innerAngle: number;
  116185. private _shadowAngleScale;
  116186. /**
  116187. * Allows scaling the angle of the light for shadow generation only.
  116188. */
  116189. /**
  116190. * Allows scaling the angle of the light for shadow generation only.
  116191. */
  116192. shadowAngleScale: number;
  116193. /**
  116194. * The light decay speed with the distance from the emission spot.
  116195. */
  116196. exponent: number;
  116197. private _projectionTextureMatrix;
  116198. /**
  116199. * Allows reading the projecton texture
  116200. */
  116201. readonly projectionTextureMatrix: Matrix;
  116202. protected _projectionTextureLightNear: number;
  116203. /**
  116204. * Gets the near clip of the Spotlight for texture projection.
  116205. */
  116206. /**
  116207. * Sets the near clip of the Spotlight for texture projection.
  116208. */
  116209. projectionTextureLightNear: number;
  116210. protected _projectionTextureLightFar: number;
  116211. /**
  116212. * Gets the far clip of the Spotlight for texture projection.
  116213. */
  116214. /**
  116215. * Sets the far clip of the Spotlight for texture projection.
  116216. */
  116217. projectionTextureLightFar: number;
  116218. protected _projectionTextureUpDirection: Vector3;
  116219. /**
  116220. * Gets the Up vector of the Spotlight for texture projection.
  116221. */
  116222. /**
  116223. * Sets the Up vector of the Spotlight for texture projection.
  116224. */
  116225. projectionTextureUpDirection: Vector3;
  116226. private _projectionTexture;
  116227. /**
  116228. * Gets the projection texture of the light.
  116229. */
  116230. /**
  116231. * Sets the projection texture of the light.
  116232. */
  116233. projectionTexture: Nullable<BaseTexture>;
  116234. private _projectionTextureViewLightDirty;
  116235. private _projectionTextureProjectionLightDirty;
  116236. private _projectionTextureDirty;
  116237. private _projectionTextureViewTargetVector;
  116238. private _projectionTextureViewLightMatrix;
  116239. private _projectionTextureProjectionLightMatrix;
  116240. private _projectionTextureScalingMatrix;
  116241. /**
  116242. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  116243. * It can cast shadows.
  116244. * Documentation : https://doc.babylonjs.com/babylon101/lights
  116245. * @param name The light friendly name
  116246. * @param position The position of the spot light in the scene
  116247. * @param direction The direction of the light in the scene
  116248. * @param angle The cone angle of the light in Radians
  116249. * @param exponent The light decay speed with the distance from the emission spot
  116250. * @param scene The scene the lights belongs to
  116251. */
  116252. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  116253. /**
  116254. * Returns the string "SpotLight".
  116255. * @returns the class name
  116256. */
  116257. getClassName(): string;
  116258. /**
  116259. * Returns the integer 2.
  116260. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  116261. */
  116262. getTypeID(): number;
  116263. /**
  116264. * Overrides the direction setter to recompute the projection texture view light Matrix.
  116265. */
  116266. protected _setDirection(value: Vector3): void;
  116267. /**
  116268. * Overrides the position setter to recompute the projection texture view light Matrix.
  116269. */
  116270. protected _setPosition(value: Vector3): void;
  116271. /**
  116272. * 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.
  116273. * Returns the SpotLight.
  116274. */
  116275. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  116276. protected _computeProjectionTextureViewLightMatrix(): void;
  116277. protected _computeProjectionTextureProjectionLightMatrix(): void;
  116278. /**
  116279. * Main function for light texture projection matrix computing.
  116280. */
  116281. protected _computeProjectionTextureMatrix(): void;
  116282. protected _buildUniformLayout(): void;
  116283. private _computeAngleValues;
  116284. /**
  116285. * Sets the passed Effect "effect" with the Light textures.
  116286. * @param effect The effect to update
  116287. * @param lightIndex The index of the light in the effect to update
  116288. * @returns The light
  116289. */
  116290. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  116291. /**
  116292. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  116293. * @param effect The effect to update
  116294. * @param lightIndex The index of the light in the effect to update
  116295. * @returns The spot light
  116296. */
  116297. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  116298. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  116299. /**
  116300. * Disposes the light and the associated resources.
  116301. */
  116302. dispose(): void;
  116303. /**
  116304. * Prepares the list of defines specific to the light type.
  116305. * @param defines the list of defines
  116306. * @param lightIndex defines the index of the light for the effect
  116307. */
  116308. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  116309. }
  116310. }
  116311. declare module BABYLON {
  116312. /**
  116313. * Gizmo that enables viewing a light
  116314. */
  116315. export class LightGizmo extends Gizmo {
  116316. private _lightMesh;
  116317. private _material;
  116318. private _cachedPosition;
  116319. private _cachedForward;
  116320. private _attachedMeshParent;
  116321. /**
  116322. * Creates a LightGizmo
  116323. * @param gizmoLayer The utility layer the gizmo will be added to
  116324. */
  116325. constructor(gizmoLayer?: UtilityLayerRenderer);
  116326. private _light;
  116327. /**
  116328. * The light that the gizmo is attached to
  116329. */
  116330. light: Nullable<Light>;
  116331. /**
  116332. * Gets the material used to render the light gizmo
  116333. */
  116334. readonly material: StandardMaterial;
  116335. /**
  116336. * @hidden
  116337. * Updates the gizmo to match the attached mesh's position/rotation
  116338. */
  116339. protected _update(): void;
  116340. private static _Scale;
  116341. /**
  116342. * Creates the lines for a light mesh
  116343. */
  116344. private static _CreateLightLines;
  116345. /**
  116346. * Disposes of the light gizmo
  116347. */
  116348. dispose(): void;
  116349. private static _CreateHemisphericLightMesh;
  116350. private static _CreatePointLightMesh;
  116351. private static _CreateSpotLightMesh;
  116352. private static _CreateDirectionalLightMesh;
  116353. }
  116354. }
  116355. declare module BABYLON {
  116356. /** @hidden */
  116357. export var backgroundFragmentDeclaration: {
  116358. name: string;
  116359. shader: string;
  116360. };
  116361. }
  116362. declare module BABYLON {
  116363. /** @hidden */
  116364. export var backgroundUboDeclaration: {
  116365. name: string;
  116366. shader: string;
  116367. };
  116368. }
  116369. declare module BABYLON {
  116370. /** @hidden */
  116371. export var backgroundPixelShader: {
  116372. name: string;
  116373. shader: string;
  116374. };
  116375. }
  116376. declare module BABYLON {
  116377. /** @hidden */
  116378. export var backgroundVertexDeclaration: {
  116379. name: string;
  116380. shader: string;
  116381. };
  116382. }
  116383. declare module BABYLON {
  116384. /** @hidden */
  116385. export var backgroundVertexShader: {
  116386. name: string;
  116387. shader: string;
  116388. };
  116389. }
  116390. declare module BABYLON {
  116391. /**
  116392. * Background material used to create an efficient environement around your scene.
  116393. */
  116394. export class BackgroundMaterial extends PushMaterial {
  116395. /**
  116396. * Standard reflectance value at parallel view angle.
  116397. */
  116398. static StandardReflectance0: number;
  116399. /**
  116400. * Standard reflectance value at grazing angle.
  116401. */
  116402. static StandardReflectance90: number;
  116403. protected _primaryColor: Color3;
  116404. /**
  116405. * Key light Color (multiply against the environement texture)
  116406. */
  116407. primaryColor: Color3;
  116408. protected __perceptualColor: Nullable<Color3>;
  116409. /**
  116410. * Experimental Internal Use Only.
  116411. *
  116412. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  116413. * This acts as a helper to set the primary color to a more "human friendly" value.
  116414. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  116415. * output color as close as possible from the chosen value.
  116416. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  116417. * part of lighting setup.)
  116418. */
  116419. _perceptualColor: Nullable<Color3>;
  116420. protected _primaryColorShadowLevel: float;
  116421. /**
  116422. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  116423. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  116424. */
  116425. primaryColorShadowLevel: float;
  116426. protected _primaryColorHighlightLevel: float;
  116427. /**
  116428. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  116429. * The primary color is used at the level chosen to define what the white area would look.
  116430. */
  116431. primaryColorHighlightLevel: float;
  116432. protected _reflectionTexture: Nullable<BaseTexture>;
  116433. /**
  116434. * Reflection Texture used in the material.
  116435. * Should be author in a specific way for the best result (refer to the documentation).
  116436. */
  116437. reflectionTexture: Nullable<BaseTexture>;
  116438. protected _reflectionBlur: float;
  116439. /**
  116440. * Reflection Texture level of blur.
  116441. *
  116442. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  116443. * texture twice.
  116444. */
  116445. reflectionBlur: float;
  116446. protected _diffuseTexture: Nullable<BaseTexture>;
  116447. /**
  116448. * Diffuse Texture used in the material.
  116449. * Should be author in a specific way for the best result (refer to the documentation).
  116450. */
  116451. diffuseTexture: Nullable<BaseTexture>;
  116452. protected _shadowLights: Nullable<IShadowLight[]>;
  116453. /**
  116454. * Specify the list of lights casting shadow on the material.
  116455. * All scene shadow lights will be included if null.
  116456. */
  116457. shadowLights: Nullable<IShadowLight[]>;
  116458. protected _shadowLevel: float;
  116459. /**
  116460. * Helps adjusting the shadow to a softer level if required.
  116461. * 0 means black shadows and 1 means no shadows.
  116462. */
  116463. shadowLevel: float;
  116464. protected _sceneCenter: Vector3;
  116465. /**
  116466. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  116467. * It is usually zero but might be interesting to modify according to your setup.
  116468. */
  116469. sceneCenter: Vector3;
  116470. protected _opacityFresnel: boolean;
  116471. /**
  116472. * This helps specifying that the material is falling off to the sky box at grazing angle.
  116473. * This helps ensuring a nice transition when the camera goes under the ground.
  116474. */
  116475. opacityFresnel: boolean;
  116476. protected _reflectionFresnel: boolean;
  116477. /**
  116478. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  116479. * This helps adding a mirror texture on the ground.
  116480. */
  116481. reflectionFresnel: boolean;
  116482. protected _reflectionFalloffDistance: number;
  116483. /**
  116484. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  116485. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  116486. */
  116487. reflectionFalloffDistance: number;
  116488. protected _reflectionAmount: number;
  116489. /**
  116490. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  116491. */
  116492. reflectionAmount: number;
  116493. protected _reflectionReflectance0: number;
  116494. /**
  116495. * This specifies the weight of the reflection at grazing angle.
  116496. */
  116497. reflectionReflectance0: number;
  116498. protected _reflectionReflectance90: number;
  116499. /**
  116500. * This specifies the weight of the reflection at a perpendicular point of view.
  116501. */
  116502. reflectionReflectance90: number;
  116503. /**
  116504. * Sets the reflection reflectance fresnel values according to the default standard
  116505. * empirically know to work well :-)
  116506. */
  116507. reflectionStandardFresnelWeight: number;
  116508. protected _useRGBColor: boolean;
  116509. /**
  116510. * Helps to directly use the maps channels instead of their level.
  116511. */
  116512. useRGBColor: boolean;
  116513. protected _enableNoise: boolean;
  116514. /**
  116515. * This helps reducing the banding effect that could occur on the background.
  116516. */
  116517. enableNoise: boolean;
  116518. /**
  116519. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  116520. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  116521. * Recommended to be keep at 1.0 except for special cases.
  116522. */
  116523. fovMultiplier: number;
  116524. private _fovMultiplier;
  116525. /**
  116526. * Enable the FOV adjustment feature controlled by fovMultiplier.
  116527. */
  116528. useEquirectangularFOV: boolean;
  116529. private _maxSimultaneousLights;
  116530. /**
  116531. * Number of Simultaneous lights allowed on the material.
  116532. */
  116533. maxSimultaneousLights: int;
  116534. /**
  116535. * Default configuration related to image processing available in the Background Material.
  116536. */
  116537. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116538. /**
  116539. * Keep track of the image processing observer to allow dispose and replace.
  116540. */
  116541. private _imageProcessingObserver;
  116542. /**
  116543. * Attaches a new image processing configuration to the PBR Material.
  116544. * @param configuration (if null the scene configuration will be use)
  116545. */
  116546. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  116547. /**
  116548. * Gets the image processing configuration used either in this material.
  116549. */
  116550. /**
  116551. * Sets the Default image processing configuration used either in the this material.
  116552. *
  116553. * If sets to null, the scene one is in use.
  116554. */
  116555. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  116556. /**
  116557. * Gets wether the color curves effect is enabled.
  116558. */
  116559. /**
  116560. * Sets wether the color curves effect is enabled.
  116561. */
  116562. cameraColorCurvesEnabled: boolean;
  116563. /**
  116564. * Gets wether the color grading effect is enabled.
  116565. */
  116566. /**
  116567. * Gets wether the color grading effect is enabled.
  116568. */
  116569. cameraColorGradingEnabled: boolean;
  116570. /**
  116571. * Gets wether tonemapping is enabled or not.
  116572. */
  116573. /**
  116574. * Sets wether tonemapping is enabled or not
  116575. */
  116576. cameraToneMappingEnabled: boolean;
  116577. /**
  116578. * The camera exposure used on this material.
  116579. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116580. * This corresponds to a photographic exposure.
  116581. */
  116582. /**
  116583. * The camera exposure used on this material.
  116584. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116585. * This corresponds to a photographic exposure.
  116586. */
  116587. cameraExposure: float;
  116588. /**
  116589. * Gets The camera contrast used on this material.
  116590. */
  116591. /**
  116592. * Sets The camera contrast used on this material.
  116593. */
  116594. cameraContrast: float;
  116595. /**
  116596. * Gets the Color Grading 2D Lookup Texture.
  116597. */
  116598. /**
  116599. * Sets the Color Grading 2D Lookup Texture.
  116600. */
  116601. cameraColorGradingTexture: Nullable<BaseTexture>;
  116602. /**
  116603. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116604. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  116605. * 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;
  116606. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  116607. */
  116608. /**
  116609. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116610. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  116611. * 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;
  116612. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  116613. */
  116614. cameraColorCurves: Nullable<ColorCurves>;
  116615. /**
  116616. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  116617. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  116618. */
  116619. switchToBGR: boolean;
  116620. private _renderTargets;
  116621. private _reflectionControls;
  116622. private _white;
  116623. private _primaryShadowColor;
  116624. private _primaryHighlightColor;
  116625. /**
  116626. * Instantiates a Background Material in the given scene
  116627. * @param name The friendly name of the material
  116628. * @param scene The scene to add the material to
  116629. */
  116630. constructor(name: string, scene: Scene);
  116631. /**
  116632. * Gets a boolean indicating that current material needs to register RTT
  116633. */
  116634. readonly hasRenderTargetTextures: boolean;
  116635. /**
  116636. * The entire material has been created in order to prevent overdraw.
  116637. * @returns false
  116638. */
  116639. needAlphaTesting(): boolean;
  116640. /**
  116641. * The entire material has been created in order to prevent overdraw.
  116642. * @returns true if blending is enable
  116643. */
  116644. needAlphaBlending(): boolean;
  116645. /**
  116646. * Checks wether the material is ready to be rendered for a given mesh.
  116647. * @param mesh The mesh to render
  116648. * @param subMesh The submesh to check against
  116649. * @param useInstances Specify wether or not the material is used with instances
  116650. * @returns true if all the dependencies are ready (Textures, Effects...)
  116651. */
  116652. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  116653. /**
  116654. * Compute the primary color according to the chosen perceptual color.
  116655. */
  116656. private _computePrimaryColorFromPerceptualColor;
  116657. /**
  116658. * Compute the highlights and shadow colors according to their chosen levels.
  116659. */
  116660. private _computePrimaryColors;
  116661. /**
  116662. * Build the uniform buffer used in the material.
  116663. */
  116664. buildUniformLayout(): void;
  116665. /**
  116666. * Unbind the material.
  116667. */
  116668. unbind(): void;
  116669. /**
  116670. * Bind only the world matrix to the material.
  116671. * @param world The world matrix to bind.
  116672. */
  116673. bindOnlyWorldMatrix(world: Matrix): void;
  116674. /**
  116675. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  116676. * @param world The world matrix to bind.
  116677. * @param subMesh The submesh to bind for.
  116678. */
  116679. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  116680. /**
  116681. * Checks to see if a texture is used in the material.
  116682. * @param texture - Base texture to use.
  116683. * @returns - Boolean specifying if a texture is used in the material.
  116684. */
  116685. hasTexture(texture: BaseTexture): boolean;
  116686. /**
  116687. * Dispose the material.
  116688. * @param forceDisposeEffect Force disposal of the associated effect.
  116689. * @param forceDisposeTextures Force disposal of the associated textures.
  116690. */
  116691. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  116692. /**
  116693. * Clones the material.
  116694. * @param name The cloned name.
  116695. * @returns The cloned material.
  116696. */
  116697. clone(name: string): BackgroundMaterial;
  116698. /**
  116699. * Serializes the current material to its JSON representation.
  116700. * @returns The JSON representation.
  116701. */
  116702. serialize(): any;
  116703. /**
  116704. * Gets the class name of the material
  116705. * @returns "BackgroundMaterial"
  116706. */
  116707. getClassName(): string;
  116708. /**
  116709. * Parse a JSON input to create back a background material.
  116710. * @param source The JSON data to parse
  116711. * @param scene The scene to create the parsed material in
  116712. * @param rootUrl The root url of the assets the material depends upon
  116713. * @returns the instantiated BackgroundMaterial.
  116714. */
  116715. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  116716. }
  116717. }
  116718. declare module BABYLON {
  116719. /**
  116720. * Represents the different options available during the creation of
  116721. * a Environment helper.
  116722. *
  116723. * This can control the default ground, skybox and image processing setup of your scene.
  116724. */
  116725. export interface IEnvironmentHelperOptions {
  116726. /**
  116727. * Specifies wether or not to create a ground.
  116728. * True by default.
  116729. */
  116730. createGround: boolean;
  116731. /**
  116732. * Specifies the ground size.
  116733. * 15 by default.
  116734. */
  116735. groundSize: number;
  116736. /**
  116737. * The texture used on the ground for the main color.
  116738. * Comes from the BabylonJS CDN by default.
  116739. *
  116740. * Remarks: Can be either a texture or a url.
  116741. */
  116742. groundTexture: string | BaseTexture;
  116743. /**
  116744. * The color mixed in the ground texture by default.
  116745. * BabylonJS clearColor by default.
  116746. */
  116747. groundColor: Color3;
  116748. /**
  116749. * Specifies the ground opacity.
  116750. * 1 by default.
  116751. */
  116752. groundOpacity: number;
  116753. /**
  116754. * Enables the ground to receive shadows.
  116755. * True by default.
  116756. */
  116757. enableGroundShadow: boolean;
  116758. /**
  116759. * Helps preventing the shadow to be fully black on the ground.
  116760. * 0.5 by default.
  116761. */
  116762. groundShadowLevel: number;
  116763. /**
  116764. * Creates a mirror texture attach to the ground.
  116765. * false by default.
  116766. */
  116767. enableGroundMirror: boolean;
  116768. /**
  116769. * Specifies the ground mirror size ratio.
  116770. * 0.3 by default as the default kernel is 64.
  116771. */
  116772. groundMirrorSizeRatio: number;
  116773. /**
  116774. * Specifies the ground mirror blur kernel size.
  116775. * 64 by default.
  116776. */
  116777. groundMirrorBlurKernel: number;
  116778. /**
  116779. * Specifies the ground mirror visibility amount.
  116780. * 1 by default
  116781. */
  116782. groundMirrorAmount: number;
  116783. /**
  116784. * Specifies the ground mirror reflectance weight.
  116785. * This uses the standard weight of the background material to setup the fresnel effect
  116786. * of the mirror.
  116787. * 1 by default.
  116788. */
  116789. groundMirrorFresnelWeight: number;
  116790. /**
  116791. * Specifies the ground mirror Falloff distance.
  116792. * This can helps reducing the size of the reflection.
  116793. * 0 by Default.
  116794. */
  116795. groundMirrorFallOffDistance: number;
  116796. /**
  116797. * Specifies the ground mirror texture type.
  116798. * Unsigned Int by Default.
  116799. */
  116800. groundMirrorTextureType: number;
  116801. /**
  116802. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  116803. * the shown objects.
  116804. */
  116805. groundYBias: number;
  116806. /**
  116807. * Specifies wether or not to create a skybox.
  116808. * True by default.
  116809. */
  116810. createSkybox: boolean;
  116811. /**
  116812. * Specifies the skybox size.
  116813. * 20 by default.
  116814. */
  116815. skyboxSize: number;
  116816. /**
  116817. * The texture used on the skybox for the main color.
  116818. * Comes from the BabylonJS CDN by default.
  116819. *
  116820. * Remarks: Can be either a texture or a url.
  116821. */
  116822. skyboxTexture: string | BaseTexture;
  116823. /**
  116824. * The color mixed in the skybox texture by default.
  116825. * BabylonJS clearColor by default.
  116826. */
  116827. skyboxColor: Color3;
  116828. /**
  116829. * The background rotation around the Y axis of the scene.
  116830. * This helps aligning the key lights of your scene with the background.
  116831. * 0 by default.
  116832. */
  116833. backgroundYRotation: number;
  116834. /**
  116835. * Compute automatically the size of the elements to best fit with the scene.
  116836. */
  116837. sizeAuto: boolean;
  116838. /**
  116839. * Default position of the rootMesh if autoSize is not true.
  116840. */
  116841. rootPosition: Vector3;
  116842. /**
  116843. * Sets up the image processing in the scene.
  116844. * true by default.
  116845. */
  116846. setupImageProcessing: boolean;
  116847. /**
  116848. * The texture used as your environment texture in the scene.
  116849. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  116850. *
  116851. * Remarks: Can be either a texture or a url.
  116852. */
  116853. environmentTexture: string | BaseTexture;
  116854. /**
  116855. * The value of the exposure to apply to the scene.
  116856. * 0.6 by default if setupImageProcessing is true.
  116857. */
  116858. cameraExposure: number;
  116859. /**
  116860. * The value of the contrast to apply to the scene.
  116861. * 1.6 by default if setupImageProcessing is true.
  116862. */
  116863. cameraContrast: number;
  116864. /**
  116865. * Specifies wether or not tonemapping should be enabled in the scene.
  116866. * true by default if setupImageProcessing is true.
  116867. */
  116868. toneMappingEnabled: boolean;
  116869. }
  116870. /**
  116871. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  116872. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  116873. * It also helps with the default setup of your imageProcessing configuration.
  116874. */
  116875. export class EnvironmentHelper {
  116876. /**
  116877. * Default ground texture URL.
  116878. */
  116879. private static _groundTextureCDNUrl;
  116880. /**
  116881. * Default skybox texture URL.
  116882. */
  116883. private static _skyboxTextureCDNUrl;
  116884. /**
  116885. * Default environment texture URL.
  116886. */
  116887. private static _environmentTextureCDNUrl;
  116888. /**
  116889. * Creates the default options for the helper.
  116890. */
  116891. private static _getDefaultOptions;
  116892. private _rootMesh;
  116893. /**
  116894. * Gets the root mesh created by the helper.
  116895. */
  116896. readonly rootMesh: Mesh;
  116897. private _skybox;
  116898. /**
  116899. * Gets the skybox created by the helper.
  116900. */
  116901. readonly skybox: Nullable<Mesh>;
  116902. private _skyboxTexture;
  116903. /**
  116904. * Gets the skybox texture created by the helper.
  116905. */
  116906. readonly skyboxTexture: Nullable<BaseTexture>;
  116907. private _skyboxMaterial;
  116908. /**
  116909. * Gets the skybox material created by the helper.
  116910. */
  116911. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  116912. private _ground;
  116913. /**
  116914. * Gets the ground mesh created by the helper.
  116915. */
  116916. readonly ground: Nullable<Mesh>;
  116917. private _groundTexture;
  116918. /**
  116919. * Gets the ground texture created by the helper.
  116920. */
  116921. readonly groundTexture: Nullable<BaseTexture>;
  116922. private _groundMirror;
  116923. /**
  116924. * Gets the ground mirror created by the helper.
  116925. */
  116926. readonly groundMirror: Nullable<MirrorTexture>;
  116927. /**
  116928. * Gets the ground mirror render list to helps pushing the meshes
  116929. * you wish in the ground reflection.
  116930. */
  116931. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  116932. private _groundMaterial;
  116933. /**
  116934. * Gets the ground material created by the helper.
  116935. */
  116936. readonly groundMaterial: Nullable<BackgroundMaterial>;
  116937. /**
  116938. * Stores the creation options.
  116939. */
  116940. private readonly _scene;
  116941. private _options;
  116942. /**
  116943. * This observable will be notified with any error during the creation of the environment,
  116944. * mainly texture creation errors.
  116945. */
  116946. onErrorObservable: Observable<{
  116947. message?: string;
  116948. exception?: any;
  116949. }>;
  116950. /**
  116951. * constructor
  116952. * @param options Defines the options we want to customize the helper
  116953. * @param scene The scene to add the material to
  116954. */
  116955. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  116956. /**
  116957. * Updates the background according to the new options
  116958. * @param options
  116959. */
  116960. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  116961. /**
  116962. * Sets the primary color of all the available elements.
  116963. * @param color the main color to affect to the ground and the background
  116964. */
  116965. setMainColor(color: Color3): void;
  116966. /**
  116967. * Setup the image processing according to the specified options.
  116968. */
  116969. private _setupImageProcessing;
  116970. /**
  116971. * Setup the environment texture according to the specified options.
  116972. */
  116973. private _setupEnvironmentTexture;
  116974. /**
  116975. * Setup the background according to the specified options.
  116976. */
  116977. private _setupBackground;
  116978. /**
  116979. * Get the scene sizes according to the setup.
  116980. */
  116981. private _getSceneSize;
  116982. /**
  116983. * Setup the ground according to the specified options.
  116984. */
  116985. private _setupGround;
  116986. /**
  116987. * Setup the ground material according to the specified options.
  116988. */
  116989. private _setupGroundMaterial;
  116990. /**
  116991. * Setup the ground diffuse texture according to the specified options.
  116992. */
  116993. private _setupGroundDiffuseTexture;
  116994. /**
  116995. * Setup the ground mirror texture according to the specified options.
  116996. */
  116997. private _setupGroundMirrorTexture;
  116998. /**
  116999. * Setup the ground to receive the mirror texture.
  117000. */
  117001. private _setupMirrorInGroundMaterial;
  117002. /**
  117003. * Setup the skybox according to the specified options.
  117004. */
  117005. private _setupSkybox;
  117006. /**
  117007. * Setup the skybox material according to the specified options.
  117008. */
  117009. private _setupSkyboxMaterial;
  117010. /**
  117011. * Setup the skybox reflection texture according to the specified options.
  117012. */
  117013. private _setupSkyboxReflectionTexture;
  117014. private _errorHandler;
  117015. /**
  117016. * Dispose all the elements created by the Helper.
  117017. */
  117018. dispose(): void;
  117019. }
  117020. }
  117021. declare module BABYLON {
  117022. /**
  117023. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  117024. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  117025. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  117026. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  117027. */
  117028. export class PhotoDome extends TransformNode {
  117029. /**
  117030. * Define the image as a Monoscopic panoramic 360 image.
  117031. */
  117032. static readonly MODE_MONOSCOPIC: number;
  117033. /**
  117034. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  117035. */
  117036. static readonly MODE_TOPBOTTOM: number;
  117037. /**
  117038. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  117039. */
  117040. static readonly MODE_SIDEBYSIDE: number;
  117041. private _useDirectMapping;
  117042. /**
  117043. * The texture being displayed on the sphere
  117044. */
  117045. protected _photoTexture: Texture;
  117046. /**
  117047. * Gets or sets the texture being displayed on the sphere
  117048. */
  117049. photoTexture: Texture;
  117050. /**
  117051. * Observable raised when an error occured while loading the 360 image
  117052. */
  117053. onLoadErrorObservable: Observable<string>;
  117054. /**
  117055. * The skybox material
  117056. */
  117057. protected _material: BackgroundMaterial;
  117058. /**
  117059. * The surface used for the skybox
  117060. */
  117061. protected _mesh: Mesh;
  117062. /**
  117063. * Gets the mesh used for the skybox.
  117064. */
  117065. readonly mesh: Mesh;
  117066. /**
  117067. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  117068. * Also see the options.resolution property.
  117069. */
  117070. fovMultiplier: number;
  117071. private _imageMode;
  117072. /**
  117073. * Gets or set the current video mode for the video. It can be:
  117074. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  117075. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  117076. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  117077. */
  117078. imageMode: number;
  117079. /**
  117080. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  117081. * @param name Element's name, child elements will append suffixes for their own names.
  117082. * @param urlsOfPhoto defines the url of the photo to display
  117083. * @param options defines an object containing optional or exposed sub element properties
  117084. * @param onError defines a callback called when an error occured while loading the texture
  117085. */
  117086. constructor(name: string, urlOfPhoto: string, options: {
  117087. resolution?: number;
  117088. size?: number;
  117089. useDirectMapping?: boolean;
  117090. faceForward?: boolean;
  117091. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  117092. private _onBeforeCameraRenderObserver;
  117093. private _changeImageMode;
  117094. /**
  117095. * Releases resources associated with this node.
  117096. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117097. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117098. */
  117099. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117100. }
  117101. }
  117102. declare module BABYLON {
  117103. /**
  117104. * Class used to host RGBD texture specific utilities
  117105. */
  117106. export class RGBDTextureTools {
  117107. /**
  117108. * Expand the RGBD Texture from RGBD to Half Float if possible.
  117109. * @param texture the texture to expand.
  117110. */
  117111. static ExpandRGBDTexture(texture: Texture): void;
  117112. }
  117113. }
  117114. declare module BABYLON {
  117115. /**
  117116. * Class used to host texture specific utilities
  117117. */
  117118. export class BRDFTextureTools {
  117119. /**
  117120. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  117121. * @param scene defines the hosting scene
  117122. * @returns the environment BRDF texture
  117123. */
  117124. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  117125. private static _environmentBRDFBase64Texture;
  117126. }
  117127. }
  117128. declare module BABYLON {
  117129. /**
  117130. * @hidden
  117131. */
  117132. export interface IMaterialClearCoatDefines {
  117133. CLEARCOAT: boolean;
  117134. CLEARCOAT_DEFAULTIOR: boolean;
  117135. CLEARCOAT_TEXTURE: boolean;
  117136. CLEARCOAT_TEXTUREDIRECTUV: number;
  117137. CLEARCOAT_BUMP: boolean;
  117138. CLEARCOAT_BUMPDIRECTUV: number;
  117139. CLEARCOAT_TINT: boolean;
  117140. CLEARCOAT_TINT_TEXTURE: boolean;
  117141. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  117142. /** @hidden */
  117143. _areTexturesDirty: boolean;
  117144. }
  117145. /**
  117146. * Define the code related to the clear coat parameters of the pbr material.
  117147. */
  117148. export class PBRClearCoatConfiguration {
  117149. /**
  117150. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  117151. * The default fits with a polyurethane material.
  117152. */
  117153. private static readonly _DefaultIndexOfRefraction;
  117154. private _isEnabled;
  117155. /**
  117156. * Defines if the clear coat is enabled in the material.
  117157. */
  117158. isEnabled: boolean;
  117159. /**
  117160. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  117161. */
  117162. intensity: number;
  117163. /**
  117164. * Defines the clear coat layer roughness.
  117165. */
  117166. roughness: number;
  117167. private _indexOfRefraction;
  117168. /**
  117169. * Defines the index of refraction of the clear coat.
  117170. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  117171. * The default fits with a polyurethane material.
  117172. * Changing the default value is more performance intensive.
  117173. */
  117174. indexOfRefraction: number;
  117175. private _texture;
  117176. /**
  117177. * Stores the clear coat values in a texture.
  117178. */
  117179. texture: Nullable<BaseTexture>;
  117180. private _bumpTexture;
  117181. /**
  117182. * Define the clear coat specific bump texture.
  117183. */
  117184. bumpTexture: Nullable<BaseTexture>;
  117185. private _isTintEnabled;
  117186. /**
  117187. * Defines if the clear coat tint is enabled in the material.
  117188. */
  117189. isTintEnabled: boolean;
  117190. /**
  117191. * Defines the clear coat tint of the material.
  117192. * This is only use if tint is enabled
  117193. */
  117194. tintColor: Color3;
  117195. /**
  117196. * Defines the distance at which the tint color should be found in the
  117197. * clear coat media.
  117198. * This is only use if tint is enabled
  117199. */
  117200. tintColorAtDistance: number;
  117201. /**
  117202. * Defines the clear coat layer thickness.
  117203. * This is only use if tint is enabled
  117204. */
  117205. tintThickness: number;
  117206. private _tintTexture;
  117207. /**
  117208. * Stores the clear tint values in a texture.
  117209. * rgb is tint
  117210. * a is a thickness factor
  117211. */
  117212. tintTexture: Nullable<BaseTexture>;
  117213. /** @hidden */
  117214. private _internalMarkAllSubMeshesAsTexturesDirty;
  117215. /** @hidden */
  117216. _markAllSubMeshesAsTexturesDirty(): void;
  117217. /**
  117218. * Instantiate a new istance of clear coat configuration.
  117219. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  117220. */
  117221. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  117222. /**
  117223. * Gets wehter the submesh is ready to be used or not.
  117224. * @param defines the list of "defines" to update.
  117225. * @param scene defines the scene the material belongs to.
  117226. * @param engine defines the engine the material belongs to.
  117227. * @param disableBumpMap defines wether the material disables bump or not.
  117228. * @returns - boolean indicating that the submesh is ready or not.
  117229. */
  117230. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  117231. /**
  117232. * Checks to see if a texture is used in the material.
  117233. * @param defines the list of "defines" to update.
  117234. * @param scene defines the scene to the material belongs to.
  117235. */
  117236. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  117237. /**
  117238. * Binds the material data.
  117239. * @param uniformBuffer defines the Uniform buffer to fill in.
  117240. * @param scene defines the scene the material belongs to.
  117241. * @param engine defines the engine the material belongs to.
  117242. * @param disableBumpMap defines wether the material disables bump or not.
  117243. * @param isFrozen defines wether the material is frozen or not.
  117244. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  117245. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  117246. */
  117247. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  117248. /**
  117249. * Checks to see if a texture is used in the material.
  117250. * @param texture - Base texture to use.
  117251. * @returns - Boolean specifying if a texture is used in the material.
  117252. */
  117253. hasTexture(texture: BaseTexture): boolean;
  117254. /**
  117255. * Returns an array of the actively used textures.
  117256. * @param activeTextures Array of BaseTextures
  117257. */
  117258. getActiveTextures(activeTextures: BaseTexture[]): void;
  117259. /**
  117260. * Returns the animatable textures.
  117261. * @param animatables Array of animatable textures.
  117262. */
  117263. getAnimatables(animatables: IAnimatable[]): void;
  117264. /**
  117265. * Disposes the resources of the material.
  117266. * @param forceDisposeTextures - Forces the disposal of all textures.
  117267. */
  117268. dispose(forceDisposeTextures?: boolean): void;
  117269. /**
  117270. * Get the current class name of the texture useful for serialization or dynamic coding.
  117271. * @returns "PBRClearCoatConfiguration"
  117272. */
  117273. getClassName(): string;
  117274. /**
  117275. * Add fallbacks to the effect fallbacks list.
  117276. * @param defines defines the Base texture to use.
  117277. * @param fallbacks defines the current fallback list.
  117278. * @param currentRank defines the current fallback rank.
  117279. * @returns the new fallback rank.
  117280. */
  117281. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  117282. /**
  117283. * Add the required uniforms to the current list.
  117284. * @param uniforms defines the current uniform list.
  117285. */
  117286. static AddUniforms(uniforms: string[]): void;
  117287. /**
  117288. * Add the required samplers to the current list.
  117289. * @param samplers defines the current sampler list.
  117290. */
  117291. static AddSamplers(samplers: string[]): void;
  117292. /**
  117293. * Add the required uniforms to the current buffer.
  117294. * @param uniformBuffer defines the current uniform buffer.
  117295. */
  117296. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  117297. /**
  117298. * Makes a duplicate of the current configuration into another one.
  117299. * @param clearCoatConfiguration define the config where to copy the info
  117300. */
  117301. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  117302. /**
  117303. * Serializes this clear coat configuration.
  117304. * @returns - An object with the serialized config.
  117305. */
  117306. serialize(): any;
  117307. /**
  117308. * Parses a anisotropy Configuration from a serialized object.
  117309. * @param source - Serialized object.
  117310. * @param scene Defines the scene we are parsing for
  117311. * @param rootUrl Defines the rootUrl to load from
  117312. */
  117313. parse(source: any, scene: Scene, rootUrl: string): void;
  117314. }
  117315. }
  117316. declare module BABYLON {
  117317. /**
  117318. * @hidden
  117319. */
  117320. export interface IMaterialAnisotropicDefines {
  117321. ANISOTROPIC: boolean;
  117322. ANISOTROPIC_TEXTURE: boolean;
  117323. ANISOTROPIC_TEXTUREDIRECTUV: number;
  117324. MAINUV1: boolean;
  117325. _areTexturesDirty: boolean;
  117326. _needUVs: boolean;
  117327. }
  117328. /**
  117329. * Define the code related to the anisotropic parameters of the pbr material.
  117330. */
  117331. export class PBRAnisotropicConfiguration {
  117332. private _isEnabled;
  117333. /**
  117334. * Defines if the anisotropy is enabled in the material.
  117335. */
  117336. isEnabled: boolean;
  117337. /**
  117338. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  117339. */
  117340. intensity: number;
  117341. /**
  117342. * Defines if the effect is along the tangents, bitangents or in between.
  117343. * By default, the effect is "strectching" the highlights along the tangents.
  117344. */
  117345. direction: Vector2;
  117346. private _texture;
  117347. /**
  117348. * Stores the anisotropy values in a texture.
  117349. * rg is direction (like normal from -1 to 1)
  117350. * b is a intensity
  117351. */
  117352. texture: Nullable<BaseTexture>;
  117353. /** @hidden */
  117354. private _internalMarkAllSubMeshesAsTexturesDirty;
  117355. /** @hidden */
  117356. _markAllSubMeshesAsTexturesDirty(): void;
  117357. /**
  117358. * Instantiate a new istance of anisotropy configuration.
  117359. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  117360. */
  117361. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  117362. /**
  117363. * Specifies that the submesh is ready to be used.
  117364. * @param defines the list of "defines" to update.
  117365. * @param scene defines the scene the material belongs to.
  117366. * @returns - boolean indicating that the submesh is ready or not.
  117367. */
  117368. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  117369. /**
  117370. * Checks to see if a texture is used in the material.
  117371. * @param defines the list of "defines" to update.
  117372. * @param mesh the mesh we are preparing the defines for.
  117373. * @param scene defines the scene the material belongs to.
  117374. */
  117375. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  117376. /**
  117377. * Binds the material data.
  117378. * @param uniformBuffer defines the Uniform buffer to fill in.
  117379. * @param scene defines the scene the material belongs to.
  117380. * @param isFrozen defines wether the material is frozen or not.
  117381. */
  117382. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  117383. /**
  117384. * Checks to see if a texture is used in the material.
  117385. * @param texture - Base texture to use.
  117386. * @returns - Boolean specifying if a texture is used in the material.
  117387. */
  117388. hasTexture(texture: BaseTexture): boolean;
  117389. /**
  117390. * Returns an array of the actively used textures.
  117391. * @param activeTextures Array of BaseTextures
  117392. */
  117393. getActiveTextures(activeTextures: BaseTexture[]): void;
  117394. /**
  117395. * Returns the animatable textures.
  117396. * @param animatables Array of animatable textures.
  117397. */
  117398. getAnimatables(animatables: IAnimatable[]): void;
  117399. /**
  117400. * Disposes the resources of the material.
  117401. * @param forceDisposeTextures - Forces the disposal of all textures.
  117402. */
  117403. dispose(forceDisposeTextures?: boolean): void;
  117404. /**
  117405. * Get the current class name of the texture useful for serialization or dynamic coding.
  117406. * @returns "PBRAnisotropicConfiguration"
  117407. */
  117408. getClassName(): string;
  117409. /**
  117410. * Add fallbacks to the effect fallbacks list.
  117411. * @param defines defines the Base texture to use.
  117412. * @param fallbacks defines the current fallback list.
  117413. * @param currentRank defines the current fallback rank.
  117414. * @returns the new fallback rank.
  117415. */
  117416. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  117417. /**
  117418. * Add the required uniforms to the current list.
  117419. * @param uniforms defines the current uniform list.
  117420. */
  117421. static AddUniforms(uniforms: string[]): void;
  117422. /**
  117423. * Add the required uniforms to the current buffer.
  117424. * @param uniformBuffer defines the current uniform buffer.
  117425. */
  117426. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  117427. /**
  117428. * Add the required samplers to the current list.
  117429. * @param samplers defines the current sampler list.
  117430. */
  117431. static AddSamplers(samplers: string[]): void;
  117432. /**
  117433. * Makes a duplicate of the current configuration into another one.
  117434. * @param anisotropicConfiguration define the config where to copy the info
  117435. */
  117436. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  117437. /**
  117438. * Serializes this anisotropy configuration.
  117439. * @returns - An object with the serialized config.
  117440. */
  117441. serialize(): any;
  117442. /**
  117443. * Parses a anisotropy Configuration from a serialized object.
  117444. * @param source - Serialized object.
  117445. * @param scene Defines the scene we are parsing for
  117446. * @param rootUrl Defines the rootUrl to load from
  117447. */
  117448. parse(source: any, scene: Scene, rootUrl: string): void;
  117449. }
  117450. }
  117451. declare module BABYLON {
  117452. /**
  117453. * @hidden
  117454. */
  117455. export interface IMaterialBRDFDefines {
  117456. BRDF_V_HEIGHT_CORRELATED: boolean;
  117457. MS_BRDF_ENERGY_CONSERVATION: boolean;
  117458. SPHERICAL_HARMONICS: boolean;
  117459. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  117460. /** @hidden */
  117461. _areMiscDirty: boolean;
  117462. }
  117463. /**
  117464. * Define the code related to the BRDF parameters of the pbr material.
  117465. */
  117466. export class PBRBRDFConfiguration {
  117467. /**
  117468. * Default value used for the energy conservation.
  117469. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  117470. */
  117471. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  117472. /**
  117473. * Default value used for the Smith Visibility Height Correlated mode.
  117474. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  117475. */
  117476. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  117477. /**
  117478. * Default value used for the IBL diffuse part.
  117479. * This can help switching back to the polynomials mode globally which is a tiny bit
  117480. * less GPU intensive at the drawback of a lower quality.
  117481. */
  117482. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  117483. /**
  117484. * Default value used for activating energy conservation for the specular workflow.
  117485. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  117486. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  117487. */
  117488. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  117489. private _useEnergyConservation;
  117490. /**
  117491. * Defines if the material uses energy conservation.
  117492. */
  117493. useEnergyConservation: boolean;
  117494. private _useSmithVisibilityHeightCorrelated;
  117495. /**
  117496. * LEGACY Mode set to false
  117497. * Defines if the material uses height smith correlated visibility term.
  117498. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  117499. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  117500. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  117501. * Not relying on height correlated will also disable energy conservation.
  117502. */
  117503. useSmithVisibilityHeightCorrelated: boolean;
  117504. private _useSphericalHarmonics;
  117505. /**
  117506. * LEGACY Mode set to false
  117507. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  117508. * diffuse part of the IBL.
  117509. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  117510. * to the ground truth.
  117511. */
  117512. useSphericalHarmonics: boolean;
  117513. private _useSpecularGlossinessInputEnergyConservation;
  117514. /**
  117515. * Defines if the material uses energy conservation, when the specular workflow is active.
  117516. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  117517. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  117518. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  117519. */
  117520. useSpecularGlossinessInputEnergyConservation: boolean;
  117521. /** @hidden */
  117522. private _internalMarkAllSubMeshesAsMiscDirty;
  117523. /** @hidden */
  117524. _markAllSubMeshesAsMiscDirty(): void;
  117525. /**
  117526. * Instantiate a new istance of clear coat configuration.
  117527. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  117528. */
  117529. constructor(markAllSubMeshesAsMiscDirty: () => void);
  117530. /**
  117531. * Checks to see if a texture is used in the material.
  117532. * @param defines the list of "defines" to update.
  117533. */
  117534. prepareDefines(defines: IMaterialBRDFDefines): void;
  117535. /**
  117536. * Get the current class name of the texture useful for serialization or dynamic coding.
  117537. * @returns "PBRClearCoatConfiguration"
  117538. */
  117539. getClassName(): string;
  117540. /**
  117541. * Makes a duplicate of the current configuration into another one.
  117542. * @param brdfConfiguration define the config where to copy the info
  117543. */
  117544. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  117545. /**
  117546. * Serializes this BRDF configuration.
  117547. * @returns - An object with the serialized config.
  117548. */
  117549. serialize(): any;
  117550. /**
  117551. * Parses a anisotropy Configuration from a serialized object.
  117552. * @param source - Serialized object.
  117553. * @param scene Defines the scene we are parsing for
  117554. * @param rootUrl Defines the rootUrl to load from
  117555. */
  117556. parse(source: any, scene: Scene, rootUrl: string): void;
  117557. }
  117558. }
  117559. declare module BABYLON {
  117560. /**
  117561. * @hidden
  117562. */
  117563. export interface IMaterialSheenDefines {
  117564. SHEEN: boolean;
  117565. SHEEN_TEXTURE: boolean;
  117566. SHEEN_TEXTUREDIRECTUV: number;
  117567. SHEEN_LINKWITHALBEDO: boolean;
  117568. /** @hidden */
  117569. _areTexturesDirty: boolean;
  117570. }
  117571. /**
  117572. * Define the code related to the Sheen parameters of the pbr material.
  117573. */
  117574. export class PBRSheenConfiguration {
  117575. private _isEnabled;
  117576. /**
  117577. * Defines if the material uses sheen.
  117578. */
  117579. isEnabled: boolean;
  117580. private _linkSheenWithAlbedo;
  117581. /**
  117582. * Defines if the sheen is linked to the sheen color.
  117583. */
  117584. linkSheenWithAlbedo: boolean;
  117585. /**
  117586. * Defines the sheen intensity.
  117587. */
  117588. intensity: number;
  117589. /**
  117590. * Defines the sheen color.
  117591. */
  117592. color: Color3;
  117593. private _texture;
  117594. /**
  117595. * Stores the sheen tint values in a texture.
  117596. * rgb is tint
  117597. * a is a intensity
  117598. */
  117599. texture: Nullable<BaseTexture>;
  117600. /** @hidden */
  117601. private _internalMarkAllSubMeshesAsTexturesDirty;
  117602. /** @hidden */
  117603. _markAllSubMeshesAsTexturesDirty(): void;
  117604. /**
  117605. * Instantiate a new istance of clear coat configuration.
  117606. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  117607. */
  117608. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  117609. /**
  117610. * Specifies that the submesh is ready to be used.
  117611. * @param defines the list of "defines" to update.
  117612. * @param scene defines the scene the material belongs to.
  117613. * @returns - boolean indicating that the submesh is ready or not.
  117614. */
  117615. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  117616. /**
  117617. * Checks to see if a texture is used in the material.
  117618. * @param defines the list of "defines" to update.
  117619. * @param scene defines the scene the material belongs to.
  117620. */
  117621. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  117622. /**
  117623. * Binds the material data.
  117624. * @param uniformBuffer defines the Uniform buffer to fill in.
  117625. * @param scene defines the scene the material belongs to.
  117626. * @param isFrozen defines wether the material is frozen or not.
  117627. */
  117628. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  117629. /**
  117630. * Checks to see if a texture is used in the material.
  117631. * @param texture - Base texture to use.
  117632. * @returns - Boolean specifying if a texture is used in the material.
  117633. */
  117634. hasTexture(texture: BaseTexture): boolean;
  117635. /**
  117636. * Returns an array of the actively used textures.
  117637. * @param activeTextures Array of BaseTextures
  117638. */
  117639. getActiveTextures(activeTextures: BaseTexture[]): void;
  117640. /**
  117641. * Returns the animatable textures.
  117642. * @param animatables Array of animatable textures.
  117643. */
  117644. getAnimatables(animatables: IAnimatable[]): void;
  117645. /**
  117646. * Disposes the resources of the material.
  117647. * @param forceDisposeTextures - Forces the disposal of all textures.
  117648. */
  117649. dispose(forceDisposeTextures?: boolean): void;
  117650. /**
  117651. * Get the current class name of the texture useful for serialization or dynamic coding.
  117652. * @returns "PBRSheenConfiguration"
  117653. */
  117654. getClassName(): string;
  117655. /**
  117656. * Add fallbacks to the effect fallbacks list.
  117657. * @param defines defines the Base texture to use.
  117658. * @param fallbacks defines the current fallback list.
  117659. * @param currentRank defines the current fallback rank.
  117660. * @returns the new fallback rank.
  117661. */
  117662. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  117663. /**
  117664. * Add the required uniforms to the current list.
  117665. * @param uniforms defines the current uniform list.
  117666. */
  117667. static AddUniforms(uniforms: string[]): void;
  117668. /**
  117669. * Add the required uniforms to the current buffer.
  117670. * @param uniformBuffer defines the current uniform buffer.
  117671. */
  117672. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  117673. /**
  117674. * Add the required samplers to the current list.
  117675. * @param samplers defines the current sampler list.
  117676. */
  117677. static AddSamplers(samplers: string[]): void;
  117678. /**
  117679. * Makes a duplicate of the current configuration into another one.
  117680. * @param sheenConfiguration define the config where to copy the info
  117681. */
  117682. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  117683. /**
  117684. * Serializes this BRDF configuration.
  117685. * @returns - An object with the serialized config.
  117686. */
  117687. serialize(): any;
  117688. /**
  117689. * Parses a anisotropy Configuration from a serialized object.
  117690. * @param source - Serialized object.
  117691. * @param scene Defines the scene we are parsing for
  117692. * @param rootUrl Defines the rootUrl to load from
  117693. */
  117694. parse(source: any, scene: Scene, rootUrl: string): void;
  117695. }
  117696. }
  117697. declare module BABYLON {
  117698. /**
  117699. * @hidden
  117700. */
  117701. export interface IMaterialSubSurfaceDefines {
  117702. SUBSURFACE: boolean;
  117703. SS_REFRACTION: boolean;
  117704. SS_TRANSLUCENCY: boolean;
  117705. SS_SCATERRING: boolean;
  117706. SS_THICKNESSANDMASK_TEXTURE: boolean;
  117707. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  117708. SS_REFRACTIONMAP_3D: boolean;
  117709. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  117710. SS_LODINREFRACTIONALPHA: boolean;
  117711. SS_GAMMAREFRACTION: boolean;
  117712. SS_RGBDREFRACTION: boolean;
  117713. SS_LINEARSPECULARREFRACTION: boolean;
  117714. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  117715. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  117716. /** @hidden */
  117717. _areTexturesDirty: boolean;
  117718. }
  117719. /**
  117720. * Define the code related to the sub surface parameters of the pbr material.
  117721. */
  117722. export class PBRSubSurfaceConfiguration {
  117723. private _isRefractionEnabled;
  117724. /**
  117725. * Defines if the refraction is enabled in the material.
  117726. */
  117727. isRefractionEnabled: boolean;
  117728. private _isTranslucencyEnabled;
  117729. /**
  117730. * Defines if the translucency is enabled in the material.
  117731. */
  117732. isTranslucencyEnabled: boolean;
  117733. private _isScatteringEnabled;
  117734. /**
  117735. * Defines the refraction intensity of the material.
  117736. * The refraction when enabled replaces the Diffuse part of the material.
  117737. * The intensity helps transitionning between diffuse and refraction.
  117738. */
  117739. refractionIntensity: number;
  117740. /**
  117741. * Defines the translucency intensity of the material.
  117742. * When translucency has been enabled, this defines how much of the "translucency"
  117743. * is addded to the diffuse part of the material.
  117744. */
  117745. translucencyIntensity: number;
  117746. /**
  117747. * Defines the scattering intensity of the material.
  117748. * When scattering has been enabled, this defines how much of the "scattered light"
  117749. * is addded to the diffuse part of the material.
  117750. */
  117751. scatteringIntensity: number;
  117752. private _thicknessTexture;
  117753. /**
  117754. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  117755. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  117756. * 0 would mean minimumThickness
  117757. * 1 would mean maximumThickness
  117758. * The other channels might be use as a mask to vary the different effects intensity.
  117759. */
  117760. thicknessTexture: Nullable<BaseTexture>;
  117761. private _refractionTexture;
  117762. /**
  117763. * Defines the texture to use for refraction.
  117764. */
  117765. refractionTexture: Nullable<BaseTexture>;
  117766. private _indexOfRefraction;
  117767. /**
  117768. * Defines the index of refraction used in the material.
  117769. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  117770. */
  117771. indexOfRefraction: number;
  117772. private _invertRefractionY;
  117773. /**
  117774. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  117775. */
  117776. invertRefractionY: boolean;
  117777. private _linkRefractionWithTransparency;
  117778. /**
  117779. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  117780. * Materials half opaque for instance using refraction could benefit from this control.
  117781. */
  117782. linkRefractionWithTransparency: boolean;
  117783. /**
  117784. * Defines the minimum thickness stored in the thickness map.
  117785. * If no thickness map is defined, this value will be used to simulate thickness.
  117786. */
  117787. minimumThickness: number;
  117788. /**
  117789. * Defines the maximum thickness stored in the thickness map.
  117790. */
  117791. maximumThickness: number;
  117792. /**
  117793. * Defines the volume tint of the material.
  117794. * This is used for both translucency and scattering.
  117795. */
  117796. tintColor: Color3;
  117797. /**
  117798. * Defines the distance at which the tint color should be found in the media.
  117799. * This is used for refraction only.
  117800. */
  117801. tintColorAtDistance: number;
  117802. /**
  117803. * Defines how far each channel transmit through the media.
  117804. * It is defined as a color to simplify it selection.
  117805. */
  117806. diffusionDistance: Color3;
  117807. private _useMaskFromThicknessTexture;
  117808. /**
  117809. * Stores the intensity of the different subsurface effects in the thickness texture.
  117810. * * the green channel is the translucency intensity.
  117811. * * the blue channel is the scattering intensity.
  117812. * * the alpha channel is the refraction intensity.
  117813. */
  117814. useMaskFromThicknessTexture: boolean;
  117815. /** @hidden */
  117816. private _internalMarkAllSubMeshesAsTexturesDirty;
  117817. /** @hidden */
  117818. _markAllSubMeshesAsTexturesDirty(): void;
  117819. /**
  117820. * Instantiate a new istance of sub surface configuration.
  117821. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  117822. */
  117823. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  117824. /**
  117825. * Gets wehter the submesh is ready to be used or not.
  117826. * @param defines the list of "defines" to update.
  117827. * @param scene defines the scene the material belongs to.
  117828. * @returns - boolean indicating that the submesh is ready or not.
  117829. */
  117830. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  117831. /**
  117832. * Checks to see if a texture is used in the material.
  117833. * @param defines the list of "defines" to update.
  117834. * @param scene defines the scene to the material belongs to.
  117835. */
  117836. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  117837. /**
  117838. * Binds the material data.
  117839. * @param uniformBuffer defines the Uniform buffer to fill in.
  117840. * @param scene defines the scene the material belongs to.
  117841. * @param engine defines the engine the material belongs to.
  117842. * @param isFrozen defines wether the material is frozen or not.
  117843. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  117844. */
  117845. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  117846. /**
  117847. * Unbinds the material from the mesh.
  117848. * @param activeEffect defines the effect that should be unbound from.
  117849. * @returns true if unbound, otherwise false
  117850. */
  117851. unbind(activeEffect: Effect): boolean;
  117852. /**
  117853. * Returns the texture used for refraction or null if none is used.
  117854. * @param scene defines the scene the material belongs to.
  117855. * @returns - Refraction texture if present. If no refraction texture and refraction
  117856. * is linked with transparency, returns environment texture. Otherwise, returns null.
  117857. */
  117858. private _getRefractionTexture;
  117859. /**
  117860. * Returns true if alpha blending should be disabled.
  117861. */
  117862. readonly disableAlphaBlending: boolean;
  117863. /**
  117864. * Fills the list of render target textures.
  117865. * @param renderTargets the list of render targets to update
  117866. */
  117867. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  117868. /**
  117869. * Checks to see if a texture is used in the material.
  117870. * @param texture - Base texture to use.
  117871. * @returns - Boolean specifying if a texture is used in the material.
  117872. */
  117873. hasTexture(texture: BaseTexture): boolean;
  117874. /**
  117875. * Gets a boolean indicating that current material needs to register RTT
  117876. * @returns true if this uses a render target otherwise false.
  117877. */
  117878. hasRenderTargetTextures(): boolean;
  117879. /**
  117880. * Returns an array of the actively used textures.
  117881. * @param activeTextures Array of BaseTextures
  117882. */
  117883. getActiveTextures(activeTextures: BaseTexture[]): void;
  117884. /**
  117885. * Returns the animatable textures.
  117886. * @param animatables Array of animatable textures.
  117887. */
  117888. getAnimatables(animatables: IAnimatable[]): void;
  117889. /**
  117890. * Disposes the resources of the material.
  117891. * @param forceDisposeTextures - Forces the disposal of all textures.
  117892. */
  117893. dispose(forceDisposeTextures?: boolean): void;
  117894. /**
  117895. * Get the current class name of the texture useful for serialization or dynamic coding.
  117896. * @returns "PBRSubSurfaceConfiguration"
  117897. */
  117898. getClassName(): string;
  117899. /**
  117900. * Add fallbacks to the effect fallbacks list.
  117901. * @param defines defines the Base texture to use.
  117902. * @param fallbacks defines the current fallback list.
  117903. * @param currentRank defines the current fallback rank.
  117904. * @returns the new fallback rank.
  117905. */
  117906. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  117907. /**
  117908. * Add the required uniforms to the current list.
  117909. * @param uniforms defines the current uniform list.
  117910. */
  117911. static AddUniforms(uniforms: string[]): void;
  117912. /**
  117913. * Add the required samplers to the current list.
  117914. * @param samplers defines the current sampler list.
  117915. */
  117916. static AddSamplers(samplers: string[]): void;
  117917. /**
  117918. * Add the required uniforms to the current buffer.
  117919. * @param uniformBuffer defines the current uniform buffer.
  117920. */
  117921. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  117922. /**
  117923. * Makes a duplicate of the current configuration into another one.
  117924. * @param configuration define the config where to copy the info
  117925. */
  117926. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  117927. /**
  117928. * Serializes this Sub Surface configuration.
  117929. * @returns - An object with the serialized config.
  117930. */
  117931. serialize(): any;
  117932. /**
  117933. * Parses a anisotropy Configuration from a serialized object.
  117934. * @param source - Serialized object.
  117935. * @param scene Defines the scene we are parsing for
  117936. * @param rootUrl Defines the rootUrl to load from
  117937. */
  117938. parse(source: any, scene: Scene, rootUrl: string): void;
  117939. }
  117940. }
  117941. declare module BABYLON {
  117942. /** @hidden */
  117943. export var pbrFragmentDeclaration: {
  117944. name: string;
  117945. shader: string;
  117946. };
  117947. }
  117948. declare module BABYLON {
  117949. /** @hidden */
  117950. export var pbrUboDeclaration: {
  117951. name: string;
  117952. shader: string;
  117953. };
  117954. }
  117955. declare module BABYLON {
  117956. /** @hidden */
  117957. export var pbrFragmentExtraDeclaration: {
  117958. name: string;
  117959. shader: string;
  117960. };
  117961. }
  117962. declare module BABYLON {
  117963. /** @hidden */
  117964. export var pbrFragmentSamplersDeclaration: {
  117965. name: string;
  117966. shader: string;
  117967. };
  117968. }
  117969. declare module BABYLON {
  117970. /** @hidden */
  117971. export var pbrHelperFunctions: {
  117972. name: string;
  117973. shader: string;
  117974. };
  117975. }
  117976. declare module BABYLON {
  117977. /** @hidden */
  117978. export var harmonicsFunctions: {
  117979. name: string;
  117980. shader: string;
  117981. };
  117982. }
  117983. declare module BABYLON {
  117984. /** @hidden */
  117985. export var pbrDirectLightingSetupFunctions: {
  117986. name: string;
  117987. shader: string;
  117988. };
  117989. }
  117990. declare module BABYLON {
  117991. /** @hidden */
  117992. export var pbrDirectLightingFalloffFunctions: {
  117993. name: string;
  117994. shader: string;
  117995. };
  117996. }
  117997. declare module BABYLON {
  117998. /** @hidden */
  117999. export var pbrBRDFFunctions: {
  118000. name: string;
  118001. shader: string;
  118002. };
  118003. }
  118004. declare module BABYLON {
  118005. /** @hidden */
  118006. export var pbrDirectLightingFunctions: {
  118007. name: string;
  118008. shader: string;
  118009. };
  118010. }
  118011. declare module BABYLON {
  118012. /** @hidden */
  118013. export var pbrIBLFunctions: {
  118014. name: string;
  118015. shader: string;
  118016. };
  118017. }
  118018. declare module BABYLON {
  118019. /** @hidden */
  118020. export var pbrDebug: {
  118021. name: string;
  118022. shader: string;
  118023. };
  118024. }
  118025. declare module BABYLON {
  118026. /** @hidden */
  118027. export var pbrPixelShader: {
  118028. name: string;
  118029. shader: string;
  118030. };
  118031. }
  118032. declare module BABYLON {
  118033. /** @hidden */
  118034. export var pbrVertexDeclaration: {
  118035. name: string;
  118036. shader: string;
  118037. };
  118038. }
  118039. declare module BABYLON {
  118040. /** @hidden */
  118041. export var pbrVertexShader: {
  118042. name: string;
  118043. shader: string;
  118044. };
  118045. }
  118046. declare module BABYLON {
  118047. /**
  118048. * Manages the defines for the PBR Material.
  118049. * @hidden
  118050. */
  118051. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  118052. PBR: boolean;
  118053. MAINUV1: boolean;
  118054. MAINUV2: boolean;
  118055. UV1: boolean;
  118056. UV2: boolean;
  118057. ALBEDO: boolean;
  118058. ALBEDODIRECTUV: number;
  118059. VERTEXCOLOR: boolean;
  118060. AMBIENT: boolean;
  118061. AMBIENTDIRECTUV: number;
  118062. AMBIENTINGRAYSCALE: boolean;
  118063. OPACITY: boolean;
  118064. VERTEXALPHA: boolean;
  118065. OPACITYDIRECTUV: number;
  118066. OPACITYRGB: boolean;
  118067. ALPHATEST: boolean;
  118068. DEPTHPREPASS: boolean;
  118069. ALPHABLEND: boolean;
  118070. ALPHAFROMALBEDO: boolean;
  118071. ALPHATESTVALUE: string;
  118072. SPECULAROVERALPHA: boolean;
  118073. RADIANCEOVERALPHA: boolean;
  118074. ALPHAFRESNEL: boolean;
  118075. LINEARALPHAFRESNEL: boolean;
  118076. PREMULTIPLYALPHA: boolean;
  118077. EMISSIVE: boolean;
  118078. EMISSIVEDIRECTUV: number;
  118079. REFLECTIVITY: boolean;
  118080. REFLECTIVITYDIRECTUV: number;
  118081. SPECULARTERM: boolean;
  118082. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  118083. MICROSURFACEAUTOMATIC: boolean;
  118084. LODBASEDMICROSFURACE: boolean;
  118085. MICROSURFACEMAP: boolean;
  118086. MICROSURFACEMAPDIRECTUV: number;
  118087. METALLICWORKFLOW: boolean;
  118088. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  118089. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  118090. METALLNESSSTOREINMETALMAPBLUE: boolean;
  118091. AOSTOREINMETALMAPRED: boolean;
  118092. METALLICF0FACTORFROMMETALLICMAP: boolean;
  118093. ENVIRONMENTBRDF: boolean;
  118094. ENVIRONMENTBRDF_RGBD: boolean;
  118095. NORMAL: boolean;
  118096. TANGENT: boolean;
  118097. BUMP: boolean;
  118098. BUMPDIRECTUV: number;
  118099. OBJECTSPACE_NORMALMAP: boolean;
  118100. PARALLAX: boolean;
  118101. PARALLAXOCCLUSION: boolean;
  118102. NORMALXYSCALE: boolean;
  118103. LIGHTMAP: boolean;
  118104. LIGHTMAPDIRECTUV: number;
  118105. USELIGHTMAPASSHADOWMAP: boolean;
  118106. GAMMALIGHTMAP: boolean;
  118107. RGBDLIGHTMAP: boolean;
  118108. REFLECTION: boolean;
  118109. REFLECTIONMAP_3D: boolean;
  118110. REFLECTIONMAP_SPHERICAL: boolean;
  118111. REFLECTIONMAP_PLANAR: boolean;
  118112. REFLECTIONMAP_CUBIC: boolean;
  118113. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  118114. REFLECTIONMAP_PROJECTION: boolean;
  118115. REFLECTIONMAP_SKYBOX: boolean;
  118116. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  118117. REFLECTIONMAP_EXPLICIT: boolean;
  118118. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  118119. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  118120. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  118121. INVERTCUBICMAP: boolean;
  118122. USESPHERICALFROMREFLECTIONMAP: boolean;
  118123. USEIRRADIANCEMAP: boolean;
  118124. SPHERICAL_HARMONICS: boolean;
  118125. USESPHERICALINVERTEX: boolean;
  118126. REFLECTIONMAP_OPPOSITEZ: boolean;
  118127. LODINREFLECTIONALPHA: boolean;
  118128. GAMMAREFLECTION: boolean;
  118129. RGBDREFLECTION: boolean;
  118130. LINEARSPECULARREFLECTION: boolean;
  118131. RADIANCEOCCLUSION: boolean;
  118132. HORIZONOCCLUSION: boolean;
  118133. INSTANCES: boolean;
  118134. NUM_BONE_INFLUENCERS: number;
  118135. BonesPerMesh: number;
  118136. BONETEXTURE: boolean;
  118137. NONUNIFORMSCALING: boolean;
  118138. MORPHTARGETS: boolean;
  118139. MORPHTARGETS_NORMAL: boolean;
  118140. MORPHTARGETS_TANGENT: boolean;
  118141. MORPHTARGETS_UV: boolean;
  118142. NUM_MORPH_INFLUENCERS: number;
  118143. IMAGEPROCESSING: boolean;
  118144. VIGNETTE: boolean;
  118145. VIGNETTEBLENDMODEMULTIPLY: boolean;
  118146. VIGNETTEBLENDMODEOPAQUE: boolean;
  118147. TONEMAPPING: boolean;
  118148. TONEMAPPING_ACES: boolean;
  118149. CONTRAST: boolean;
  118150. COLORCURVES: boolean;
  118151. COLORGRADING: boolean;
  118152. COLORGRADING3D: boolean;
  118153. SAMPLER3DGREENDEPTH: boolean;
  118154. SAMPLER3DBGRMAP: boolean;
  118155. IMAGEPROCESSINGPOSTPROCESS: boolean;
  118156. EXPOSURE: boolean;
  118157. MULTIVIEW: boolean;
  118158. USEPHYSICALLIGHTFALLOFF: boolean;
  118159. USEGLTFLIGHTFALLOFF: boolean;
  118160. TWOSIDEDLIGHTING: boolean;
  118161. SHADOWFLOAT: boolean;
  118162. CLIPPLANE: boolean;
  118163. CLIPPLANE2: boolean;
  118164. CLIPPLANE3: boolean;
  118165. CLIPPLANE4: boolean;
  118166. POINTSIZE: boolean;
  118167. FOG: boolean;
  118168. LOGARITHMICDEPTH: boolean;
  118169. FORCENORMALFORWARD: boolean;
  118170. SPECULARAA: boolean;
  118171. CLEARCOAT: boolean;
  118172. CLEARCOAT_DEFAULTIOR: boolean;
  118173. CLEARCOAT_TEXTURE: boolean;
  118174. CLEARCOAT_TEXTUREDIRECTUV: number;
  118175. CLEARCOAT_BUMP: boolean;
  118176. CLEARCOAT_BUMPDIRECTUV: number;
  118177. CLEARCOAT_TINT: boolean;
  118178. CLEARCOAT_TINT_TEXTURE: boolean;
  118179. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  118180. ANISOTROPIC: boolean;
  118181. ANISOTROPIC_TEXTURE: boolean;
  118182. ANISOTROPIC_TEXTUREDIRECTUV: number;
  118183. BRDF_V_HEIGHT_CORRELATED: boolean;
  118184. MS_BRDF_ENERGY_CONSERVATION: boolean;
  118185. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  118186. SHEEN: boolean;
  118187. SHEEN_TEXTURE: boolean;
  118188. SHEEN_TEXTUREDIRECTUV: number;
  118189. SHEEN_LINKWITHALBEDO: boolean;
  118190. SUBSURFACE: boolean;
  118191. SS_REFRACTION: boolean;
  118192. SS_TRANSLUCENCY: boolean;
  118193. SS_SCATERRING: boolean;
  118194. SS_THICKNESSANDMASK_TEXTURE: boolean;
  118195. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  118196. SS_REFRACTIONMAP_3D: boolean;
  118197. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  118198. SS_LODINREFRACTIONALPHA: boolean;
  118199. SS_GAMMAREFRACTION: boolean;
  118200. SS_RGBDREFRACTION: boolean;
  118201. SS_LINEARSPECULARREFRACTION: boolean;
  118202. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  118203. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  118204. UNLIT: boolean;
  118205. DEBUGMODE: number;
  118206. /**
  118207. * Initializes the PBR Material defines.
  118208. */
  118209. constructor();
  118210. /**
  118211. * Resets the PBR Material defines.
  118212. */
  118213. reset(): void;
  118214. }
  118215. /**
  118216. * The Physically based material base class of BJS.
  118217. *
  118218. * This offers the main features of a standard PBR material.
  118219. * For more information, please refer to the documentation :
  118220. * https://doc.babylonjs.com/how_to/physically_based_rendering
  118221. */
  118222. export abstract class PBRBaseMaterial extends PushMaterial {
  118223. /**
  118224. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  118225. */
  118226. static readonly PBRMATERIAL_OPAQUE: number;
  118227. /**
  118228. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  118229. */
  118230. static readonly PBRMATERIAL_ALPHATEST: number;
  118231. /**
  118232. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  118233. */
  118234. static readonly PBRMATERIAL_ALPHABLEND: number;
  118235. /**
  118236. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  118237. * They are also discarded below the alpha cutoff threshold to improve performances.
  118238. */
  118239. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  118240. /**
  118241. * Defines the default value of how much AO map is occluding the analytical lights
  118242. * (point spot...).
  118243. */
  118244. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  118245. /**
  118246. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  118247. */
  118248. static readonly LIGHTFALLOFF_PHYSICAL: number;
  118249. /**
  118250. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  118251. * to enhance interoperability with other engines.
  118252. */
  118253. static readonly LIGHTFALLOFF_GLTF: number;
  118254. /**
  118255. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  118256. * to enhance interoperability with other materials.
  118257. */
  118258. static readonly LIGHTFALLOFF_STANDARD: number;
  118259. /**
  118260. * Intensity of the direct lights e.g. the four lights available in your scene.
  118261. * This impacts both the direct diffuse and specular highlights.
  118262. */
  118263. protected _directIntensity: number;
  118264. /**
  118265. * Intensity of the emissive part of the material.
  118266. * This helps controlling the emissive effect without modifying the emissive color.
  118267. */
  118268. protected _emissiveIntensity: number;
  118269. /**
  118270. * Intensity of the environment e.g. how much the environment will light the object
  118271. * either through harmonics for rough material or through the refelction for shiny ones.
  118272. */
  118273. protected _environmentIntensity: number;
  118274. /**
  118275. * This is a special control allowing the reduction of the specular highlights coming from the
  118276. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  118277. */
  118278. protected _specularIntensity: number;
  118279. /**
  118280. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  118281. */
  118282. private _lightingInfos;
  118283. /**
  118284. * Debug Control allowing disabling the bump map on this material.
  118285. */
  118286. protected _disableBumpMap: boolean;
  118287. /**
  118288. * AKA Diffuse Texture in standard nomenclature.
  118289. */
  118290. protected _albedoTexture: Nullable<BaseTexture>;
  118291. /**
  118292. * AKA Occlusion Texture in other nomenclature.
  118293. */
  118294. protected _ambientTexture: Nullable<BaseTexture>;
  118295. /**
  118296. * AKA Occlusion Texture Intensity in other nomenclature.
  118297. */
  118298. protected _ambientTextureStrength: number;
  118299. /**
  118300. * Defines how much the AO map is occluding the analytical lights (point spot...).
  118301. * 1 means it completely occludes it
  118302. * 0 mean it has no impact
  118303. */
  118304. protected _ambientTextureImpactOnAnalyticalLights: number;
  118305. /**
  118306. * Stores the alpha values in a texture.
  118307. */
  118308. protected _opacityTexture: Nullable<BaseTexture>;
  118309. /**
  118310. * Stores the reflection values in a texture.
  118311. */
  118312. protected _reflectionTexture: Nullable<BaseTexture>;
  118313. /**
  118314. * Stores the emissive values in a texture.
  118315. */
  118316. protected _emissiveTexture: Nullable<BaseTexture>;
  118317. /**
  118318. * AKA Specular texture in other nomenclature.
  118319. */
  118320. protected _reflectivityTexture: Nullable<BaseTexture>;
  118321. /**
  118322. * Used to switch from specular/glossiness to metallic/roughness workflow.
  118323. */
  118324. protected _metallicTexture: Nullable<BaseTexture>;
  118325. /**
  118326. * Specifies the metallic scalar of the metallic/roughness workflow.
  118327. * Can also be used to scale the metalness values of the metallic texture.
  118328. */
  118329. protected _metallic: Nullable<number>;
  118330. /**
  118331. * Specifies the roughness scalar of the metallic/roughness workflow.
  118332. * Can also be used to scale the roughness values of the metallic texture.
  118333. */
  118334. protected _roughness: Nullable<number>;
  118335. /**
  118336. * Specifies the an F0 factor to help configuring the material F0.
  118337. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  118338. * to 0.5 the previously hard coded value stays the same.
  118339. * Can also be used to scale the F0 values of the metallic texture.
  118340. */
  118341. protected _metallicF0Factor: number;
  118342. /**
  118343. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  118344. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  118345. * your expectation as it multiplies with the texture data.
  118346. */
  118347. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  118348. /**
  118349. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  118350. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  118351. */
  118352. protected _microSurfaceTexture: Nullable<BaseTexture>;
  118353. /**
  118354. * Stores surface normal data used to displace a mesh in a texture.
  118355. */
  118356. protected _bumpTexture: Nullable<BaseTexture>;
  118357. /**
  118358. * Stores the pre-calculated light information of a mesh in a texture.
  118359. */
  118360. protected _lightmapTexture: Nullable<BaseTexture>;
  118361. /**
  118362. * The color of a material in ambient lighting.
  118363. */
  118364. protected _ambientColor: Color3;
  118365. /**
  118366. * AKA Diffuse Color in other nomenclature.
  118367. */
  118368. protected _albedoColor: Color3;
  118369. /**
  118370. * AKA Specular Color in other nomenclature.
  118371. */
  118372. protected _reflectivityColor: Color3;
  118373. /**
  118374. * The color applied when light is reflected from a material.
  118375. */
  118376. protected _reflectionColor: Color3;
  118377. /**
  118378. * The color applied when light is emitted from a material.
  118379. */
  118380. protected _emissiveColor: Color3;
  118381. /**
  118382. * AKA Glossiness in other nomenclature.
  118383. */
  118384. protected _microSurface: number;
  118385. /**
  118386. * Specifies that the material will use the light map as a show map.
  118387. */
  118388. protected _useLightmapAsShadowmap: boolean;
  118389. /**
  118390. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  118391. * makes the reflect vector face the model (under horizon).
  118392. */
  118393. protected _useHorizonOcclusion: boolean;
  118394. /**
  118395. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  118396. * too much the area relying on ambient texture to define their ambient occlusion.
  118397. */
  118398. protected _useRadianceOcclusion: boolean;
  118399. /**
  118400. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  118401. */
  118402. protected _useAlphaFromAlbedoTexture: boolean;
  118403. /**
  118404. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  118405. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  118406. */
  118407. protected _useSpecularOverAlpha: boolean;
  118408. /**
  118409. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  118410. */
  118411. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  118412. /**
  118413. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  118414. */
  118415. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  118416. /**
  118417. * Specifies if the metallic texture contains the roughness information in its green channel.
  118418. */
  118419. protected _useRoughnessFromMetallicTextureGreen: boolean;
  118420. /**
  118421. * Specifies if the metallic texture contains the metallness information in its blue channel.
  118422. */
  118423. protected _useMetallnessFromMetallicTextureBlue: boolean;
  118424. /**
  118425. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  118426. */
  118427. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  118428. /**
  118429. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  118430. */
  118431. protected _useAmbientInGrayScale: boolean;
  118432. /**
  118433. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  118434. * The material will try to infer what glossiness each pixel should be.
  118435. */
  118436. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  118437. /**
  118438. * Defines the falloff type used in this material.
  118439. * It by default is Physical.
  118440. */
  118441. protected _lightFalloff: number;
  118442. /**
  118443. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  118444. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  118445. */
  118446. protected _useRadianceOverAlpha: boolean;
  118447. /**
  118448. * Allows using an object space normal map (instead of tangent space).
  118449. */
  118450. protected _useObjectSpaceNormalMap: boolean;
  118451. /**
  118452. * Allows using the bump map in parallax mode.
  118453. */
  118454. protected _useParallax: boolean;
  118455. /**
  118456. * Allows using the bump map in parallax occlusion mode.
  118457. */
  118458. protected _useParallaxOcclusion: boolean;
  118459. /**
  118460. * Controls the scale bias of the parallax mode.
  118461. */
  118462. protected _parallaxScaleBias: number;
  118463. /**
  118464. * If sets to true, disables all the lights affecting the material.
  118465. */
  118466. protected _disableLighting: boolean;
  118467. /**
  118468. * Number of Simultaneous lights allowed on the material.
  118469. */
  118470. protected _maxSimultaneousLights: number;
  118471. /**
  118472. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  118473. */
  118474. protected _invertNormalMapX: boolean;
  118475. /**
  118476. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  118477. */
  118478. protected _invertNormalMapY: boolean;
  118479. /**
  118480. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118481. */
  118482. protected _twoSidedLighting: boolean;
  118483. /**
  118484. * Defines the alpha limits in alpha test mode.
  118485. */
  118486. protected _alphaCutOff: number;
  118487. /**
  118488. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  118489. */
  118490. protected _forceAlphaTest: boolean;
  118491. /**
  118492. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  118493. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  118494. */
  118495. protected _useAlphaFresnel: boolean;
  118496. /**
  118497. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  118498. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  118499. */
  118500. protected _useLinearAlphaFresnel: boolean;
  118501. /**
  118502. * The transparency mode of the material.
  118503. */
  118504. protected _transparencyMode: Nullable<number>;
  118505. /**
  118506. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  118507. * from cos thetav and roughness:
  118508. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  118509. */
  118510. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  118511. /**
  118512. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  118513. */
  118514. protected _forceIrradianceInFragment: boolean;
  118515. /**
  118516. * Force normal to face away from face.
  118517. */
  118518. protected _forceNormalForward: boolean;
  118519. /**
  118520. * Enables specular anti aliasing in the PBR shader.
  118521. * It will both interacts on the Geometry for analytical and IBL lighting.
  118522. * It also prefilter the roughness map based on the bump values.
  118523. */
  118524. protected _enableSpecularAntiAliasing: boolean;
  118525. /**
  118526. * Default configuration related to image processing available in the PBR Material.
  118527. */
  118528. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118529. /**
  118530. * Keep track of the image processing observer to allow dispose and replace.
  118531. */
  118532. private _imageProcessingObserver;
  118533. /**
  118534. * Attaches a new image processing configuration to the PBR Material.
  118535. * @param configuration
  118536. */
  118537. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  118538. /**
  118539. * Stores the available render targets.
  118540. */
  118541. private _renderTargets;
  118542. /**
  118543. * Sets the global ambient color for the material used in lighting calculations.
  118544. */
  118545. private _globalAmbientColor;
  118546. /**
  118547. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  118548. */
  118549. private _useLogarithmicDepth;
  118550. /**
  118551. * If set to true, no lighting calculations will be applied.
  118552. */
  118553. private _unlit;
  118554. private _debugMode;
  118555. /**
  118556. * @hidden
  118557. * This is reserved for the inspector.
  118558. * Defines the material debug mode.
  118559. * It helps seeing only some components of the material while troubleshooting.
  118560. */
  118561. debugMode: number;
  118562. /**
  118563. * @hidden
  118564. * This is reserved for the inspector.
  118565. * Specify from where on screen the debug mode should start.
  118566. * The value goes from -1 (full screen) to 1 (not visible)
  118567. * It helps with side by side comparison against the final render
  118568. * This defaults to -1
  118569. */
  118570. private debugLimit;
  118571. /**
  118572. * @hidden
  118573. * This is reserved for the inspector.
  118574. * As the default viewing range might not be enough (if the ambient is really small for instance)
  118575. * You can use the factor to better multiply the final value.
  118576. */
  118577. private debugFactor;
  118578. /**
  118579. * Defines the clear coat layer parameters for the material.
  118580. */
  118581. readonly clearCoat: PBRClearCoatConfiguration;
  118582. /**
  118583. * Defines the anisotropic parameters for the material.
  118584. */
  118585. readonly anisotropy: PBRAnisotropicConfiguration;
  118586. /**
  118587. * Defines the BRDF parameters for the material.
  118588. */
  118589. readonly brdf: PBRBRDFConfiguration;
  118590. /**
  118591. * Defines the Sheen parameters for the material.
  118592. */
  118593. readonly sheen: PBRSheenConfiguration;
  118594. /**
  118595. * Defines the SubSurface parameters for the material.
  118596. */
  118597. readonly subSurface: PBRSubSurfaceConfiguration;
  118598. /**
  118599. * Custom callback helping to override the default shader used in the material.
  118600. */
  118601. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  118602. protected _rebuildInParallel: boolean;
  118603. /**
  118604. * Instantiates a new PBRMaterial instance.
  118605. *
  118606. * @param name The material name
  118607. * @param scene The scene the material will be use in.
  118608. */
  118609. constructor(name: string, scene: Scene);
  118610. /**
  118611. * Gets a boolean indicating that current material needs to register RTT
  118612. */
  118613. readonly hasRenderTargetTextures: boolean;
  118614. /**
  118615. * Gets the name of the material class.
  118616. */
  118617. getClassName(): string;
  118618. /**
  118619. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  118620. */
  118621. /**
  118622. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  118623. */
  118624. useLogarithmicDepth: boolean;
  118625. /**
  118626. * Gets the current transparency mode.
  118627. */
  118628. /**
  118629. * Sets the transparency mode of the material.
  118630. *
  118631. * | Value | Type | Description |
  118632. * | ----- | ----------------------------------- | ----------- |
  118633. * | 0 | OPAQUE | |
  118634. * | 1 | ALPHATEST | |
  118635. * | 2 | ALPHABLEND | |
  118636. * | 3 | ALPHATESTANDBLEND | |
  118637. *
  118638. */
  118639. transparencyMode: Nullable<number>;
  118640. /**
  118641. * Returns true if alpha blending should be disabled.
  118642. */
  118643. private readonly _disableAlphaBlending;
  118644. /**
  118645. * Specifies whether or not this material should be rendered in alpha blend mode.
  118646. */
  118647. needAlphaBlending(): boolean;
  118648. /**
  118649. * Specifies if the mesh will require alpha blending.
  118650. * @param mesh - BJS mesh.
  118651. */
  118652. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  118653. /**
  118654. * Specifies whether or not this material should be rendered in alpha test mode.
  118655. */
  118656. needAlphaTesting(): boolean;
  118657. /**
  118658. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  118659. */
  118660. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  118661. /**
  118662. * Gets the texture used for the alpha test.
  118663. */
  118664. getAlphaTestTexture(): Nullable<BaseTexture>;
  118665. /**
  118666. * Specifies that the submesh is ready to be used.
  118667. * @param mesh - BJS mesh.
  118668. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  118669. * @param useInstances - Specifies that instances should be used.
  118670. * @returns - boolean indicating that the submesh is ready or not.
  118671. */
  118672. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  118673. /**
  118674. * Specifies if the material uses metallic roughness workflow.
  118675. * @returns boolean specifiying if the material uses metallic roughness workflow.
  118676. */
  118677. isMetallicWorkflow(): boolean;
  118678. private _prepareEffect;
  118679. private _prepareDefines;
  118680. /**
  118681. * Force shader compilation
  118682. */
  118683. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  118684. /**
  118685. * Initializes the uniform buffer layout for the shader.
  118686. */
  118687. buildUniformLayout(): void;
  118688. /**
  118689. * Unbinds the material from the mesh
  118690. */
  118691. unbind(): void;
  118692. /**
  118693. * Binds the submesh data.
  118694. * @param world - The world matrix.
  118695. * @param mesh - The BJS mesh.
  118696. * @param subMesh - A submesh of the BJS mesh.
  118697. */
  118698. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  118699. /**
  118700. * Returns the animatable textures.
  118701. * @returns - Array of animatable textures.
  118702. */
  118703. getAnimatables(): IAnimatable[];
  118704. /**
  118705. * Returns the texture used for reflections.
  118706. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  118707. */
  118708. private _getReflectionTexture;
  118709. /**
  118710. * Returns an array of the actively used textures.
  118711. * @returns - Array of BaseTextures
  118712. */
  118713. getActiveTextures(): BaseTexture[];
  118714. /**
  118715. * Checks to see if a texture is used in the material.
  118716. * @param texture - Base texture to use.
  118717. * @returns - Boolean specifying if a texture is used in the material.
  118718. */
  118719. hasTexture(texture: BaseTexture): boolean;
  118720. /**
  118721. * Disposes the resources of the material.
  118722. * @param forceDisposeEffect - Forces the disposal of effects.
  118723. * @param forceDisposeTextures - Forces the disposal of all textures.
  118724. */
  118725. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  118726. }
  118727. }
  118728. declare module BABYLON {
  118729. /**
  118730. * The Physically based material of BJS.
  118731. *
  118732. * This offers the main features of a standard PBR material.
  118733. * For more information, please refer to the documentation :
  118734. * https://doc.babylonjs.com/how_to/physically_based_rendering
  118735. */
  118736. export class PBRMaterial extends PBRBaseMaterial {
  118737. /**
  118738. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  118739. */
  118740. static readonly PBRMATERIAL_OPAQUE: number;
  118741. /**
  118742. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  118743. */
  118744. static readonly PBRMATERIAL_ALPHATEST: number;
  118745. /**
  118746. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  118747. */
  118748. static readonly PBRMATERIAL_ALPHABLEND: number;
  118749. /**
  118750. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  118751. * They are also discarded below the alpha cutoff threshold to improve performances.
  118752. */
  118753. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  118754. /**
  118755. * Defines the default value of how much AO map is occluding the analytical lights
  118756. * (point spot...).
  118757. */
  118758. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  118759. /**
  118760. * Intensity of the direct lights e.g. the four lights available in your scene.
  118761. * This impacts both the direct diffuse and specular highlights.
  118762. */
  118763. directIntensity: number;
  118764. /**
  118765. * Intensity of the emissive part of the material.
  118766. * This helps controlling the emissive effect without modifying the emissive color.
  118767. */
  118768. emissiveIntensity: number;
  118769. /**
  118770. * Intensity of the environment e.g. how much the environment will light the object
  118771. * either through harmonics for rough material or through the refelction for shiny ones.
  118772. */
  118773. environmentIntensity: number;
  118774. /**
  118775. * This is a special control allowing the reduction of the specular highlights coming from the
  118776. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  118777. */
  118778. specularIntensity: number;
  118779. /**
  118780. * Debug Control allowing disabling the bump map on this material.
  118781. */
  118782. disableBumpMap: boolean;
  118783. /**
  118784. * AKA Diffuse Texture in standard nomenclature.
  118785. */
  118786. albedoTexture: BaseTexture;
  118787. /**
  118788. * AKA Occlusion Texture in other nomenclature.
  118789. */
  118790. ambientTexture: BaseTexture;
  118791. /**
  118792. * AKA Occlusion Texture Intensity in other nomenclature.
  118793. */
  118794. ambientTextureStrength: number;
  118795. /**
  118796. * Defines how much the AO map is occluding the analytical lights (point spot...).
  118797. * 1 means it completely occludes it
  118798. * 0 mean it has no impact
  118799. */
  118800. ambientTextureImpactOnAnalyticalLights: number;
  118801. /**
  118802. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  118803. */
  118804. opacityTexture: BaseTexture;
  118805. /**
  118806. * Stores the reflection values in a texture.
  118807. */
  118808. reflectionTexture: Nullable<BaseTexture>;
  118809. /**
  118810. * Stores the emissive values in a texture.
  118811. */
  118812. emissiveTexture: BaseTexture;
  118813. /**
  118814. * AKA Specular texture in other nomenclature.
  118815. */
  118816. reflectivityTexture: BaseTexture;
  118817. /**
  118818. * Used to switch from specular/glossiness to metallic/roughness workflow.
  118819. */
  118820. metallicTexture: BaseTexture;
  118821. /**
  118822. * Specifies the metallic scalar of the metallic/roughness workflow.
  118823. * Can also be used to scale the metalness values of the metallic texture.
  118824. */
  118825. metallic: Nullable<number>;
  118826. /**
  118827. * Specifies the roughness scalar of the metallic/roughness workflow.
  118828. * Can also be used to scale the roughness values of the metallic texture.
  118829. */
  118830. roughness: Nullable<number>;
  118831. /**
  118832. * Specifies the an F0 factor to help configuring the material F0.
  118833. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  118834. * to 0.5 the previously hard coded value stays the same.
  118835. * Can also be used to scale the F0 values of the metallic texture.
  118836. */
  118837. metallicF0Factor: number;
  118838. /**
  118839. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  118840. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  118841. * your expectation as it multiplies with the texture data.
  118842. */
  118843. useMetallicF0FactorFromMetallicTexture: boolean;
  118844. /**
  118845. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  118846. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  118847. */
  118848. microSurfaceTexture: BaseTexture;
  118849. /**
  118850. * Stores surface normal data used to displace a mesh in a texture.
  118851. */
  118852. bumpTexture: BaseTexture;
  118853. /**
  118854. * Stores the pre-calculated light information of a mesh in a texture.
  118855. */
  118856. lightmapTexture: BaseTexture;
  118857. /**
  118858. * Stores the refracted light information in a texture.
  118859. */
  118860. refractionTexture: Nullable<BaseTexture>;
  118861. /**
  118862. * The color of a material in ambient lighting.
  118863. */
  118864. ambientColor: Color3;
  118865. /**
  118866. * AKA Diffuse Color in other nomenclature.
  118867. */
  118868. albedoColor: Color3;
  118869. /**
  118870. * AKA Specular Color in other nomenclature.
  118871. */
  118872. reflectivityColor: Color3;
  118873. /**
  118874. * The color reflected from the material.
  118875. */
  118876. reflectionColor: Color3;
  118877. /**
  118878. * The color emitted from the material.
  118879. */
  118880. emissiveColor: Color3;
  118881. /**
  118882. * AKA Glossiness in other nomenclature.
  118883. */
  118884. microSurface: number;
  118885. /**
  118886. * source material index of refraction (IOR)' / 'destination material IOR.
  118887. */
  118888. indexOfRefraction: number;
  118889. /**
  118890. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  118891. */
  118892. invertRefractionY: boolean;
  118893. /**
  118894. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  118895. * Materials half opaque for instance using refraction could benefit from this control.
  118896. */
  118897. linkRefractionWithTransparency: boolean;
  118898. /**
  118899. * If true, the light map contains occlusion information instead of lighting info.
  118900. */
  118901. useLightmapAsShadowmap: boolean;
  118902. /**
  118903. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  118904. */
  118905. useAlphaFromAlbedoTexture: boolean;
  118906. /**
  118907. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  118908. */
  118909. forceAlphaTest: boolean;
  118910. /**
  118911. * Defines the alpha limits in alpha test mode.
  118912. */
  118913. alphaCutOff: number;
  118914. /**
  118915. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  118916. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  118917. */
  118918. useSpecularOverAlpha: boolean;
  118919. /**
  118920. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  118921. */
  118922. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  118923. /**
  118924. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  118925. */
  118926. useRoughnessFromMetallicTextureAlpha: boolean;
  118927. /**
  118928. * Specifies if the metallic texture contains the roughness information in its green channel.
  118929. */
  118930. useRoughnessFromMetallicTextureGreen: boolean;
  118931. /**
  118932. * Specifies if the metallic texture contains the metallness information in its blue channel.
  118933. */
  118934. useMetallnessFromMetallicTextureBlue: boolean;
  118935. /**
  118936. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  118937. */
  118938. useAmbientOcclusionFromMetallicTextureRed: boolean;
  118939. /**
  118940. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  118941. */
  118942. useAmbientInGrayScale: boolean;
  118943. /**
  118944. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  118945. * The material will try to infer what glossiness each pixel should be.
  118946. */
  118947. useAutoMicroSurfaceFromReflectivityMap: boolean;
  118948. /**
  118949. * BJS is using an harcoded light falloff based on a manually sets up range.
  118950. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  118951. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  118952. */
  118953. /**
  118954. * BJS is using an harcoded light falloff based on a manually sets up range.
  118955. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  118956. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  118957. */
  118958. usePhysicalLightFalloff: boolean;
  118959. /**
  118960. * In order to support the falloff compatibility with gltf, a special mode has been added
  118961. * to reproduce the gltf light falloff.
  118962. */
  118963. /**
  118964. * In order to support the falloff compatibility with gltf, a special mode has been added
  118965. * to reproduce the gltf light falloff.
  118966. */
  118967. useGLTFLightFalloff: boolean;
  118968. /**
  118969. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  118970. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  118971. */
  118972. useRadianceOverAlpha: boolean;
  118973. /**
  118974. * Allows using an object space normal map (instead of tangent space).
  118975. */
  118976. useObjectSpaceNormalMap: boolean;
  118977. /**
  118978. * Allows using the bump map in parallax mode.
  118979. */
  118980. useParallax: boolean;
  118981. /**
  118982. * Allows using the bump map in parallax occlusion mode.
  118983. */
  118984. useParallaxOcclusion: boolean;
  118985. /**
  118986. * Controls the scale bias of the parallax mode.
  118987. */
  118988. parallaxScaleBias: number;
  118989. /**
  118990. * If sets to true, disables all the lights affecting the material.
  118991. */
  118992. disableLighting: boolean;
  118993. /**
  118994. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  118995. */
  118996. forceIrradianceInFragment: boolean;
  118997. /**
  118998. * Number of Simultaneous lights allowed on the material.
  118999. */
  119000. maxSimultaneousLights: number;
  119001. /**
  119002. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  119003. */
  119004. invertNormalMapX: boolean;
  119005. /**
  119006. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  119007. */
  119008. invertNormalMapY: boolean;
  119009. /**
  119010. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  119011. */
  119012. twoSidedLighting: boolean;
  119013. /**
  119014. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  119015. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  119016. */
  119017. useAlphaFresnel: boolean;
  119018. /**
  119019. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  119020. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  119021. */
  119022. useLinearAlphaFresnel: boolean;
  119023. /**
  119024. * Let user defines the brdf lookup texture used for IBL.
  119025. * A default 8bit version is embedded but you could point at :
  119026. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  119027. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  119028. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  119029. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  119030. */
  119031. environmentBRDFTexture: Nullable<BaseTexture>;
  119032. /**
  119033. * Force normal to face away from face.
  119034. */
  119035. forceNormalForward: boolean;
  119036. /**
  119037. * Enables specular anti aliasing in the PBR shader.
  119038. * It will both interacts on the Geometry for analytical and IBL lighting.
  119039. * It also prefilter the roughness map based on the bump values.
  119040. */
  119041. enableSpecularAntiAliasing: boolean;
  119042. /**
  119043. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  119044. * makes the reflect vector face the model (under horizon).
  119045. */
  119046. useHorizonOcclusion: boolean;
  119047. /**
  119048. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  119049. * too much the area relying on ambient texture to define their ambient occlusion.
  119050. */
  119051. useRadianceOcclusion: boolean;
  119052. /**
  119053. * If set to true, no lighting calculations will be applied.
  119054. */
  119055. unlit: boolean;
  119056. /**
  119057. * Gets the image processing configuration used either in this material.
  119058. */
  119059. /**
  119060. * Sets the Default image processing configuration used either in the this material.
  119061. *
  119062. * If sets to null, the scene one is in use.
  119063. */
  119064. imageProcessingConfiguration: ImageProcessingConfiguration;
  119065. /**
  119066. * Gets wether the color curves effect is enabled.
  119067. */
  119068. /**
  119069. * Sets wether the color curves effect is enabled.
  119070. */
  119071. cameraColorCurvesEnabled: boolean;
  119072. /**
  119073. * Gets wether the color grading effect is enabled.
  119074. */
  119075. /**
  119076. * Gets wether the color grading effect is enabled.
  119077. */
  119078. cameraColorGradingEnabled: boolean;
  119079. /**
  119080. * Gets wether tonemapping is enabled or not.
  119081. */
  119082. /**
  119083. * Sets wether tonemapping is enabled or not
  119084. */
  119085. cameraToneMappingEnabled: boolean;
  119086. /**
  119087. * The camera exposure used on this material.
  119088. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  119089. * This corresponds to a photographic exposure.
  119090. */
  119091. /**
  119092. * The camera exposure used on this material.
  119093. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  119094. * This corresponds to a photographic exposure.
  119095. */
  119096. cameraExposure: number;
  119097. /**
  119098. * Gets The camera contrast used on this material.
  119099. */
  119100. /**
  119101. * Sets The camera contrast used on this material.
  119102. */
  119103. cameraContrast: number;
  119104. /**
  119105. * Gets the Color Grading 2D Lookup Texture.
  119106. */
  119107. /**
  119108. * Sets the Color Grading 2D Lookup Texture.
  119109. */
  119110. cameraColorGradingTexture: Nullable<BaseTexture>;
  119111. /**
  119112. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  119113. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  119114. * 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;
  119115. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  119116. */
  119117. /**
  119118. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  119119. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  119120. * 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;
  119121. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  119122. */
  119123. cameraColorCurves: Nullable<ColorCurves>;
  119124. /**
  119125. * Instantiates a new PBRMaterial instance.
  119126. *
  119127. * @param name The material name
  119128. * @param scene The scene the material will be use in.
  119129. */
  119130. constructor(name: string, scene: Scene);
  119131. /**
  119132. * Returns the name of this material class.
  119133. */
  119134. getClassName(): string;
  119135. /**
  119136. * Makes a duplicate of the current material.
  119137. * @param name - name to use for the new material.
  119138. */
  119139. clone(name: string): PBRMaterial;
  119140. /**
  119141. * Serializes this PBR Material.
  119142. * @returns - An object with the serialized material.
  119143. */
  119144. serialize(): any;
  119145. /**
  119146. * Parses a PBR Material from a serialized object.
  119147. * @param source - Serialized object.
  119148. * @param scene - BJS scene instance.
  119149. * @param rootUrl - url for the scene object
  119150. * @returns - PBRMaterial
  119151. */
  119152. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  119153. }
  119154. }
  119155. declare module BABYLON {
  119156. /**
  119157. * Direct draw surface info
  119158. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  119159. */
  119160. export interface DDSInfo {
  119161. /**
  119162. * Width of the texture
  119163. */
  119164. width: number;
  119165. /**
  119166. * Width of the texture
  119167. */
  119168. height: number;
  119169. /**
  119170. * Number of Mipmaps for the texture
  119171. * @see https://en.wikipedia.org/wiki/Mipmap
  119172. */
  119173. mipmapCount: number;
  119174. /**
  119175. * If the textures format is a known fourCC format
  119176. * @see https://www.fourcc.org/
  119177. */
  119178. isFourCC: boolean;
  119179. /**
  119180. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  119181. */
  119182. isRGB: boolean;
  119183. /**
  119184. * If the texture is a lumincance format
  119185. */
  119186. isLuminance: boolean;
  119187. /**
  119188. * If this is a cube texture
  119189. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  119190. */
  119191. isCube: boolean;
  119192. /**
  119193. * If the texture is a compressed format eg. FOURCC_DXT1
  119194. */
  119195. isCompressed: boolean;
  119196. /**
  119197. * The dxgiFormat of the texture
  119198. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  119199. */
  119200. dxgiFormat: number;
  119201. /**
  119202. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  119203. */
  119204. textureType: number;
  119205. /**
  119206. * Sphericle polynomial created for the dds texture
  119207. */
  119208. sphericalPolynomial?: SphericalPolynomial;
  119209. }
  119210. /**
  119211. * Class used to provide DDS decompression tools
  119212. */
  119213. export class DDSTools {
  119214. /**
  119215. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  119216. */
  119217. static StoreLODInAlphaChannel: boolean;
  119218. /**
  119219. * Gets DDS information from an array buffer
  119220. * @param arrayBuffer defines the array buffer to read data from
  119221. * @returns the DDS information
  119222. */
  119223. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  119224. private static _FloatView;
  119225. private static _Int32View;
  119226. private static _ToHalfFloat;
  119227. private static _FromHalfFloat;
  119228. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  119229. private static _GetHalfFloatRGBAArrayBuffer;
  119230. private static _GetFloatRGBAArrayBuffer;
  119231. private static _GetFloatAsUIntRGBAArrayBuffer;
  119232. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  119233. private static _GetRGBAArrayBuffer;
  119234. private static _ExtractLongWordOrder;
  119235. private static _GetRGBArrayBuffer;
  119236. private static _GetLuminanceArrayBuffer;
  119237. /**
  119238. * Uploads DDS Levels to a Babylon Texture
  119239. * @hidden
  119240. */
  119241. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  119242. }
  119243. interface ThinEngine {
  119244. /**
  119245. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  119246. * @param rootUrl defines the url where the file to load is located
  119247. * @param scene defines the current scene
  119248. * @param lodScale defines scale to apply to the mip map selection
  119249. * @param lodOffset defines offset to apply to the mip map selection
  119250. * @param onLoad defines an optional callback raised when the texture is loaded
  119251. * @param onError defines an optional callback raised if there is an issue to load the texture
  119252. * @param format defines the format of the data
  119253. * @param forcedExtension defines the extension to use to pick the right loader
  119254. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  119255. * @returns the cube texture as an InternalTexture
  119256. */
  119257. 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;
  119258. }
  119259. }
  119260. declare module BABYLON {
  119261. /**
  119262. * Implementation of the DDS Texture Loader.
  119263. * @hidden
  119264. */
  119265. export class _DDSTextureLoader implements IInternalTextureLoader {
  119266. /**
  119267. * Defines wether the loader supports cascade loading the different faces.
  119268. */
  119269. readonly supportCascades: boolean;
  119270. /**
  119271. * This returns if the loader support the current file information.
  119272. * @param extension defines the file extension of the file being loaded
  119273. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119274. * @param fallback defines the fallback internal texture if any
  119275. * @param isBase64 defines whether the texture is encoded as a base64
  119276. * @param isBuffer defines whether the texture data are stored as a buffer
  119277. * @returns true if the loader can load the specified file
  119278. */
  119279. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119280. /**
  119281. * Transform the url before loading if required.
  119282. * @param rootUrl the url of the texture
  119283. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119284. * @returns the transformed texture
  119285. */
  119286. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119287. /**
  119288. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119289. * @param rootUrl the url of the texture
  119290. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119291. * @returns the fallback texture
  119292. */
  119293. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119294. /**
  119295. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  119296. * @param data contains the texture data
  119297. * @param texture defines the BabylonJS internal texture
  119298. * @param createPolynomials will be true if polynomials have been requested
  119299. * @param onLoad defines the callback to trigger once the texture is ready
  119300. * @param onError defines the callback to trigger in case of error
  119301. */
  119302. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119303. /**
  119304. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119305. * @param data contains the texture data
  119306. * @param texture defines the BabylonJS internal texture
  119307. * @param callback defines the method to call once ready to upload
  119308. */
  119309. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119310. }
  119311. }
  119312. declare module BABYLON {
  119313. /**
  119314. * Implementation of the ENV Texture Loader.
  119315. * @hidden
  119316. */
  119317. export class _ENVTextureLoader implements IInternalTextureLoader {
  119318. /**
  119319. * Defines wether the loader supports cascade loading the different faces.
  119320. */
  119321. readonly supportCascades: boolean;
  119322. /**
  119323. * This returns if the loader support the current file information.
  119324. * @param extension defines the file extension of the file being loaded
  119325. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119326. * @param fallback defines the fallback internal texture if any
  119327. * @param isBase64 defines whether the texture is encoded as a base64
  119328. * @param isBuffer defines whether the texture data are stored as a buffer
  119329. * @returns true if the loader can load the specified file
  119330. */
  119331. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119332. /**
  119333. * Transform the url before loading if required.
  119334. * @param rootUrl the url of the texture
  119335. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119336. * @returns the transformed texture
  119337. */
  119338. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119339. /**
  119340. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119341. * @param rootUrl the url of the texture
  119342. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119343. * @returns the fallback texture
  119344. */
  119345. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119346. /**
  119347. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  119348. * @param data contains the texture data
  119349. * @param texture defines the BabylonJS internal texture
  119350. * @param createPolynomials will be true if polynomials have been requested
  119351. * @param onLoad defines the callback to trigger once the texture is ready
  119352. * @param onError defines the callback to trigger in case of error
  119353. */
  119354. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119355. /**
  119356. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119357. * @param data contains the texture data
  119358. * @param texture defines the BabylonJS internal texture
  119359. * @param callback defines the method to call once ready to upload
  119360. */
  119361. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119362. }
  119363. }
  119364. declare module BABYLON {
  119365. /**
  119366. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  119367. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  119368. */
  119369. export class KhronosTextureContainer {
  119370. /** contents of the KTX container file */
  119371. arrayBuffer: any;
  119372. private static HEADER_LEN;
  119373. private static COMPRESSED_2D;
  119374. private static COMPRESSED_3D;
  119375. private static TEX_2D;
  119376. private static TEX_3D;
  119377. /**
  119378. * Gets the openGL type
  119379. */
  119380. glType: number;
  119381. /**
  119382. * Gets the openGL type size
  119383. */
  119384. glTypeSize: number;
  119385. /**
  119386. * Gets the openGL format
  119387. */
  119388. glFormat: number;
  119389. /**
  119390. * Gets the openGL internal format
  119391. */
  119392. glInternalFormat: number;
  119393. /**
  119394. * Gets the base internal format
  119395. */
  119396. glBaseInternalFormat: number;
  119397. /**
  119398. * Gets image width in pixel
  119399. */
  119400. pixelWidth: number;
  119401. /**
  119402. * Gets image height in pixel
  119403. */
  119404. pixelHeight: number;
  119405. /**
  119406. * Gets image depth in pixels
  119407. */
  119408. pixelDepth: number;
  119409. /**
  119410. * Gets the number of array elements
  119411. */
  119412. numberOfArrayElements: number;
  119413. /**
  119414. * Gets the number of faces
  119415. */
  119416. numberOfFaces: number;
  119417. /**
  119418. * Gets the number of mipmap levels
  119419. */
  119420. numberOfMipmapLevels: number;
  119421. /**
  119422. * Gets the bytes of key value data
  119423. */
  119424. bytesOfKeyValueData: number;
  119425. /**
  119426. * Gets the load type
  119427. */
  119428. loadType: number;
  119429. /**
  119430. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  119431. */
  119432. isInvalid: boolean;
  119433. /**
  119434. * Creates a new KhronosTextureContainer
  119435. * @param arrayBuffer contents of the KTX container file
  119436. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  119437. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  119438. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  119439. */
  119440. constructor(
  119441. /** contents of the KTX container file */
  119442. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  119443. /**
  119444. * Uploads KTX content to a Babylon Texture.
  119445. * It is assumed that the texture has already been created & is currently bound
  119446. * @hidden
  119447. */
  119448. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  119449. private _upload2DCompressedLevels;
  119450. }
  119451. }
  119452. declare module BABYLON {
  119453. /**
  119454. * Implementation of the KTX Texture Loader.
  119455. * @hidden
  119456. */
  119457. export class _KTXTextureLoader implements IInternalTextureLoader {
  119458. /**
  119459. * Defines wether the loader supports cascade loading the different faces.
  119460. */
  119461. readonly supportCascades: boolean;
  119462. /**
  119463. * This returns if the loader support the current file information.
  119464. * @param extension defines the file extension of the file being loaded
  119465. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119466. * @param fallback defines the fallback internal texture if any
  119467. * @param isBase64 defines whether the texture is encoded as a base64
  119468. * @param isBuffer defines whether the texture data are stored as a buffer
  119469. * @returns true if the loader can load the specified file
  119470. */
  119471. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119472. /**
  119473. * Transform the url before loading if required.
  119474. * @param rootUrl the url of the texture
  119475. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119476. * @returns the transformed texture
  119477. */
  119478. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119479. /**
  119480. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119481. * @param rootUrl the url of the texture
  119482. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119483. * @returns the fallback texture
  119484. */
  119485. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119486. /**
  119487. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  119488. * @param data contains the texture data
  119489. * @param texture defines the BabylonJS internal texture
  119490. * @param createPolynomials will be true if polynomials have been requested
  119491. * @param onLoad defines the callback to trigger once the texture is ready
  119492. * @param onError defines the callback to trigger in case of error
  119493. */
  119494. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119495. /**
  119496. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119497. * @param data contains the texture data
  119498. * @param texture defines the BabylonJS internal texture
  119499. * @param callback defines the method to call once ready to upload
  119500. */
  119501. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  119502. }
  119503. }
  119504. declare module BABYLON {
  119505. /** @hidden */
  119506. export var _forceSceneHelpersToBundle: boolean;
  119507. interface Scene {
  119508. /**
  119509. * Creates a default light for the scene.
  119510. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  119511. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  119512. */
  119513. createDefaultLight(replace?: boolean): void;
  119514. /**
  119515. * Creates a default camera for the scene.
  119516. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  119517. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  119518. * @param replace has default false, when true replaces the active camera in the scene
  119519. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  119520. */
  119521. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  119522. /**
  119523. * Creates a default camera and a default light.
  119524. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  119525. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  119526. * @param replace has the default false, when true replaces the active camera/light in the scene
  119527. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  119528. */
  119529. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  119530. /**
  119531. * Creates a new sky box
  119532. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  119533. * @param environmentTexture defines the texture to use as environment texture
  119534. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  119535. * @param scale defines the overall scale of the skybox
  119536. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  119537. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  119538. * @returns a new mesh holding the sky box
  119539. */
  119540. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  119541. /**
  119542. * Creates a new environment
  119543. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  119544. * @param options defines the options you can use to configure the environment
  119545. * @returns the new EnvironmentHelper
  119546. */
  119547. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  119548. /**
  119549. * Creates a new VREXperienceHelper
  119550. * @see http://doc.babylonjs.com/how_to/webvr_helper
  119551. * @param webVROptions defines the options used to create the new VREXperienceHelper
  119552. * @returns a new VREXperienceHelper
  119553. */
  119554. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  119555. /**
  119556. * Creates a new WebXRDefaultExperience
  119557. * @see http://doc.babylonjs.com/how_to/webxr
  119558. * @param options experience options
  119559. * @returns a promise for a new WebXRDefaultExperience
  119560. */
  119561. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  119562. }
  119563. }
  119564. declare module BABYLON {
  119565. /**
  119566. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  119567. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  119568. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  119569. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  119570. */
  119571. export class VideoDome extends TransformNode {
  119572. /**
  119573. * Define the video source as a Monoscopic panoramic 360 video.
  119574. */
  119575. static readonly MODE_MONOSCOPIC: number;
  119576. /**
  119577. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  119578. */
  119579. static readonly MODE_TOPBOTTOM: number;
  119580. /**
  119581. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  119582. */
  119583. static readonly MODE_SIDEBYSIDE: number;
  119584. private _halfDome;
  119585. private _useDirectMapping;
  119586. /**
  119587. * The video texture being displayed on the sphere
  119588. */
  119589. protected _videoTexture: VideoTexture;
  119590. /**
  119591. * Gets the video texture being displayed on the sphere
  119592. */
  119593. readonly videoTexture: VideoTexture;
  119594. /**
  119595. * The skybox material
  119596. */
  119597. protected _material: BackgroundMaterial;
  119598. /**
  119599. * The surface used for the skybox
  119600. */
  119601. protected _mesh: Mesh;
  119602. /**
  119603. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  119604. */
  119605. private _halfDomeMask;
  119606. /**
  119607. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  119608. * Also see the options.resolution property.
  119609. */
  119610. fovMultiplier: number;
  119611. private _videoMode;
  119612. /**
  119613. * Gets or set the current video mode for the video. It can be:
  119614. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  119615. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  119616. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  119617. */
  119618. videoMode: number;
  119619. /**
  119620. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  119621. *
  119622. */
  119623. /**
  119624. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  119625. */
  119626. halfDome: boolean;
  119627. /**
  119628. * Oberserver used in Stereoscopic VR Mode.
  119629. */
  119630. private _onBeforeCameraRenderObserver;
  119631. /**
  119632. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  119633. * @param name Element's name, child elements will append suffixes for their own names.
  119634. * @param urlsOrVideo defines the url(s) or the video element to use
  119635. * @param options An object containing optional or exposed sub element properties
  119636. */
  119637. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  119638. resolution?: number;
  119639. clickToPlay?: boolean;
  119640. autoPlay?: boolean;
  119641. loop?: boolean;
  119642. size?: number;
  119643. poster?: string;
  119644. faceForward?: boolean;
  119645. useDirectMapping?: boolean;
  119646. halfDomeMode?: boolean;
  119647. }, scene: Scene);
  119648. private _changeVideoMode;
  119649. /**
  119650. * Releases resources associated with this node.
  119651. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  119652. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  119653. */
  119654. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  119655. }
  119656. }
  119657. declare module BABYLON {
  119658. /**
  119659. * This class can be used to get instrumentation data from a Babylon engine
  119660. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  119661. */
  119662. export class EngineInstrumentation implements IDisposable {
  119663. /**
  119664. * Define the instrumented engine.
  119665. */
  119666. engine: Engine;
  119667. private _captureGPUFrameTime;
  119668. private _gpuFrameTimeToken;
  119669. private _gpuFrameTime;
  119670. private _captureShaderCompilationTime;
  119671. private _shaderCompilationTime;
  119672. private _onBeginFrameObserver;
  119673. private _onEndFrameObserver;
  119674. private _onBeforeShaderCompilationObserver;
  119675. private _onAfterShaderCompilationObserver;
  119676. /**
  119677. * Gets the perf counter used for GPU frame time
  119678. */
  119679. readonly gpuFrameTimeCounter: PerfCounter;
  119680. /**
  119681. * Gets the GPU frame time capture status
  119682. */
  119683. /**
  119684. * Enable or disable the GPU frame time capture
  119685. */
  119686. captureGPUFrameTime: boolean;
  119687. /**
  119688. * Gets the perf counter used for shader compilation time
  119689. */
  119690. readonly shaderCompilationTimeCounter: PerfCounter;
  119691. /**
  119692. * Gets the shader compilation time capture status
  119693. */
  119694. /**
  119695. * Enable or disable the shader compilation time capture
  119696. */
  119697. captureShaderCompilationTime: boolean;
  119698. /**
  119699. * Instantiates a new engine instrumentation.
  119700. * This class can be used to get instrumentation data from a Babylon engine
  119701. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  119702. * @param engine Defines the engine to instrument
  119703. */
  119704. constructor(
  119705. /**
  119706. * Define the instrumented engine.
  119707. */
  119708. engine: Engine);
  119709. /**
  119710. * Dispose and release associated resources.
  119711. */
  119712. dispose(): void;
  119713. }
  119714. }
  119715. declare module BABYLON {
  119716. /**
  119717. * This class can be used to get instrumentation data from a Babylon engine
  119718. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  119719. */
  119720. export class SceneInstrumentation implements IDisposable {
  119721. /**
  119722. * Defines the scene to instrument
  119723. */
  119724. scene: Scene;
  119725. private _captureActiveMeshesEvaluationTime;
  119726. private _activeMeshesEvaluationTime;
  119727. private _captureRenderTargetsRenderTime;
  119728. private _renderTargetsRenderTime;
  119729. private _captureFrameTime;
  119730. private _frameTime;
  119731. private _captureRenderTime;
  119732. private _renderTime;
  119733. private _captureInterFrameTime;
  119734. private _interFrameTime;
  119735. private _captureParticlesRenderTime;
  119736. private _particlesRenderTime;
  119737. private _captureSpritesRenderTime;
  119738. private _spritesRenderTime;
  119739. private _capturePhysicsTime;
  119740. private _physicsTime;
  119741. private _captureAnimationsTime;
  119742. private _animationsTime;
  119743. private _captureCameraRenderTime;
  119744. private _cameraRenderTime;
  119745. private _onBeforeActiveMeshesEvaluationObserver;
  119746. private _onAfterActiveMeshesEvaluationObserver;
  119747. private _onBeforeRenderTargetsRenderObserver;
  119748. private _onAfterRenderTargetsRenderObserver;
  119749. private _onAfterRenderObserver;
  119750. private _onBeforeDrawPhaseObserver;
  119751. private _onAfterDrawPhaseObserver;
  119752. private _onBeforeAnimationsObserver;
  119753. private _onBeforeParticlesRenderingObserver;
  119754. private _onAfterParticlesRenderingObserver;
  119755. private _onBeforeSpritesRenderingObserver;
  119756. private _onAfterSpritesRenderingObserver;
  119757. private _onBeforePhysicsObserver;
  119758. private _onAfterPhysicsObserver;
  119759. private _onAfterAnimationsObserver;
  119760. private _onBeforeCameraRenderObserver;
  119761. private _onAfterCameraRenderObserver;
  119762. /**
  119763. * Gets the perf counter used for active meshes evaluation time
  119764. */
  119765. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  119766. /**
  119767. * Gets the active meshes evaluation time capture status
  119768. */
  119769. /**
  119770. * Enable or disable the active meshes evaluation time capture
  119771. */
  119772. captureActiveMeshesEvaluationTime: boolean;
  119773. /**
  119774. * Gets the perf counter used for render targets render time
  119775. */
  119776. readonly renderTargetsRenderTimeCounter: PerfCounter;
  119777. /**
  119778. * Gets the render targets render time capture status
  119779. */
  119780. /**
  119781. * Enable or disable the render targets render time capture
  119782. */
  119783. captureRenderTargetsRenderTime: boolean;
  119784. /**
  119785. * Gets the perf counter used for particles render time
  119786. */
  119787. readonly particlesRenderTimeCounter: PerfCounter;
  119788. /**
  119789. * Gets the particles render time capture status
  119790. */
  119791. /**
  119792. * Enable or disable the particles render time capture
  119793. */
  119794. captureParticlesRenderTime: boolean;
  119795. /**
  119796. * Gets the perf counter used for sprites render time
  119797. */
  119798. readonly spritesRenderTimeCounter: PerfCounter;
  119799. /**
  119800. * Gets the sprites render time capture status
  119801. */
  119802. /**
  119803. * Enable or disable the sprites render time capture
  119804. */
  119805. captureSpritesRenderTime: boolean;
  119806. /**
  119807. * Gets the perf counter used for physics time
  119808. */
  119809. readonly physicsTimeCounter: PerfCounter;
  119810. /**
  119811. * Gets the physics time capture status
  119812. */
  119813. /**
  119814. * Enable or disable the physics time capture
  119815. */
  119816. capturePhysicsTime: boolean;
  119817. /**
  119818. * Gets the perf counter used for animations time
  119819. */
  119820. readonly animationsTimeCounter: PerfCounter;
  119821. /**
  119822. * Gets the animations time capture status
  119823. */
  119824. /**
  119825. * Enable or disable the animations time capture
  119826. */
  119827. captureAnimationsTime: boolean;
  119828. /**
  119829. * Gets the perf counter used for frame time capture
  119830. */
  119831. readonly frameTimeCounter: PerfCounter;
  119832. /**
  119833. * Gets the frame time capture status
  119834. */
  119835. /**
  119836. * Enable or disable the frame time capture
  119837. */
  119838. captureFrameTime: boolean;
  119839. /**
  119840. * Gets the perf counter used for inter-frames time capture
  119841. */
  119842. readonly interFrameTimeCounter: PerfCounter;
  119843. /**
  119844. * Gets the inter-frames time capture status
  119845. */
  119846. /**
  119847. * Enable or disable the inter-frames time capture
  119848. */
  119849. captureInterFrameTime: boolean;
  119850. /**
  119851. * Gets the perf counter used for render time capture
  119852. */
  119853. readonly renderTimeCounter: PerfCounter;
  119854. /**
  119855. * Gets the render time capture status
  119856. */
  119857. /**
  119858. * Enable or disable the render time capture
  119859. */
  119860. captureRenderTime: boolean;
  119861. /**
  119862. * Gets the perf counter used for camera render time capture
  119863. */
  119864. readonly cameraRenderTimeCounter: PerfCounter;
  119865. /**
  119866. * Gets the camera render time capture status
  119867. */
  119868. /**
  119869. * Enable or disable the camera render time capture
  119870. */
  119871. captureCameraRenderTime: boolean;
  119872. /**
  119873. * Gets the perf counter used for draw calls
  119874. */
  119875. readonly drawCallsCounter: PerfCounter;
  119876. /**
  119877. * Instantiates a new scene instrumentation.
  119878. * This class can be used to get instrumentation data from a Babylon engine
  119879. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  119880. * @param scene Defines the scene to instrument
  119881. */
  119882. constructor(
  119883. /**
  119884. * Defines the scene to instrument
  119885. */
  119886. scene: Scene);
  119887. /**
  119888. * Dispose and release associated resources.
  119889. */
  119890. dispose(): void;
  119891. }
  119892. }
  119893. declare module BABYLON {
  119894. /** @hidden */
  119895. export var glowMapGenerationPixelShader: {
  119896. name: string;
  119897. shader: string;
  119898. };
  119899. }
  119900. declare module BABYLON {
  119901. /** @hidden */
  119902. export var glowMapGenerationVertexShader: {
  119903. name: string;
  119904. shader: string;
  119905. };
  119906. }
  119907. declare module BABYLON {
  119908. /**
  119909. * Effect layer options. This helps customizing the behaviour
  119910. * of the effect layer.
  119911. */
  119912. export interface IEffectLayerOptions {
  119913. /**
  119914. * Multiplication factor apply to the canvas size to compute the render target size
  119915. * used to generated the objects (the smaller the faster).
  119916. */
  119917. mainTextureRatio: number;
  119918. /**
  119919. * Enforces a fixed size texture to ensure effect stability across devices.
  119920. */
  119921. mainTextureFixedSize?: number;
  119922. /**
  119923. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  119924. */
  119925. alphaBlendingMode: number;
  119926. /**
  119927. * The camera attached to the layer.
  119928. */
  119929. camera: Nullable<Camera>;
  119930. /**
  119931. * The rendering group to draw the layer in.
  119932. */
  119933. renderingGroupId: number;
  119934. }
  119935. /**
  119936. * The effect layer Helps adding post process effect blended with the main pass.
  119937. *
  119938. * This can be for instance use to generate glow or higlight effects on the scene.
  119939. *
  119940. * The effect layer class can not be used directly and is intented to inherited from to be
  119941. * customized per effects.
  119942. */
  119943. export abstract class EffectLayer {
  119944. private _vertexBuffers;
  119945. private _indexBuffer;
  119946. private _cachedDefines;
  119947. private _effectLayerMapGenerationEffect;
  119948. private _effectLayerOptions;
  119949. private _mergeEffect;
  119950. protected _scene: Scene;
  119951. protected _engine: Engine;
  119952. protected _maxSize: number;
  119953. protected _mainTextureDesiredSize: ISize;
  119954. protected _mainTexture: RenderTargetTexture;
  119955. protected _shouldRender: boolean;
  119956. protected _postProcesses: PostProcess[];
  119957. protected _textures: BaseTexture[];
  119958. protected _emissiveTextureAndColor: {
  119959. texture: Nullable<BaseTexture>;
  119960. color: Color4;
  119961. };
  119962. /**
  119963. * The name of the layer
  119964. */
  119965. name: string;
  119966. /**
  119967. * The clear color of the texture used to generate the glow map.
  119968. */
  119969. neutralColor: Color4;
  119970. /**
  119971. * Specifies wether the highlight layer is enabled or not.
  119972. */
  119973. isEnabled: boolean;
  119974. /**
  119975. * Gets the camera attached to the layer.
  119976. */
  119977. readonly camera: Nullable<Camera>;
  119978. /**
  119979. * Gets the rendering group id the layer should render in.
  119980. */
  119981. renderingGroupId: number;
  119982. /**
  119983. * An event triggered when the effect layer has been disposed.
  119984. */
  119985. onDisposeObservable: Observable<EffectLayer>;
  119986. /**
  119987. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  119988. */
  119989. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  119990. /**
  119991. * An event triggered when the generated texture is being merged in the scene.
  119992. */
  119993. onBeforeComposeObservable: Observable<EffectLayer>;
  119994. /**
  119995. * An event triggered when the mesh is rendered into the effect render target.
  119996. */
  119997. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  119998. /**
  119999. * An event triggered after the mesh has been rendered into the effect render target.
  120000. */
  120001. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  120002. /**
  120003. * An event triggered when the generated texture has been merged in the scene.
  120004. */
  120005. onAfterComposeObservable: Observable<EffectLayer>;
  120006. /**
  120007. * An event triggered when the efffect layer changes its size.
  120008. */
  120009. onSizeChangedObservable: Observable<EffectLayer>;
  120010. /** @hidden */
  120011. static _SceneComponentInitialization: (scene: Scene) => void;
  120012. /**
  120013. * Instantiates a new effect Layer and references it in the scene.
  120014. * @param name The name of the layer
  120015. * @param scene The scene to use the layer in
  120016. */
  120017. constructor(
  120018. /** The Friendly of the effect in the scene */
  120019. name: string, scene: Scene);
  120020. /**
  120021. * Get the effect name of the layer.
  120022. * @return The effect name
  120023. */
  120024. abstract getEffectName(): string;
  120025. /**
  120026. * Checks for the readiness of the element composing the layer.
  120027. * @param subMesh the mesh to check for
  120028. * @param useInstances specify wether or not to use instances to render the mesh
  120029. * @return true if ready otherwise, false
  120030. */
  120031. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120032. /**
  120033. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  120034. * @returns true if the effect requires stencil during the main canvas render pass.
  120035. */
  120036. abstract needStencil(): boolean;
  120037. /**
  120038. * Create the merge effect. This is the shader use to blit the information back
  120039. * to the main canvas at the end of the scene rendering.
  120040. * @returns The effect containing the shader used to merge the effect on the main canvas
  120041. */
  120042. protected abstract _createMergeEffect(): Effect;
  120043. /**
  120044. * Creates the render target textures and post processes used in the effect layer.
  120045. */
  120046. protected abstract _createTextureAndPostProcesses(): void;
  120047. /**
  120048. * Implementation specific of rendering the generating effect on the main canvas.
  120049. * @param effect The effect used to render through
  120050. */
  120051. protected abstract _internalRender(effect: Effect): void;
  120052. /**
  120053. * Sets the required values for both the emissive texture and and the main color.
  120054. */
  120055. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  120056. /**
  120057. * Free any resources and references associated to a mesh.
  120058. * Internal use
  120059. * @param mesh The mesh to free.
  120060. */
  120061. abstract _disposeMesh(mesh: Mesh): void;
  120062. /**
  120063. * Serializes this layer (Glow or Highlight for example)
  120064. * @returns a serialized layer object
  120065. */
  120066. abstract serialize?(): any;
  120067. /**
  120068. * Initializes the effect layer with the required options.
  120069. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  120070. */
  120071. protected _init(options: Partial<IEffectLayerOptions>): void;
  120072. /**
  120073. * Generates the index buffer of the full screen quad blending to the main canvas.
  120074. */
  120075. private _generateIndexBuffer;
  120076. /**
  120077. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  120078. */
  120079. private _generateVertexBuffer;
  120080. /**
  120081. * Sets the main texture desired size which is the closest power of two
  120082. * of the engine canvas size.
  120083. */
  120084. private _setMainTextureSize;
  120085. /**
  120086. * Creates the main texture for the effect layer.
  120087. */
  120088. protected _createMainTexture(): void;
  120089. /**
  120090. * Adds specific effects defines.
  120091. * @param defines The defines to add specifics to.
  120092. */
  120093. protected _addCustomEffectDefines(defines: string[]): void;
  120094. /**
  120095. * Checks for the readiness of the element composing the layer.
  120096. * @param subMesh the mesh to check for
  120097. * @param useInstances specify wether or not to use instances to render the mesh
  120098. * @param emissiveTexture the associated emissive texture used to generate the glow
  120099. * @return true if ready otherwise, false
  120100. */
  120101. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  120102. /**
  120103. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  120104. */
  120105. render(): void;
  120106. /**
  120107. * Determine if a given mesh will be used in the current effect.
  120108. * @param mesh mesh to test
  120109. * @returns true if the mesh will be used
  120110. */
  120111. hasMesh(mesh: AbstractMesh): boolean;
  120112. /**
  120113. * Returns true if the layer contains information to display, otherwise false.
  120114. * @returns true if the glow layer should be rendered
  120115. */
  120116. shouldRender(): boolean;
  120117. /**
  120118. * Returns true if the mesh should render, otherwise false.
  120119. * @param mesh The mesh to render
  120120. * @returns true if it should render otherwise false
  120121. */
  120122. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  120123. /**
  120124. * Returns true if the mesh can be rendered, otherwise false.
  120125. * @param mesh The mesh to render
  120126. * @param material The material used on the mesh
  120127. * @returns true if it can be rendered otherwise false
  120128. */
  120129. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  120130. /**
  120131. * Returns true if the mesh should render, otherwise false.
  120132. * @param mesh The mesh to render
  120133. * @returns true if it should render otherwise false
  120134. */
  120135. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  120136. /**
  120137. * Renders the submesh passed in parameter to the generation map.
  120138. */
  120139. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  120140. /**
  120141. * Defines wether the current material of the mesh should be use to render the effect.
  120142. * @param mesh defines the current mesh to render
  120143. */
  120144. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  120145. /**
  120146. * Rebuild the required buffers.
  120147. * @hidden Internal use only.
  120148. */
  120149. _rebuild(): void;
  120150. /**
  120151. * Dispose only the render target textures and post process.
  120152. */
  120153. private _disposeTextureAndPostProcesses;
  120154. /**
  120155. * Dispose the highlight layer and free resources.
  120156. */
  120157. dispose(): void;
  120158. /**
  120159. * Gets the class name of the effect layer
  120160. * @returns the string with the class name of the effect layer
  120161. */
  120162. getClassName(): string;
  120163. /**
  120164. * Creates an effect layer from parsed effect layer data
  120165. * @param parsedEffectLayer defines effect layer data
  120166. * @param scene defines the current scene
  120167. * @param rootUrl defines the root URL containing the effect layer information
  120168. * @returns a parsed effect Layer
  120169. */
  120170. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  120171. }
  120172. }
  120173. declare module BABYLON {
  120174. interface AbstractScene {
  120175. /**
  120176. * The list of effect layers (highlights/glow) added to the scene
  120177. * @see http://doc.babylonjs.com/how_to/highlight_layer
  120178. * @see http://doc.babylonjs.com/how_to/glow_layer
  120179. */
  120180. effectLayers: Array<EffectLayer>;
  120181. /**
  120182. * Removes the given effect layer from this scene.
  120183. * @param toRemove defines the effect layer to remove
  120184. * @returns the index of the removed effect layer
  120185. */
  120186. removeEffectLayer(toRemove: EffectLayer): number;
  120187. /**
  120188. * Adds the given effect layer to this scene
  120189. * @param newEffectLayer defines the effect layer to add
  120190. */
  120191. addEffectLayer(newEffectLayer: EffectLayer): void;
  120192. }
  120193. /**
  120194. * Defines the layer scene component responsible to manage any effect layers
  120195. * in a given scene.
  120196. */
  120197. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  120198. /**
  120199. * The component name helpfull to identify the component in the list of scene components.
  120200. */
  120201. readonly name: string;
  120202. /**
  120203. * The scene the component belongs to.
  120204. */
  120205. scene: Scene;
  120206. private _engine;
  120207. private _renderEffects;
  120208. private _needStencil;
  120209. private _previousStencilState;
  120210. /**
  120211. * Creates a new instance of the component for the given scene
  120212. * @param scene Defines the scene to register the component in
  120213. */
  120214. constructor(scene: Scene);
  120215. /**
  120216. * Registers the component in a given scene
  120217. */
  120218. register(): void;
  120219. /**
  120220. * Rebuilds the elements related to this component in case of
  120221. * context lost for instance.
  120222. */
  120223. rebuild(): void;
  120224. /**
  120225. * Serializes the component data to the specified json object
  120226. * @param serializationObject The object to serialize to
  120227. */
  120228. serialize(serializationObject: any): void;
  120229. /**
  120230. * Adds all the elements from the container to the scene
  120231. * @param container the container holding the elements
  120232. */
  120233. addFromContainer(container: AbstractScene): void;
  120234. /**
  120235. * Removes all the elements in the container from the scene
  120236. * @param container contains the elements to remove
  120237. * @param dispose if the removed element should be disposed (default: false)
  120238. */
  120239. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120240. /**
  120241. * Disposes the component and the associated ressources.
  120242. */
  120243. dispose(): void;
  120244. private _isReadyForMesh;
  120245. private _renderMainTexture;
  120246. private _setStencil;
  120247. private _setStencilBack;
  120248. private _draw;
  120249. private _drawCamera;
  120250. private _drawRenderingGroup;
  120251. }
  120252. }
  120253. declare module BABYLON {
  120254. /** @hidden */
  120255. export var glowMapMergePixelShader: {
  120256. name: string;
  120257. shader: string;
  120258. };
  120259. }
  120260. declare module BABYLON {
  120261. /** @hidden */
  120262. export var glowMapMergeVertexShader: {
  120263. name: string;
  120264. shader: string;
  120265. };
  120266. }
  120267. declare module BABYLON {
  120268. interface AbstractScene {
  120269. /**
  120270. * Return a the first highlight layer of the scene with a given name.
  120271. * @param name The name of the highlight layer to look for.
  120272. * @return The highlight layer if found otherwise null.
  120273. */
  120274. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  120275. }
  120276. /**
  120277. * Glow layer options. This helps customizing the behaviour
  120278. * of the glow layer.
  120279. */
  120280. export interface IGlowLayerOptions {
  120281. /**
  120282. * Multiplication factor apply to the canvas size to compute the render target size
  120283. * used to generated the glowing objects (the smaller the faster).
  120284. */
  120285. mainTextureRatio: number;
  120286. /**
  120287. * Enforces a fixed size texture to ensure resize independant blur.
  120288. */
  120289. mainTextureFixedSize?: number;
  120290. /**
  120291. * How big is the kernel of the blur texture.
  120292. */
  120293. blurKernelSize: number;
  120294. /**
  120295. * The camera attached to the layer.
  120296. */
  120297. camera: Nullable<Camera>;
  120298. /**
  120299. * Enable MSAA by chosing the number of samples.
  120300. */
  120301. mainTextureSamples?: number;
  120302. /**
  120303. * The rendering group to draw the layer in.
  120304. */
  120305. renderingGroupId: number;
  120306. }
  120307. /**
  120308. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  120309. *
  120310. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  120311. *
  120312. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  120313. */
  120314. export class GlowLayer extends EffectLayer {
  120315. /**
  120316. * Effect Name of the layer.
  120317. */
  120318. static readonly EffectName: string;
  120319. /**
  120320. * The default blur kernel size used for the glow.
  120321. */
  120322. static DefaultBlurKernelSize: number;
  120323. /**
  120324. * The default texture size ratio used for the glow.
  120325. */
  120326. static DefaultTextureRatio: number;
  120327. /**
  120328. * Sets the kernel size of the blur.
  120329. */
  120330. /**
  120331. * Gets the kernel size of the blur.
  120332. */
  120333. blurKernelSize: number;
  120334. /**
  120335. * Sets the glow intensity.
  120336. */
  120337. /**
  120338. * Gets the glow intensity.
  120339. */
  120340. intensity: number;
  120341. private _options;
  120342. private _intensity;
  120343. private _horizontalBlurPostprocess1;
  120344. private _verticalBlurPostprocess1;
  120345. private _horizontalBlurPostprocess2;
  120346. private _verticalBlurPostprocess2;
  120347. private _blurTexture1;
  120348. private _blurTexture2;
  120349. private _postProcesses1;
  120350. private _postProcesses2;
  120351. private _includedOnlyMeshes;
  120352. private _excludedMeshes;
  120353. private _meshesUsingTheirOwnMaterials;
  120354. /**
  120355. * Callback used to let the user override the color selection on a per mesh basis
  120356. */
  120357. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  120358. /**
  120359. * Callback used to let the user override the texture selection on a per mesh basis
  120360. */
  120361. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  120362. /**
  120363. * Instantiates a new glow Layer and references it to the scene.
  120364. * @param name The name of the layer
  120365. * @param scene The scene to use the layer in
  120366. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  120367. */
  120368. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  120369. /**
  120370. * Get the effect name of the layer.
  120371. * @return The effect name
  120372. */
  120373. getEffectName(): string;
  120374. /**
  120375. * Create the merge effect. This is the shader use to blit the information back
  120376. * to the main canvas at the end of the scene rendering.
  120377. */
  120378. protected _createMergeEffect(): Effect;
  120379. /**
  120380. * Creates the render target textures and post processes used in the glow layer.
  120381. */
  120382. protected _createTextureAndPostProcesses(): void;
  120383. /**
  120384. * Checks for the readiness of the element composing the layer.
  120385. * @param subMesh the mesh to check for
  120386. * @param useInstances specify wether or not to use instances to render the mesh
  120387. * @param emissiveTexture the associated emissive texture used to generate the glow
  120388. * @return true if ready otherwise, false
  120389. */
  120390. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120391. /**
  120392. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  120393. */
  120394. needStencil(): boolean;
  120395. /**
  120396. * Returns true if the mesh can be rendered, otherwise false.
  120397. * @param mesh The mesh to render
  120398. * @param material The material used on the mesh
  120399. * @returns true if it can be rendered otherwise false
  120400. */
  120401. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  120402. /**
  120403. * Implementation specific of rendering the generating effect on the main canvas.
  120404. * @param effect The effect used to render through
  120405. */
  120406. protected _internalRender(effect: Effect): void;
  120407. /**
  120408. * Sets the required values for both the emissive texture and and the main color.
  120409. */
  120410. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  120411. /**
  120412. * Returns true if the mesh should render, otherwise false.
  120413. * @param mesh The mesh to render
  120414. * @returns true if it should render otherwise false
  120415. */
  120416. protected _shouldRenderMesh(mesh: Mesh): boolean;
  120417. /**
  120418. * Adds specific effects defines.
  120419. * @param defines The defines to add specifics to.
  120420. */
  120421. protected _addCustomEffectDefines(defines: string[]): void;
  120422. /**
  120423. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  120424. * @param mesh The mesh to exclude from the glow layer
  120425. */
  120426. addExcludedMesh(mesh: Mesh): void;
  120427. /**
  120428. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  120429. * @param mesh The mesh to remove
  120430. */
  120431. removeExcludedMesh(mesh: Mesh): void;
  120432. /**
  120433. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  120434. * @param mesh The mesh to include in the glow layer
  120435. */
  120436. addIncludedOnlyMesh(mesh: Mesh): void;
  120437. /**
  120438. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  120439. * @param mesh The mesh to remove
  120440. */
  120441. removeIncludedOnlyMesh(mesh: Mesh): void;
  120442. /**
  120443. * Determine if a given mesh will be used in the glow layer
  120444. * @param mesh The mesh to test
  120445. * @returns true if the mesh will be highlighted by the current glow layer
  120446. */
  120447. hasMesh(mesh: AbstractMesh): boolean;
  120448. /**
  120449. * Defines wether the current material of the mesh should be use to render the effect.
  120450. * @param mesh defines the current mesh to render
  120451. */
  120452. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  120453. /**
  120454. * Add a mesh to be rendered through its own material and not with emissive only.
  120455. * @param mesh The mesh for which we need to use its material
  120456. */
  120457. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  120458. /**
  120459. * Remove a mesh from being rendered through its own material and not with emissive only.
  120460. * @param mesh The mesh for which we need to not use its material
  120461. */
  120462. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  120463. /**
  120464. * Free any resources and references associated to a mesh.
  120465. * Internal use
  120466. * @param mesh The mesh to free.
  120467. * @hidden
  120468. */
  120469. _disposeMesh(mesh: Mesh): void;
  120470. /**
  120471. * Gets the class name of the effect layer
  120472. * @returns the string with the class name of the effect layer
  120473. */
  120474. getClassName(): string;
  120475. /**
  120476. * Serializes this glow layer
  120477. * @returns a serialized glow layer object
  120478. */
  120479. serialize(): any;
  120480. /**
  120481. * Creates a Glow Layer from parsed glow layer data
  120482. * @param parsedGlowLayer defines glow layer data
  120483. * @param scene defines the current scene
  120484. * @param rootUrl defines the root URL containing the glow layer information
  120485. * @returns a parsed Glow Layer
  120486. */
  120487. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  120488. }
  120489. }
  120490. declare module BABYLON {
  120491. /** @hidden */
  120492. export var glowBlurPostProcessPixelShader: {
  120493. name: string;
  120494. shader: string;
  120495. };
  120496. }
  120497. declare module BABYLON {
  120498. interface AbstractScene {
  120499. /**
  120500. * Return a the first highlight layer of the scene with a given name.
  120501. * @param name The name of the highlight layer to look for.
  120502. * @return The highlight layer if found otherwise null.
  120503. */
  120504. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  120505. }
  120506. /**
  120507. * Highlight layer options. This helps customizing the behaviour
  120508. * of the highlight layer.
  120509. */
  120510. export interface IHighlightLayerOptions {
  120511. /**
  120512. * Multiplication factor apply to the canvas size to compute the render target size
  120513. * used to generated the glowing objects (the smaller the faster).
  120514. */
  120515. mainTextureRatio: number;
  120516. /**
  120517. * Enforces a fixed size texture to ensure resize independant blur.
  120518. */
  120519. mainTextureFixedSize?: number;
  120520. /**
  120521. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  120522. * of the picture to blur (the smaller the faster).
  120523. */
  120524. blurTextureSizeRatio: number;
  120525. /**
  120526. * How big in texel of the blur texture is the vertical blur.
  120527. */
  120528. blurVerticalSize: number;
  120529. /**
  120530. * How big in texel of the blur texture is the horizontal blur.
  120531. */
  120532. blurHorizontalSize: number;
  120533. /**
  120534. * Alpha blending mode used to apply the blur. Default is combine.
  120535. */
  120536. alphaBlendingMode: number;
  120537. /**
  120538. * The camera attached to the layer.
  120539. */
  120540. camera: Nullable<Camera>;
  120541. /**
  120542. * Should we display highlight as a solid stroke?
  120543. */
  120544. isStroke?: boolean;
  120545. /**
  120546. * The rendering group to draw the layer in.
  120547. */
  120548. renderingGroupId: number;
  120549. }
  120550. /**
  120551. * The highlight layer Helps adding a glow effect around a mesh.
  120552. *
  120553. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  120554. * glowy meshes to your scene.
  120555. *
  120556. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  120557. */
  120558. export class HighlightLayer extends EffectLayer {
  120559. name: string;
  120560. /**
  120561. * Effect Name of the highlight layer.
  120562. */
  120563. static readonly EffectName: string;
  120564. /**
  120565. * The neutral color used during the preparation of the glow effect.
  120566. * This is black by default as the blend operation is a blend operation.
  120567. */
  120568. static NeutralColor: Color4;
  120569. /**
  120570. * Stencil value used for glowing meshes.
  120571. */
  120572. static GlowingMeshStencilReference: number;
  120573. /**
  120574. * Stencil value used for the other meshes in the scene.
  120575. */
  120576. static NormalMeshStencilReference: number;
  120577. /**
  120578. * Specifies whether or not the inner glow is ACTIVE in the layer.
  120579. */
  120580. innerGlow: boolean;
  120581. /**
  120582. * Specifies whether or not the outer glow is ACTIVE in the layer.
  120583. */
  120584. outerGlow: boolean;
  120585. /**
  120586. * Specifies the horizontal size of the blur.
  120587. */
  120588. /**
  120589. * Gets the horizontal size of the blur.
  120590. */
  120591. blurHorizontalSize: number;
  120592. /**
  120593. * Specifies the vertical size of the blur.
  120594. */
  120595. /**
  120596. * Gets the vertical size of the blur.
  120597. */
  120598. blurVerticalSize: number;
  120599. /**
  120600. * An event triggered when the highlight layer is being blurred.
  120601. */
  120602. onBeforeBlurObservable: Observable<HighlightLayer>;
  120603. /**
  120604. * An event triggered when the highlight layer has been blurred.
  120605. */
  120606. onAfterBlurObservable: Observable<HighlightLayer>;
  120607. private _instanceGlowingMeshStencilReference;
  120608. private _options;
  120609. private _downSamplePostprocess;
  120610. private _horizontalBlurPostprocess;
  120611. private _verticalBlurPostprocess;
  120612. private _blurTexture;
  120613. private _meshes;
  120614. private _excludedMeshes;
  120615. /**
  120616. * Instantiates a new highlight Layer and references it to the scene..
  120617. * @param name The name of the layer
  120618. * @param scene The scene to use the layer in
  120619. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  120620. */
  120621. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  120622. /**
  120623. * Get the effect name of the layer.
  120624. * @return The effect name
  120625. */
  120626. getEffectName(): string;
  120627. /**
  120628. * Create the merge effect. This is the shader use to blit the information back
  120629. * to the main canvas at the end of the scene rendering.
  120630. */
  120631. protected _createMergeEffect(): Effect;
  120632. /**
  120633. * Creates the render target textures and post processes used in the highlight layer.
  120634. */
  120635. protected _createTextureAndPostProcesses(): void;
  120636. /**
  120637. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  120638. */
  120639. needStencil(): boolean;
  120640. /**
  120641. * Checks for the readiness of the element composing the layer.
  120642. * @param subMesh the mesh to check for
  120643. * @param useInstances specify wether or not to use instances to render the mesh
  120644. * @param emissiveTexture the associated emissive texture used to generate the glow
  120645. * @return true if ready otherwise, false
  120646. */
  120647. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120648. /**
  120649. * Implementation specific of rendering the generating effect on the main canvas.
  120650. * @param effect The effect used to render through
  120651. */
  120652. protected _internalRender(effect: Effect): void;
  120653. /**
  120654. * Returns true if the layer contains information to display, otherwise false.
  120655. */
  120656. shouldRender(): boolean;
  120657. /**
  120658. * Returns true if the mesh should render, otherwise false.
  120659. * @param mesh The mesh to render
  120660. * @returns true if it should render otherwise false
  120661. */
  120662. protected _shouldRenderMesh(mesh: Mesh): boolean;
  120663. /**
  120664. * Sets the required values for both the emissive texture and and the main color.
  120665. */
  120666. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  120667. /**
  120668. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  120669. * @param mesh The mesh to exclude from the highlight layer
  120670. */
  120671. addExcludedMesh(mesh: Mesh): void;
  120672. /**
  120673. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  120674. * @param mesh The mesh to highlight
  120675. */
  120676. removeExcludedMesh(mesh: Mesh): void;
  120677. /**
  120678. * Determine if a given mesh will be highlighted by the current HighlightLayer
  120679. * @param mesh mesh to test
  120680. * @returns true if the mesh will be highlighted by the current HighlightLayer
  120681. */
  120682. hasMesh(mesh: AbstractMesh): boolean;
  120683. /**
  120684. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  120685. * @param mesh The mesh to highlight
  120686. * @param color The color of the highlight
  120687. * @param glowEmissiveOnly Extract the glow from the emissive texture
  120688. */
  120689. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  120690. /**
  120691. * Remove a mesh from the highlight layer in order to make it stop glowing.
  120692. * @param mesh The mesh to highlight
  120693. */
  120694. removeMesh(mesh: Mesh): void;
  120695. /**
  120696. * Force the stencil to the normal expected value for none glowing parts
  120697. */
  120698. private _defaultStencilReference;
  120699. /**
  120700. * Free any resources and references associated to a mesh.
  120701. * Internal use
  120702. * @param mesh The mesh to free.
  120703. * @hidden
  120704. */
  120705. _disposeMesh(mesh: Mesh): void;
  120706. /**
  120707. * Dispose the highlight layer and free resources.
  120708. */
  120709. dispose(): void;
  120710. /**
  120711. * Gets the class name of the effect layer
  120712. * @returns the string with the class name of the effect layer
  120713. */
  120714. getClassName(): string;
  120715. /**
  120716. * Serializes this Highlight layer
  120717. * @returns a serialized Highlight layer object
  120718. */
  120719. serialize(): any;
  120720. /**
  120721. * Creates a Highlight layer from parsed Highlight layer data
  120722. * @param parsedHightlightLayer defines the Highlight layer data
  120723. * @param scene defines the current scene
  120724. * @param rootUrl defines the root URL containing the Highlight layer information
  120725. * @returns a parsed Highlight layer
  120726. */
  120727. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  120728. }
  120729. }
  120730. declare module BABYLON {
  120731. interface AbstractScene {
  120732. /**
  120733. * The list of layers (background and foreground) of the scene
  120734. */
  120735. layers: Array<Layer>;
  120736. }
  120737. /**
  120738. * Defines the layer scene component responsible to manage any layers
  120739. * in a given scene.
  120740. */
  120741. export class LayerSceneComponent implements ISceneComponent {
  120742. /**
  120743. * The component name helpfull to identify the component in the list of scene components.
  120744. */
  120745. readonly name: string;
  120746. /**
  120747. * The scene the component belongs to.
  120748. */
  120749. scene: Scene;
  120750. private _engine;
  120751. /**
  120752. * Creates a new instance of the component for the given scene
  120753. * @param scene Defines the scene to register the component in
  120754. */
  120755. constructor(scene: Scene);
  120756. /**
  120757. * Registers the component in a given scene
  120758. */
  120759. register(): void;
  120760. /**
  120761. * Rebuilds the elements related to this component in case of
  120762. * context lost for instance.
  120763. */
  120764. rebuild(): void;
  120765. /**
  120766. * Disposes the component and the associated ressources.
  120767. */
  120768. dispose(): void;
  120769. private _draw;
  120770. private _drawCameraPredicate;
  120771. private _drawCameraBackground;
  120772. private _drawCameraForeground;
  120773. private _drawRenderTargetPredicate;
  120774. private _drawRenderTargetBackground;
  120775. private _drawRenderTargetForeground;
  120776. /**
  120777. * Adds all the elements from the container to the scene
  120778. * @param container the container holding the elements
  120779. */
  120780. addFromContainer(container: AbstractScene): void;
  120781. /**
  120782. * Removes all the elements in the container from the scene
  120783. * @param container contains the elements to remove
  120784. * @param dispose if the removed element should be disposed (default: false)
  120785. */
  120786. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120787. }
  120788. }
  120789. declare module BABYLON {
  120790. /** @hidden */
  120791. export var layerPixelShader: {
  120792. name: string;
  120793. shader: string;
  120794. };
  120795. }
  120796. declare module BABYLON {
  120797. /** @hidden */
  120798. export var layerVertexShader: {
  120799. name: string;
  120800. shader: string;
  120801. };
  120802. }
  120803. declare module BABYLON {
  120804. /**
  120805. * This represents a full screen 2d layer.
  120806. * This can be useful to display a picture in the background of your scene for instance.
  120807. * @see https://www.babylonjs-playground.com/#08A2BS#1
  120808. */
  120809. export class Layer {
  120810. /**
  120811. * Define the name of the layer.
  120812. */
  120813. name: string;
  120814. /**
  120815. * Define the texture the layer should display.
  120816. */
  120817. texture: Nullable<Texture>;
  120818. /**
  120819. * Is the layer in background or foreground.
  120820. */
  120821. isBackground: boolean;
  120822. /**
  120823. * Define the color of the layer (instead of texture).
  120824. */
  120825. color: Color4;
  120826. /**
  120827. * Define the scale of the layer in order to zoom in out of the texture.
  120828. */
  120829. scale: Vector2;
  120830. /**
  120831. * Define an offset for the layer in order to shift the texture.
  120832. */
  120833. offset: Vector2;
  120834. /**
  120835. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  120836. */
  120837. alphaBlendingMode: number;
  120838. /**
  120839. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  120840. * Alpha test will not mix with the background color in case of transparency.
  120841. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  120842. */
  120843. alphaTest: boolean;
  120844. /**
  120845. * Define a mask to restrict the layer to only some of the scene cameras.
  120846. */
  120847. layerMask: number;
  120848. /**
  120849. * Define the list of render target the layer is visible into.
  120850. */
  120851. renderTargetTextures: RenderTargetTexture[];
  120852. /**
  120853. * Define if the layer is only used in renderTarget or if it also
  120854. * renders in the main frame buffer of the canvas.
  120855. */
  120856. renderOnlyInRenderTargetTextures: boolean;
  120857. private _scene;
  120858. private _vertexBuffers;
  120859. private _indexBuffer;
  120860. private _effect;
  120861. private _previousDefines;
  120862. /**
  120863. * An event triggered when the layer is disposed.
  120864. */
  120865. onDisposeObservable: Observable<Layer>;
  120866. private _onDisposeObserver;
  120867. /**
  120868. * Back compatibility with callback before the onDisposeObservable existed.
  120869. * The set callback will be triggered when the layer has been disposed.
  120870. */
  120871. onDispose: () => void;
  120872. /**
  120873. * An event triggered before rendering the scene
  120874. */
  120875. onBeforeRenderObservable: Observable<Layer>;
  120876. private _onBeforeRenderObserver;
  120877. /**
  120878. * Back compatibility with callback before the onBeforeRenderObservable existed.
  120879. * The set callback will be triggered just before rendering the layer.
  120880. */
  120881. onBeforeRender: () => void;
  120882. /**
  120883. * An event triggered after rendering the scene
  120884. */
  120885. onAfterRenderObservable: Observable<Layer>;
  120886. private _onAfterRenderObserver;
  120887. /**
  120888. * Back compatibility with callback before the onAfterRenderObservable existed.
  120889. * The set callback will be triggered just after rendering the layer.
  120890. */
  120891. onAfterRender: () => void;
  120892. /**
  120893. * Instantiates a new layer.
  120894. * This represents a full screen 2d layer.
  120895. * This can be useful to display a picture in the background of your scene for instance.
  120896. * @see https://www.babylonjs-playground.com/#08A2BS#1
  120897. * @param name Define the name of the layer in the scene
  120898. * @param imgUrl Define the url of the texture to display in the layer
  120899. * @param scene Define the scene the layer belongs to
  120900. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  120901. * @param color Defines a color for the layer
  120902. */
  120903. constructor(
  120904. /**
  120905. * Define the name of the layer.
  120906. */
  120907. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  120908. private _createIndexBuffer;
  120909. /** @hidden */
  120910. _rebuild(): void;
  120911. /**
  120912. * Renders the layer in the scene.
  120913. */
  120914. render(): void;
  120915. /**
  120916. * Disposes and releases the associated ressources.
  120917. */
  120918. dispose(): void;
  120919. }
  120920. }
  120921. declare module BABYLON {
  120922. /** @hidden */
  120923. export var lensFlarePixelShader: {
  120924. name: string;
  120925. shader: string;
  120926. };
  120927. }
  120928. declare module BABYLON {
  120929. /** @hidden */
  120930. export var lensFlareVertexShader: {
  120931. name: string;
  120932. shader: string;
  120933. };
  120934. }
  120935. declare module BABYLON {
  120936. /**
  120937. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  120938. * It is usually composed of several `lensFlare`.
  120939. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120940. */
  120941. export class LensFlareSystem {
  120942. /**
  120943. * Define the name of the lens flare system
  120944. */
  120945. name: string;
  120946. /**
  120947. * List of lens flares used in this system.
  120948. */
  120949. lensFlares: LensFlare[];
  120950. /**
  120951. * Define a limit from the border the lens flare can be visible.
  120952. */
  120953. borderLimit: number;
  120954. /**
  120955. * Define a viewport border we do not want to see the lens flare in.
  120956. */
  120957. viewportBorder: number;
  120958. /**
  120959. * Define a predicate which could limit the list of meshes able to occlude the effect.
  120960. */
  120961. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  120962. /**
  120963. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  120964. */
  120965. layerMask: number;
  120966. /**
  120967. * Define the id of the lens flare system in the scene.
  120968. * (equal to name by default)
  120969. */
  120970. id: string;
  120971. private _scene;
  120972. private _emitter;
  120973. private _vertexBuffers;
  120974. private _indexBuffer;
  120975. private _effect;
  120976. private _positionX;
  120977. private _positionY;
  120978. private _isEnabled;
  120979. /** @hidden */
  120980. static _SceneComponentInitialization: (scene: Scene) => void;
  120981. /**
  120982. * Instantiates a lens flare system.
  120983. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  120984. * It is usually composed of several `lensFlare`.
  120985. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120986. * @param name Define the name of the lens flare system in the scene
  120987. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  120988. * @param scene Define the scene the lens flare system belongs to
  120989. */
  120990. constructor(
  120991. /**
  120992. * Define the name of the lens flare system
  120993. */
  120994. name: string, emitter: any, scene: Scene);
  120995. /**
  120996. * Define if the lens flare system is enabled.
  120997. */
  120998. isEnabled: boolean;
  120999. /**
  121000. * Get the scene the effects belongs to.
  121001. * @returns the scene holding the lens flare system
  121002. */
  121003. getScene(): Scene;
  121004. /**
  121005. * Get the emitter of the lens flare system.
  121006. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  121007. * @returns the emitter of the lens flare system
  121008. */
  121009. getEmitter(): any;
  121010. /**
  121011. * Set the emitter of the lens flare system.
  121012. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  121013. * @param newEmitter Define the new emitter of the system
  121014. */
  121015. setEmitter(newEmitter: any): void;
  121016. /**
  121017. * Get the lens flare system emitter position.
  121018. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  121019. * @returns the position
  121020. */
  121021. getEmitterPosition(): Vector3;
  121022. /**
  121023. * @hidden
  121024. */
  121025. computeEffectivePosition(globalViewport: Viewport): boolean;
  121026. /** @hidden */
  121027. _isVisible(): boolean;
  121028. /**
  121029. * @hidden
  121030. */
  121031. render(): boolean;
  121032. /**
  121033. * Dispose and release the lens flare with its associated resources.
  121034. */
  121035. dispose(): void;
  121036. /**
  121037. * Parse a lens flare system from a JSON repressentation
  121038. * @param parsedLensFlareSystem Define the JSON to parse
  121039. * @param scene Define the scene the parsed system should be instantiated in
  121040. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  121041. * @returns the parsed system
  121042. */
  121043. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  121044. /**
  121045. * Serialize the current Lens Flare System into a JSON representation.
  121046. * @returns the serialized JSON
  121047. */
  121048. serialize(): any;
  121049. }
  121050. }
  121051. declare module BABYLON {
  121052. /**
  121053. * This represents one of the lens effect in a `lensFlareSystem`.
  121054. * It controls one of the indiviual texture used in the effect.
  121055. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  121056. */
  121057. export class LensFlare {
  121058. /**
  121059. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  121060. */
  121061. size: number;
  121062. /**
  121063. * 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.
  121064. */
  121065. position: number;
  121066. /**
  121067. * Define the lens color.
  121068. */
  121069. color: Color3;
  121070. /**
  121071. * Define the lens texture.
  121072. */
  121073. texture: Nullable<Texture>;
  121074. /**
  121075. * Define the alpha mode to render this particular lens.
  121076. */
  121077. alphaMode: number;
  121078. private _system;
  121079. /**
  121080. * Creates a new Lens Flare.
  121081. * This represents one of the lens effect in a `lensFlareSystem`.
  121082. * It controls one of the indiviual texture used in the effect.
  121083. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  121084. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  121085. * @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.
  121086. * @param color Define the lens color
  121087. * @param imgUrl Define the lens texture url
  121088. * @param system Define the `lensFlareSystem` this flare is part of
  121089. * @returns The newly created Lens Flare
  121090. */
  121091. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  121092. /**
  121093. * Instantiates a new Lens Flare.
  121094. * This represents one of the lens effect in a `lensFlareSystem`.
  121095. * It controls one of the indiviual texture used in the effect.
  121096. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  121097. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  121098. * @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.
  121099. * @param color Define the lens color
  121100. * @param imgUrl Define the lens texture url
  121101. * @param system Define the `lensFlareSystem` this flare is part of
  121102. */
  121103. constructor(
  121104. /**
  121105. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  121106. */
  121107. size: number,
  121108. /**
  121109. * 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.
  121110. */
  121111. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  121112. /**
  121113. * Dispose and release the lens flare with its associated resources.
  121114. */
  121115. dispose(): void;
  121116. }
  121117. }
  121118. declare module BABYLON {
  121119. interface AbstractScene {
  121120. /**
  121121. * The list of lens flare system added to the scene
  121122. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  121123. */
  121124. lensFlareSystems: Array<LensFlareSystem>;
  121125. /**
  121126. * Removes the given lens flare system from this scene.
  121127. * @param toRemove The lens flare system to remove
  121128. * @returns The index of the removed lens flare system
  121129. */
  121130. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  121131. /**
  121132. * Adds the given lens flare system to this scene
  121133. * @param newLensFlareSystem The lens flare system to add
  121134. */
  121135. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  121136. /**
  121137. * Gets a lens flare system using its name
  121138. * @param name defines the name to look for
  121139. * @returns the lens flare system or null if not found
  121140. */
  121141. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  121142. /**
  121143. * Gets a lens flare system using its id
  121144. * @param id defines the id to look for
  121145. * @returns the lens flare system or null if not found
  121146. */
  121147. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  121148. }
  121149. /**
  121150. * Defines the lens flare scene component responsible to manage any lens flares
  121151. * in a given scene.
  121152. */
  121153. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  121154. /**
  121155. * The component name helpfull to identify the component in the list of scene components.
  121156. */
  121157. readonly name: string;
  121158. /**
  121159. * The scene the component belongs to.
  121160. */
  121161. scene: Scene;
  121162. /**
  121163. * Creates a new instance of the component for the given scene
  121164. * @param scene Defines the scene to register the component in
  121165. */
  121166. constructor(scene: Scene);
  121167. /**
  121168. * Registers the component in a given scene
  121169. */
  121170. register(): void;
  121171. /**
  121172. * Rebuilds the elements related to this component in case of
  121173. * context lost for instance.
  121174. */
  121175. rebuild(): void;
  121176. /**
  121177. * Adds all the elements from the container to the scene
  121178. * @param container the container holding the elements
  121179. */
  121180. addFromContainer(container: AbstractScene): void;
  121181. /**
  121182. * Removes all the elements in the container from the scene
  121183. * @param container contains the elements to remove
  121184. * @param dispose if the removed element should be disposed (default: false)
  121185. */
  121186. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  121187. /**
  121188. * Serializes the component data to the specified json object
  121189. * @param serializationObject The object to serialize to
  121190. */
  121191. serialize(serializationObject: any): void;
  121192. /**
  121193. * Disposes the component and the associated ressources.
  121194. */
  121195. dispose(): void;
  121196. private _draw;
  121197. }
  121198. }
  121199. declare module BABYLON {
  121200. /**
  121201. * Defines the shadow generator component responsible to manage any shadow generators
  121202. * in a given scene.
  121203. */
  121204. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  121205. /**
  121206. * The component name helpfull to identify the component in the list of scene components.
  121207. */
  121208. readonly name: string;
  121209. /**
  121210. * The scene the component belongs to.
  121211. */
  121212. scene: Scene;
  121213. /**
  121214. * Creates a new instance of the component for the given scene
  121215. * @param scene Defines the scene to register the component in
  121216. */
  121217. constructor(scene: Scene);
  121218. /**
  121219. * Registers the component in a given scene
  121220. */
  121221. register(): void;
  121222. /**
  121223. * Rebuilds the elements related to this component in case of
  121224. * context lost for instance.
  121225. */
  121226. rebuild(): void;
  121227. /**
  121228. * Serializes the component data to the specified json object
  121229. * @param serializationObject The object to serialize to
  121230. */
  121231. serialize(serializationObject: any): void;
  121232. /**
  121233. * Adds all the elements from the container to the scene
  121234. * @param container the container holding the elements
  121235. */
  121236. addFromContainer(container: AbstractScene): void;
  121237. /**
  121238. * Removes all the elements in the container from the scene
  121239. * @param container contains the elements to remove
  121240. * @param dispose if the removed element should be disposed (default: false)
  121241. */
  121242. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  121243. /**
  121244. * Rebuilds the elements related to this component in case of
  121245. * context lost for instance.
  121246. */
  121247. dispose(): void;
  121248. private _gatherRenderTargets;
  121249. }
  121250. }
  121251. declare module BABYLON {
  121252. /**
  121253. * A point light is a light defined by an unique point in world space.
  121254. * The light is emitted in every direction from this point.
  121255. * A good example of a point light is a standard light bulb.
  121256. * Documentation: https://doc.babylonjs.com/babylon101/lights
  121257. */
  121258. export class PointLight extends ShadowLight {
  121259. private _shadowAngle;
  121260. /**
  121261. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  121262. * This specifies what angle the shadow will use to be created.
  121263. *
  121264. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  121265. */
  121266. /**
  121267. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  121268. * This specifies what angle the shadow will use to be created.
  121269. *
  121270. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  121271. */
  121272. shadowAngle: number;
  121273. /**
  121274. * Gets the direction if it has been set.
  121275. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  121276. */
  121277. /**
  121278. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  121279. */
  121280. direction: Vector3;
  121281. /**
  121282. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  121283. * A PointLight emits the light in every direction.
  121284. * It can cast shadows.
  121285. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  121286. * ```javascript
  121287. * var pointLight = new PointLight("pl", camera.position, scene);
  121288. * ```
  121289. * Documentation : https://doc.babylonjs.com/babylon101/lights
  121290. * @param name The light friendly name
  121291. * @param position The position of the point light in the scene
  121292. * @param scene The scene the lights belongs to
  121293. */
  121294. constructor(name: string, position: Vector3, scene: Scene);
  121295. /**
  121296. * Returns the string "PointLight"
  121297. * @returns the class name
  121298. */
  121299. getClassName(): string;
  121300. /**
  121301. * Returns the integer 0.
  121302. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  121303. */
  121304. getTypeID(): number;
  121305. /**
  121306. * Specifies wether or not the shadowmap should be a cube texture.
  121307. * @returns true if the shadowmap needs to be a cube texture.
  121308. */
  121309. needCube(): boolean;
  121310. /**
  121311. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  121312. * @param faceIndex The index of the face we are computed the direction to generate shadow
  121313. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  121314. */
  121315. getShadowDirection(faceIndex?: number): Vector3;
  121316. /**
  121317. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  121318. * - fov = PI / 2
  121319. * - aspect ratio : 1.0
  121320. * - z-near and far equal to the active camera minZ and maxZ.
  121321. * Returns the PointLight.
  121322. */
  121323. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121324. protected _buildUniformLayout(): void;
  121325. /**
  121326. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  121327. * @param effect The effect to update
  121328. * @param lightIndex The index of the light in the effect to update
  121329. * @returns The point light
  121330. */
  121331. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  121332. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  121333. /**
  121334. * Prepares the list of defines specific to the light type.
  121335. * @param defines the list of defines
  121336. * @param lightIndex defines the index of the light for the effect
  121337. */
  121338. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  121339. }
  121340. }
  121341. declare module BABYLON {
  121342. /**
  121343. * Header information of HDR texture files.
  121344. */
  121345. export interface HDRInfo {
  121346. /**
  121347. * The height of the texture in pixels.
  121348. */
  121349. height: number;
  121350. /**
  121351. * The width of the texture in pixels.
  121352. */
  121353. width: number;
  121354. /**
  121355. * The index of the beginning of the data in the binary file.
  121356. */
  121357. dataPosition: number;
  121358. }
  121359. /**
  121360. * This groups tools to convert HDR texture to native colors array.
  121361. */
  121362. export class HDRTools {
  121363. private static Ldexp;
  121364. private static Rgbe2float;
  121365. private static readStringLine;
  121366. /**
  121367. * Reads header information from an RGBE texture stored in a native array.
  121368. * More information on this format are available here:
  121369. * https://en.wikipedia.org/wiki/RGBE_image_format
  121370. *
  121371. * @param uint8array The binary file stored in native array.
  121372. * @return The header information.
  121373. */
  121374. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  121375. /**
  121376. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  121377. * This RGBE texture needs to store the information as a panorama.
  121378. *
  121379. * More information on this format are available here:
  121380. * https://en.wikipedia.org/wiki/RGBE_image_format
  121381. *
  121382. * @param buffer The binary file stored in an array buffer.
  121383. * @param size The expected size of the extracted cubemap.
  121384. * @return The Cube Map information.
  121385. */
  121386. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  121387. /**
  121388. * Returns the pixels data extracted from an RGBE texture.
  121389. * This pixels will be stored left to right up to down in the R G B order in one array.
  121390. *
  121391. * More information on this format are available here:
  121392. * https://en.wikipedia.org/wiki/RGBE_image_format
  121393. *
  121394. * @param uint8array The binary file stored in an array buffer.
  121395. * @param hdrInfo The header information of the file.
  121396. * @return The pixels data in RGB right to left up to down order.
  121397. */
  121398. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  121399. private static RGBE_ReadPixels_RLE;
  121400. }
  121401. }
  121402. declare module BABYLON {
  121403. /**
  121404. * This represents a texture coming from an HDR input.
  121405. *
  121406. * The only supported format is currently panorama picture stored in RGBE format.
  121407. * Example of such files can be found on HDRLib: http://hdrlib.com/
  121408. */
  121409. export class HDRCubeTexture extends BaseTexture {
  121410. private static _facesMapping;
  121411. private _generateHarmonics;
  121412. private _noMipmap;
  121413. private _textureMatrix;
  121414. private _size;
  121415. private _onLoad;
  121416. private _onError;
  121417. /**
  121418. * The texture URL.
  121419. */
  121420. url: string;
  121421. /**
  121422. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  121423. */
  121424. coordinatesMode: number;
  121425. protected _isBlocking: boolean;
  121426. /**
  121427. * Sets wether or not the texture is blocking during loading.
  121428. */
  121429. /**
  121430. * Gets wether or not the texture is blocking during loading.
  121431. */
  121432. isBlocking: boolean;
  121433. protected _rotationY: number;
  121434. /**
  121435. * Sets texture matrix rotation angle around Y axis in radians.
  121436. */
  121437. /**
  121438. * Gets texture matrix rotation angle around Y axis radians.
  121439. */
  121440. rotationY: number;
  121441. /**
  121442. * Gets or sets the center of the bounding box associated with the cube texture
  121443. * It must define where the camera used to render the texture was set
  121444. */
  121445. boundingBoxPosition: Vector3;
  121446. private _boundingBoxSize;
  121447. /**
  121448. * Gets or sets the size of the bounding box associated with the cube texture
  121449. * When defined, the cubemap will switch to local mode
  121450. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  121451. * @example https://www.babylonjs-playground.com/#RNASML
  121452. */
  121453. boundingBoxSize: Vector3;
  121454. /**
  121455. * Instantiates an HDRTexture from the following parameters.
  121456. *
  121457. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  121458. * @param scene The scene the texture will be used in
  121459. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  121460. * @param noMipmap Forces to not generate the mipmap if true
  121461. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  121462. * @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)
  121463. * @param reserved Reserved flag for internal use.
  121464. */
  121465. 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>);
  121466. /**
  121467. * Get the current class name of the texture useful for serialization or dynamic coding.
  121468. * @returns "HDRCubeTexture"
  121469. */
  121470. getClassName(): string;
  121471. /**
  121472. * Occurs when the file is raw .hdr file.
  121473. */
  121474. private loadTexture;
  121475. clone(): HDRCubeTexture;
  121476. delayLoad(): void;
  121477. /**
  121478. * Get the texture reflection matrix used to rotate/transform the reflection.
  121479. * @returns the reflection matrix
  121480. */
  121481. getReflectionTextureMatrix(): Matrix;
  121482. /**
  121483. * Set the texture reflection matrix used to rotate/transform the reflection.
  121484. * @param value Define the reflection matrix to set
  121485. */
  121486. setReflectionTextureMatrix(value: Matrix): void;
  121487. /**
  121488. * Parses a JSON representation of an HDR Texture in order to create the texture
  121489. * @param parsedTexture Define the JSON representation
  121490. * @param scene Define the scene the texture should be created in
  121491. * @param rootUrl Define the root url in case we need to load relative dependencies
  121492. * @returns the newly created texture after parsing
  121493. */
  121494. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  121495. serialize(): any;
  121496. }
  121497. }
  121498. declare module BABYLON {
  121499. /**
  121500. * Class used to control physics engine
  121501. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  121502. */
  121503. export class PhysicsEngine implements IPhysicsEngine {
  121504. private _physicsPlugin;
  121505. /**
  121506. * Global value used to control the smallest number supported by the simulation
  121507. */
  121508. static Epsilon: number;
  121509. private _impostors;
  121510. private _joints;
  121511. private _subTimeStep;
  121512. /**
  121513. * Gets the gravity vector used by the simulation
  121514. */
  121515. gravity: Vector3;
  121516. /**
  121517. * Factory used to create the default physics plugin.
  121518. * @returns The default physics plugin
  121519. */
  121520. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  121521. /**
  121522. * Creates a new Physics Engine
  121523. * @param gravity defines the gravity vector used by the simulation
  121524. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  121525. */
  121526. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  121527. /**
  121528. * Sets the gravity vector used by the simulation
  121529. * @param gravity defines the gravity vector to use
  121530. */
  121531. setGravity(gravity: Vector3): void;
  121532. /**
  121533. * Set the time step of the physics engine.
  121534. * Default is 1/60.
  121535. * To slow it down, enter 1/600 for example.
  121536. * To speed it up, 1/30
  121537. * @param newTimeStep defines the new timestep to apply to this world.
  121538. */
  121539. setTimeStep(newTimeStep?: number): void;
  121540. /**
  121541. * Get the time step of the physics engine.
  121542. * @returns the current time step
  121543. */
  121544. getTimeStep(): number;
  121545. /**
  121546. * Set the sub time step of the physics engine.
  121547. * Default is 0 meaning there is no sub steps
  121548. * To increase physics resolution precision, set a small value (like 1 ms)
  121549. * @param subTimeStep defines the new sub timestep used for physics resolution.
  121550. */
  121551. setSubTimeStep(subTimeStep?: number): void;
  121552. /**
  121553. * Get the sub time step of the physics engine.
  121554. * @returns the current sub time step
  121555. */
  121556. getSubTimeStep(): number;
  121557. /**
  121558. * Release all resources
  121559. */
  121560. dispose(): void;
  121561. /**
  121562. * Gets the name of the current physics plugin
  121563. * @returns the name of the plugin
  121564. */
  121565. getPhysicsPluginName(): string;
  121566. /**
  121567. * Adding a new impostor for the impostor tracking.
  121568. * This will be done by the impostor itself.
  121569. * @param impostor the impostor to add
  121570. */
  121571. addImpostor(impostor: PhysicsImpostor): void;
  121572. /**
  121573. * Remove an impostor from the engine.
  121574. * This impostor and its mesh will not longer be updated by the physics engine.
  121575. * @param impostor the impostor to remove
  121576. */
  121577. removeImpostor(impostor: PhysicsImpostor): void;
  121578. /**
  121579. * Add a joint to the physics engine
  121580. * @param mainImpostor defines the main impostor to which the joint is added.
  121581. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  121582. * @param joint defines the joint that will connect both impostors.
  121583. */
  121584. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  121585. /**
  121586. * Removes a joint from the simulation
  121587. * @param mainImpostor defines the impostor used with the joint
  121588. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  121589. * @param joint defines the joint to remove
  121590. */
  121591. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  121592. /**
  121593. * Called by the scene. No need to call it.
  121594. * @param delta defines the timespam between frames
  121595. */
  121596. _step(delta: number): void;
  121597. /**
  121598. * Gets the current plugin used to run the simulation
  121599. * @returns current plugin
  121600. */
  121601. getPhysicsPlugin(): IPhysicsEnginePlugin;
  121602. /**
  121603. * Gets the list of physic impostors
  121604. * @returns an array of PhysicsImpostor
  121605. */
  121606. getImpostors(): Array<PhysicsImpostor>;
  121607. /**
  121608. * Gets the impostor for a physics enabled object
  121609. * @param object defines the object impersonated by the impostor
  121610. * @returns the PhysicsImpostor or null if not found
  121611. */
  121612. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  121613. /**
  121614. * Gets the impostor for a physics body object
  121615. * @param body defines physics body used by the impostor
  121616. * @returns the PhysicsImpostor or null if not found
  121617. */
  121618. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  121619. /**
  121620. * Does a raycast in the physics world
  121621. * @param from when should the ray start?
  121622. * @param to when should the ray end?
  121623. * @returns PhysicsRaycastResult
  121624. */
  121625. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121626. }
  121627. }
  121628. declare module BABYLON {
  121629. /** @hidden */
  121630. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  121631. private _useDeltaForWorldStep;
  121632. world: any;
  121633. name: string;
  121634. private _physicsMaterials;
  121635. private _fixedTimeStep;
  121636. private _cannonRaycastResult;
  121637. private _raycastResult;
  121638. private _physicsBodysToRemoveAfterStep;
  121639. BJSCANNON: any;
  121640. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  121641. setGravity(gravity: Vector3): void;
  121642. setTimeStep(timeStep: number): void;
  121643. getTimeStep(): number;
  121644. executeStep(delta: number): void;
  121645. private _removeMarkedPhysicsBodiesFromWorld;
  121646. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121647. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121648. generatePhysicsBody(impostor: PhysicsImpostor): void;
  121649. private _processChildMeshes;
  121650. removePhysicsBody(impostor: PhysicsImpostor): void;
  121651. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  121652. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  121653. private _addMaterial;
  121654. private _checkWithEpsilon;
  121655. private _createShape;
  121656. private _createHeightmap;
  121657. private _minus90X;
  121658. private _plus90X;
  121659. private _tmpPosition;
  121660. private _tmpDeltaPosition;
  121661. private _tmpUnityRotation;
  121662. private _updatePhysicsBodyTransformation;
  121663. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  121664. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  121665. isSupported(): boolean;
  121666. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121667. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121668. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121669. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121670. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  121671. getBodyMass(impostor: PhysicsImpostor): number;
  121672. getBodyFriction(impostor: PhysicsImpostor): number;
  121673. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  121674. getBodyRestitution(impostor: PhysicsImpostor): number;
  121675. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  121676. sleepBody(impostor: PhysicsImpostor): void;
  121677. wakeUpBody(impostor: PhysicsImpostor): void;
  121678. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  121679. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  121680. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  121681. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  121682. getRadius(impostor: PhysicsImpostor): number;
  121683. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  121684. dispose(): void;
  121685. private _extendNamespace;
  121686. /**
  121687. * Does a raycast in the physics world
  121688. * @param from when should the ray start?
  121689. * @param to when should the ray end?
  121690. * @returns PhysicsRaycastResult
  121691. */
  121692. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121693. }
  121694. }
  121695. declare module BABYLON {
  121696. /** @hidden */
  121697. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  121698. world: any;
  121699. name: string;
  121700. BJSOIMO: any;
  121701. private _raycastResult;
  121702. constructor(iterations?: number, oimoInjection?: any);
  121703. setGravity(gravity: Vector3): void;
  121704. setTimeStep(timeStep: number): void;
  121705. getTimeStep(): number;
  121706. private _tmpImpostorsArray;
  121707. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  121708. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121709. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121710. generatePhysicsBody(impostor: PhysicsImpostor): void;
  121711. private _tmpPositionVector;
  121712. removePhysicsBody(impostor: PhysicsImpostor): void;
  121713. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  121714. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  121715. isSupported(): boolean;
  121716. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  121717. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  121718. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121719. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121720. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121721. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121722. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  121723. getBodyMass(impostor: PhysicsImpostor): number;
  121724. getBodyFriction(impostor: PhysicsImpostor): number;
  121725. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  121726. getBodyRestitution(impostor: PhysicsImpostor): number;
  121727. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  121728. sleepBody(impostor: PhysicsImpostor): void;
  121729. wakeUpBody(impostor: PhysicsImpostor): void;
  121730. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  121731. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  121732. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  121733. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  121734. getRadius(impostor: PhysicsImpostor): number;
  121735. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  121736. dispose(): void;
  121737. /**
  121738. * Does a raycast in the physics world
  121739. * @param from when should the ray start?
  121740. * @param to when should the ray end?
  121741. * @returns PhysicsRaycastResult
  121742. */
  121743. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121744. }
  121745. }
  121746. declare module BABYLON {
  121747. /**
  121748. * Class containing static functions to help procedurally build meshes
  121749. */
  121750. export class RibbonBuilder {
  121751. /**
  121752. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121753. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  121754. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  121755. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  121756. * * 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
  121757. * * 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
  121758. * * 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
  121759. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121760. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121761. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121762. * * 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
  121763. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  121764. * * 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
  121765. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  121766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121767. * @param name defines the name of the mesh
  121768. * @param options defines the options used to create the mesh
  121769. * @param scene defines the hosting scene
  121770. * @returns the ribbon mesh
  121771. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  121772. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121773. */
  121774. static CreateRibbon(name: string, options: {
  121775. pathArray: Vector3[][];
  121776. closeArray?: boolean;
  121777. closePath?: boolean;
  121778. offset?: number;
  121779. updatable?: boolean;
  121780. sideOrientation?: number;
  121781. frontUVs?: Vector4;
  121782. backUVs?: Vector4;
  121783. instance?: Mesh;
  121784. invertUV?: boolean;
  121785. uvs?: Vector2[];
  121786. colors?: Color4[];
  121787. }, scene?: Nullable<Scene>): Mesh;
  121788. }
  121789. }
  121790. declare module BABYLON {
  121791. /**
  121792. * Class containing static functions to help procedurally build meshes
  121793. */
  121794. export class ShapeBuilder {
  121795. /**
  121796. * 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.
  121797. * * 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.
  121798. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121799. * * 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.
  121800. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  121801. * * 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
  121802. * * 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
  121803. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  121804. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121805. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121806. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  121807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121808. * @param name defines the name of the mesh
  121809. * @param options defines the options used to create the mesh
  121810. * @param scene defines the hosting scene
  121811. * @returns the extruded shape mesh
  121812. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121813. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121814. */
  121815. static ExtrudeShape(name: string, options: {
  121816. shape: Vector3[];
  121817. path: Vector3[];
  121818. scale?: number;
  121819. rotation?: number;
  121820. cap?: number;
  121821. updatable?: boolean;
  121822. sideOrientation?: number;
  121823. frontUVs?: Vector4;
  121824. backUVs?: Vector4;
  121825. instance?: Mesh;
  121826. invertUV?: boolean;
  121827. }, scene?: Nullable<Scene>): Mesh;
  121828. /**
  121829. * Creates an custom extruded shape mesh.
  121830. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  121831. * * 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.
  121832. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121833. * * 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
  121834. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  121835. * * 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
  121836. * * It must returns a float value that will be the scale value applied to the shape on each path point
  121837. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  121838. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  121839. * * 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
  121840. * * 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
  121841. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  121842. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121843. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121844. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121846. * @param name defines the name of the mesh
  121847. * @param options defines the options used to create the mesh
  121848. * @param scene defines the hosting scene
  121849. * @returns the custom extruded shape mesh
  121850. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  121851. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121852. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121853. */
  121854. static ExtrudeShapeCustom(name: string, options: {
  121855. shape: Vector3[];
  121856. path: Vector3[];
  121857. scaleFunction?: any;
  121858. rotationFunction?: any;
  121859. ribbonCloseArray?: boolean;
  121860. ribbonClosePath?: boolean;
  121861. cap?: number;
  121862. updatable?: boolean;
  121863. sideOrientation?: number;
  121864. frontUVs?: Vector4;
  121865. backUVs?: Vector4;
  121866. instance?: Mesh;
  121867. invertUV?: boolean;
  121868. }, scene?: Nullable<Scene>): Mesh;
  121869. private static _ExtrudeShapeGeneric;
  121870. }
  121871. }
  121872. declare module BABYLON {
  121873. /**
  121874. * AmmoJS Physics plugin
  121875. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  121876. * @see https://github.com/kripken/ammo.js/
  121877. */
  121878. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  121879. private _useDeltaForWorldStep;
  121880. /**
  121881. * Reference to the Ammo library
  121882. */
  121883. bjsAMMO: any;
  121884. /**
  121885. * Created ammoJS world which physics bodies are added to
  121886. */
  121887. world: any;
  121888. /**
  121889. * Name of the plugin
  121890. */
  121891. name: string;
  121892. private _timeStep;
  121893. private _fixedTimeStep;
  121894. private _maxSteps;
  121895. private _tmpQuaternion;
  121896. private _tmpAmmoTransform;
  121897. private _tmpAmmoQuaternion;
  121898. private _tmpAmmoConcreteContactResultCallback;
  121899. private _collisionConfiguration;
  121900. private _dispatcher;
  121901. private _overlappingPairCache;
  121902. private _solver;
  121903. private _softBodySolver;
  121904. private _tmpAmmoVectorA;
  121905. private _tmpAmmoVectorB;
  121906. private _tmpAmmoVectorC;
  121907. private _tmpAmmoVectorD;
  121908. private _tmpContactCallbackResult;
  121909. private _tmpAmmoVectorRCA;
  121910. private _tmpAmmoVectorRCB;
  121911. private _raycastResult;
  121912. private static readonly DISABLE_COLLISION_FLAG;
  121913. private static readonly KINEMATIC_FLAG;
  121914. private static readonly DISABLE_DEACTIVATION_FLAG;
  121915. /**
  121916. * Initializes the ammoJS plugin
  121917. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  121918. * @param ammoInjection can be used to inject your own ammo reference
  121919. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  121920. */
  121921. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  121922. /**
  121923. * Sets the gravity of the physics world (m/(s^2))
  121924. * @param gravity Gravity to set
  121925. */
  121926. setGravity(gravity: Vector3): void;
  121927. /**
  121928. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  121929. * @param timeStep timestep to use in seconds
  121930. */
  121931. setTimeStep(timeStep: number): void;
  121932. /**
  121933. * 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)
  121934. * @param fixedTimeStep fixedTimeStep to use in seconds
  121935. */
  121936. setFixedTimeStep(fixedTimeStep: number): void;
  121937. /**
  121938. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  121939. * @param maxSteps the maximum number of steps by the physics engine per frame
  121940. */
  121941. setMaxSteps(maxSteps: number): void;
  121942. /**
  121943. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  121944. * @returns the current timestep in seconds
  121945. */
  121946. getTimeStep(): number;
  121947. /**
  121948. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  121949. */
  121950. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  121951. private _isImpostorInContact;
  121952. private _isImpostorPairInContact;
  121953. private _stepSimulation;
  121954. /**
  121955. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  121956. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  121957. * After the step the babylon meshes are set to the position of the physics imposters
  121958. * @param delta amount of time to step forward
  121959. * @param impostors array of imposters to update before/after the step
  121960. */
  121961. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  121962. /**
  121963. * Update babylon mesh to match physics world object
  121964. * @param impostor imposter to match
  121965. */
  121966. private _afterSoftStep;
  121967. /**
  121968. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  121969. * @param impostor imposter to match
  121970. */
  121971. private _ropeStep;
  121972. /**
  121973. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  121974. * @param impostor imposter to match
  121975. */
  121976. private _softbodyOrClothStep;
  121977. private _tmpVector;
  121978. private _tmpMatrix;
  121979. /**
  121980. * Applies an impulse on the imposter
  121981. * @param impostor imposter to apply impulse to
  121982. * @param force amount of force to be applied to the imposter
  121983. * @param contactPoint the location to apply the impulse on the imposter
  121984. */
  121985. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121986. /**
  121987. * Applies a force on the imposter
  121988. * @param impostor imposter to apply force
  121989. * @param force amount of force to be applied to the imposter
  121990. * @param contactPoint the location to apply the force on the imposter
  121991. */
  121992. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121993. /**
  121994. * Creates a physics body using the plugin
  121995. * @param impostor the imposter to create the physics body on
  121996. */
  121997. generatePhysicsBody(impostor: PhysicsImpostor): void;
  121998. /**
  121999. * Removes the physics body from the imposter and disposes of the body's memory
  122000. * @param impostor imposter to remove the physics body from
  122001. */
  122002. removePhysicsBody(impostor: PhysicsImpostor): void;
  122003. /**
  122004. * Generates a joint
  122005. * @param impostorJoint the imposter joint to create the joint with
  122006. */
  122007. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  122008. /**
  122009. * Removes a joint
  122010. * @param impostorJoint the imposter joint to remove the joint from
  122011. */
  122012. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  122013. private _addMeshVerts;
  122014. /**
  122015. * Initialise the soft body vertices to match its object's (mesh) vertices
  122016. * Softbody vertices (nodes) are in world space and to match this
  122017. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  122018. * @param impostor to create the softbody for
  122019. */
  122020. private _softVertexData;
  122021. /**
  122022. * Create an impostor's soft body
  122023. * @param impostor to create the softbody for
  122024. */
  122025. private _createSoftbody;
  122026. /**
  122027. * Create cloth for an impostor
  122028. * @param impostor to create the softbody for
  122029. */
  122030. private _createCloth;
  122031. /**
  122032. * Create rope for an impostor
  122033. * @param impostor to create the softbody for
  122034. */
  122035. private _createRope;
  122036. /**
  122037. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  122038. * @param impostor to create the custom physics shape for
  122039. */
  122040. private _createCustom;
  122041. private _addHullVerts;
  122042. private _createShape;
  122043. /**
  122044. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  122045. * @param impostor imposter containing the physics body and babylon object
  122046. */
  122047. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  122048. /**
  122049. * Sets the babylon object's position/rotation from the physics body's position/rotation
  122050. * @param impostor imposter containing the physics body and babylon object
  122051. * @param newPosition new position
  122052. * @param newRotation new rotation
  122053. */
  122054. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  122055. /**
  122056. * If this plugin is supported
  122057. * @returns true if its supported
  122058. */
  122059. isSupported(): boolean;
  122060. /**
  122061. * Sets the linear velocity of the physics body
  122062. * @param impostor imposter to set the velocity on
  122063. * @param velocity velocity to set
  122064. */
  122065. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  122066. /**
  122067. * Sets the angular velocity of the physics body
  122068. * @param impostor imposter to set the velocity on
  122069. * @param velocity velocity to set
  122070. */
  122071. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  122072. /**
  122073. * gets the linear velocity
  122074. * @param impostor imposter to get linear velocity from
  122075. * @returns linear velocity
  122076. */
  122077. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  122078. /**
  122079. * gets the angular velocity
  122080. * @param impostor imposter to get angular velocity from
  122081. * @returns angular velocity
  122082. */
  122083. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  122084. /**
  122085. * Sets the mass of physics body
  122086. * @param impostor imposter to set the mass on
  122087. * @param mass mass to set
  122088. */
  122089. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  122090. /**
  122091. * Gets the mass of the physics body
  122092. * @param impostor imposter to get the mass from
  122093. * @returns mass
  122094. */
  122095. getBodyMass(impostor: PhysicsImpostor): number;
  122096. /**
  122097. * Gets friction of the impostor
  122098. * @param impostor impostor to get friction from
  122099. * @returns friction value
  122100. */
  122101. getBodyFriction(impostor: PhysicsImpostor): number;
  122102. /**
  122103. * Sets friction of the impostor
  122104. * @param impostor impostor to set friction on
  122105. * @param friction friction value
  122106. */
  122107. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  122108. /**
  122109. * Gets restitution of the impostor
  122110. * @param impostor impostor to get restitution from
  122111. * @returns restitution value
  122112. */
  122113. getBodyRestitution(impostor: PhysicsImpostor): number;
  122114. /**
  122115. * Sets resitution of the impostor
  122116. * @param impostor impostor to set resitution on
  122117. * @param restitution resitution value
  122118. */
  122119. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  122120. /**
  122121. * Gets pressure inside the impostor
  122122. * @param impostor impostor to get pressure from
  122123. * @returns pressure value
  122124. */
  122125. getBodyPressure(impostor: PhysicsImpostor): number;
  122126. /**
  122127. * Sets pressure inside a soft body impostor
  122128. * Cloth and rope must remain 0 pressure
  122129. * @param impostor impostor to set pressure on
  122130. * @param pressure pressure value
  122131. */
  122132. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  122133. /**
  122134. * Gets stiffness of the impostor
  122135. * @param impostor impostor to get stiffness from
  122136. * @returns pressure value
  122137. */
  122138. getBodyStiffness(impostor: PhysicsImpostor): number;
  122139. /**
  122140. * Sets stiffness of the impostor
  122141. * @param impostor impostor to set stiffness on
  122142. * @param stiffness stiffness value from 0 to 1
  122143. */
  122144. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  122145. /**
  122146. * Gets velocityIterations of the impostor
  122147. * @param impostor impostor to get velocity iterations from
  122148. * @returns velocityIterations value
  122149. */
  122150. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  122151. /**
  122152. * Sets velocityIterations of the impostor
  122153. * @param impostor impostor to set velocity iterations on
  122154. * @param velocityIterations velocityIterations value
  122155. */
  122156. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  122157. /**
  122158. * Gets positionIterations of the impostor
  122159. * @param impostor impostor to get position iterations from
  122160. * @returns positionIterations value
  122161. */
  122162. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  122163. /**
  122164. * Sets positionIterations of the impostor
  122165. * @param impostor impostor to set position on
  122166. * @param positionIterations positionIterations value
  122167. */
  122168. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  122169. /**
  122170. * Append an anchor to a cloth object
  122171. * @param impostor is the cloth impostor to add anchor to
  122172. * @param otherImpostor is the rigid impostor to anchor to
  122173. * @param width ratio across width from 0 to 1
  122174. * @param height ratio up height from 0 to 1
  122175. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  122176. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  122177. */
  122178. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  122179. /**
  122180. * Append an hook to a rope object
  122181. * @param impostor is the rope impostor to add hook to
  122182. * @param otherImpostor is the rigid impostor to hook to
  122183. * @param length ratio along the rope from 0 to 1
  122184. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  122185. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  122186. */
  122187. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  122188. /**
  122189. * Sleeps the physics body and stops it from being active
  122190. * @param impostor impostor to sleep
  122191. */
  122192. sleepBody(impostor: PhysicsImpostor): void;
  122193. /**
  122194. * Activates the physics body
  122195. * @param impostor impostor to activate
  122196. */
  122197. wakeUpBody(impostor: PhysicsImpostor): void;
  122198. /**
  122199. * Updates the distance parameters of the joint
  122200. * @param joint joint to update
  122201. * @param maxDistance maximum distance of the joint
  122202. * @param minDistance minimum distance of the joint
  122203. */
  122204. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  122205. /**
  122206. * Sets a motor on the joint
  122207. * @param joint joint to set motor on
  122208. * @param speed speed of the motor
  122209. * @param maxForce maximum force of the motor
  122210. * @param motorIndex index of the motor
  122211. */
  122212. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  122213. /**
  122214. * Sets the motors limit
  122215. * @param joint joint to set limit on
  122216. * @param upperLimit upper limit
  122217. * @param lowerLimit lower limit
  122218. */
  122219. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  122220. /**
  122221. * Syncs the position and rotation of a mesh with the impostor
  122222. * @param mesh mesh to sync
  122223. * @param impostor impostor to update the mesh with
  122224. */
  122225. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  122226. /**
  122227. * Gets the radius of the impostor
  122228. * @param impostor impostor to get radius from
  122229. * @returns the radius
  122230. */
  122231. getRadius(impostor: PhysicsImpostor): number;
  122232. /**
  122233. * Gets the box size of the impostor
  122234. * @param impostor impostor to get box size from
  122235. * @param result the resulting box size
  122236. */
  122237. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  122238. /**
  122239. * Disposes of the impostor
  122240. */
  122241. dispose(): void;
  122242. /**
  122243. * Does a raycast in the physics world
  122244. * @param from when should the ray start?
  122245. * @param to when should the ray end?
  122246. * @returns PhysicsRaycastResult
  122247. */
  122248. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  122249. }
  122250. }
  122251. declare module BABYLON {
  122252. interface AbstractScene {
  122253. /**
  122254. * The list of reflection probes added to the scene
  122255. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  122256. */
  122257. reflectionProbes: Array<ReflectionProbe>;
  122258. /**
  122259. * Removes the given reflection probe from this scene.
  122260. * @param toRemove The reflection probe to remove
  122261. * @returns The index of the removed reflection probe
  122262. */
  122263. removeReflectionProbe(toRemove: ReflectionProbe): number;
  122264. /**
  122265. * Adds the given reflection probe to this scene.
  122266. * @param newReflectionProbe The reflection probe to add
  122267. */
  122268. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  122269. }
  122270. /**
  122271. * Class used to generate realtime reflection / refraction cube textures
  122272. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  122273. */
  122274. export class ReflectionProbe {
  122275. /** defines the name of the probe */
  122276. name: string;
  122277. private _scene;
  122278. private _renderTargetTexture;
  122279. private _projectionMatrix;
  122280. private _viewMatrix;
  122281. private _target;
  122282. private _add;
  122283. private _attachedMesh;
  122284. private _invertYAxis;
  122285. /** Gets or sets probe position (center of the cube map) */
  122286. position: Vector3;
  122287. /**
  122288. * Creates a new reflection probe
  122289. * @param name defines the name of the probe
  122290. * @param size defines the texture resolution (for each face)
  122291. * @param scene defines the hosting scene
  122292. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  122293. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  122294. */
  122295. constructor(
  122296. /** defines the name of the probe */
  122297. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  122298. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  122299. samples: number;
  122300. /** Gets or sets the refresh rate to use (on every frame by default) */
  122301. refreshRate: number;
  122302. /**
  122303. * Gets the hosting scene
  122304. * @returns a Scene
  122305. */
  122306. getScene(): Scene;
  122307. /** Gets the internal CubeTexture used to render to */
  122308. readonly cubeTexture: RenderTargetTexture;
  122309. /** Gets the list of meshes to render */
  122310. readonly renderList: Nullable<AbstractMesh[]>;
  122311. /**
  122312. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  122313. * @param mesh defines the mesh to attach to
  122314. */
  122315. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  122316. /**
  122317. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  122318. * @param renderingGroupId The rendering group id corresponding to its index
  122319. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  122320. */
  122321. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  122322. /**
  122323. * Clean all associated resources
  122324. */
  122325. dispose(): void;
  122326. /**
  122327. * Converts the reflection probe information to a readable string for debug purpose.
  122328. * @param fullDetails Supports for multiple levels of logging within scene loading
  122329. * @returns the human readable reflection probe info
  122330. */
  122331. toString(fullDetails?: boolean): string;
  122332. /**
  122333. * Get the class name of the relfection probe.
  122334. * @returns "ReflectionProbe"
  122335. */
  122336. getClassName(): string;
  122337. /**
  122338. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  122339. * @returns The JSON representation of the texture
  122340. */
  122341. serialize(): any;
  122342. /**
  122343. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  122344. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  122345. * @param scene Define the scene the parsed reflection probe should be instantiated in
  122346. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  122347. * @returns The parsed reflection probe if successful
  122348. */
  122349. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  122350. }
  122351. }
  122352. declare module BABYLON {
  122353. /** @hidden */
  122354. export var _BabylonLoaderRegistered: boolean;
  122355. /**
  122356. * Helps setting up some configuration for the babylon file loader.
  122357. */
  122358. export class BabylonFileLoaderConfiguration {
  122359. /**
  122360. * The loader does not allow injecting custom physix engine into the plugins.
  122361. * Unfortunately in ES6, we need to manually inject them into the plugin.
  122362. * So you could set this variable to your engine import to make it work.
  122363. */
  122364. static LoaderInjectedPhysicsEngine: any;
  122365. }
  122366. }
  122367. declare module BABYLON {
  122368. /**
  122369. * The Physically based simple base material of BJS.
  122370. *
  122371. * This enables better naming and convention enforcements on top of the pbrMaterial.
  122372. * It is used as the base class for both the specGloss and metalRough conventions.
  122373. */
  122374. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  122375. /**
  122376. * Number of Simultaneous lights allowed on the material.
  122377. */
  122378. maxSimultaneousLights: number;
  122379. /**
  122380. * If sets to true, disables all the lights affecting the material.
  122381. */
  122382. disableLighting: boolean;
  122383. /**
  122384. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  122385. */
  122386. environmentTexture: BaseTexture;
  122387. /**
  122388. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  122389. */
  122390. invertNormalMapX: boolean;
  122391. /**
  122392. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  122393. */
  122394. invertNormalMapY: boolean;
  122395. /**
  122396. * Normal map used in the model.
  122397. */
  122398. normalTexture: BaseTexture;
  122399. /**
  122400. * Emissivie color used to self-illuminate the model.
  122401. */
  122402. emissiveColor: Color3;
  122403. /**
  122404. * Emissivie texture used to self-illuminate the model.
  122405. */
  122406. emissiveTexture: BaseTexture;
  122407. /**
  122408. * Occlusion Channel Strenght.
  122409. */
  122410. occlusionStrength: number;
  122411. /**
  122412. * Occlusion Texture of the material (adding extra occlusion effects).
  122413. */
  122414. occlusionTexture: BaseTexture;
  122415. /**
  122416. * Defines the alpha limits in alpha test mode.
  122417. */
  122418. alphaCutOff: number;
  122419. /**
  122420. * Gets the current double sided mode.
  122421. */
  122422. /**
  122423. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  122424. */
  122425. doubleSided: boolean;
  122426. /**
  122427. * Stores the pre-calculated light information of a mesh in a texture.
  122428. */
  122429. lightmapTexture: BaseTexture;
  122430. /**
  122431. * If true, the light map contains occlusion information instead of lighting info.
  122432. */
  122433. useLightmapAsShadowmap: boolean;
  122434. /**
  122435. * Instantiates a new PBRMaterial instance.
  122436. *
  122437. * @param name The material name
  122438. * @param scene The scene the material will be use in.
  122439. */
  122440. constructor(name: string, scene: Scene);
  122441. getClassName(): string;
  122442. }
  122443. }
  122444. declare module BABYLON {
  122445. /**
  122446. * The PBR material of BJS following the metal roughness convention.
  122447. *
  122448. * This fits to the PBR convention in the GLTF definition:
  122449. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  122450. */
  122451. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  122452. /**
  122453. * The base color has two different interpretations depending on the value of metalness.
  122454. * When the material is a metal, the base color is the specific measured reflectance value
  122455. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  122456. * of the material.
  122457. */
  122458. baseColor: Color3;
  122459. /**
  122460. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  122461. * well as opacity information in the alpha channel.
  122462. */
  122463. baseTexture: BaseTexture;
  122464. /**
  122465. * Specifies the metallic scalar value of the material.
  122466. * Can also be used to scale the metalness values of the metallic texture.
  122467. */
  122468. metallic: number;
  122469. /**
  122470. * Specifies the roughness scalar value of the material.
  122471. * Can also be used to scale the roughness values of the metallic texture.
  122472. */
  122473. roughness: number;
  122474. /**
  122475. * Texture containing both the metallic value in the B channel and the
  122476. * roughness value in the G channel to keep better precision.
  122477. */
  122478. metallicRoughnessTexture: BaseTexture;
  122479. /**
  122480. * Instantiates a new PBRMetalRoughnessMaterial instance.
  122481. *
  122482. * @param name The material name
  122483. * @param scene The scene the material will be use in.
  122484. */
  122485. constructor(name: string, scene: Scene);
  122486. /**
  122487. * Return the currrent class name of the material.
  122488. */
  122489. getClassName(): string;
  122490. /**
  122491. * Makes a duplicate of the current material.
  122492. * @param name - name to use for the new material.
  122493. */
  122494. clone(name: string): PBRMetallicRoughnessMaterial;
  122495. /**
  122496. * Serialize the material to a parsable JSON object.
  122497. */
  122498. serialize(): any;
  122499. /**
  122500. * Parses a JSON object correponding to the serialize function.
  122501. */
  122502. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  122503. }
  122504. }
  122505. declare module BABYLON {
  122506. /**
  122507. * The PBR material of BJS following the specular glossiness convention.
  122508. *
  122509. * This fits to the PBR convention in the GLTF definition:
  122510. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  122511. */
  122512. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  122513. /**
  122514. * Specifies the diffuse color of the material.
  122515. */
  122516. diffuseColor: Color3;
  122517. /**
  122518. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  122519. * channel.
  122520. */
  122521. diffuseTexture: BaseTexture;
  122522. /**
  122523. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  122524. */
  122525. specularColor: Color3;
  122526. /**
  122527. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  122528. */
  122529. glossiness: number;
  122530. /**
  122531. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  122532. */
  122533. specularGlossinessTexture: BaseTexture;
  122534. /**
  122535. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  122536. *
  122537. * @param name The material name
  122538. * @param scene The scene the material will be use in.
  122539. */
  122540. constructor(name: string, scene: Scene);
  122541. /**
  122542. * Return the currrent class name of the material.
  122543. */
  122544. getClassName(): string;
  122545. /**
  122546. * Makes a duplicate of the current material.
  122547. * @param name - name to use for the new material.
  122548. */
  122549. clone(name: string): PBRSpecularGlossinessMaterial;
  122550. /**
  122551. * Serialize the material to a parsable JSON object.
  122552. */
  122553. serialize(): any;
  122554. /**
  122555. * Parses a JSON object correponding to the serialize function.
  122556. */
  122557. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  122558. }
  122559. }
  122560. declare module BABYLON {
  122561. /**
  122562. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  122563. * It can help converting any input color in a desired output one. This can then be used to create effects
  122564. * from sepia, black and white to sixties or futuristic rendering...
  122565. *
  122566. * The only supported format is currently 3dl.
  122567. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  122568. */
  122569. export class ColorGradingTexture extends BaseTexture {
  122570. /**
  122571. * The current texture matrix. (will always be identity in color grading texture)
  122572. */
  122573. private _textureMatrix;
  122574. /**
  122575. * The texture URL.
  122576. */
  122577. url: string;
  122578. /**
  122579. * Empty line regex stored for GC.
  122580. */
  122581. private static _noneEmptyLineRegex;
  122582. private _engine;
  122583. /**
  122584. * Instantiates a ColorGradingTexture from the following parameters.
  122585. *
  122586. * @param url The location of the color gradind data (currently only supporting 3dl)
  122587. * @param scene The scene the texture will be used in
  122588. */
  122589. constructor(url: string, scene: Scene);
  122590. /**
  122591. * Returns the texture matrix used in most of the material.
  122592. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  122593. */
  122594. getTextureMatrix(): Matrix;
  122595. /**
  122596. * Occurs when the file being loaded is a .3dl LUT file.
  122597. */
  122598. private load3dlTexture;
  122599. /**
  122600. * Starts the loading process of the texture.
  122601. */
  122602. private loadTexture;
  122603. /**
  122604. * Clones the color gradind texture.
  122605. */
  122606. clone(): ColorGradingTexture;
  122607. /**
  122608. * Called during delayed load for textures.
  122609. */
  122610. delayLoad(): void;
  122611. /**
  122612. * Parses a color grading texture serialized by Babylon.
  122613. * @param parsedTexture The texture information being parsedTexture
  122614. * @param scene The scene to load the texture in
  122615. * @param rootUrl The root url of the data assets to load
  122616. * @return A color gradind texture
  122617. */
  122618. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  122619. /**
  122620. * Serializes the LUT texture to json format.
  122621. */
  122622. serialize(): any;
  122623. }
  122624. }
  122625. declare module BABYLON {
  122626. /**
  122627. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  122628. */
  122629. export class EquiRectangularCubeTexture extends BaseTexture {
  122630. /** The six faces of the cube. */
  122631. private static _FacesMapping;
  122632. private _noMipmap;
  122633. private _onLoad;
  122634. private _onError;
  122635. /** The size of the cubemap. */
  122636. private _size;
  122637. /** The buffer of the image. */
  122638. private _buffer;
  122639. /** The width of the input image. */
  122640. private _width;
  122641. /** The height of the input image. */
  122642. private _height;
  122643. /** The URL to the image. */
  122644. url: string;
  122645. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  122646. coordinatesMode: number;
  122647. /**
  122648. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  122649. * @param url The location of the image
  122650. * @param scene The scene the texture will be used in
  122651. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  122652. * @param noMipmap Forces to not generate the mipmap if true
  122653. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  122654. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  122655. * @param onLoad — defines a callback called when texture is loaded
  122656. * @param onError — defines a callback called if there is an error
  122657. */
  122658. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  122659. /**
  122660. * Load the image data, by putting the image on a canvas and extracting its buffer.
  122661. */
  122662. private loadImage;
  122663. /**
  122664. * Convert the image buffer into a cubemap and create a CubeTexture.
  122665. */
  122666. private loadTexture;
  122667. /**
  122668. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  122669. * @param buffer The ArrayBuffer that should be converted.
  122670. * @returns The buffer as Float32Array.
  122671. */
  122672. private getFloat32ArrayFromArrayBuffer;
  122673. /**
  122674. * Get the current class name of the texture useful for serialization or dynamic coding.
  122675. * @returns "EquiRectangularCubeTexture"
  122676. */
  122677. getClassName(): string;
  122678. /**
  122679. * Create a clone of the current EquiRectangularCubeTexture and return it.
  122680. * @returns A clone of the current EquiRectangularCubeTexture.
  122681. */
  122682. clone(): EquiRectangularCubeTexture;
  122683. }
  122684. }
  122685. declare module BABYLON {
  122686. /**
  122687. * Based on jsTGALoader - Javascript loader for TGA file
  122688. * By Vincent Thibault
  122689. * @see http://blog.robrowser.com/javascript-tga-loader.html
  122690. */
  122691. export class TGATools {
  122692. private static _TYPE_INDEXED;
  122693. private static _TYPE_RGB;
  122694. private static _TYPE_GREY;
  122695. private static _TYPE_RLE_INDEXED;
  122696. private static _TYPE_RLE_RGB;
  122697. private static _TYPE_RLE_GREY;
  122698. private static _ORIGIN_MASK;
  122699. private static _ORIGIN_SHIFT;
  122700. private static _ORIGIN_BL;
  122701. private static _ORIGIN_BR;
  122702. private static _ORIGIN_UL;
  122703. private static _ORIGIN_UR;
  122704. /**
  122705. * Gets the header of a TGA file
  122706. * @param data defines the TGA data
  122707. * @returns the header
  122708. */
  122709. static GetTGAHeader(data: Uint8Array): any;
  122710. /**
  122711. * Uploads TGA content to a Babylon Texture
  122712. * @hidden
  122713. */
  122714. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  122715. /** @hidden */
  122716. 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;
  122717. /** @hidden */
  122718. 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;
  122719. /** @hidden */
  122720. 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;
  122721. /** @hidden */
  122722. 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;
  122723. /** @hidden */
  122724. 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;
  122725. /** @hidden */
  122726. 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;
  122727. }
  122728. }
  122729. declare module BABYLON {
  122730. /**
  122731. * Implementation of the TGA Texture Loader.
  122732. * @hidden
  122733. */
  122734. export class _TGATextureLoader implements IInternalTextureLoader {
  122735. /**
  122736. * Defines wether the loader supports cascade loading the different faces.
  122737. */
  122738. readonly supportCascades: boolean;
  122739. /**
  122740. * This returns if the loader support the current file information.
  122741. * @param extension defines the file extension of the file being loaded
  122742. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122743. * @param fallback defines the fallback internal texture if any
  122744. * @param isBase64 defines whether the texture is encoded as a base64
  122745. * @param isBuffer defines whether the texture data are stored as a buffer
  122746. * @returns true if the loader can load the specified file
  122747. */
  122748. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  122749. /**
  122750. * Transform the url before loading if required.
  122751. * @param rootUrl the url of the texture
  122752. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122753. * @returns the transformed texture
  122754. */
  122755. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  122756. /**
  122757. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  122758. * @param rootUrl the url of the texture
  122759. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122760. * @returns the fallback texture
  122761. */
  122762. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  122763. /**
  122764. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  122765. * @param data contains the texture data
  122766. * @param texture defines the BabylonJS internal texture
  122767. * @param createPolynomials will be true if polynomials have been requested
  122768. * @param onLoad defines the callback to trigger once the texture is ready
  122769. * @param onError defines the callback to trigger in case of error
  122770. */
  122771. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  122772. /**
  122773. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  122774. * @param data contains the texture data
  122775. * @param texture defines the BabylonJS internal texture
  122776. * @param callback defines the method to call once ready to upload
  122777. */
  122778. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  122779. }
  122780. }
  122781. declare module BABYLON {
  122782. /**
  122783. * Info about the .basis files
  122784. */
  122785. class BasisFileInfo {
  122786. /**
  122787. * If the file has alpha
  122788. */
  122789. hasAlpha: boolean;
  122790. /**
  122791. * Info about each image of the basis file
  122792. */
  122793. images: Array<{
  122794. levels: Array<{
  122795. width: number;
  122796. height: number;
  122797. transcodedPixels: ArrayBufferView;
  122798. }>;
  122799. }>;
  122800. }
  122801. /**
  122802. * Result of transcoding a basis file
  122803. */
  122804. class TranscodeResult {
  122805. /**
  122806. * Info about the .basis file
  122807. */
  122808. fileInfo: BasisFileInfo;
  122809. /**
  122810. * Format to use when loading the file
  122811. */
  122812. format: number;
  122813. }
  122814. /**
  122815. * Configuration options for the Basis transcoder
  122816. */
  122817. export class BasisTranscodeConfiguration {
  122818. /**
  122819. * Supported compression formats used to determine the supported output format of the transcoder
  122820. */
  122821. supportedCompressionFormats?: {
  122822. /**
  122823. * etc1 compression format
  122824. */
  122825. etc1?: boolean;
  122826. /**
  122827. * s3tc compression format
  122828. */
  122829. s3tc?: boolean;
  122830. /**
  122831. * pvrtc compression format
  122832. */
  122833. pvrtc?: boolean;
  122834. /**
  122835. * etc2 compression format
  122836. */
  122837. etc2?: boolean;
  122838. };
  122839. /**
  122840. * If mipmap levels should be loaded for transcoded images (Default: true)
  122841. */
  122842. loadMipmapLevels?: boolean;
  122843. /**
  122844. * Index of a single image to load (Default: all images)
  122845. */
  122846. loadSingleImage?: number;
  122847. }
  122848. /**
  122849. * Used to load .Basis files
  122850. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  122851. */
  122852. export class BasisTools {
  122853. private static _IgnoreSupportedFormats;
  122854. /**
  122855. * URL to use when loading the basis transcoder
  122856. */
  122857. static JSModuleURL: string;
  122858. /**
  122859. * URL to use when loading the wasm module for the transcoder
  122860. */
  122861. static WasmModuleURL: string;
  122862. /**
  122863. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  122864. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  122865. * @returns internal format corresponding to the Basis format
  122866. */
  122867. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  122868. private static _WorkerPromise;
  122869. private static _Worker;
  122870. private static _actionId;
  122871. private static _CreateWorkerAsync;
  122872. /**
  122873. * Transcodes a loaded image file to compressed pixel data
  122874. * @param imageData image data to transcode
  122875. * @param config configuration options for the transcoding
  122876. * @returns a promise resulting in the transcoded image
  122877. */
  122878. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  122879. /**
  122880. * Loads a texture from the transcode result
  122881. * @param texture texture load to
  122882. * @param transcodeResult the result of transcoding the basis file to load from
  122883. */
  122884. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  122885. }
  122886. }
  122887. declare module BABYLON {
  122888. /**
  122889. * Loader for .basis file format
  122890. */
  122891. export class _BasisTextureLoader implements IInternalTextureLoader {
  122892. /**
  122893. * Defines whether the loader supports cascade loading the different faces.
  122894. */
  122895. readonly supportCascades: boolean;
  122896. /**
  122897. * This returns if the loader support the current file information.
  122898. * @param extension defines the file extension of the file being loaded
  122899. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122900. * @param fallback defines the fallback internal texture if any
  122901. * @param isBase64 defines whether the texture is encoded as a base64
  122902. * @param isBuffer defines whether the texture data are stored as a buffer
  122903. * @returns true if the loader can load the specified file
  122904. */
  122905. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  122906. /**
  122907. * Transform the url before loading if required.
  122908. * @param rootUrl the url of the texture
  122909. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122910. * @returns the transformed texture
  122911. */
  122912. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  122913. /**
  122914. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  122915. * @param rootUrl the url of the texture
  122916. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122917. * @returns the fallback texture
  122918. */
  122919. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  122920. /**
  122921. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  122922. * @param data contains the texture data
  122923. * @param texture defines the BabylonJS internal texture
  122924. * @param createPolynomials will be true if polynomials have been requested
  122925. * @param onLoad defines the callback to trigger once the texture is ready
  122926. * @param onError defines the callback to trigger in case of error
  122927. */
  122928. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  122929. /**
  122930. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  122931. * @param data contains the texture data
  122932. * @param texture defines the BabylonJS internal texture
  122933. * @param callback defines the method to call once ready to upload
  122934. */
  122935. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  122936. }
  122937. }
  122938. declare module BABYLON {
  122939. /**
  122940. * 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.
  122941. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  122942. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  122943. */
  122944. export class CustomProceduralTexture extends ProceduralTexture {
  122945. private _animate;
  122946. private _time;
  122947. private _config;
  122948. private _texturePath;
  122949. /**
  122950. * Instantiates a new Custom Procedural Texture.
  122951. * 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.
  122952. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  122953. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  122954. * @param name Define the name of the texture
  122955. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  122956. * @param size Define the size of the texture to create
  122957. * @param scene Define the scene the texture belongs to
  122958. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  122959. * @param generateMipMaps Define if the texture should creates mip maps or not
  122960. */
  122961. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  122962. private _loadJson;
  122963. /**
  122964. * Is the texture ready to be used ? (rendered at least once)
  122965. * @returns true if ready, otherwise, false.
  122966. */
  122967. isReady(): boolean;
  122968. /**
  122969. * Render the texture to its associated render target.
  122970. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  122971. */
  122972. render(useCameraPostProcess?: boolean): void;
  122973. /**
  122974. * Update the list of dependant textures samplers in the shader.
  122975. */
  122976. updateTextures(): void;
  122977. /**
  122978. * Update the uniform values of the procedural texture in the shader.
  122979. */
  122980. updateShaderUniforms(): void;
  122981. /**
  122982. * Define if the texture animates or not.
  122983. */
  122984. animate: boolean;
  122985. }
  122986. }
  122987. declare module BABYLON {
  122988. /** @hidden */
  122989. export var noisePixelShader: {
  122990. name: string;
  122991. shader: string;
  122992. };
  122993. }
  122994. declare module BABYLON {
  122995. /**
  122996. * Class used to generate noise procedural textures
  122997. */
  122998. export class NoiseProceduralTexture extends ProceduralTexture {
  122999. private _time;
  123000. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  123001. brightness: number;
  123002. /** Defines the number of octaves to process */
  123003. octaves: number;
  123004. /** Defines the level of persistence (0.8 by default) */
  123005. persistence: number;
  123006. /** Gets or sets animation speed factor (default is 1) */
  123007. animationSpeedFactor: number;
  123008. /**
  123009. * Creates a new NoiseProceduralTexture
  123010. * @param name defines the name fo the texture
  123011. * @param size defines the size of the texture (default is 256)
  123012. * @param scene defines the hosting scene
  123013. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  123014. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  123015. */
  123016. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  123017. private _updateShaderUniforms;
  123018. protected _getDefines(): string;
  123019. /** Generate the current state of the procedural texture */
  123020. render(useCameraPostProcess?: boolean): void;
  123021. /**
  123022. * Serializes this noise procedural texture
  123023. * @returns a serialized noise procedural texture object
  123024. */
  123025. serialize(): any;
  123026. /**
  123027. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  123028. * @param parsedTexture defines parsed texture data
  123029. * @param scene defines the current scene
  123030. * @param rootUrl defines the root URL containing noise procedural texture information
  123031. * @returns a parsed NoiseProceduralTexture
  123032. */
  123033. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  123034. }
  123035. }
  123036. declare module BABYLON {
  123037. /**
  123038. * Raw cube texture where the raw buffers are passed in
  123039. */
  123040. export class RawCubeTexture extends CubeTexture {
  123041. /**
  123042. * Creates a cube texture where the raw buffers are passed in.
  123043. * @param scene defines the scene the texture is attached to
  123044. * @param data defines the array of data to use to create each face
  123045. * @param size defines the size of the textures
  123046. * @param format defines the format of the data
  123047. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  123048. * @param generateMipMaps defines if the engine should generate the mip levels
  123049. * @param invertY defines if data must be stored with Y axis inverted
  123050. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  123051. * @param compression defines the compression used (null by default)
  123052. */
  123053. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  123054. /**
  123055. * Updates the raw cube texture.
  123056. * @param data defines the data to store
  123057. * @param format defines the data format
  123058. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  123059. * @param invertY defines if data must be stored with Y axis inverted
  123060. * @param compression defines the compression used (null by default)
  123061. * @param level defines which level of the texture to update
  123062. */
  123063. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  123064. /**
  123065. * Updates a raw cube texture with RGBD encoded data.
  123066. * @param data defines the array of data [mipmap][face] to use to create each face
  123067. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  123068. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  123069. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  123070. * @returns a promsie that resolves when the operation is complete
  123071. */
  123072. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  123073. /**
  123074. * Clones the raw cube texture.
  123075. * @return a new cube texture
  123076. */
  123077. clone(): CubeTexture;
  123078. /** @hidden */
  123079. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  123080. }
  123081. }
  123082. declare module BABYLON {
  123083. /**
  123084. * Class used to store 3D textures containing user data
  123085. */
  123086. export class RawTexture3D extends Texture {
  123087. /** Gets or sets the texture format to use */
  123088. format: number;
  123089. private _engine;
  123090. /**
  123091. * Create a new RawTexture3D
  123092. * @param data defines the data of the texture
  123093. * @param width defines the width of the texture
  123094. * @param height defines the height of the texture
  123095. * @param depth defines the depth of the texture
  123096. * @param format defines the texture format to use
  123097. * @param scene defines the hosting scene
  123098. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  123099. * @param invertY defines if texture must be stored with Y axis inverted
  123100. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  123101. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  123102. */
  123103. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  123104. /** Gets or sets the texture format to use */
  123105. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  123106. /**
  123107. * Update the texture with new data
  123108. * @param data defines the data to store in the texture
  123109. */
  123110. update(data: ArrayBufferView): void;
  123111. }
  123112. }
  123113. declare module BABYLON {
  123114. /**
  123115. * Class used to store 2D array textures containing user data
  123116. */
  123117. export class RawTexture2DArray extends Texture {
  123118. /** Gets or sets the texture format to use */
  123119. format: number;
  123120. private _engine;
  123121. /**
  123122. * Create a new RawTexture2DArray
  123123. * @param data defines the data of the texture
  123124. * @param width defines the width of the texture
  123125. * @param height defines the height of the texture
  123126. * @param depth defines the number of layers of the texture
  123127. * @param format defines the texture format to use
  123128. * @param scene defines the hosting scene
  123129. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  123130. * @param invertY defines if texture must be stored with Y axis inverted
  123131. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  123132. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  123133. */
  123134. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  123135. /** Gets or sets the texture format to use */
  123136. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  123137. /**
  123138. * Update the texture with new data
  123139. * @param data defines the data to store in the texture
  123140. */
  123141. update(data: ArrayBufferView): void;
  123142. }
  123143. }
  123144. declare module BABYLON {
  123145. /**
  123146. * Creates a refraction texture used by refraction channel of the standard material.
  123147. * It is like a mirror but to see through a material.
  123148. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  123149. */
  123150. export class RefractionTexture extends RenderTargetTexture {
  123151. /**
  123152. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  123153. * 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.
  123154. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  123155. */
  123156. refractionPlane: Plane;
  123157. /**
  123158. * Define how deep under the surface we should see.
  123159. */
  123160. depth: number;
  123161. /**
  123162. * Creates a refraction texture used by refraction channel of the standard material.
  123163. * It is like a mirror but to see through a material.
  123164. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  123165. * @param name Define the texture name
  123166. * @param size Define the size of the underlying texture
  123167. * @param scene Define the scene the refraction belongs to
  123168. * @param generateMipMaps Define if we need to generate mips level for the refraction
  123169. */
  123170. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  123171. /**
  123172. * Clone the refraction texture.
  123173. * @returns the cloned texture
  123174. */
  123175. clone(): RefractionTexture;
  123176. /**
  123177. * Serialize the texture to a JSON representation you could use in Parse later on
  123178. * @returns the serialized JSON representation
  123179. */
  123180. serialize(): any;
  123181. }
  123182. }
  123183. declare module BABYLON {
  123184. /**
  123185. * Defines the options related to the creation of an HtmlElementTexture
  123186. */
  123187. export interface IHtmlElementTextureOptions {
  123188. /**
  123189. * Defines wether mip maps should be created or not.
  123190. */
  123191. generateMipMaps?: boolean;
  123192. /**
  123193. * Defines the sampling mode of the texture.
  123194. */
  123195. samplingMode?: number;
  123196. /**
  123197. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  123198. */
  123199. engine: Nullable<ThinEngine>;
  123200. /**
  123201. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  123202. */
  123203. scene: Nullable<Scene>;
  123204. }
  123205. /**
  123206. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  123207. * To be as efficient as possible depending on your constraints nothing aside the first upload
  123208. * is automatically managed.
  123209. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  123210. * in your application.
  123211. *
  123212. * As the update is not automatic, you need to call them manually.
  123213. */
  123214. export class HtmlElementTexture extends BaseTexture {
  123215. /**
  123216. * The texture URL.
  123217. */
  123218. element: HTMLVideoElement | HTMLCanvasElement;
  123219. private static readonly DefaultOptions;
  123220. private _textureMatrix;
  123221. private _engine;
  123222. private _isVideo;
  123223. private _generateMipMaps;
  123224. private _samplingMode;
  123225. /**
  123226. * Instantiates a HtmlElementTexture from the following parameters.
  123227. *
  123228. * @param name Defines the name of the texture
  123229. * @param element Defines the video or canvas the texture is filled with
  123230. * @param options Defines the other none mandatory texture creation options
  123231. */
  123232. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  123233. private _createInternalTexture;
  123234. /**
  123235. * Returns the texture matrix used in most of the material.
  123236. */
  123237. getTextureMatrix(): Matrix;
  123238. /**
  123239. * Updates the content of the texture.
  123240. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  123241. */
  123242. update(invertY?: Nullable<boolean>): void;
  123243. }
  123244. }
  123245. declare module BABYLON {
  123246. /**
  123247. * Enum used to define the target of a block
  123248. */
  123249. export enum NodeMaterialBlockTargets {
  123250. /** Vertex shader */
  123251. Vertex = 1,
  123252. /** Fragment shader */
  123253. Fragment = 2,
  123254. /** Neutral */
  123255. Neutral = 4,
  123256. /** Vertex and Fragment */
  123257. VertexAndFragment = 3
  123258. }
  123259. }
  123260. declare module BABYLON {
  123261. /**
  123262. * Defines the kind of connection point for node based material
  123263. */
  123264. export enum NodeMaterialBlockConnectionPointTypes {
  123265. /** Float */
  123266. Float = 1,
  123267. /** Int */
  123268. Int = 2,
  123269. /** Vector2 */
  123270. Vector2 = 4,
  123271. /** Vector3 */
  123272. Vector3 = 8,
  123273. /** Vector4 */
  123274. Vector4 = 16,
  123275. /** Color3 */
  123276. Color3 = 32,
  123277. /** Color4 */
  123278. Color4 = 64,
  123279. /** Matrix */
  123280. Matrix = 128,
  123281. /** Detect type based on connection */
  123282. AutoDetect = 1024,
  123283. /** Output type that will be defined by input type */
  123284. BasedOnInput = 2048
  123285. }
  123286. }
  123287. declare module BABYLON {
  123288. /**
  123289. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  123290. */
  123291. export enum NodeMaterialBlockConnectionPointMode {
  123292. /** Value is an uniform */
  123293. Uniform = 0,
  123294. /** Value is a mesh attribute */
  123295. Attribute = 1,
  123296. /** Value is a varying between vertex and fragment shaders */
  123297. Varying = 2,
  123298. /** Mode is undefined */
  123299. Undefined = 3
  123300. }
  123301. }
  123302. declare module BABYLON {
  123303. /**
  123304. * Enum used to define system values e.g. values automatically provided by the system
  123305. */
  123306. export enum NodeMaterialSystemValues {
  123307. /** World */
  123308. World = 1,
  123309. /** View */
  123310. View = 2,
  123311. /** Projection */
  123312. Projection = 3,
  123313. /** ViewProjection */
  123314. ViewProjection = 4,
  123315. /** WorldView */
  123316. WorldView = 5,
  123317. /** WorldViewProjection */
  123318. WorldViewProjection = 6,
  123319. /** CameraPosition */
  123320. CameraPosition = 7,
  123321. /** Fog Color */
  123322. FogColor = 8,
  123323. /** Delta time */
  123324. DeltaTime = 9
  123325. }
  123326. }
  123327. declare module BABYLON {
  123328. /**
  123329. * Root class for all node material optimizers
  123330. */
  123331. export class NodeMaterialOptimizer {
  123332. /**
  123333. * Function used to optimize a NodeMaterial graph
  123334. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  123335. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  123336. */
  123337. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  123338. }
  123339. }
  123340. declare module BABYLON {
  123341. /**
  123342. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  123343. */
  123344. export class TransformBlock extends NodeMaterialBlock {
  123345. /**
  123346. * Defines the value to use to complement W value to transform it to a Vector4
  123347. */
  123348. complementW: number;
  123349. /**
  123350. * Defines the value to use to complement z value to transform it to a Vector4
  123351. */
  123352. complementZ: number;
  123353. /**
  123354. * Creates a new TransformBlock
  123355. * @param name defines the block name
  123356. */
  123357. constructor(name: string);
  123358. /**
  123359. * Gets the current class name
  123360. * @returns the class name
  123361. */
  123362. getClassName(): string;
  123363. /**
  123364. * Gets the vector input
  123365. */
  123366. readonly vector: NodeMaterialConnectionPoint;
  123367. /**
  123368. * Gets the output component
  123369. */
  123370. readonly output: NodeMaterialConnectionPoint;
  123371. /**
  123372. * Gets the matrix transform input
  123373. */
  123374. readonly transform: NodeMaterialConnectionPoint;
  123375. protected _buildBlock(state: NodeMaterialBuildState): this;
  123376. serialize(): any;
  123377. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123378. protected _dumpPropertiesCode(): string;
  123379. }
  123380. }
  123381. declare module BABYLON {
  123382. /**
  123383. * Block used to output the vertex position
  123384. */
  123385. export class VertexOutputBlock extends NodeMaterialBlock {
  123386. /**
  123387. * Creates a new VertexOutputBlock
  123388. * @param name defines the block name
  123389. */
  123390. constructor(name: string);
  123391. /**
  123392. * Gets the current class name
  123393. * @returns the class name
  123394. */
  123395. getClassName(): string;
  123396. /**
  123397. * Gets the vector input component
  123398. */
  123399. readonly vector: NodeMaterialConnectionPoint;
  123400. protected _buildBlock(state: NodeMaterialBuildState): this;
  123401. }
  123402. }
  123403. declare module BABYLON {
  123404. /**
  123405. * Block used to output the final color
  123406. */
  123407. export class FragmentOutputBlock extends NodeMaterialBlock {
  123408. /**
  123409. * Create a new FragmentOutputBlock
  123410. * @param name defines the block name
  123411. */
  123412. constructor(name: string);
  123413. /**
  123414. * Gets the current class name
  123415. * @returns the class name
  123416. */
  123417. getClassName(): string;
  123418. /**
  123419. * Gets the rgba input component
  123420. */
  123421. readonly rgba: NodeMaterialConnectionPoint;
  123422. /**
  123423. * Gets the rgb input component
  123424. */
  123425. readonly rgb: NodeMaterialConnectionPoint;
  123426. /**
  123427. * Gets the a input component
  123428. */
  123429. readonly a: NodeMaterialConnectionPoint;
  123430. protected _buildBlock(state: NodeMaterialBuildState): this;
  123431. }
  123432. }
  123433. declare module BABYLON {
  123434. /**
  123435. * Block used to read a reflection texture from a sampler
  123436. */
  123437. export class ReflectionTextureBlock extends NodeMaterialBlock {
  123438. private _define3DName;
  123439. private _defineCubicName;
  123440. private _defineExplicitName;
  123441. private _defineProjectionName;
  123442. private _defineLocalCubicName;
  123443. private _defineSphericalName;
  123444. private _definePlanarName;
  123445. private _defineEquirectangularName;
  123446. private _defineMirroredEquirectangularFixedName;
  123447. private _defineEquirectangularFixedName;
  123448. private _defineSkyboxName;
  123449. private _cubeSamplerName;
  123450. private _2DSamplerName;
  123451. private _positionUVWName;
  123452. private _directionWName;
  123453. private _reflectionCoordsName;
  123454. private _reflection2DCoordsName;
  123455. private _reflectionColorName;
  123456. private _reflectionMatrixName;
  123457. /**
  123458. * Gets or sets the texture associated with the node
  123459. */
  123460. texture: Nullable<BaseTexture>;
  123461. /**
  123462. * Create a new TextureBlock
  123463. * @param name defines the block name
  123464. */
  123465. constructor(name: string);
  123466. /**
  123467. * Gets the current class name
  123468. * @returns the class name
  123469. */
  123470. getClassName(): string;
  123471. /**
  123472. * Gets the world position input component
  123473. */
  123474. readonly position: NodeMaterialConnectionPoint;
  123475. /**
  123476. * Gets the world position input component
  123477. */
  123478. readonly worldPosition: NodeMaterialConnectionPoint;
  123479. /**
  123480. * Gets the world normal input component
  123481. */
  123482. readonly worldNormal: NodeMaterialConnectionPoint;
  123483. /**
  123484. * Gets the world input component
  123485. */
  123486. readonly world: NodeMaterialConnectionPoint;
  123487. /**
  123488. * Gets the camera (or eye) position component
  123489. */
  123490. readonly cameraPosition: NodeMaterialConnectionPoint;
  123491. /**
  123492. * Gets the view input component
  123493. */
  123494. readonly view: NodeMaterialConnectionPoint;
  123495. /**
  123496. * Gets the rgb output component
  123497. */
  123498. readonly rgb: NodeMaterialConnectionPoint;
  123499. /**
  123500. * Gets the r output component
  123501. */
  123502. readonly r: NodeMaterialConnectionPoint;
  123503. /**
  123504. * Gets the g output component
  123505. */
  123506. readonly g: NodeMaterialConnectionPoint;
  123507. /**
  123508. * Gets the b output component
  123509. */
  123510. readonly b: NodeMaterialConnectionPoint;
  123511. autoConfigure(material: NodeMaterial): void;
  123512. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123513. isReady(): boolean;
  123514. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123515. private _injectVertexCode;
  123516. private _writeOutput;
  123517. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123518. protected _dumpPropertiesCode(): string;
  123519. serialize(): any;
  123520. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123521. }
  123522. }
  123523. declare module BABYLON {
  123524. /**
  123525. * Interface used to configure the node material editor
  123526. */
  123527. export interface INodeMaterialEditorOptions {
  123528. /** Define the URl to load node editor script */
  123529. editorURL?: string;
  123530. }
  123531. /** @hidden */
  123532. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  123533. /** BONES */
  123534. NUM_BONE_INFLUENCERS: number;
  123535. BonesPerMesh: number;
  123536. BONETEXTURE: boolean;
  123537. /** MORPH TARGETS */
  123538. MORPHTARGETS: boolean;
  123539. MORPHTARGETS_NORMAL: boolean;
  123540. MORPHTARGETS_TANGENT: boolean;
  123541. MORPHTARGETS_UV: boolean;
  123542. NUM_MORPH_INFLUENCERS: number;
  123543. /** IMAGE PROCESSING */
  123544. IMAGEPROCESSING: boolean;
  123545. VIGNETTE: boolean;
  123546. VIGNETTEBLENDMODEMULTIPLY: boolean;
  123547. VIGNETTEBLENDMODEOPAQUE: boolean;
  123548. TONEMAPPING: boolean;
  123549. TONEMAPPING_ACES: boolean;
  123550. CONTRAST: boolean;
  123551. EXPOSURE: boolean;
  123552. COLORCURVES: boolean;
  123553. COLORGRADING: boolean;
  123554. COLORGRADING3D: boolean;
  123555. SAMPLER3DGREENDEPTH: boolean;
  123556. SAMPLER3DBGRMAP: boolean;
  123557. IMAGEPROCESSINGPOSTPROCESS: boolean;
  123558. /** MISC. */
  123559. BUMPDIRECTUV: number;
  123560. constructor();
  123561. setValue(name: string, value: boolean): void;
  123562. }
  123563. /**
  123564. * Class used to configure NodeMaterial
  123565. */
  123566. export interface INodeMaterialOptions {
  123567. /**
  123568. * Defines if blocks should emit comments
  123569. */
  123570. emitComments: boolean;
  123571. }
  123572. /**
  123573. * Class used to create a node based material built by assembling shader blocks
  123574. */
  123575. export class NodeMaterial extends PushMaterial {
  123576. private static _BuildIdGenerator;
  123577. private _options;
  123578. private _vertexCompilationState;
  123579. private _fragmentCompilationState;
  123580. private _sharedData;
  123581. private _buildId;
  123582. private _buildWasSuccessful;
  123583. private _cachedWorldViewMatrix;
  123584. private _cachedWorldViewProjectionMatrix;
  123585. private _optimizers;
  123586. private _animationFrame;
  123587. /** Define the URl to load node editor script */
  123588. static EditorURL: string;
  123589. private BJSNODEMATERIALEDITOR;
  123590. /** Get the inspector from bundle or global */
  123591. private _getGlobalNodeMaterialEditor;
  123592. /**
  123593. * Gets or sets data used by visual editor
  123594. * @see https://nme.babylonjs.com
  123595. */
  123596. editorData: any;
  123597. /**
  123598. * 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)
  123599. */
  123600. ignoreAlpha: boolean;
  123601. /**
  123602. * Defines the maximum number of lights that can be used in the material
  123603. */
  123604. maxSimultaneousLights: number;
  123605. /**
  123606. * Observable raised when the material is built
  123607. */
  123608. onBuildObservable: Observable<NodeMaterial>;
  123609. /**
  123610. * Gets or sets the root nodes of the material vertex shader
  123611. */
  123612. _vertexOutputNodes: NodeMaterialBlock[];
  123613. /**
  123614. * Gets or sets the root nodes of the material fragment (pixel) shader
  123615. */
  123616. _fragmentOutputNodes: NodeMaterialBlock[];
  123617. /** Gets or sets options to control the node material overall behavior */
  123618. options: INodeMaterialOptions;
  123619. /**
  123620. * Default configuration related to image processing available in the standard Material.
  123621. */
  123622. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123623. /**
  123624. * Gets the image processing configuration used either in this material.
  123625. */
  123626. /**
  123627. * Sets the Default image processing configuration used either in the this material.
  123628. *
  123629. * If sets to null, the scene one is in use.
  123630. */
  123631. imageProcessingConfiguration: ImageProcessingConfiguration;
  123632. /**
  123633. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  123634. */
  123635. attachedBlocks: NodeMaterialBlock[];
  123636. /**
  123637. * Create a new node based material
  123638. * @param name defines the material name
  123639. * @param scene defines the hosting scene
  123640. * @param options defines creation option
  123641. */
  123642. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  123643. /**
  123644. * Gets the current class name of the material e.g. "NodeMaterial"
  123645. * @returns the class name
  123646. */
  123647. getClassName(): string;
  123648. /**
  123649. * Keep track of the image processing observer to allow dispose and replace.
  123650. */
  123651. private _imageProcessingObserver;
  123652. /**
  123653. * Attaches a new image processing configuration to the Standard Material.
  123654. * @param configuration
  123655. */
  123656. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  123657. /**
  123658. * Get a block by its name
  123659. * @param name defines the name of the block to retrieve
  123660. * @returns the required block or null if not found
  123661. */
  123662. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  123663. /**
  123664. * Get a block by its name
  123665. * @param predicate defines the predicate used to find the good candidate
  123666. * @returns the required block or null if not found
  123667. */
  123668. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  123669. /**
  123670. * Get an input block by its name
  123671. * @param predicate defines the predicate used to find the good candidate
  123672. * @returns the required input block or null if not found
  123673. */
  123674. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  123675. /**
  123676. * Gets the list of input blocks attached to this material
  123677. * @returns an array of InputBlocks
  123678. */
  123679. getInputBlocks(): InputBlock[];
  123680. /**
  123681. * Adds a new optimizer to the list of optimizers
  123682. * @param optimizer defines the optimizers to add
  123683. * @returns the current material
  123684. */
  123685. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  123686. /**
  123687. * Remove an optimizer from the list of optimizers
  123688. * @param optimizer defines the optimizers to remove
  123689. * @returns the current material
  123690. */
  123691. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  123692. /**
  123693. * Add a new block to the list of output nodes
  123694. * @param node defines the node to add
  123695. * @returns the current material
  123696. */
  123697. addOutputNode(node: NodeMaterialBlock): this;
  123698. /**
  123699. * Remove a block from the list of root nodes
  123700. * @param node defines the node to remove
  123701. * @returns the current material
  123702. */
  123703. removeOutputNode(node: NodeMaterialBlock): this;
  123704. private _addVertexOutputNode;
  123705. private _removeVertexOutputNode;
  123706. private _addFragmentOutputNode;
  123707. private _removeFragmentOutputNode;
  123708. /**
  123709. * Specifies if the material will require alpha blending
  123710. * @returns a boolean specifying if alpha blending is needed
  123711. */
  123712. needAlphaBlending(): boolean;
  123713. /**
  123714. * Specifies if this material should be rendered in alpha test mode
  123715. * @returns a boolean specifying if an alpha test is needed.
  123716. */
  123717. needAlphaTesting(): boolean;
  123718. private _initializeBlock;
  123719. private _resetDualBlocks;
  123720. /**
  123721. * Remove a block from the current node material
  123722. * @param block defines the block to remove
  123723. */
  123724. removeBlock(block: NodeMaterialBlock): void;
  123725. /**
  123726. * Build the material and generates the inner effect
  123727. * @param verbose defines if the build should log activity
  123728. */
  123729. build(verbose?: boolean): void;
  123730. /**
  123731. * Runs an otpimization phase to try to improve the shader code
  123732. */
  123733. optimize(): void;
  123734. private _prepareDefinesForAttributes;
  123735. /**
  123736. * Get if the submesh is ready to be used and all its information available.
  123737. * Child classes can use it to update shaders
  123738. * @param mesh defines the mesh to check
  123739. * @param subMesh defines which submesh to check
  123740. * @param useInstances specifies that instances should be used
  123741. * @returns a boolean indicating that the submesh is ready or not
  123742. */
  123743. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  123744. /**
  123745. * Get a string representing the shaders built by the current node graph
  123746. */
  123747. readonly compiledShaders: string;
  123748. /**
  123749. * Binds the world matrix to the material
  123750. * @param world defines the world transformation matrix
  123751. */
  123752. bindOnlyWorldMatrix(world: Matrix): void;
  123753. /**
  123754. * Binds the submesh to this material by preparing the effect and shader to draw
  123755. * @param world defines the world transformation matrix
  123756. * @param mesh defines the mesh containing the submesh
  123757. * @param subMesh defines the submesh to bind the material to
  123758. */
  123759. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  123760. /**
  123761. * Gets the active textures from the material
  123762. * @returns an array of textures
  123763. */
  123764. getActiveTextures(): BaseTexture[];
  123765. /**
  123766. * Gets the list of texture blocks
  123767. * @returns an array of texture blocks
  123768. */
  123769. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  123770. /**
  123771. * Specifies if the material uses a texture
  123772. * @param texture defines the texture to check against the material
  123773. * @returns a boolean specifying if the material uses the texture
  123774. */
  123775. hasTexture(texture: BaseTexture): boolean;
  123776. /**
  123777. * Disposes the material
  123778. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  123779. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  123780. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  123781. */
  123782. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  123783. /** Creates the node editor window. */
  123784. private _createNodeEditor;
  123785. /**
  123786. * Launch the node material editor
  123787. * @param config Define the configuration of the editor
  123788. * @return a promise fulfilled when the node editor is visible
  123789. */
  123790. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  123791. /**
  123792. * Clear the current material
  123793. */
  123794. clear(): void;
  123795. /**
  123796. * Clear the current material and set it to a default state
  123797. */
  123798. setToDefault(): void;
  123799. /**
  123800. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  123801. * @param url defines the url to load from
  123802. * @returns a promise that will fullfil when the material is fully loaded
  123803. */
  123804. loadAsync(url: string): Promise<void>;
  123805. private _gatherBlocks;
  123806. /**
  123807. * Generate a string containing the code declaration required to create an equivalent of this material
  123808. * @returns a string
  123809. */
  123810. generateCode(): string;
  123811. /**
  123812. * Serializes this material in a JSON representation
  123813. * @returns the serialized material object
  123814. */
  123815. serialize(): any;
  123816. private _restoreConnections;
  123817. /**
  123818. * Clear the current graph and load a new one from a serialization object
  123819. * @param source defines the JSON representation of the material
  123820. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  123821. */
  123822. loadFromSerialization(source: any, rootUrl?: string): void;
  123823. /**
  123824. * Creates a node material from parsed material data
  123825. * @param source defines the JSON representation of the material
  123826. * @param scene defines the hosting scene
  123827. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  123828. * @returns a new node material
  123829. */
  123830. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  123831. /**
  123832. * Creates a new node material set to default basic configuration
  123833. * @param name defines the name of the material
  123834. * @param scene defines the hosting scene
  123835. * @returns a new NodeMaterial
  123836. */
  123837. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  123838. }
  123839. }
  123840. declare module BABYLON {
  123841. /**
  123842. * Block used to read a texture from a sampler
  123843. */
  123844. export class TextureBlock extends NodeMaterialBlock {
  123845. private _defineName;
  123846. private _linearDefineName;
  123847. private _tempTextureRead;
  123848. private _samplerName;
  123849. private _transformedUVName;
  123850. private _textureTransformName;
  123851. private _textureInfoName;
  123852. private _mainUVName;
  123853. private _mainUVDefineName;
  123854. /**
  123855. * Gets or sets the texture associated with the node
  123856. */
  123857. texture: Nullable<Texture>;
  123858. /**
  123859. * Create a new TextureBlock
  123860. * @param name defines the block name
  123861. */
  123862. constructor(name: string);
  123863. /**
  123864. * Gets the current class name
  123865. * @returns the class name
  123866. */
  123867. getClassName(): string;
  123868. /**
  123869. * Gets the uv input component
  123870. */
  123871. readonly uv: NodeMaterialConnectionPoint;
  123872. /**
  123873. * Gets the rgba output component
  123874. */
  123875. readonly rgba: NodeMaterialConnectionPoint;
  123876. /**
  123877. * Gets the rgb output component
  123878. */
  123879. readonly rgb: NodeMaterialConnectionPoint;
  123880. /**
  123881. * Gets the r output component
  123882. */
  123883. readonly r: NodeMaterialConnectionPoint;
  123884. /**
  123885. * Gets the g output component
  123886. */
  123887. readonly g: NodeMaterialConnectionPoint;
  123888. /**
  123889. * Gets the b output component
  123890. */
  123891. readonly b: NodeMaterialConnectionPoint;
  123892. /**
  123893. * Gets the a output component
  123894. */
  123895. readonly a: NodeMaterialConnectionPoint;
  123896. readonly target: NodeMaterialBlockTargets;
  123897. autoConfigure(material: NodeMaterial): void;
  123898. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123899. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123900. private _getTextureBase;
  123901. isReady(): boolean;
  123902. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123903. private readonly _isMixed;
  123904. private _injectVertexCode;
  123905. private _writeTextureRead;
  123906. private _writeOutput;
  123907. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123908. protected _dumpPropertiesCode(): string;
  123909. serialize(): any;
  123910. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123911. }
  123912. }
  123913. declare module BABYLON {
  123914. /**
  123915. * Class used to store shared data between 2 NodeMaterialBuildState
  123916. */
  123917. export class NodeMaterialBuildStateSharedData {
  123918. /**
  123919. * Gets the list of emitted varyings
  123920. */
  123921. temps: string[];
  123922. /**
  123923. * Gets the list of emitted varyings
  123924. */
  123925. varyings: string[];
  123926. /**
  123927. * Gets the varying declaration string
  123928. */
  123929. varyingDeclaration: string;
  123930. /**
  123931. * Input blocks
  123932. */
  123933. inputBlocks: InputBlock[];
  123934. /**
  123935. * Input blocks
  123936. */
  123937. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  123938. /**
  123939. * Bindable blocks (Blocks that need to set data to the effect)
  123940. */
  123941. bindableBlocks: NodeMaterialBlock[];
  123942. /**
  123943. * List of blocks that can provide a compilation fallback
  123944. */
  123945. blocksWithFallbacks: NodeMaterialBlock[];
  123946. /**
  123947. * List of blocks that can provide a define update
  123948. */
  123949. blocksWithDefines: NodeMaterialBlock[];
  123950. /**
  123951. * List of blocks that can provide a repeatable content
  123952. */
  123953. repeatableContentBlocks: NodeMaterialBlock[];
  123954. /**
  123955. * List of blocks that can provide a dynamic list of uniforms
  123956. */
  123957. dynamicUniformBlocks: NodeMaterialBlock[];
  123958. /**
  123959. * List of blocks that can block the isReady function for the material
  123960. */
  123961. blockingBlocks: NodeMaterialBlock[];
  123962. /**
  123963. * Gets the list of animated inputs
  123964. */
  123965. animatedInputs: InputBlock[];
  123966. /**
  123967. * Build Id used to avoid multiple recompilations
  123968. */
  123969. buildId: number;
  123970. /** List of emitted variables */
  123971. variableNames: {
  123972. [key: string]: number;
  123973. };
  123974. /** List of emitted defines */
  123975. defineNames: {
  123976. [key: string]: number;
  123977. };
  123978. /** Should emit comments? */
  123979. emitComments: boolean;
  123980. /** Emit build activity */
  123981. verbose: boolean;
  123982. /** Gets or sets the hosting scene */
  123983. scene: Scene;
  123984. /**
  123985. * Gets the compilation hints emitted at compilation time
  123986. */
  123987. hints: {
  123988. needWorldViewMatrix: boolean;
  123989. needWorldViewProjectionMatrix: boolean;
  123990. needAlphaBlending: boolean;
  123991. needAlphaTesting: boolean;
  123992. };
  123993. /**
  123994. * List of compilation checks
  123995. */
  123996. checks: {
  123997. emitVertex: boolean;
  123998. emitFragment: boolean;
  123999. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  124000. };
  124001. /** Creates a new shared data */
  124002. constructor();
  124003. /**
  124004. * Emits console errors and exceptions if there is a failing check
  124005. */
  124006. emitErrors(): void;
  124007. }
  124008. }
  124009. declare module BABYLON {
  124010. /**
  124011. * Class used to store node based material build state
  124012. */
  124013. export class NodeMaterialBuildState {
  124014. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  124015. supportUniformBuffers: boolean;
  124016. /**
  124017. * Gets the list of emitted attributes
  124018. */
  124019. attributes: string[];
  124020. /**
  124021. * Gets the list of emitted uniforms
  124022. */
  124023. uniforms: string[];
  124024. /**
  124025. * Gets the list of emitted constants
  124026. */
  124027. constants: string[];
  124028. /**
  124029. * Gets the list of emitted samplers
  124030. */
  124031. samplers: string[];
  124032. /**
  124033. * Gets the list of emitted functions
  124034. */
  124035. functions: {
  124036. [key: string]: string;
  124037. };
  124038. /**
  124039. * Gets the list of emitted extensions
  124040. */
  124041. extensions: {
  124042. [key: string]: string;
  124043. };
  124044. /**
  124045. * Gets the target of the compilation state
  124046. */
  124047. target: NodeMaterialBlockTargets;
  124048. /**
  124049. * Gets the list of emitted counters
  124050. */
  124051. counters: {
  124052. [key: string]: number;
  124053. };
  124054. /**
  124055. * Shared data between multiple NodeMaterialBuildState instances
  124056. */
  124057. sharedData: NodeMaterialBuildStateSharedData;
  124058. /** @hidden */
  124059. _vertexState: NodeMaterialBuildState;
  124060. /** @hidden */
  124061. _attributeDeclaration: string;
  124062. /** @hidden */
  124063. _uniformDeclaration: string;
  124064. /** @hidden */
  124065. _constantDeclaration: string;
  124066. /** @hidden */
  124067. _samplerDeclaration: string;
  124068. /** @hidden */
  124069. _varyingTransfer: string;
  124070. private _repeatableContentAnchorIndex;
  124071. /** @hidden */
  124072. _builtCompilationString: string;
  124073. /**
  124074. * Gets the emitted compilation strings
  124075. */
  124076. compilationString: string;
  124077. /**
  124078. * Finalize the compilation strings
  124079. * @param state defines the current compilation state
  124080. */
  124081. finalize(state: NodeMaterialBuildState): void;
  124082. /** @hidden */
  124083. readonly _repeatableContentAnchor: string;
  124084. /** @hidden */
  124085. _getFreeVariableName(prefix: string): string;
  124086. /** @hidden */
  124087. _getFreeDefineName(prefix: string): string;
  124088. /** @hidden */
  124089. _excludeVariableName(name: string): void;
  124090. /** @hidden */
  124091. _emit2DSampler(name: string): void;
  124092. /** @hidden */
  124093. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  124094. /** @hidden */
  124095. _emitExtension(name: string, extension: string): void;
  124096. /** @hidden */
  124097. _emitFunction(name: string, code: string, comments: string): void;
  124098. /** @hidden */
  124099. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  124100. replaceStrings?: {
  124101. search: RegExp;
  124102. replace: string;
  124103. }[];
  124104. repeatKey?: string;
  124105. }): string;
  124106. /** @hidden */
  124107. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  124108. repeatKey?: string;
  124109. removeAttributes?: boolean;
  124110. removeUniforms?: boolean;
  124111. removeVaryings?: boolean;
  124112. removeIfDef?: boolean;
  124113. replaceStrings?: {
  124114. search: RegExp;
  124115. replace: string;
  124116. }[];
  124117. }, storeKey?: string): void;
  124118. /** @hidden */
  124119. _registerTempVariable(name: string): boolean;
  124120. /** @hidden */
  124121. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  124122. /** @hidden */
  124123. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  124124. /** @hidden */
  124125. _emitFloat(value: number): string;
  124126. }
  124127. }
  124128. declare module BABYLON {
  124129. /**
  124130. * Defines a block that can be used inside a node based material
  124131. */
  124132. export class NodeMaterialBlock {
  124133. private _buildId;
  124134. private _buildTarget;
  124135. private _target;
  124136. private _isFinalMerger;
  124137. private _isInput;
  124138. protected _isUnique: boolean;
  124139. /** @hidden */
  124140. _codeVariableName: string;
  124141. /** @hidden */
  124142. _inputs: NodeMaterialConnectionPoint[];
  124143. /** @hidden */
  124144. _outputs: NodeMaterialConnectionPoint[];
  124145. /** @hidden */
  124146. _preparationId: number;
  124147. /**
  124148. * Gets or sets the name of the block
  124149. */
  124150. name: string;
  124151. /**
  124152. * Gets or sets the unique id of the node
  124153. */
  124154. uniqueId: number;
  124155. /**
  124156. * Gets or sets the comments associated with this block
  124157. */
  124158. comments: string;
  124159. /**
  124160. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  124161. */
  124162. readonly isUnique: boolean;
  124163. /**
  124164. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  124165. */
  124166. readonly isFinalMerger: boolean;
  124167. /**
  124168. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  124169. */
  124170. readonly isInput: boolean;
  124171. /**
  124172. * Gets or sets the build Id
  124173. */
  124174. buildId: number;
  124175. /**
  124176. * Gets or sets the target of the block
  124177. */
  124178. target: NodeMaterialBlockTargets;
  124179. /**
  124180. * Gets the list of input points
  124181. */
  124182. readonly inputs: NodeMaterialConnectionPoint[];
  124183. /** Gets the list of output points */
  124184. readonly outputs: NodeMaterialConnectionPoint[];
  124185. /**
  124186. * Find an input by its name
  124187. * @param name defines the name of the input to look for
  124188. * @returns the input or null if not found
  124189. */
  124190. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  124191. /**
  124192. * Find an output by its name
  124193. * @param name defines the name of the outputto look for
  124194. * @returns the output or null if not found
  124195. */
  124196. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  124197. /**
  124198. * Creates a new NodeMaterialBlock
  124199. * @param name defines the block name
  124200. * @param target defines the target of that block (Vertex by default)
  124201. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  124202. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  124203. */
  124204. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  124205. /**
  124206. * Initialize the block and prepare the context for build
  124207. * @param state defines the state that will be used for the build
  124208. */
  124209. initialize(state: NodeMaterialBuildState): void;
  124210. /**
  124211. * Bind data to effect. Will only be called for blocks with isBindable === true
  124212. * @param effect defines the effect to bind data to
  124213. * @param nodeMaterial defines the hosting NodeMaterial
  124214. * @param mesh defines the mesh that will be rendered
  124215. */
  124216. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124217. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  124218. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  124219. protected _writeFloat(value: number): string;
  124220. /**
  124221. * Gets the current class name e.g. "NodeMaterialBlock"
  124222. * @returns the class name
  124223. */
  124224. getClassName(): string;
  124225. /**
  124226. * Register a new input. Must be called inside a block constructor
  124227. * @param name defines the connection point name
  124228. * @param type defines the connection point type
  124229. * @param isOptional defines a boolean indicating that this input can be omitted
  124230. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  124231. * @returns the current block
  124232. */
  124233. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  124234. /**
  124235. * Register a new output. Must be called inside a block constructor
  124236. * @param name defines the connection point name
  124237. * @param type defines the connection point type
  124238. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  124239. * @returns the current block
  124240. */
  124241. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  124242. /**
  124243. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  124244. * @param forOutput defines an optional connection point to check compatibility with
  124245. * @returns the first available input or null
  124246. */
  124247. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  124248. /**
  124249. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  124250. * @param forBlock defines an optional block to check compatibility with
  124251. * @returns the first available input or null
  124252. */
  124253. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  124254. /**
  124255. * Gets the sibling of the given output
  124256. * @param current defines the current output
  124257. * @returns the next output in the list or null
  124258. */
  124259. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  124260. /**
  124261. * Connect current block with another block
  124262. * @param other defines the block to connect with
  124263. * @param options define the various options to help pick the right connections
  124264. * @returns the current block
  124265. */
  124266. connectTo(other: NodeMaterialBlock, options?: {
  124267. input?: string;
  124268. output?: string;
  124269. outputSwizzle?: string;
  124270. }): this | undefined;
  124271. protected _buildBlock(state: NodeMaterialBuildState): void;
  124272. /**
  124273. * Add uniforms, samplers and uniform buffers at compilation time
  124274. * @param state defines the state to update
  124275. * @param nodeMaterial defines the node material requesting the update
  124276. * @param defines defines the material defines to update
  124277. * @param uniformBuffers defines the list of uniform buffer names
  124278. */
  124279. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  124280. /**
  124281. * Add potential fallbacks if shader compilation fails
  124282. * @param mesh defines the mesh to be rendered
  124283. * @param fallbacks defines the current prioritized list of fallbacks
  124284. */
  124285. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  124286. /**
  124287. * Initialize defines for shader compilation
  124288. * @param mesh defines the mesh to be rendered
  124289. * @param nodeMaterial defines the node material requesting the update
  124290. * @param defines defines the material defines to update
  124291. * @param useInstances specifies that instances should be used
  124292. */
  124293. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  124294. /**
  124295. * Update defines for shader compilation
  124296. * @param mesh defines the mesh to be rendered
  124297. * @param nodeMaterial defines the node material requesting the update
  124298. * @param defines defines the material defines to update
  124299. * @param useInstances specifies that instances should be used
  124300. */
  124301. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  124302. /**
  124303. * Lets the block try to connect some inputs automatically
  124304. * @param material defines the hosting NodeMaterial
  124305. */
  124306. autoConfigure(material: NodeMaterial): void;
  124307. /**
  124308. * Function called when a block is declared as repeatable content generator
  124309. * @param vertexShaderState defines the current compilation state for the vertex shader
  124310. * @param fragmentShaderState defines the current compilation state for the fragment shader
  124311. * @param mesh defines the mesh to be rendered
  124312. * @param defines defines the material defines to update
  124313. */
  124314. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  124315. /**
  124316. * Checks if the block is ready
  124317. * @param mesh defines the mesh to be rendered
  124318. * @param nodeMaterial defines the node material requesting the update
  124319. * @param defines defines the material defines to update
  124320. * @param useInstances specifies that instances should be used
  124321. * @returns true if the block is ready
  124322. */
  124323. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  124324. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  124325. private _processBuild;
  124326. /**
  124327. * Compile the current node and generate the shader code
  124328. * @param state defines the current compilation state (uniforms, samplers, current string)
  124329. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  124330. * @returns true if already built
  124331. */
  124332. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  124333. protected _inputRename(name: string): string;
  124334. protected _outputRename(name: string): string;
  124335. protected _dumpPropertiesCode(): string;
  124336. /** @hidden */
  124337. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  124338. /** @hidden */
  124339. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  124340. /**
  124341. * Clone the current block to a new identical block
  124342. * @param scene defines the hosting scene
  124343. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  124344. * @returns a copy of the current block
  124345. */
  124346. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  124347. /**
  124348. * Serializes this block in a JSON representation
  124349. * @returns the serialized block object
  124350. */
  124351. serialize(): any;
  124352. /** @hidden */
  124353. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124354. /**
  124355. * Release resources
  124356. */
  124357. dispose(): void;
  124358. }
  124359. }
  124360. declare module BABYLON {
  124361. /**
  124362. * Enum defining the type of animations supported by InputBlock
  124363. */
  124364. export enum AnimatedInputBlockTypes {
  124365. /** No animation */
  124366. None = 0,
  124367. /** Time based animation. Will only work for floats */
  124368. Time = 1
  124369. }
  124370. }
  124371. declare module BABYLON {
  124372. /**
  124373. * Block used to expose an input value
  124374. */
  124375. export class InputBlock extends NodeMaterialBlock {
  124376. private _mode;
  124377. private _associatedVariableName;
  124378. private _storedValue;
  124379. private _valueCallback;
  124380. private _type;
  124381. private _animationType;
  124382. /** Gets or set a value used to limit the range of float values */
  124383. min: number;
  124384. /** Gets or set a value used to limit the range of float values */
  124385. max: number;
  124386. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  124387. matrixMode: number;
  124388. /** @hidden */
  124389. _systemValue: Nullable<NodeMaterialSystemValues>;
  124390. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  124391. visibleInInspector: boolean;
  124392. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  124393. isConstant: boolean;
  124394. /** Gets or sets the group to use to display this block in the Inspector */
  124395. groupInInspector: string;
  124396. /**
  124397. * Gets or sets the connection point type (default is float)
  124398. */
  124399. readonly type: NodeMaterialBlockConnectionPointTypes;
  124400. /**
  124401. * Creates a new InputBlock
  124402. * @param name defines the block name
  124403. * @param target defines the target of that block (Vertex by default)
  124404. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  124405. */
  124406. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  124407. /**
  124408. * Gets the output component
  124409. */
  124410. readonly output: NodeMaterialConnectionPoint;
  124411. /**
  124412. * Set the source of this connection point to a vertex attribute
  124413. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  124414. * @returns the current connection point
  124415. */
  124416. setAsAttribute(attributeName?: string): InputBlock;
  124417. /**
  124418. * Set the source of this connection point to a system value
  124419. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  124420. * @returns the current connection point
  124421. */
  124422. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  124423. /**
  124424. * Gets or sets the value of that point.
  124425. * Please note that this value will be ignored if valueCallback is defined
  124426. */
  124427. value: any;
  124428. /**
  124429. * Gets or sets a callback used to get the value of that point.
  124430. * Please note that setting this value will force the connection point to ignore the value property
  124431. */
  124432. valueCallback: () => any;
  124433. /**
  124434. * Gets or sets the associated variable name in the shader
  124435. */
  124436. associatedVariableName: string;
  124437. /** Gets or sets the type of animation applied to the input */
  124438. animationType: AnimatedInputBlockTypes;
  124439. /**
  124440. * Gets a boolean indicating that this connection point not defined yet
  124441. */
  124442. readonly isUndefined: boolean;
  124443. /**
  124444. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  124445. * In this case the connection point name must be the name of the uniform to use.
  124446. * Can only be set on inputs
  124447. */
  124448. isUniform: boolean;
  124449. /**
  124450. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  124451. * In this case the connection point name must be the name of the attribute to use
  124452. * Can only be set on inputs
  124453. */
  124454. isAttribute: boolean;
  124455. /**
  124456. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  124457. * Can only be set on exit points
  124458. */
  124459. isVarying: boolean;
  124460. /**
  124461. * Gets a boolean indicating that the current connection point is a system value
  124462. */
  124463. readonly isSystemValue: boolean;
  124464. /**
  124465. * Gets or sets the current well known value or null if not defined as a system value
  124466. */
  124467. systemValue: Nullable<NodeMaterialSystemValues>;
  124468. /**
  124469. * Gets the current class name
  124470. * @returns the class name
  124471. */
  124472. getClassName(): string;
  124473. /**
  124474. * Animate the input if animationType !== None
  124475. * @param scene defines the rendering scene
  124476. */
  124477. animate(scene: Scene): void;
  124478. private _emitDefine;
  124479. initialize(state: NodeMaterialBuildState): void;
  124480. /**
  124481. * Set the input block to its default value (based on its type)
  124482. */
  124483. setDefaultValue(): void;
  124484. private _emitConstant;
  124485. private _emit;
  124486. /** @hidden */
  124487. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  124488. /** @hidden */
  124489. _transmit(effect: Effect, scene: Scene): void;
  124490. protected _buildBlock(state: NodeMaterialBuildState): void;
  124491. protected _dumpPropertiesCode(): string;
  124492. serialize(): any;
  124493. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124494. }
  124495. }
  124496. declare module BABYLON {
  124497. /**
  124498. * Enum used to define the compatibility state between two connection points
  124499. */
  124500. export enum NodeMaterialConnectionPointCompatibilityStates {
  124501. /** Points are compatibles */
  124502. Compatible = 0,
  124503. /** Points are incompatible because of their types */
  124504. TypeIncompatible = 1,
  124505. /** Points are incompatible because of their targets (vertex vs fragment) */
  124506. TargetIncompatible = 2
  124507. }
  124508. /**
  124509. * Defines the direction of a connection point
  124510. */
  124511. export enum NodeMaterialConnectionPointDirection {
  124512. /** Input */
  124513. Input = 0,
  124514. /** Output */
  124515. Output = 1
  124516. }
  124517. /**
  124518. * Defines a connection point for a block
  124519. */
  124520. export class NodeMaterialConnectionPoint {
  124521. /** @hidden */
  124522. _ownerBlock: NodeMaterialBlock;
  124523. /** @hidden */
  124524. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  124525. private _endpoints;
  124526. private _associatedVariableName;
  124527. private _direction;
  124528. /** @hidden */
  124529. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  124530. /** @hidden */
  124531. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  124532. private _type;
  124533. /** @hidden */
  124534. _enforceAssociatedVariableName: boolean;
  124535. /** Gets the direction of the point */
  124536. readonly direction: NodeMaterialConnectionPointDirection;
  124537. /**
  124538. * Gets or sets the additional types supported by this connection point
  124539. */
  124540. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  124541. /**
  124542. * Gets or sets the additional types excluded by this connection point
  124543. */
  124544. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  124545. /**
  124546. * Observable triggered when this point is connected
  124547. */
  124548. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  124549. /**
  124550. * Gets or sets the associated variable name in the shader
  124551. */
  124552. associatedVariableName: string;
  124553. /**
  124554. * Gets or sets the connection point type (default is float)
  124555. */
  124556. type: NodeMaterialBlockConnectionPointTypes;
  124557. /**
  124558. * Gets or sets the connection point name
  124559. */
  124560. name: string;
  124561. /**
  124562. * Gets or sets a boolean indicating that this connection point can be omitted
  124563. */
  124564. isOptional: boolean;
  124565. /**
  124566. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  124567. */
  124568. define: string;
  124569. /** @hidden */
  124570. _prioritizeVertex: boolean;
  124571. private _target;
  124572. /** Gets or sets the target of that connection point */
  124573. target: NodeMaterialBlockTargets;
  124574. /**
  124575. * Gets a boolean indicating that the current point is connected
  124576. */
  124577. readonly isConnected: boolean;
  124578. /**
  124579. * Gets a boolean indicating that the current point is connected to an input block
  124580. */
  124581. readonly isConnectedToInputBlock: boolean;
  124582. /**
  124583. * Gets a the connected input block (if any)
  124584. */
  124585. readonly connectInputBlock: Nullable<InputBlock>;
  124586. /** Get the other side of the connection (if any) */
  124587. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  124588. /** Get the block that owns this connection point */
  124589. readonly ownerBlock: NodeMaterialBlock;
  124590. /** Get the block connected on the other side of this connection (if any) */
  124591. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  124592. /** Get the block connected on the endpoints of this connection (if any) */
  124593. readonly connectedBlocks: Array<NodeMaterialBlock>;
  124594. /** Gets the list of connected endpoints */
  124595. readonly endpoints: NodeMaterialConnectionPoint[];
  124596. /** Gets a boolean indicating if that output point is connected to at least one input */
  124597. readonly hasEndpoints: boolean;
  124598. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  124599. readonly isConnectedInVertexShader: boolean;
  124600. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  124601. readonly isConnectedInFragmentShader: boolean;
  124602. /**
  124603. * Creates a new connection point
  124604. * @param name defines the connection point name
  124605. * @param ownerBlock defines the block hosting this connection point
  124606. * @param direction defines the direction of the connection point
  124607. */
  124608. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  124609. /**
  124610. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  124611. * @returns the class name
  124612. */
  124613. getClassName(): string;
  124614. /**
  124615. * Gets a boolean indicating if the current point can be connected to another point
  124616. * @param connectionPoint defines the other connection point
  124617. * @returns a boolean
  124618. */
  124619. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  124620. /**
  124621. * Gets a number indicating if the current point can be connected to another point
  124622. * @param connectionPoint defines the other connection point
  124623. * @returns a number defining the compatibility state
  124624. */
  124625. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  124626. /**
  124627. * Connect this point to another connection point
  124628. * @param connectionPoint defines the other connection point
  124629. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  124630. * @returns the current connection point
  124631. */
  124632. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  124633. /**
  124634. * Disconnect this point from one of his endpoint
  124635. * @param endpoint defines the other connection point
  124636. * @returns the current connection point
  124637. */
  124638. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  124639. /**
  124640. * Serializes this point in a JSON representation
  124641. * @returns the serialized point object
  124642. */
  124643. serialize(): any;
  124644. /**
  124645. * Release resources
  124646. */
  124647. dispose(): void;
  124648. }
  124649. }
  124650. declare module BABYLON {
  124651. /**
  124652. * Block used to add support for vertex skinning (bones)
  124653. */
  124654. export class BonesBlock extends NodeMaterialBlock {
  124655. /**
  124656. * Creates a new BonesBlock
  124657. * @param name defines the block name
  124658. */
  124659. constructor(name: string);
  124660. /**
  124661. * Initialize the block and prepare the context for build
  124662. * @param state defines the state that will be used for the build
  124663. */
  124664. initialize(state: NodeMaterialBuildState): void;
  124665. /**
  124666. * Gets the current class name
  124667. * @returns the class name
  124668. */
  124669. getClassName(): string;
  124670. /**
  124671. * Gets the matrix indices input component
  124672. */
  124673. readonly matricesIndices: NodeMaterialConnectionPoint;
  124674. /**
  124675. * Gets the matrix weights input component
  124676. */
  124677. readonly matricesWeights: NodeMaterialConnectionPoint;
  124678. /**
  124679. * Gets the extra matrix indices input component
  124680. */
  124681. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  124682. /**
  124683. * Gets the extra matrix weights input component
  124684. */
  124685. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  124686. /**
  124687. * Gets the world input component
  124688. */
  124689. readonly world: NodeMaterialConnectionPoint;
  124690. /**
  124691. * Gets the output component
  124692. */
  124693. readonly output: NodeMaterialConnectionPoint;
  124694. autoConfigure(material: NodeMaterial): void;
  124695. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  124696. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124697. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124698. protected _buildBlock(state: NodeMaterialBuildState): this;
  124699. }
  124700. }
  124701. declare module BABYLON {
  124702. /**
  124703. * Block used to add support for instances
  124704. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  124705. */
  124706. export class InstancesBlock extends NodeMaterialBlock {
  124707. /**
  124708. * Creates a new InstancesBlock
  124709. * @param name defines the block name
  124710. */
  124711. constructor(name: string);
  124712. /**
  124713. * Gets the current class name
  124714. * @returns the class name
  124715. */
  124716. getClassName(): string;
  124717. /**
  124718. * Gets the first world row input component
  124719. */
  124720. readonly world0: NodeMaterialConnectionPoint;
  124721. /**
  124722. * Gets the second world row input component
  124723. */
  124724. readonly world1: NodeMaterialConnectionPoint;
  124725. /**
  124726. * Gets the third world row input component
  124727. */
  124728. readonly world2: NodeMaterialConnectionPoint;
  124729. /**
  124730. * Gets the forth world row input component
  124731. */
  124732. readonly world3: NodeMaterialConnectionPoint;
  124733. /**
  124734. * Gets the world input component
  124735. */
  124736. readonly world: NodeMaterialConnectionPoint;
  124737. /**
  124738. * Gets the output component
  124739. */
  124740. readonly output: NodeMaterialConnectionPoint;
  124741. autoConfigure(material: NodeMaterial): void;
  124742. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  124743. protected _buildBlock(state: NodeMaterialBuildState): this;
  124744. }
  124745. }
  124746. declare module BABYLON {
  124747. /**
  124748. * Block used to add morph targets support to vertex shader
  124749. */
  124750. export class MorphTargetsBlock extends NodeMaterialBlock {
  124751. private _repeatableContentAnchor;
  124752. private _repeatebleContentGenerated;
  124753. /**
  124754. * Create a new MorphTargetsBlock
  124755. * @param name defines the block name
  124756. */
  124757. constructor(name: string);
  124758. /**
  124759. * Gets the current class name
  124760. * @returns the class name
  124761. */
  124762. getClassName(): string;
  124763. /**
  124764. * Gets the position input component
  124765. */
  124766. readonly position: NodeMaterialConnectionPoint;
  124767. /**
  124768. * Gets the normal input component
  124769. */
  124770. readonly normal: NodeMaterialConnectionPoint;
  124771. /**
  124772. * Gets the tangent input component
  124773. */
  124774. readonly tangent: NodeMaterialConnectionPoint;
  124775. /**
  124776. * Gets the tangent input component
  124777. */
  124778. readonly uv: NodeMaterialConnectionPoint;
  124779. /**
  124780. * Gets the position output component
  124781. */
  124782. readonly positionOutput: NodeMaterialConnectionPoint;
  124783. /**
  124784. * Gets the normal output component
  124785. */
  124786. readonly normalOutput: NodeMaterialConnectionPoint;
  124787. /**
  124788. * Gets the tangent output component
  124789. */
  124790. readonly tangentOutput: NodeMaterialConnectionPoint;
  124791. /**
  124792. * Gets the tangent output component
  124793. */
  124794. readonly uvOutput: NodeMaterialConnectionPoint;
  124795. initialize(state: NodeMaterialBuildState): void;
  124796. autoConfigure(material: NodeMaterial): void;
  124797. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124798. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124799. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  124800. protected _buildBlock(state: NodeMaterialBuildState): this;
  124801. }
  124802. }
  124803. declare module BABYLON {
  124804. /**
  124805. * Block used to get data information from a light
  124806. */
  124807. export class LightInformationBlock extends NodeMaterialBlock {
  124808. private _lightDataUniformName;
  124809. private _lightColorUniformName;
  124810. private _lightTypeDefineName;
  124811. /**
  124812. * Gets or sets the light associated with this block
  124813. */
  124814. light: Nullable<Light>;
  124815. /**
  124816. * Creates a new LightInformationBlock
  124817. * @param name defines the block name
  124818. */
  124819. constructor(name: string);
  124820. /**
  124821. * Gets the current class name
  124822. * @returns the class name
  124823. */
  124824. getClassName(): string;
  124825. /**
  124826. * Gets the world position input component
  124827. */
  124828. readonly worldPosition: NodeMaterialConnectionPoint;
  124829. /**
  124830. * Gets the direction output component
  124831. */
  124832. readonly direction: NodeMaterialConnectionPoint;
  124833. /**
  124834. * Gets the direction output component
  124835. */
  124836. readonly color: NodeMaterialConnectionPoint;
  124837. /**
  124838. * Gets the direction output component
  124839. */
  124840. readonly intensity: NodeMaterialConnectionPoint;
  124841. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124842. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124843. protected _buildBlock(state: NodeMaterialBuildState): this;
  124844. serialize(): any;
  124845. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124846. }
  124847. }
  124848. declare module BABYLON {
  124849. /**
  124850. * Block used to add image processing support to fragment shader
  124851. */
  124852. export class ImageProcessingBlock extends NodeMaterialBlock {
  124853. /**
  124854. * Create a new ImageProcessingBlock
  124855. * @param name defines the block name
  124856. */
  124857. constructor(name: string);
  124858. /**
  124859. * Gets the current class name
  124860. * @returns the class name
  124861. */
  124862. getClassName(): string;
  124863. /**
  124864. * Gets the color input component
  124865. */
  124866. readonly color: NodeMaterialConnectionPoint;
  124867. /**
  124868. * Gets the output component
  124869. */
  124870. readonly output: NodeMaterialConnectionPoint;
  124871. /**
  124872. * Initialize the block and prepare the context for build
  124873. * @param state defines the state that will be used for the build
  124874. */
  124875. initialize(state: NodeMaterialBuildState): void;
  124876. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  124877. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124878. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124879. protected _buildBlock(state: NodeMaterialBuildState): this;
  124880. }
  124881. }
  124882. declare module BABYLON {
  124883. /**
  124884. * Block used to pertub normals based on a normal map
  124885. */
  124886. export class PerturbNormalBlock extends NodeMaterialBlock {
  124887. private _tangentSpaceParameterName;
  124888. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  124889. invertX: boolean;
  124890. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  124891. invertY: boolean;
  124892. /**
  124893. * Create a new PerturbNormalBlock
  124894. * @param name defines the block name
  124895. */
  124896. constructor(name: string);
  124897. /**
  124898. * Gets the current class name
  124899. * @returns the class name
  124900. */
  124901. getClassName(): string;
  124902. /**
  124903. * Gets the world position input component
  124904. */
  124905. readonly worldPosition: NodeMaterialConnectionPoint;
  124906. /**
  124907. * Gets the world normal input component
  124908. */
  124909. readonly worldNormal: NodeMaterialConnectionPoint;
  124910. /**
  124911. * Gets the uv input component
  124912. */
  124913. readonly uv: NodeMaterialConnectionPoint;
  124914. /**
  124915. * Gets the normal map color input component
  124916. */
  124917. readonly normalMapColor: NodeMaterialConnectionPoint;
  124918. /**
  124919. * Gets the strength input component
  124920. */
  124921. readonly strength: NodeMaterialConnectionPoint;
  124922. /**
  124923. * Gets the output component
  124924. */
  124925. readonly output: NodeMaterialConnectionPoint;
  124926. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124927. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124928. autoConfigure(material: NodeMaterial): void;
  124929. protected _buildBlock(state: NodeMaterialBuildState): this;
  124930. protected _dumpPropertiesCode(): string;
  124931. serialize(): any;
  124932. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124933. }
  124934. }
  124935. declare module BABYLON {
  124936. /**
  124937. * Block used to discard a pixel if a value is smaller than a cutoff
  124938. */
  124939. export class DiscardBlock extends NodeMaterialBlock {
  124940. /**
  124941. * Create a new DiscardBlock
  124942. * @param name defines the block name
  124943. */
  124944. constructor(name: string);
  124945. /**
  124946. * Gets the current class name
  124947. * @returns the class name
  124948. */
  124949. getClassName(): string;
  124950. /**
  124951. * Gets the color input component
  124952. */
  124953. readonly value: NodeMaterialConnectionPoint;
  124954. /**
  124955. * Gets the cutoff input component
  124956. */
  124957. readonly cutoff: NodeMaterialConnectionPoint;
  124958. protected _buildBlock(state: NodeMaterialBuildState): this;
  124959. }
  124960. }
  124961. declare module BABYLON {
  124962. /**
  124963. * Block used to test if the fragment shader is front facing
  124964. */
  124965. export class FrontFacingBlock extends NodeMaterialBlock {
  124966. /**
  124967. * Creates a new FrontFacingBlock
  124968. * @param name defines the block name
  124969. */
  124970. constructor(name: string);
  124971. /**
  124972. * Gets the current class name
  124973. * @returns the class name
  124974. */
  124975. getClassName(): string;
  124976. /**
  124977. * Gets the output component
  124978. */
  124979. readonly output: NodeMaterialConnectionPoint;
  124980. protected _buildBlock(state: NodeMaterialBuildState): this;
  124981. }
  124982. }
  124983. declare module BABYLON {
  124984. /**
  124985. * Block used to get the derivative value on x and y of a given input
  124986. */
  124987. export class DerivativeBlock extends NodeMaterialBlock {
  124988. /**
  124989. * Create a new DerivativeBlock
  124990. * @param name defines the block name
  124991. */
  124992. constructor(name: string);
  124993. /**
  124994. * Gets the current class name
  124995. * @returns the class name
  124996. */
  124997. getClassName(): string;
  124998. /**
  124999. * Gets the input component
  125000. */
  125001. readonly input: NodeMaterialConnectionPoint;
  125002. /**
  125003. * Gets the derivative output on x
  125004. */
  125005. readonly dx: NodeMaterialConnectionPoint;
  125006. /**
  125007. * Gets the derivative output on y
  125008. */
  125009. readonly dy: NodeMaterialConnectionPoint;
  125010. protected _buildBlock(state: NodeMaterialBuildState): this;
  125011. }
  125012. }
  125013. declare module BABYLON {
  125014. /**
  125015. * Block used to add support for scene fog
  125016. */
  125017. export class FogBlock extends NodeMaterialBlock {
  125018. private _fogDistanceName;
  125019. private _fogParameters;
  125020. /**
  125021. * Create a new FogBlock
  125022. * @param name defines the block name
  125023. */
  125024. constructor(name: string);
  125025. /**
  125026. * Gets the current class name
  125027. * @returns the class name
  125028. */
  125029. getClassName(): string;
  125030. /**
  125031. * Gets the world position input component
  125032. */
  125033. readonly worldPosition: NodeMaterialConnectionPoint;
  125034. /**
  125035. * Gets the view input component
  125036. */
  125037. readonly view: NodeMaterialConnectionPoint;
  125038. /**
  125039. * Gets the color input component
  125040. */
  125041. readonly input: NodeMaterialConnectionPoint;
  125042. /**
  125043. * Gets the fog color input component
  125044. */
  125045. readonly fogColor: NodeMaterialConnectionPoint;
  125046. /**
  125047. * Gets the output component
  125048. */
  125049. readonly output: NodeMaterialConnectionPoint;
  125050. autoConfigure(material: NodeMaterial): void;
  125051. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  125052. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  125053. protected _buildBlock(state: NodeMaterialBuildState): this;
  125054. }
  125055. }
  125056. declare module BABYLON {
  125057. /**
  125058. * Block used to add light in the fragment shader
  125059. */
  125060. export class LightBlock extends NodeMaterialBlock {
  125061. private _lightId;
  125062. /**
  125063. * Gets or sets the light associated with this block
  125064. */
  125065. light: Nullable<Light>;
  125066. /**
  125067. * Create a new LightBlock
  125068. * @param name defines the block name
  125069. */
  125070. constructor(name: string);
  125071. /**
  125072. * Gets the current class name
  125073. * @returns the class name
  125074. */
  125075. getClassName(): string;
  125076. /**
  125077. * Gets the world position input component
  125078. */
  125079. readonly worldPosition: NodeMaterialConnectionPoint;
  125080. /**
  125081. * Gets the world normal input component
  125082. */
  125083. readonly worldNormal: NodeMaterialConnectionPoint;
  125084. /**
  125085. * Gets the camera (or eye) position component
  125086. */
  125087. readonly cameraPosition: NodeMaterialConnectionPoint;
  125088. /**
  125089. * Gets the glossiness component
  125090. */
  125091. readonly glossiness: NodeMaterialConnectionPoint;
  125092. /**
  125093. * Gets the glossinness power component
  125094. */
  125095. readonly glossPower: NodeMaterialConnectionPoint;
  125096. /**
  125097. * Gets the diffuse color component
  125098. */
  125099. readonly diffuseColor: NodeMaterialConnectionPoint;
  125100. /**
  125101. * Gets the specular color component
  125102. */
  125103. readonly specularColor: NodeMaterialConnectionPoint;
  125104. /**
  125105. * Gets the diffuse output component
  125106. */
  125107. readonly diffuseOutput: NodeMaterialConnectionPoint;
  125108. /**
  125109. * Gets the specular output component
  125110. */
  125111. readonly specularOutput: NodeMaterialConnectionPoint;
  125112. autoConfigure(material: NodeMaterial): void;
  125113. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  125114. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  125115. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  125116. private _injectVertexCode;
  125117. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125118. serialize(): any;
  125119. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125120. }
  125121. }
  125122. declare module BABYLON {
  125123. /**
  125124. * Block used to multiply 2 values
  125125. */
  125126. export class MultiplyBlock extends NodeMaterialBlock {
  125127. /**
  125128. * Creates a new MultiplyBlock
  125129. * @param name defines the block name
  125130. */
  125131. constructor(name: string);
  125132. /**
  125133. * Gets the current class name
  125134. * @returns the class name
  125135. */
  125136. getClassName(): string;
  125137. /**
  125138. * Gets the left operand input component
  125139. */
  125140. readonly left: NodeMaterialConnectionPoint;
  125141. /**
  125142. * Gets the right operand input component
  125143. */
  125144. readonly right: NodeMaterialConnectionPoint;
  125145. /**
  125146. * Gets the output component
  125147. */
  125148. readonly output: NodeMaterialConnectionPoint;
  125149. protected _buildBlock(state: NodeMaterialBuildState): this;
  125150. }
  125151. }
  125152. declare module BABYLON {
  125153. /**
  125154. * Block used to add 2 vectors
  125155. */
  125156. export class AddBlock extends NodeMaterialBlock {
  125157. /**
  125158. * Creates a new AddBlock
  125159. * @param name defines the block name
  125160. */
  125161. constructor(name: string);
  125162. /**
  125163. * Gets the current class name
  125164. * @returns the class name
  125165. */
  125166. getClassName(): string;
  125167. /**
  125168. * Gets the left operand input component
  125169. */
  125170. readonly left: NodeMaterialConnectionPoint;
  125171. /**
  125172. * Gets the right operand input component
  125173. */
  125174. readonly right: NodeMaterialConnectionPoint;
  125175. /**
  125176. * Gets the output component
  125177. */
  125178. readonly output: NodeMaterialConnectionPoint;
  125179. protected _buildBlock(state: NodeMaterialBuildState): this;
  125180. }
  125181. }
  125182. declare module BABYLON {
  125183. /**
  125184. * Block used to scale a vector by a float
  125185. */
  125186. export class ScaleBlock extends NodeMaterialBlock {
  125187. /**
  125188. * Creates a new ScaleBlock
  125189. * @param name defines the block name
  125190. */
  125191. constructor(name: string);
  125192. /**
  125193. * Gets the current class name
  125194. * @returns the class name
  125195. */
  125196. getClassName(): string;
  125197. /**
  125198. * Gets the input component
  125199. */
  125200. readonly input: NodeMaterialConnectionPoint;
  125201. /**
  125202. * Gets the factor input component
  125203. */
  125204. readonly factor: NodeMaterialConnectionPoint;
  125205. /**
  125206. * Gets the output component
  125207. */
  125208. readonly output: NodeMaterialConnectionPoint;
  125209. protected _buildBlock(state: NodeMaterialBuildState): this;
  125210. }
  125211. }
  125212. declare module BABYLON {
  125213. /**
  125214. * Block used to clamp a float
  125215. */
  125216. export class ClampBlock extends NodeMaterialBlock {
  125217. /** Gets or sets the minimum range */
  125218. minimum: number;
  125219. /** Gets or sets the maximum range */
  125220. maximum: number;
  125221. /**
  125222. * Creates a new ClampBlock
  125223. * @param name defines the block name
  125224. */
  125225. constructor(name: string);
  125226. /**
  125227. * Gets the current class name
  125228. * @returns the class name
  125229. */
  125230. getClassName(): string;
  125231. /**
  125232. * Gets the value input component
  125233. */
  125234. readonly value: NodeMaterialConnectionPoint;
  125235. /**
  125236. * Gets the output component
  125237. */
  125238. readonly output: NodeMaterialConnectionPoint;
  125239. protected _buildBlock(state: NodeMaterialBuildState): this;
  125240. protected _dumpPropertiesCode(): string;
  125241. serialize(): any;
  125242. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125243. }
  125244. }
  125245. declare module BABYLON {
  125246. /**
  125247. * Block used to apply a cross product between 2 vectors
  125248. */
  125249. export class CrossBlock extends NodeMaterialBlock {
  125250. /**
  125251. * Creates a new CrossBlock
  125252. * @param name defines the block name
  125253. */
  125254. constructor(name: string);
  125255. /**
  125256. * Gets the current class name
  125257. * @returns the class name
  125258. */
  125259. getClassName(): string;
  125260. /**
  125261. * Gets the left operand input component
  125262. */
  125263. readonly left: NodeMaterialConnectionPoint;
  125264. /**
  125265. * Gets the right operand input component
  125266. */
  125267. readonly right: NodeMaterialConnectionPoint;
  125268. /**
  125269. * Gets the output component
  125270. */
  125271. readonly output: NodeMaterialConnectionPoint;
  125272. protected _buildBlock(state: NodeMaterialBuildState): this;
  125273. }
  125274. }
  125275. declare module BABYLON {
  125276. /**
  125277. * Block used to apply a dot product between 2 vectors
  125278. */
  125279. export class DotBlock extends NodeMaterialBlock {
  125280. /**
  125281. * Creates a new DotBlock
  125282. * @param name defines the block name
  125283. */
  125284. constructor(name: string);
  125285. /**
  125286. * Gets the current class name
  125287. * @returns the class name
  125288. */
  125289. getClassName(): string;
  125290. /**
  125291. * Gets the left operand input component
  125292. */
  125293. readonly left: NodeMaterialConnectionPoint;
  125294. /**
  125295. * Gets the right operand input component
  125296. */
  125297. readonly right: NodeMaterialConnectionPoint;
  125298. /**
  125299. * Gets the output component
  125300. */
  125301. readonly output: NodeMaterialConnectionPoint;
  125302. protected _buildBlock(state: NodeMaterialBuildState): this;
  125303. }
  125304. }
  125305. declare module BABYLON {
  125306. /**
  125307. * Block used to remap a float from a range to a new one
  125308. */
  125309. export class RemapBlock extends NodeMaterialBlock {
  125310. /**
  125311. * Gets or sets the source range
  125312. */
  125313. sourceRange: Vector2;
  125314. /**
  125315. * Gets or sets the target range
  125316. */
  125317. targetRange: Vector2;
  125318. /**
  125319. * Creates a new RemapBlock
  125320. * @param name defines the block name
  125321. */
  125322. constructor(name: string);
  125323. /**
  125324. * Gets the current class name
  125325. * @returns the class name
  125326. */
  125327. getClassName(): string;
  125328. /**
  125329. * Gets the input component
  125330. */
  125331. readonly input: NodeMaterialConnectionPoint;
  125332. /**
  125333. * Gets the source min input component
  125334. */
  125335. readonly sourceMin: NodeMaterialConnectionPoint;
  125336. /**
  125337. * Gets the source max input component
  125338. */
  125339. readonly sourceMax: NodeMaterialConnectionPoint;
  125340. /**
  125341. * Gets the target min input component
  125342. */
  125343. readonly targetMin: NodeMaterialConnectionPoint;
  125344. /**
  125345. * Gets the target max input component
  125346. */
  125347. readonly targetMax: NodeMaterialConnectionPoint;
  125348. /**
  125349. * Gets the output component
  125350. */
  125351. readonly output: NodeMaterialConnectionPoint;
  125352. protected _buildBlock(state: NodeMaterialBuildState): this;
  125353. protected _dumpPropertiesCode(): string;
  125354. serialize(): any;
  125355. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125356. }
  125357. }
  125358. declare module BABYLON {
  125359. /**
  125360. * Block used to normalize a vector
  125361. */
  125362. export class NormalizeBlock extends NodeMaterialBlock {
  125363. /**
  125364. * Creates a new NormalizeBlock
  125365. * @param name defines the block name
  125366. */
  125367. constructor(name: string);
  125368. /**
  125369. * Gets the current class name
  125370. * @returns the class name
  125371. */
  125372. getClassName(): string;
  125373. /**
  125374. * Gets the input component
  125375. */
  125376. readonly input: NodeMaterialConnectionPoint;
  125377. /**
  125378. * Gets the output component
  125379. */
  125380. readonly output: NodeMaterialConnectionPoint;
  125381. protected _buildBlock(state: NodeMaterialBuildState): this;
  125382. }
  125383. }
  125384. declare module BABYLON {
  125385. /**
  125386. * Operations supported by the Trigonometry block
  125387. */
  125388. export enum TrigonometryBlockOperations {
  125389. /** Cos */
  125390. Cos = 0,
  125391. /** Sin */
  125392. Sin = 1,
  125393. /** Abs */
  125394. Abs = 2,
  125395. /** Exp */
  125396. Exp = 3,
  125397. /** Exp2 */
  125398. Exp2 = 4,
  125399. /** Round */
  125400. Round = 5,
  125401. /** Floor */
  125402. Floor = 6,
  125403. /** Ceiling */
  125404. Ceiling = 7,
  125405. /** Square root */
  125406. Sqrt = 8,
  125407. /** Log */
  125408. Log = 9,
  125409. /** Tangent */
  125410. Tan = 10,
  125411. /** Arc tangent */
  125412. ArcTan = 11,
  125413. /** Arc cosinus */
  125414. ArcCos = 12,
  125415. /** Arc sinus */
  125416. ArcSin = 13,
  125417. /** Fraction */
  125418. Fract = 14,
  125419. /** Sign */
  125420. Sign = 15,
  125421. /** To radians (from degrees) */
  125422. Radians = 16,
  125423. /** To degrees (from radians) */
  125424. Degrees = 17
  125425. }
  125426. /**
  125427. * Block used to apply trigonometry operation to floats
  125428. */
  125429. export class TrigonometryBlock extends NodeMaterialBlock {
  125430. /**
  125431. * Gets or sets the operation applied by the block
  125432. */
  125433. operation: TrigonometryBlockOperations;
  125434. /**
  125435. * Creates a new TrigonometryBlock
  125436. * @param name defines the block name
  125437. */
  125438. constructor(name: string);
  125439. /**
  125440. * Gets the current class name
  125441. * @returns the class name
  125442. */
  125443. getClassName(): string;
  125444. /**
  125445. * Gets the input component
  125446. */
  125447. readonly input: NodeMaterialConnectionPoint;
  125448. /**
  125449. * Gets the output component
  125450. */
  125451. readonly output: NodeMaterialConnectionPoint;
  125452. protected _buildBlock(state: NodeMaterialBuildState): this;
  125453. serialize(): any;
  125454. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125455. protected _dumpPropertiesCode(): string;
  125456. }
  125457. }
  125458. declare module BABYLON {
  125459. /**
  125460. * Block used to create a Color3/4 out of individual inputs (one for each component)
  125461. */
  125462. export class ColorMergerBlock extends NodeMaterialBlock {
  125463. /**
  125464. * Create a new ColorMergerBlock
  125465. * @param name defines the block name
  125466. */
  125467. constructor(name: string);
  125468. /**
  125469. * Gets the current class name
  125470. * @returns the class name
  125471. */
  125472. getClassName(): string;
  125473. /**
  125474. * Gets the rgb component (input)
  125475. */
  125476. readonly rgbIn: NodeMaterialConnectionPoint;
  125477. /**
  125478. * Gets the r component (input)
  125479. */
  125480. readonly r: NodeMaterialConnectionPoint;
  125481. /**
  125482. * Gets the g component (input)
  125483. */
  125484. readonly g: NodeMaterialConnectionPoint;
  125485. /**
  125486. * Gets the b component (input)
  125487. */
  125488. readonly b: NodeMaterialConnectionPoint;
  125489. /**
  125490. * Gets the a component (input)
  125491. */
  125492. readonly a: NodeMaterialConnectionPoint;
  125493. /**
  125494. * Gets the rgba component (output)
  125495. */
  125496. readonly rgba: NodeMaterialConnectionPoint;
  125497. /**
  125498. * Gets the rgb component (output)
  125499. */
  125500. readonly rgbOut: NodeMaterialConnectionPoint;
  125501. /**
  125502. * Gets the rgb component (output)
  125503. * @deprecated Please use rgbOut instead.
  125504. */
  125505. readonly rgb: NodeMaterialConnectionPoint;
  125506. protected _buildBlock(state: NodeMaterialBuildState): this;
  125507. }
  125508. }
  125509. declare module BABYLON {
  125510. /**
  125511. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  125512. */
  125513. export class VectorMergerBlock extends NodeMaterialBlock {
  125514. /**
  125515. * Create a new VectorMergerBlock
  125516. * @param name defines the block name
  125517. */
  125518. constructor(name: string);
  125519. /**
  125520. * Gets the current class name
  125521. * @returns the class name
  125522. */
  125523. getClassName(): string;
  125524. /**
  125525. * Gets the xyz component (input)
  125526. */
  125527. readonly xyzIn: NodeMaterialConnectionPoint;
  125528. /**
  125529. * Gets the xy component (input)
  125530. */
  125531. readonly xyIn: NodeMaterialConnectionPoint;
  125532. /**
  125533. * Gets the x component (input)
  125534. */
  125535. readonly x: NodeMaterialConnectionPoint;
  125536. /**
  125537. * Gets the y component (input)
  125538. */
  125539. readonly y: NodeMaterialConnectionPoint;
  125540. /**
  125541. * Gets the z component (input)
  125542. */
  125543. readonly z: NodeMaterialConnectionPoint;
  125544. /**
  125545. * Gets the w component (input)
  125546. */
  125547. readonly w: NodeMaterialConnectionPoint;
  125548. /**
  125549. * Gets the xyzw component (output)
  125550. */
  125551. readonly xyzw: NodeMaterialConnectionPoint;
  125552. /**
  125553. * Gets the xyz component (output)
  125554. */
  125555. readonly xyzOut: NodeMaterialConnectionPoint;
  125556. /**
  125557. * Gets the xy component (output)
  125558. */
  125559. readonly xyOut: NodeMaterialConnectionPoint;
  125560. /**
  125561. * Gets the xy component (output)
  125562. * @deprecated Please use xyOut instead.
  125563. */
  125564. readonly xy: NodeMaterialConnectionPoint;
  125565. /**
  125566. * Gets the xyz component (output)
  125567. * @deprecated Please use xyzOut instead.
  125568. */
  125569. readonly xyz: NodeMaterialConnectionPoint;
  125570. protected _buildBlock(state: NodeMaterialBuildState): this;
  125571. }
  125572. }
  125573. declare module BABYLON {
  125574. /**
  125575. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  125576. */
  125577. export class ColorSplitterBlock extends NodeMaterialBlock {
  125578. /**
  125579. * Create a new ColorSplitterBlock
  125580. * @param name defines the block name
  125581. */
  125582. constructor(name: string);
  125583. /**
  125584. * Gets the current class name
  125585. * @returns the class name
  125586. */
  125587. getClassName(): string;
  125588. /**
  125589. * Gets the rgba component (input)
  125590. */
  125591. readonly rgba: NodeMaterialConnectionPoint;
  125592. /**
  125593. * Gets the rgb component (input)
  125594. */
  125595. readonly rgbIn: NodeMaterialConnectionPoint;
  125596. /**
  125597. * Gets the rgb component (output)
  125598. */
  125599. readonly rgbOut: NodeMaterialConnectionPoint;
  125600. /**
  125601. * Gets the r component (output)
  125602. */
  125603. readonly r: NodeMaterialConnectionPoint;
  125604. /**
  125605. * Gets the g component (output)
  125606. */
  125607. readonly g: NodeMaterialConnectionPoint;
  125608. /**
  125609. * Gets the b component (output)
  125610. */
  125611. readonly b: NodeMaterialConnectionPoint;
  125612. /**
  125613. * Gets the a component (output)
  125614. */
  125615. readonly a: NodeMaterialConnectionPoint;
  125616. protected _inputRename(name: string): string;
  125617. protected _outputRename(name: string): string;
  125618. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125619. }
  125620. }
  125621. declare module BABYLON {
  125622. /**
  125623. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  125624. */
  125625. export class VectorSplitterBlock extends NodeMaterialBlock {
  125626. /**
  125627. * Create a new VectorSplitterBlock
  125628. * @param name defines the block name
  125629. */
  125630. constructor(name: string);
  125631. /**
  125632. * Gets the current class name
  125633. * @returns the class name
  125634. */
  125635. getClassName(): string;
  125636. /**
  125637. * Gets the xyzw component (input)
  125638. */
  125639. readonly xyzw: NodeMaterialConnectionPoint;
  125640. /**
  125641. * Gets the xyz component (input)
  125642. */
  125643. readonly xyzIn: NodeMaterialConnectionPoint;
  125644. /**
  125645. * Gets the xy component (input)
  125646. */
  125647. readonly xyIn: NodeMaterialConnectionPoint;
  125648. /**
  125649. * Gets the xyz component (output)
  125650. */
  125651. readonly xyzOut: NodeMaterialConnectionPoint;
  125652. /**
  125653. * Gets the xy component (output)
  125654. */
  125655. readonly xyOut: NodeMaterialConnectionPoint;
  125656. /**
  125657. * Gets the x component (output)
  125658. */
  125659. readonly x: NodeMaterialConnectionPoint;
  125660. /**
  125661. * Gets the y component (output)
  125662. */
  125663. readonly y: NodeMaterialConnectionPoint;
  125664. /**
  125665. * Gets the z component (output)
  125666. */
  125667. readonly z: NodeMaterialConnectionPoint;
  125668. /**
  125669. * Gets the w component (output)
  125670. */
  125671. readonly w: NodeMaterialConnectionPoint;
  125672. protected _inputRename(name: string): string;
  125673. protected _outputRename(name: string): string;
  125674. protected _buildBlock(state: NodeMaterialBuildState): this;
  125675. }
  125676. }
  125677. declare module BABYLON {
  125678. /**
  125679. * Block used to lerp between 2 values
  125680. */
  125681. export class LerpBlock extends NodeMaterialBlock {
  125682. /**
  125683. * Creates a new LerpBlock
  125684. * @param name defines the block name
  125685. */
  125686. constructor(name: string);
  125687. /**
  125688. * Gets the current class name
  125689. * @returns the class name
  125690. */
  125691. getClassName(): string;
  125692. /**
  125693. * Gets the left operand input component
  125694. */
  125695. readonly left: NodeMaterialConnectionPoint;
  125696. /**
  125697. * Gets the right operand input component
  125698. */
  125699. readonly right: NodeMaterialConnectionPoint;
  125700. /**
  125701. * Gets the gradient operand input component
  125702. */
  125703. readonly gradient: NodeMaterialConnectionPoint;
  125704. /**
  125705. * Gets the output component
  125706. */
  125707. readonly output: NodeMaterialConnectionPoint;
  125708. protected _buildBlock(state: NodeMaterialBuildState): this;
  125709. }
  125710. }
  125711. declare module BABYLON {
  125712. /**
  125713. * Block used to divide 2 vectors
  125714. */
  125715. export class DivideBlock extends NodeMaterialBlock {
  125716. /**
  125717. * Creates a new DivideBlock
  125718. * @param name defines the block name
  125719. */
  125720. constructor(name: string);
  125721. /**
  125722. * Gets the current class name
  125723. * @returns the class name
  125724. */
  125725. getClassName(): string;
  125726. /**
  125727. * Gets the left operand input component
  125728. */
  125729. readonly left: NodeMaterialConnectionPoint;
  125730. /**
  125731. * Gets the right operand input component
  125732. */
  125733. readonly right: NodeMaterialConnectionPoint;
  125734. /**
  125735. * Gets the output component
  125736. */
  125737. readonly output: NodeMaterialConnectionPoint;
  125738. protected _buildBlock(state: NodeMaterialBuildState): this;
  125739. }
  125740. }
  125741. declare module BABYLON {
  125742. /**
  125743. * Block used to subtract 2 vectors
  125744. */
  125745. export class SubtractBlock extends NodeMaterialBlock {
  125746. /**
  125747. * Creates a new SubtractBlock
  125748. * @param name defines the block name
  125749. */
  125750. constructor(name: string);
  125751. /**
  125752. * Gets the current class name
  125753. * @returns the class name
  125754. */
  125755. getClassName(): string;
  125756. /**
  125757. * Gets the left operand input component
  125758. */
  125759. readonly left: NodeMaterialConnectionPoint;
  125760. /**
  125761. * Gets the right operand input component
  125762. */
  125763. readonly right: NodeMaterialConnectionPoint;
  125764. /**
  125765. * Gets the output component
  125766. */
  125767. readonly output: NodeMaterialConnectionPoint;
  125768. protected _buildBlock(state: NodeMaterialBuildState): this;
  125769. }
  125770. }
  125771. declare module BABYLON {
  125772. /**
  125773. * Block used to step a value
  125774. */
  125775. export class StepBlock extends NodeMaterialBlock {
  125776. /**
  125777. * Creates a new StepBlock
  125778. * @param name defines the block name
  125779. */
  125780. constructor(name: string);
  125781. /**
  125782. * Gets the current class name
  125783. * @returns the class name
  125784. */
  125785. getClassName(): string;
  125786. /**
  125787. * Gets the value operand input component
  125788. */
  125789. readonly value: NodeMaterialConnectionPoint;
  125790. /**
  125791. * Gets the edge operand input component
  125792. */
  125793. readonly edge: NodeMaterialConnectionPoint;
  125794. /**
  125795. * Gets the output component
  125796. */
  125797. readonly output: NodeMaterialConnectionPoint;
  125798. protected _buildBlock(state: NodeMaterialBuildState): this;
  125799. }
  125800. }
  125801. declare module BABYLON {
  125802. /**
  125803. * Block used to get the opposite (1 - x) of a value
  125804. */
  125805. export class OneMinusBlock extends NodeMaterialBlock {
  125806. /**
  125807. * Creates a new OneMinusBlock
  125808. * @param name defines the block name
  125809. */
  125810. constructor(name: string);
  125811. /**
  125812. * Gets the current class name
  125813. * @returns the class name
  125814. */
  125815. getClassName(): string;
  125816. /**
  125817. * Gets the input component
  125818. */
  125819. readonly input: NodeMaterialConnectionPoint;
  125820. /**
  125821. * Gets the output component
  125822. */
  125823. readonly output: NodeMaterialConnectionPoint;
  125824. protected _buildBlock(state: NodeMaterialBuildState): this;
  125825. }
  125826. }
  125827. declare module BABYLON {
  125828. /**
  125829. * Block used to get the view direction
  125830. */
  125831. export class ViewDirectionBlock extends NodeMaterialBlock {
  125832. /**
  125833. * Creates a new ViewDirectionBlock
  125834. * @param name defines the block name
  125835. */
  125836. constructor(name: string);
  125837. /**
  125838. * Gets the current class name
  125839. * @returns the class name
  125840. */
  125841. getClassName(): string;
  125842. /**
  125843. * Gets the world position component
  125844. */
  125845. readonly worldPosition: NodeMaterialConnectionPoint;
  125846. /**
  125847. * Gets the camera position component
  125848. */
  125849. readonly cameraPosition: NodeMaterialConnectionPoint;
  125850. /**
  125851. * Gets the output component
  125852. */
  125853. readonly output: NodeMaterialConnectionPoint;
  125854. autoConfigure(material: NodeMaterial): void;
  125855. protected _buildBlock(state: NodeMaterialBuildState): this;
  125856. }
  125857. }
  125858. declare module BABYLON {
  125859. /**
  125860. * Block used to compute fresnel value
  125861. */
  125862. export class FresnelBlock extends NodeMaterialBlock {
  125863. /**
  125864. * Create a new FresnelBlock
  125865. * @param name defines the block name
  125866. */
  125867. constructor(name: string);
  125868. /**
  125869. * Gets the current class name
  125870. * @returns the class name
  125871. */
  125872. getClassName(): string;
  125873. /**
  125874. * Gets the world normal input component
  125875. */
  125876. readonly worldNormal: NodeMaterialConnectionPoint;
  125877. /**
  125878. * Gets the view direction input component
  125879. */
  125880. readonly viewDirection: NodeMaterialConnectionPoint;
  125881. /**
  125882. * Gets the bias input component
  125883. */
  125884. readonly bias: NodeMaterialConnectionPoint;
  125885. /**
  125886. * Gets the camera (or eye) position component
  125887. */
  125888. readonly power: NodeMaterialConnectionPoint;
  125889. /**
  125890. * Gets the fresnel output component
  125891. */
  125892. readonly fresnel: NodeMaterialConnectionPoint;
  125893. autoConfigure(material: NodeMaterial): void;
  125894. protected _buildBlock(state: NodeMaterialBuildState): this;
  125895. }
  125896. }
  125897. declare module BABYLON {
  125898. /**
  125899. * Block used to get the max of 2 values
  125900. */
  125901. export class MaxBlock extends NodeMaterialBlock {
  125902. /**
  125903. * Creates a new MaxBlock
  125904. * @param name defines the block name
  125905. */
  125906. constructor(name: string);
  125907. /**
  125908. * Gets the current class name
  125909. * @returns the class name
  125910. */
  125911. getClassName(): string;
  125912. /**
  125913. * Gets the left operand input component
  125914. */
  125915. readonly left: NodeMaterialConnectionPoint;
  125916. /**
  125917. * Gets the right operand input component
  125918. */
  125919. readonly right: NodeMaterialConnectionPoint;
  125920. /**
  125921. * Gets the output component
  125922. */
  125923. readonly output: NodeMaterialConnectionPoint;
  125924. protected _buildBlock(state: NodeMaterialBuildState): this;
  125925. }
  125926. }
  125927. declare module BABYLON {
  125928. /**
  125929. * Block used to get the min of 2 values
  125930. */
  125931. export class MinBlock extends NodeMaterialBlock {
  125932. /**
  125933. * Creates a new MinBlock
  125934. * @param name defines the block name
  125935. */
  125936. constructor(name: string);
  125937. /**
  125938. * Gets the current class name
  125939. * @returns the class name
  125940. */
  125941. getClassName(): string;
  125942. /**
  125943. * Gets the left operand input component
  125944. */
  125945. readonly left: NodeMaterialConnectionPoint;
  125946. /**
  125947. * Gets the right operand input component
  125948. */
  125949. readonly right: NodeMaterialConnectionPoint;
  125950. /**
  125951. * Gets the output component
  125952. */
  125953. readonly output: NodeMaterialConnectionPoint;
  125954. protected _buildBlock(state: NodeMaterialBuildState): this;
  125955. }
  125956. }
  125957. declare module BABYLON {
  125958. /**
  125959. * Block used to get the distance between 2 values
  125960. */
  125961. export class DistanceBlock extends NodeMaterialBlock {
  125962. /**
  125963. * Creates a new DistanceBlock
  125964. * @param name defines the block name
  125965. */
  125966. constructor(name: string);
  125967. /**
  125968. * Gets the current class name
  125969. * @returns the class name
  125970. */
  125971. getClassName(): string;
  125972. /**
  125973. * Gets the left operand input component
  125974. */
  125975. readonly left: NodeMaterialConnectionPoint;
  125976. /**
  125977. * Gets the right operand input component
  125978. */
  125979. readonly right: NodeMaterialConnectionPoint;
  125980. /**
  125981. * Gets the output component
  125982. */
  125983. readonly output: NodeMaterialConnectionPoint;
  125984. protected _buildBlock(state: NodeMaterialBuildState): this;
  125985. }
  125986. }
  125987. declare module BABYLON {
  125988. /**
  125989. * Block used to get the length of a vector
  125990. */
  125991. export class LengthBlock extends NodeMaterialBlock {
  125992. /**
  125993. * Creates a new LengthBlock
  125994. * @param name defines the block name
  125995. */
  125996. constructor(name: string);
  125997. /**
  125998. * Gets the current class name
  125999. * @returns the class name
  126000. */
  126001. getClassName(): string;
  126002. /**
  126003. * Gets the value input component
  126004. */
  126005. readonly value: NodeMaterialConnectionPoint;
  126006. /**
  126007. * Gets the output component
  126008. */
  126009. readonly output: NodeMaterialConnectionPoint;
  126010. protected _buildBlock(state: NodeMaterialBuildState): this;
  126011. }
  126012. }
  126013. declare module BABYLON {
  126014. /**
  126015. * Block used to get negative version of a value (i.e. x * -1)
  126016. */
  126017. export class NegateBlock extends NodeMaterialBlock {
  126018. /**
  126019. * Creates a new NegateBlock
  126020. * @param name defines the block name
  126021. */
  126022. constructor(name: string);
  126023. /**
  126024. * Gets the current class name
  126025. * @returns the class name
  126026. */
  126027. getClassName(): string;
  126028. /**
  126029. * Gets the value input component
  126030. */
  126031. readonly value: NodeMaterialConnectionPoint;
  126032. /**
  126033. * Gets the output component
  126034. */
  126035. readonly output: NodeMaterialConnectionPoint;
  126036. protected _buildBlock(state: NodeMaterialBuildState): this;
  126037. }
  126038. }
  126039. declare module BABYLON {
  126040. /**
  126041. * Block used to get the value of the first parameter raised to the power of the second
  126042. */
  126043. export class PowBlock extends NodeMaterialBlock {
  126044. /**
  126045. * Creates a new PowBlock
  126046. * @param name defines the block name
  126047. */
  126048. constructor(name: string);
  126049. /**
  126050. * Gets the current class name
  126051. * @returns the class name
  126052. */
  126053. getClassName(): string;
  126054. /**
  126055. * Gets the value operand input component
  126056. */
  126057. readonly value: NodeMaterialConnectionPoint;
  126058. /**
  126059. * Gets the power operand input component
  126060. */
  126061. readonly power: NodeMaterialConnectionPoint;
  126062. /**
  126063. * Gets the output component
  126064. */
  126065. readonly output: NodeMaterialConnectionPoint;
  126066. protected _buildBlock(state: NodeMaterialBuildState): this;
  126067. }
  126068. }
  126069. declare module BABYLON {
  126070. /**
  126071. * Block used to get a random number
  126072. */
  126073. export class RandomNumberBlock extends NodeMaterialBlock {
  126074. /**
  126075. * Creates a new RandomNumberBlock
  126076. * @param name defines the block name
  126077. */
  126078. constructor(name: string);
  126079. /**
  126080. * Gets the current class name
  126081. * @returns the class name
  126082. */
  126083. getClassName(): string;
  126084. /**
  126085. * Gets the seed input component
  126086. */
  126087. readonly seed: NodeMaterialConnectionPoint;
  126088. /**
  126089. * Gets the output component
  126090. */
  126091. readonly output: NodeMaterialConnectionPoint;
  126092. protected _buildBlock(state: NodeMaterialBuildState): this;
  126093. }
  126094. }
  126095. declare module BABYLON {
  126096. /**
  126097. * Block used to compute arc tangent of 2 values
  126098. */
  126099. export class ArcTan2Block extends NodeMaterialBlock {
  126100. /**
  126101. * Creates a new ArcTan2Block
  126102. * @param name defines the block name
  126103. */
  126104. constructor(name: string);
  126105. /**
  126106. * Gets the current class name
  126107. * @returns the class name
  126108. */
  126109. getClassName(): string;
  126110. /**
  126111. * Gets the x operand input component
  126112. */
  126113. readonly x: NodeMaterialConnectionPoint;
  126114. /**
  126115. * Gets the y operand input component
  126116. */
  126117. readonly y: NodeMaterialConnectionPoint;
  126118. /**
  126119. * Gets the output component
  126120. */
  126121. readonly output: NodeMaterialConnectionPoint;
  126122. protected _buildBlock(state: NodeMaterialBuildState): this;
  126123. }
  126124. }
  126125. declare module BABYLON {
  126126. /**
  126127. * Block used to smooth step a value
  126128. */
  126129. export class SmoothStepBlock extends NodeMaterialBlock {
  126130. /**
  126131. * Creates a new SmoothStepBlock
  126132. * @param name defines the block name
  126133. */
  126134. constructor(name: string);
  126135. /**
  126136. * Gets the current class name
  126137. * @returns the class name
  126138. */
  126139. getClassName(): string;
  126140. /**
  126141. * Gets the value operand input component
  126142. */
  126143. readonly value: NodeMaterialConnectionPoint;
  126144. /**
  126145. * Gets the first edge operand input component
  126146. */
  126147. readonly edge0: NodeMaterialConnectionPoint;
  126148. /**
  126149. * Gets the second edge operand input component
  126150. */
  126151. readonly edge1: NodeMaterialConnectionPoint;
  126152. /**
  126153. * Gets the output component
  126154. */
  126155. readonly output: NodeMaterialConnectionPoint;
  126156. protected _buildBlock(state: NodeMaterialBuildState): this;
  126157. }
  126158. }
  126159. declare module BABYLON {
  126160. /**
  126161. * Block used to get the reciprocal (1 / x) of a value
  126162. */
  126163. export class ReciprocalBlock extends NodeMaterialBlock {
  126164. /**
  126165. * Creates a new ReciprocalBlock
  126166. * @param name defines the block name
  126167. */
  126168. constructor(name: string);
  126169. /**
  126170. * Gets the current class name
  126171. * @returns the class name
  126172. */
  126173. getClassName(): string;
  126174. /**
  126175. * Gets the input component
  126176. */
  126177. readonly input: NodeMaterialConnectionPoint;
  126178. /**
  126179. * Gets the output component
  126180. */
  126181. readonly output: NodeMaterialConnectionPoint;
  126182. protected _buildBlock(state: NodeMaterialBuildState): this;
  126183. }
  126184. }
  126185. declare module BABYLON {
  126186. /**
  126187. * Block used to replace a color by another one
  126188. */
  126189. export class ReplaceColorBlock extends NodeMaterialBlock {
  126190. /**
  126191. * Creates a new ReplaceColorBlock
  126192. * @param name defines the block name
  126193. */
  126194. constructor(name: string);
  126195. /**
  126196. * Gets the current class name
  126197. * @returns the class name
  126198. */
  126199. getClassName(): string;
  126200. /**
  126201. * Gets the value input component
  126202. */
  126203. readonly value: NodeMaterialConnectionPoint;
  126204. /**
  126205. * Gets the reference input component
  126206. */
  126207. readonly reference: NodeMaterialConnectionPoint;
  126208. /**
  126209. * Gets the distance input component
  126210. */
  126211. readonly distance: NodeMaterialConnectionPoint;
  126212. /**
  126213. * Gets the replacement input component
  126214. */
  126215. readonly replacement: NodeMaterialConnectionPoint;
  126216. /**
  126217. * Gets the output component
  126218. */
  126219. readonly output: NodeMaterialConnectionPoint;
  126220. protected _buildBlock(state: NodeMaterialBuildState): this;
  126221. }
  126222. }
  126223. declare module BABYLON {
  126224. /**
  126225. * Block used to posterize a value
  126226. * @see https://en.wikipedia.org/wiki/Posterization
  126227. */
  126228. export class PosterizeBlock extends NodeMaterialBlock {
  126229. /**
  126230. * Creates a new PosterizeBlock
  126231. * @param name defines the block name
  126232. */
  126233. constructor(name: string);
  126234. /**
  126235. * Gets the current class name
  126236. * @returns the class name
  126237. */
  126238. getClassName(): string;
  126239. /**
  126240. * Gets the value input component
  126241. */
  126242. readonly value: NodeMaterialConnectionPoint;
  126243. /**
  126244. * Gets the steps input component
  126245. */
  126246. readonly steps: NodeMaterialConnectionPoint;
  126247. /**
  126248. * Gets the output component
  126249. */
  126250. readonly output: NodeMaterialConnectionPoint;
  126251. protected _buildBlock(state: NodeMaterialBuildState): this;
  126252. }
  126253. }
  126254. declare module BABYLON {
  126255. /**
  126256. * Operations supported by the Wave block
  126257. */
  126258. export enum WaveBlockKind {
  126259. /** SawTooth */
  126260. SawTooth = 0,
  126261. /** Square */
  126262. Square = 1,
  126263. /** Triangle */
  126264. Triangle = 2
  126265. }
  126266. /**
  126267. * Block used to apply wave operation to floats
  126268. */
  126269. export class WaveBlock extends NodeMaterialBlock {
  126270. /**
  126271. * Gets or sets the kibnd of wave to be applied by the block
  126272. */
  126273. kind: WaveBlockKind;
  126274. /**
  126275. * Creates a new WaveBlock
  126276. * @param name defines the block name
  126277. */
  126278. constructor(name: string);
  126279. /**
  126280. * Gets the current class name
  126281. * @returns the class name
  126282. */
  126283. getClassName(): string;
  126284. /**
  126285. * Gets the input component
  126286. */
  126287. readonly input: NodeMaterialConnectionPoint;
  126288. /**
  126289. * Gets the output component
  126290. */
  126291. readonly output: NodeMaterialConnectionPoint;
  126292. protected _buildBlock(state: NodeMaterialBuildState): this;
  126293. serialize(): any;
  126294. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126295. }
  126296. }
  126297. declare module BABYLON {
  126298. /**
  126299. * Class used to store a color step for the GradientBlock
  126300. */
  126301. export class GradientBlockColorStep {
  126302. /**
  126303. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  126304. */
  126305. step: number;
  126306. /**
  126307. * Gets or sets the color associated with this step
  126308. */
  126309. color: Color3;
  126310. /**
  126311. * Creates a new GradientBlockColorStep
  126312. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  126313. * @param color defines the color associated with this step
  126314. */
  126315. constructor(
  126316. /**
  126317. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  126318. */
  126319. step: number,
  126320. /**
  126321. * Gets or sets the color associated with this step
  126322. */
  126323. color: Color3);
  126324. }
  126325. /**
  126326. * Block used to return a color from a gradient based on an input value between 0 and 1
  126327. */
  126328. export class GradientBlock extends NodeMaterialBlock {
  126329. /**
  126330. * Gets or sets the list of color steps
  126331. */
  126332. colorSteps: GradientBlockColorStep[];
  126333. /**
  126334. * Creates a new GradientBlock
  126335. * @param name defines the block name
  126336. */
  126337. constructor(name: string);
  126338. /**
  126339. * Gets the current class name
  126340. * @returns the class name
  126341. */
  126342. getClassName(): string;
  126343. /**
  126344. * Gets the gradient input component
  126345. */
  126346. readonly gradient: NodeMaterialConnectionPoint;
  126347. /**
  126348. * Gets the output component
  126349. */
  126350. readonly output: NodeMaterialConnectionPoint;
  126351. private _writeColorConstant;
  126352. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  126353. serialize(): any;
  126354. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126355. protected _dumpPropertiesCode(): string;
  126356. }
  126357. }
  126358. declare module BABYLON {
  126359. /**
  126360. * Block used to normalize lerp between 2 values
  126361. */
  126362. export class NLerpBlock extends NodeMaterialBlock {
  126363. /**
  126364. * Creates a new NLerpBlock
  126365. * @param name defines the block name
  126366. */
  126367. constructor(name: string);
  126368. /**
  126369. * Gets the current class name
  126370. * @returns the class name
  126371. */
  126372. getClassName(): string;
  126373. /**
  126374. * Gets the left operand input component
  126375. */
  126376. readonly left: NodeMaterialConnectionPoint;
  126377. /**
  126378. * Gets the right operand input component
  126379. */
  126380. readonly right: NodeMaterialConnectionPoint;
  126381. /**
  126382. * Gets the gradient operand input component
  126383. */
  126384. readonly gradient: NodeMaterialConnectionPoint;
  126385. /**
  126386. * Gets the output component
  126387. */
  126388. readonly output: NodeMaterialConnectionPoint;
  126389. protected _buildBlock(state: NodeMaterialBuildState): this;
  126390. }
  126391. }
  126392. declare module BABYLON {
  126393. /**
  126394. * block used to Generate a Worley Noise 3D Noise Pattern
  126395. */
  126396. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  126397. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  126398. manhattanDistance: boolean;
  126399. /**
  126400. * Creates a new WorleyNoise3DBlock
  126401. * @param name defines the block name
  126402. */
  126403. constructor(name: string);
  126404. /**
  126405. * Gets the current class name
  126406. * @returns the class name
  126407. */
  126408. getClassName(): string;
  126409. /**
  126410. * Gets the seed input component
  126411. */
  126412. readonly seed: NodeMaterialConnectionPoint;
  126413. /**
  126414. * Gets the jitter input component
  126415. */
  126416. readonly jitter: NodeMaterialConnectionPoint;
  126417. /**
  126418. * Gets the output component
  126419. */
  126420. readonly output: NodeMaterialConnectionPoint;
  126421. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  126422. /**
  126423. * Exposes the properties to the UI?
  126424. */
  126425. protected _dumpPropertiesCode(): string;
  126426. /**
  126427. * Exposes the properties to the Seralize?
  126428. */
  126429. serialize(): any;
  126430. /**
  126431. * Exposes the properties to the deseralize?
  126432. */
  126433. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126434. }
  126435. }
  126436. declare module BABYLON {
  126437. /**
  126438. * block used to Generate a Simplex Perlin 3d Noise Pattern
  126439. */
  126440. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  126441. /**
  126442. * Creates a new SimplexPerlin3DBlock
  126443. * @param name defines the block name
  126444. */
  126445. constructor(name: string);
  126446. /**
  126447. * Gets the current class name
  126448. * @returns the class name
  126449. */
  126450. getClassName(): string;
  126451. /**
  126452. * Gets the seed operand input component
  126453. */
  126454. readonly seed: NodeMaterialConnectionPoint;
  126455. /**
  126456. * Gets the output component
  126457. */
  126458. readonly output: NodeMaterialConnectionPoint;
  126459. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  126460. }
  126461. }
  126462. declare module BABYLON {
  126463. /**
  126464. * Block used to blend normals
  126465. */
  126466. export class NormalBlendBlock extends NodeMaterialBlock {
  126467. /**
  126468. * Creates a new NormalBlendBlock
  126469. * @param name defines the block name
  126470. */
  126471. constructor(name: string);
  126472. /**
  126473. * Gets the current class name
  126474. * @returns the class name
  126475. */
  126476. getClassName(): string;
  126477. /**
  126478. * Gets the first input component
  126479. */
  126480. readonly normalMap0: NodeMaterialConnectionPoint;
  126481. /**
  126482. * Gets the second input component
  126483. */
  126484. readonly normalMap1: NodeMaterialConnectionPoint;
  126485. /**
  126486. * Gets the output component
  126487. */
  126488. readonly output: NodeMaterialConnectionPoint;
  126489. protected _buildBlock(state: NodeMaterialBuildState): this;
  126490. }
  126491. }
  126492. declare module BABYLON {
  126493. /**
  126494. * Block used to rotate a 2d vector by a given angle
  126495. */
  126496. export class Rotate2dBlock extends NodeMaterialBlock {
  126497. /**
  126498. * Creates a new Rotate2dBlock
  126499. * @param name defines the block name
  126500. */
  126501. constructor(name: string);
  126502. /**
  126503. * Gets the current class name
  126504. * @returns the class name
  126505. */
  126506. getClassName(): string;
  126507. /**
  126508. * Gets the input vector
  126509. */
  126510. readonly input: NodeMaterialConnectionPoint;
  126511. /**
  126512. * Gets the input angle
  126513. */
  126514. readonly angle: NodeMaterialConnectionPoint;
  126515. /**
  126516. * Gets the output component
  126517. */
  126518. readonly output: NodeMaterialConnectionPoint;
  126519. autoConfigure(material: NodeMaterial): void;
  126520. protected _buildBlock(state: NodeMaterialBuildState): this;
  126521. }
  126522. }
  126523. declare module BABYLON {
  126524. /**
  126525. * Block used to get the reflected vector from a direction and a normal
  126526. */
  126527. export class ReflectBlock extends NodeMaterialBlock {
  126528. /**
  126529. * Creates a new ReflectBlock
  126530. * @param name defines the block name
  126531. */
  126532. constructor(name: string);
  126533. /**
  126534. * Gets the current class name
  126535. * @returns the class name
  126536. */
  126537. getClassName(): string;
  126538. /**
  126539. * Gets the incident component
  126540. */
  126541. readonly incident: NodeMaterialConnectionPoint;
  126542. /**
  126543. * Gets the normal component
  126544. */
  126545. readonly normal: NodeMaterialConnectionPoint;
  126546. /**
  126547. * Gets the output component
  126548. */
  126549. readonly output: NodeMaterialConnectionPoint;
  126550. protected _buildBlock(state: NodeMaterialBuildState): this;
  126551. }
  126552. }
  126553. declare module BABYLON {
  126554. /**
  126555. * Block used to get the refracted vector from a direction and a normal
  126556. */
  126557. export class RefractBlock extends NodeMaterialBlock {
  126558. /**
  126559. * Creates a new RefractBlock
  126560. * @param name defines the block name
  126561. */
  126562. constructor(name: string);
  126563. /**
  126564. * Gets the current class name
  126565. * @returns the class name
  126566. */
  126567. getClassName(): string;
  126568. /**
  126569. * Gets the incident component
  126570. */
  126571. readonly incident: NodeMaterialConnectionPoint;
  126572. /**
  126573. * Gets the normal component
  126574. */
  126575. readonly normal: NodeMaterialConnectionPoint;
  126576. /**
  126577. * Gets the index of refraction component
  126578. */
  126579. readonly ior: NodeMaterialConnectionPoint;
  126580. /**
  126581. * Gets the output component
  126582. */
  126583. readonly output: NodeMaterialConnectionPoint;
  126584. protected _buildBlock(state: NodeMaterialBuildState): this;
  126585. }
  126586. }
  126587. declare module BABYLON {
  126588. /**
  126589. * Block used to desaturate a color
  126590. */
  126591. export class DesaturateBlock extends NodeMaterialBlock {
  126592. /**
  126593. * Creates a new DesaturateBlock
  126594. * @param name defines the block name
  126595. */
  126596. constructor(name: string);
  126597. /**
  126598. * Gets the current class name
  126599. * @returns the class name
  126600. */
  126601. getClassName(): string;
  126602. /**
  126603. * Gets the color operand input component
  126604. */
  126605. readonly color: NodeMaterialConnectionPoint;
  126606. /**
  126607. * Gets the level operand input component
  126608. */
  126609. readonly level: NodeMaterialConnectionPoint;
  126610. /**
  126611. * Gets the output component
  126612. */
  126613. readonly output: NodeMaterialConnectionPoint;
  126614. protected _buildBlock(state: NodeMaterialBuildState): this;
  126615. }
  126616. }
  126617. declare module BABYLON {
  126618. /**
  126619. * Effect Render Options
  126620. */
  126621. export interface IEffectRendererOptions {
  126622. /**
  126623. * Defines the vertices positions.
  126624. */
  126625. positions?: number[];
  126626. /**
  126627. * Defines the indices.
  126628. */
  126629. indices?: number[];
  126630. }
  126631. /**
  126632. * Helper class to render one or more effects
  126633. */
  126634. export class EffectRenderer {
  126635. private engine;
  126636. private static _DefaultOptions;
  126637. private _vertexBuffers;
  126638. private _indexBuffer;
  126639. private _ringBufferIndex;
  126640. private _ringScreenBuffer;
  126641. private _fullscreenViewport;
  126642. private _getNextFrameBuffer;
  126643. /**
  126644. * Creates an effect renderer
  126645. * @param engine the engine to use for rendering
  126646. * @param options defines the options of the effect renderer
  126647. */
  126648. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  126649. /**
  126650. * Sets the current viewport in normalized coordinates 0-1
  126651. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  126652. */
  126653. setViewport(viewport?: Viewport): void;
  126654. /**
  126655. * Binds the embedded attributes buffer to the effect.
  126656. * @param effect Defines the effect to bind the attributes for
  126657. */
  126658. bindBuffers(effect: Effect): void;
  126659. /**
  126660. * Sets the current effect wrapper to use during draw.
  126661. * The effect needs to be ready before calling this api.
  126662. * This also sets the default full screen position attribute.
  126663. * @param effectWrapper Defines the effect to draw with
  126664. */
  126665. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  126666. /**
  126667. * Draws a full screen quad.
  126668. */
  126669. draw(): void;
  126670. /**
  126671. * renders one or more effects to a specified texture
  126672. * @param effectWrappers list of effects to renderer
  126673. * @param outputTexture texture to draw to, if null it will render to the screen
  126674. */
  126675. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  126676. /**
  126677. * Disposes of the effect renderer
  126678. */
  126679. dispose(): void;
  126680. }
  126681. /**
  126682. * Options to create an EffectWrapper
  126683. */
  126684. interface EffectWrapperCreationOptions {
  126685. /**
  126686. * Engine to use to create the effect
  126687. */
  126688. engine: ThinEngine;
  126689. /**
  126690. * Fragment shader for the effect
  126691. */
  126692. fragmentShader: string;
  126693. /**
  126694. * Vertex shader for the effect
  126695. */
  126696. vertexShader?: string;
  126697. /**
  126698. * Attributes to use in the shader
  126699. */
  126700. attributeNames?: Array<string>;
  126701. /**
  126702. * Uniforms to use in the shader
  126703. */
  126704. uniformNames?: Array<string>;
  126705. /**
  126706. * Texture sampler names to use in the shader
  126707. */
  126708. samplerNames?: Array<string>;
  126709. /**
  126710. * The friendly name of the effect displayed in Spector.
  126711. */
  126712. name?: string;
  126713. }
  126714. /**
  126715. * Wraps an effect to be used for rendering
  126716. */
  126717. export class EffectWrapper {
  126718. /**
  126719. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  126720. */
  126721. onApplyObservable: Observable<{}>;
  126722. /**
  126723. * The underlying effect
  126724. */
  126725. effect: Effect;
  126726. /**
  126727. * Creates an effect to be renderer
  126728. * @param creationOptions options to create the effect
  126729. */
  126730. constructor(creationOptions: EffectWrapperCreationOptions);
  126731. /**
  126732. * Disposes of the effect wrapper
  126733. */
  126734. dispose(): void;
  126735. }
  126736. }
  126737. declare module BABYLON {
  126738. /**
  126739. * Helper class to push actions to a pool of workers.
  126740. */
  126741. export class WorkerPool implements IDisposable {
  126742. private _workerInfos;
  126743. private _pendingActions;
  126744. /**
  126745. * Constructor
  126746. * @param workers Array of workers to use for actions
  126747. */
  126748. constructor(workers: Array<Worker>);
  126749. /**
  126750. * Terminates all workers and clears any pending actions.
  126751. */
  126752. dispose(): void;
  126753. /**
  126754. * Pushes an action to the worker pool. If all the workers are active, the action will be
  126755. * pended until a worker has completed its action.
  126756. * @param action The action to perform. Call onComplete when the action is complete.
  126757. */
  126758. push(action: (worker: Worker, onComplete: () => void) => void): void;
  126759. private _execute;
  126760. }
  126761. }
  126762. declare module BABYLON {
  126763. /**
  126764. * Configuration for Draco compression
  126765. */
  126766. export interface IDracoCompressionConfiguration {
  126767. /**
  126768. * Configuration for the decoder.
  126769. */
  126770. decoder: {
  126771. /**
  126772. * The url to the WebAssembly module.
  126773. */
  126774. wasmUrl?: string;
  126775. /**
  126776. * The url to the WebAssembly binary.
  126777. */
  126778. wasmBinaryUrl?: string;
  126779. /**
  126780. * The url to the fallback JavaScript module.
  126781. */
  126782. fallbackUrl?: string;
  126783. };
  126784. }
  126785. /**
  126786. * Draco compression (https://google.github.io/draco/)
  126787. *
  126788. * This class wraps the Draco module.
  126789. *
  126790. * **Encoder**
  126791. *
  126792. * The encoder is not currently implemented.
  126793. *
  126794. * **Decoder**
  126795. *
  126796. * 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.
  126797. *
  126798. * To update the configuration, use the following code:
  126799. * ```javascript
  126800. * DracoCompression.Configuration = {
  126801. * decoder: {
  126802. * wasmUrl: "<url to the WebAssembly library>",
  126803. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  126804. * fallbackUrl: "<url to the fallback JavaScript library>",
  126805. * }
  126806. * };
  126807. * ```
  126808. *
  126809. * 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.
  126810. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  126811. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  126812. *
  126813. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  126814. * ```javascript
  126815. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  126816. * ```
  126817. *
  126818. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  126819. */
  126820. export class DracoCompression implements IDisposable {
  126821. private _workerPoolPromise?;
  126822. private _decoderModulePromise?;
  126823. /**
  126824. * The configuration. Defaults to the following urls:
  126825. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  126826. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  126827. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  126828. */
  126829. static Configuration: IDracoCompressionConfiguration;
  126830. /**
  126831. * Returns true if the decoder configuration is available.
  126832. */
  126833. static readonly DecoderAvailable: boolean;
  126834. /**
  126835. * Default number of workers to create when creating the draco compression object.
  126836. */
  126837. static DefaultNumWorkers: number;
  126838. private static GetDefaultNumWorkers;
  126839. private static _Default;
  126840. /**
  126841. * Default instance for the draco compression object.
  126842. */
  126843. static readonly Default: DracoCompression;
  126844. /**
  126845. * Constructor
  126846. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  126847. */
  126848. constructor(numWorkers?: number);
  126849. /**
  126850. * Stop all async operations and release resources.
  126851. */
  126852. dispose(): void;
  126853. /**
  126854. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  126855. * @returns a promise that resolves when ready
  126856. */
  126857. whenReadyAsync(): Promise<void>;
  126858. /**
  126859. * Decode Draco compressed mesh data to vertex data.
  126860. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  126861. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  126862. * @returns A promise that resolves with the decoded vertex data
  126863. */
  126864. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  126865. [kind: string]: number;
  126866. }): Promise<VertexData>;
  126867. }
  126868. }
  126869. declare module BABYLON {
  126870. /**
  126871. * Class for building Constructive Solid Geometry
  126872. */
  126873. export class CSG {
  126874. private polygons;
  126875. /**
  126876. * The world matrix
  126877. */
  126878. matrix: Matrix;
  126879. /**
  126880. * Stores the position
  126881. */
  126882. position: Vector3;
  126883. /**
  126884. * Stores the rotation
  126885. */
  126886. rotation: Vector3;
  126887. /**
  126888. * Stores the rotation quaternion
  126889. */
  126890. rotationQuaternion: Nullable<Quaternion>;
  126891. /**
  126892. * Stores the scaling vector
  126893. */
  126894. scaling: Vector3;
  126895. /**
  126896. * Convert the Mesh to CSG
  126897. * @param mesh The Mesh to convert to CSG
  126898. * @returns A new CSG from the Mesh
  126899. */
  126900. static FromMesh(mesh: Mesh): CSG;
  126901. /**
  126902. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  126903. * @param polygons Polygons used to construct a CSG solid
  126904. */
  126905. private static FromPolygons;
  126906. /**
  126907. * Clones, or makes a deep copy, of the CSG
  126908. * @returns A new CSG
  126909. */
  126910. clone(): CSG;
  126911. /**
  126912. * Unions this CSG with another CSG
  126913. * @param csg The CSG to union against this CSG
  126914. * @returns The unioned CSG
  126915. */
  126916. union(csg: CSG): CSG;
  126917. /**
  126918. * Unions this CSG with another CSG in place
  126919. * @param csg The CSG to union against this CSG
  126920. */
  126921. unionInPlace(csg: CSG): void;
  126922. /**
  126923. * Subtracts this CSG with another CSG
  126924. * @param csg The CSG to subtract against this CSG
  126925. * @returns A new CSG
  126926. */
  126927. subtract(csg: CSG): CSG;
  126928. /**
  126929. * Subtracts this CSG with another CSG in place
  126930. * @param csg The CSG to subtact against this CSG
  126931. */
  126932. subtractInPlace(csg: CSG): void;
  126933. /**
  126934. * Intersect this CSG with another CSG
  126935. * @param csg The CSG to intersect against this CSG
  126936. * @returns A new CSG
  126937. */
  126938. intersect(csg: CSG): CSG;
  126939. /**
  126940. * Intersects this CSG with another CSG in place
  126941. * @param csg The CSG to intersect against this CSG
  126942. */
  126943. intersectInPlace(csg: CSG): void;
  126944. /**
  126945. * Return a new CSG solid with solid and empty space switched. This solid is
  126946. * not modified.
  126947. * @returns A new CSG solid with solid and empty space switched
  126948. */
  126949. inverse(): CSG;
  126950. /**
  126951. * Inverses the CSG in place
  126952. */
  126953. inverseInPlace(): void;
  126954. /**
  126955. * This is used to keep meshes transformations so they can be restored
  126956. * when we build back a Babylon Mesh
  126957. * NB : All CSG operations are performed in world coordinates
  126958. * @param csg The CSG to copy the transform attributes from
  126959. * @returns This CSG
  126960. */
  126961. copyTransformAttributes(csg: CSG): CSG;
  126962. /**
  126963. * Build Raw mesh from CSG
  126964. * Coordinates here are in world space
  126965. * @param name The name of the mesh geometry
  126966. * @param scene The Scene
  126967. * @param keepSubMeshes Specifies if the submeshes should be kept
  126968. * @returns A new Mesh
  126969. */
  126970. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  126971. /**
  126972. * Build Mesh from CSG taking material and transforms into account
  126973. * @param name The name of the Mesh
  126974. * @param material The material of the Mesh
  126975. * @param scene The Scene
  126976. * @param keepSubMeshes Specifies if submeshes should be kept
  126977. * @returns The new Mesh
  126978. */
  126979. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  126980. }
  126981. }
  126982. declare module BABYLON {
  126983. /**
  126984. * Class used to create a trail following a mesh
  126985. */
  126986. export class TrailMesh extends Mesh {
  126987. private _generator;
  126988. private _autoStart;
  126989. private _running;
  126990. private _diameter;
  126991. private _length;
  126992. private _sectionPolygonPointsCount;
  126993. private _sectionVectors;
  126994. private _sectionNormalVectors;
  126995. private _beforeRenderObserver;
  126996. /**
  126997. * @constructor
  126998. * @param name The value used by scene.getMeshByName() to do a lookup.
  126999. * @param generator The mesh to generate a trail.
  127000. * @param scene The scene to add this mesh to.
  127001. * @param diameter Diameter of trailing mesh. Default is 1.
  127002. * @param length Length of trailing mesh. Default is 60.
  127003. * @param autoStart Automatically start trailing mesh. Default true.
  127004. */
  127005. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  127006. /**
  127007. * "TrailMesh"
  127008. * @returns "TrailMesh"
  127009. */
  127010. getClassName(): string;
  127011. private _createMesh;
  127012. /**
  127013. * Start trailing mesh.
  127014. */
  127015. start(): void;
  127016. /**
  127017. * Stop trailing mesh.
  127018. */
  127019. stop(): void;
  127020. /**
  127021. * Update trailing mesh geometry.
  127022. */
  127023. update(): void;
  127024. /**
  127025. * Returns a new TrailMesh object.
  127026. * @param name is a string, the name given to the new mesh
  127027. * @param newGenerator use new generator object for cloned trail mesh
  127028. * @returns a new mesh
  127029. */
  127030. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  127031. /**
  127032. * Serializes this trail mesh
  127033. * @param serializationObject object to write serialization to
  127034. */
  127035. serialize(serializationObject: any): void;
  127036. /**
  127037. * Parses a serialized trail mesh
  127038. * @param parsedMesh the serialized mesh
  127039. * @param scene the scene to create the trail mesh in
  127040. * @returns the created trail mesh
  127041. */
  127042. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  127043. }
  127044. }
  127045. declare module BABYLON {
  127046. /**
  127047. * Class containing static functions to help procedurally build meshes
  127048. */
  127049. export class TiledBoxBuilder {
  127050. /**
  127051. * Creates a box mesh
  127052. * 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)
  127053. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  127054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127055. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127057. * @param name defines the name of the mesh
  127058. * @param options defines the options used to create the mesh
  127059. * @param scene defines the hosting scene
  127060. * @returns the box mesh
  127061. */
  127062. static CreateTiledBox(name: string, options: {
  127063. pattern?: number;
  127064. width?: number;
  127065. height?: number;
  127066. depth?: number;
  127067. tileSize?: number;
  127068. tileWidth?: number;
  127069. tileHeight?: number;
  127070. alignHorizontal?: number;
  127071. alignVertical?: number;
  127072. faceUV?: Vector4[];
  127073. faceColors?: Color4[];
  127074. sideOrientation?: number;
  127075. updatable?: boolean;
  127076. }, scene?: Nullable<Scene>): Mesh;
  127077. }
  127078. }
  127079. declare module BABYLON {
  127080. /**
  127081. * Class containing static functions to help procedurally build meshes
  127082. */
  127083. export class TorusKnotBuilder {
  127084. /**
  127085. * Creates a torus knot mesh
  127086. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  127087. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  127088. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  127089. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  127090. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127091. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127093. * @param name defines the name of the mesh
  127094. * @param options defines the options used to create the mesh
  127095. * @param scene defines the hosting scene
  127096. * @returns the torus knot mesh
  127097. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  127098. */
  127099. static CreateTorusKnot(name: string, options: {
  127100. radius?: number;
  127101. tube?: number;
  127102. radialSegments?: number;
  127103. tubularSegments?: number;
  127104. p?: number;
  127105. q?: number;
  127106. updatable?: boolean;
  127107. sideOrientation?: number;
  127108. frontUVs?: Vector4;
  127109. backUVs?: Vector4;
  127110. }, scene: any): Mesh;
  127111. }
  127112. }
  127113. declare module BABYLON {
  127114. /**
  127115. * Polygon
  127116. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  127117. */
  127118. export class Polygon {
  127119. /**
  127120. * Creates a rectangle
  127121. * @param xmin bottom X coord
  127122. * @param ymin bottom Y coord
  127123. * @param xmax top X coord
  127124. * @param ymax top Y coord
  127125. * @returns points that make the resulting rectation
  127126. */
  127127. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  127128. /**
  127129. * Creates a circle
  127130. * @param radius radius of circle
  127131. * @param cx scale in x
  127132. * @param cy scale in y
  127133. * @param numberOfSides number of sides that make up the circle
  127134. * @returns points that make the resulting circle
  127135. */
  127136. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  127137. /**
  127138. * Creates a polygon from input string
  127139. * @param input Input polygon data
  127140. * @returns the parsed points
  127141. */
  127142. static Parse(input: string): Vector2[];
  127143. /**
  127144. * Starts building a polygon from x and y coordinates
  127145. * @param x x coordinate
  127146. * @param y y coordinate
  127147. * @returns the started path2
  127148. */
  127149. static StartingAt(x: number, y: number): Path2;
  127150. }
  127151. /**
  127152. * Builds a polygon
  127153. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  127154. */
  127155. export class PolygonMeshBuilder {
  127156. private _points;
  127157. private _outlinepoints;
  127158. private _holes;
  127159. private _name;
  127160. private _scene;
  127161. private _epoints;
  127162. private _eholes;
  127163. private _addToepoint;
  127164. /**
  127165. * Babylon reference to the earcut plugin.
  127166. */
  127167. bjsEarcut: any;
  127168. /**
  127169. * Creates a PolygonMeshBuilder
  127170. * @param name name of the builder
  127171. * @param contours Path of the polygon
  127172. * @param scene scene to add to when creating the mesh
  127173. * @param earcutInjection can be used to inject your own earcut reference
  127174. */
  127175. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  127176. /**
  127177. * Adds a whole within the polygon
  127178. * @param hole Array of points defining the hole
  127179. * @returns this
  127180. */
  127181. addHole(hole: Vector2[]): PolygonMeshBuilder;
  127182. /**
  127183. * Creates the polygon
  127184. * @param updatable If the mesh should be updatable
  127185. * @param depth The depth of the mesh created
  127186. * @returns the created mesh
  127187. */
  127188. build(updatable?: boolean, depth?: number): Mesh;
  127189. /**
  127190. * Creates the polygon
  127191. * @param depth The depth of the mesh created
  127192. * @returns the created VertexData
  127193. */
  127194. buildVertexData(depth?: number): VertexData;
  127195. /**
  127196. * Adds a side to the polygon
  127197. * @param positions points that make the polygon
  127198. * @param normals normals of the polygon
  127199. * @param uvs uvs of the polygon
  127200. * @param indices indices of the polygon
  127201. * @param bounds bounds of the polygon
  127202. * @param points points of the polygon
  127203. * @param depth depth of the polygon
  127204. * @param flip flip of the polygon
  127205. */
  127206. private addSide;
  127207. }
  127208. }
  127209. declare module BABYLON {
  127210. /**
  127211. * Class containing static functions to help procedurally build meshes
  127212. */
  127213. export class PolygonBuilder {
  127214. /**
  127215. * Creates a polygon mesh
  127216. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  127217. * * 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
  127218. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  127219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127220. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  127221. * * Remember you can only change the shape positions, not their number when updating a polygon
  127222. * @param name defines the name of the mesh
  127223. * @param options defines the options used to create the mesh
  127224. * @param scene defines the hosting scene
  127225. * @param earcutInjection can be used to inject your own earcut reference
  127226. * @returns the polygon mesh
  127227. */
  127228. static CreatePolygon(name: string, options: {
  127229. shape: Vector3[];
  127230. holes?: Vector3[][];
  127231. depth?: number;
  127232. faceUV?: Vector4[];
  127233. faceColors?: Color4[];
  127234. updatable?: boolean;
  127235. sideOrientation?: number;
  127236. frontUVs?: Vector4;
  127237. backUVs?: Vector4;
  127238. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  127239. /**
  127240. * Creates an extruded polygon mesh, with depth in the Y direction.
  127241. * * 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)
  127242. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  127243. * @param name defines the name of the mesh
  127244. * @param options defines the options used to create the mesh
  127245. * @param scene defines the hosting scene
  127246. * @param earcutInjection can be used to inject your own earcut reference
  127247. * @returns the polygon mesh
  127248. */
  127249. static ExtrudePolygon(name: string, options: {
  127250. shape: Vector3[];
  127251. holes?: Vector3[][];
  127252. depth?: number;
  127253. faceUV?: Vector4[];
  127254. faceColors?: Color4[];
  127255. updatable?: boolean;
  127256. sideOrientation?: number;
  127257. frontUVs?: Vector4;
  127258. backUVs?: Vector4;
  127259. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  127260. }
  127261. }
  127262. declare module BABYLON {
  127263. /**
  127264. * Class containing static functions to help procedurally build meshes
  127265. */
  127266. export class LatheBuilder {
  127267. /**
  127268. * Creates lathe mesh.
  127269. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  127270. * * 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
  127271. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  127272. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  127273. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  127274. * * 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
  127275. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  127276. * * 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
  127277. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127278. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127279. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127281. * @param name defines the name of the mesh
  127282. * @param options defines the options used to create the mesh
  127283. * @param scene defines the hosting scene
  127284. * @returns the lathe mesh
  127285. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  127286. */
  127287. static CreateLathe(name: string, options: {
  127288. shape: Vector3[];
  127289. radius?: number;
  127290. tessellation?: number;
  127291. clip?: number;
  127292. arc?: number;
  127293. closed?: boolean;
  127294. updatable?: boolean;
  127295. sideOrientation?: number;
  127296. frontUVs?: Vector4;
  127297. backUVs?: Vector4;
  127298. cap?: number;
  127299. invertUV?: boolean;
  127300. }, scene?: Nullable<Scene>): Mesh;
  127301. }
  127302. }
  127303. declare module BABYLON {
  127304. /**
  127305. * Class containing static functions to help procedurally build meshes
  127306. */
  127307. export class TiledPlaneBuilder {
  127308. /**
  127309. * Creates a tiled plane mesh
  127310. * * The parameter `pattern` will, depending on value, do nothing or
  127311. * * * flip (reflect about central vertical) alternate tiles across and up
  127312. * * * flip every tile on alternate rows
  127313. * * * rotate (180 degs) alternate tiles across and up
  127314. * * * rotate every tile on alternate rows
  127315. * * * flip and rotate alternate tiles across and up
  127316. * * * flip and rotate every tile on alternate rows
  127317. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  127318. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  127319. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127320. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  127321. * * 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)
  127322. * * 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)
  127323. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  127324. * @param name defines the name of the mesh
  127325. * @param options defines the options used to create the mesh
  127326. * @param scene defines the hosting scene
  127327. * @returns the box mesh
  127328. */
  127329. static CreateTiledPlane(name: string, options: {
  127330. pattern?: number;
  127331. tileSize?: number;
  127332. tileWidth?: number;
  127333. tileHeight?: number;
  127334. size?: number;
  127335. width?: number;
  127336. height?: number;
  127337. alignHorizontal?: number;
  127338. alignVertical?: number;
  127339. sideOrientation?: number;
  127340. frontUVs?: Vector4;
  127341. backUVs?: Vector4;
  127342. updatable?: boolean;
  127343. }, scene?: Nullable<Scene>): Mesh;
  127344. }
  127345. }
  127346. declare module BABYLON {
  127347. /**
  127348. * Class containing static functions to help procedurally build meshes
  127349. */
  127350. export class TubeBuilder {
  127351. /**
  127352. * Creates a tube mesh.
  127353. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  127354. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  127355. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  127356. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  127357. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  127358. * * 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)
  127359. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  127360. * * 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
  127361. * * 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
  127362. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127363. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127364. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127366. * @param name defines the name of the mesh
  127367. * @param options defines the options used to create the mesh
  127368. * @param scene defines the hosting scene
  127369. * @returns the tube mesh
  127370. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127371. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  127372. */
  127373. static CreateTube(name: string, options: {
  127374. path: Vector3[];
  127375. radius?: number;
  127376. tessellation?: number;
  127377. radiusFunction?: {
  127378. (i: number, distance: number): number;
  127379. };
  127380. cap?: number;
  127381. arc?: number;
  127382. updatable?: boolean;
  127383. sideOrientation?: number;
  127384. frontUVs?: Vector4;
  127385. backUVs?: Vector4;
  127386. instance?: Mesh;
  127387. invertUV?: boolean;
  127388. }, scene?: Nullable<Scene>): Mesh;
  127389. }
  127390. }
  127391. declare module BABYLON {
  127392. /**
  127393. * Class containing static functions to help procedurally build meshes
  127394. */
  127395. export class IcoSphereBuilder {
  127396. /**
  127397. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  127398. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  127399. * * 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`)
  127400. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  127401. * * 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
  127402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127403. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127405. * @param name defines the name of the mesh
  127406. * @param options defines the options used to create the mesh
  127407. * @param scene defines the hosting scene
  127408. * @returns the icosahedron mesh
  127409. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  127410. */
  127411. static CreateIcoSphere(name: string, options: {
  127412. radius?: number;
  127413. radiusX?: number;
  127414. radiusY?: number;
  127415. radiusZ?: number;
  127416. flat?: boolean;
  127417. subdivisions?: number;
  127418. sideOrientation?: number;
  127419. frontUVs?: Vector4;
  127420. backUVs?: Vector4;
  127421. updatable?: boolean;
  127422. }, scene?: Nullable<Scene>): Mesh;
  127423. }
  127424. }
  127425. declare module BABYLON {
  127426. /**
  127427. * Class containing static functions to help procedurally build meshes
  127428. */
  127429. export class DecalBuilder {
  127430. /**
  127431. * Creates a decal mesh.
  127432. * 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
  127433. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  127434. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  127435. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  127436. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  127437. * @param name defines the name of the mesh
  127438. * @param sourceMesh defines the mesh where the decal must be applied
  127439. * @param options defines the options used to create the mesh
  127440. * @param scene defines the hosting scene
  127441. * @returns the decal mesh
  127442. * @see https://doc.babylonjs.com/how_to/decals
  127443. */
  127444. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  127445. position?: Vector3;
  127446. normal?: Vector3;
  127447. size?: Vector3;
  127448. angle?: number;
  127449. }): Mesh;
  127450. }
  127451. }
  127452. declare module BABYLON {
  127453. /**
  127454. * Class containing static functions to help procedurally build meshes
  127455. */
  127456. export class MeshBuilder {
  127457. /**
  127458. * Creates a box mesh
  127459. * * The parameter `size` sets the size (float) of each box side (default 1)
  127460. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  127461. * * 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)
  127462. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  127463. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127464. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127466. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  127467. * @param name defines the name of the mesh
  127468. * @param options defines the options used to create the mesh
  127469. * @param scene defines the hosting scene
  127470. * @returns the box mesh
  127471. */
  127472. static CreateBox(name: string, options: {
  127473. size?: number;
  127474. width?: number;
  127475. height?: number;
  127476. depth?: number;
  127477. faceUV?: Vector4[];
  127478. faceColors?: Color4[];
  127479. sideOrientation?: number;
  127480. frontUVs?: Vector4;
  127481. backUVs?: Vector4;
  127482. updatable?: boolean;
  127483. }, scene?: Nullable<Scene>): Mesh;
  127484. /**
  127485. * Creates a tiled box mesh
  127486. * * faceTiles sets the pattern, tile size and number of tiles for a face
  127487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127488. * @param name defines the name of the mesh
  127489. * @param options defines the options used to create the mesh
  127490. * @param scene defines the hosting scene
  127491. * @returns the tiled box mesh
  127492. */
  127493. static CreateTiledBox(name: string, options: {
  127494. pattern?: number;
  127495. size?: number;
  127496. width?: number;
  127497. height?: number;
  127498. depth: number;
  127499. tileSize?: number;
  127500. tileWidth?: number;
  127501. tileHeight?: number;
  127502. faceUV?: Vector4[];
  127503. faceColors?: Color4[];
  127504. alignHorizontal?: number;
  127505. alignVertical?: number;
  127506. sideOrientation?: number;
  127507. updatable?: boolean;
  127508. }, scene?: Nullable<Scene>): Mesh;
  127509. /**
  127510. * Creates a sphere mesh
  127511. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  127512. * * 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`)
  127513. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  127514. * * 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
  127515. * * 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)
  127516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127517. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127519. * @param name defines the name of the mesh
  127520. * @param options defines the options used to create the mesh
  127521. * @param scene defines the hosting scene
  127522. * @returns the sphere mesh
  127523. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  127524. */
  127525. static CreateSphere(name: string, options: {
  127526. segments?: number;
  127527. diameter?: number;
  127528. diameterX?: number;
  127529. diameterY?: number;
  127530. diameterZ?: number;
  127531. arc?: number;
  127532. slice?: number;
  127533. sideOrientation?: number;
  127534. frontUVs?: Vector4;
  127535. backUVs?: Vector4;
  127536. updatable?: boolean;
  127537. }, scene?: Nullable<Scene>): Mesh;
  127538. /**
  127539. * Creates a plane polygonal mesh. By default, this is a disc
  127540. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  127541. * * 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
  127542. * * 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
  127543. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127544. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127546. * @param name defines the name of the mesh
  127547. * @param options defines the options used to create the mesh
  127548. * @param scene defines the hosting scene
  127549. * @returns the plane polygonal mesh
  127550. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  127551. */
  127552. static CreateDisc(name: string, options: {
  127553. radius?: number;
  127554. tessellation?: number;
  127555. arc?: number;
  127556. updatable?: boolean;
  127557. sideOrientation?: number;
  127558. frontUVs?: Vector4;
  127559. backUVs?: Vector4;
  127560. }, scene?: Nullable<Scene>): Mesh;
  127561. /**
  127562. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  127563. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  127564. * * 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`)
  127565. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  127566. * * 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
  127567. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127568. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127570. * @param name defines the name of the mesh
  127571. * @param options defines the options used to create the mesh
  127572. * @param scene defines the hosting scene
  127573. * @returns the icosahedron mesh
  127574. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  127575. */
  127576. static CreateIcoSphere(name: string, options: {
  127577. radius?: number;
  127578. radiusX?: number;
  127579. radiusY?: number;
  127580. radiusZ?: number;
  127581. flat?: boolean;
  127582. subdivisions?: number;
  127583. sideOrientation?: number;
  127584. frontUVs?: Vector4;
  127585. backUVs?: Vector4;
  127586. updatable?: boolean;
  127587. }, scene?: Nullable<Scene>): Mesh;
  127588. /**
  127589. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  127590. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  127591. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  127592. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  127593. * * 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
  127594. * * 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
  127595. * * 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
  127596. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127597. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127598. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127599. * * 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
  127600. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  127601. * * 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
  127602. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  127603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127604. * @param name defines the name of the mesh
  127605. * @param options defines the options used to create the mesh
  127606. * @param scene defines the hosting scene
  127607. * @returns the ribbon mesh
  127608. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  127609. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127610. */
  127611. static CreateRibbon(name: string, options: {
  127612. pathArray: Vector3[][];
  127613. closeArray?: boolean;
  127614. closePath?: boolean;
  127615. offset?: number;
  127616. updatable?: boolean;
  127617. sideOrientation?: number;
  127618. frontUVs?: Vector4;
  127619. backUVs?: Vector4;
  127620. instance?: Mesh;
  127621. invertUV?: boolean;
  127622. uvs?: Vector2[];
  127623. colors?: Color4[];
  127624. }, scene?: Nullable<Scene>): Mesh;
  127625. /**
  127626. * Creates a cylinder or a cone mesh
  127627. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  127628. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  127629. * * 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.
  127630. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  127631. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  127632. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  127633. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  127634. * * 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).
  127635. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  127636. * * 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).
  127637. * * 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
  127638. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  127639. * * 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
  127640. * * 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.
  127641. * * If `enclose` is false, a ring surface is one element.
  127642. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  127643. * * 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
  127644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127645. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127647. * @param name defines the name of the mesh
  127648. * @param options defines the options used to create the mesh
  127649. * @param scene defines the hosting scene
  127650. * @returns the cylinder mesh
  127651. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  127652. */
  127653. static CreateCylinder(name: string, options: {
  127654. height?: number;
  127655. diameterTop?: number;
  127656. diameterBottom?: number;
  127657. diameter?: number;
  127658. tessellation?: number;
  127659. subdivisions?: number;
  127660. arc?: number;
  127661. faceColors?: Color4[];
  127662. faceUV?: Vector4[];
  127663. updatable?: boolean;
  127664. hasRings?: boolean;
  127665. enclose?: boolean;
  127666. cap?: number;
  127667. sideOrientation?: number;
  127668. frontUVs?: Vector4;
  127669. backUVs?: Vector4;
  127670. }, scene?: Nullable<Scene>): Mesh;
  127671. /**
  127672. * Creates a torus mesh
  127673. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  127674. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  127675. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  127676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127677. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127679. * @param name defines the name of the mesh
  127680. * @param options defines the options used to create the mesh
  127681. * @param scene defines the hosting scene
  127682. * @returns the torus mesh
  127683. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  127684. */
  127685. static CreateTorus(name: string, options: {
  127686. diameter?: number;
  127687. thickness?: number;
  127688. tessellation?: number;
  127689. updatable?: boolean;
  127690. sideOrientation?: number;
  127691. frontUVs?: Vector4;
  127692. backUVs?: Vector4;
  127693. }, scene?: Nullable<Scene>): Mesh;
  127694. /**
  127695. * Creates a torus knot mesh
  127696. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  127697. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  127698. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  127699. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  127700. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127701. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127703. * @param name defines the name of the mesh
  127704. * @param options defines the options used to create the mesh
  127705. * @param scene defines the hosting scene
  127706. * @returns the torus knot mesh
  127707. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  127708. */
  127709. static CreateTorusKnot(name: string, options: {
  127710. radius?: number;
  127711. tube?: number;
  127712. radialSegments?: number;
  127713. tubularSegments?: number;
  127714. p?: number;
  127715. q?: number;
  127716. updatable?: boolean;
  127717. sideOrientation?: number;
  127718. frontUVs?: Vector4;
  127719. backUVs?: Vector4;
  127720. }, scene?: Nullable<Scene>): Mesh;
  127721. /**
  127722. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  127723. * * 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
  127724. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  127725. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  127726. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  127727. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  127728. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  127729. * * 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
  127730. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  127731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127732. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  127733. * @param name defines the name of the new line system
  127734. * @param options defines the options used to create the line system
  127735. * @param scene defines the hosting scene
  127736. * @returns a new line system mesh
  127737. */
  127738. static CreateLineSystem(name: string, options: {
  127739. lines: Vector3[][];
  127740. updatable?: boolean;
  127741. instance?: Nullable<LinesMesh>;
  127742. colors?: Nullable<Color4[][]>;
  127743. useVertexAlpha?: boolean;
  127744. }, scene: Nullable<Scene>): LinesMesh;
  127745. /**
  127746. * Creates a line mesh
  127747. * 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
  127748. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127749. * * The parameter `points` is an array successive Vector3
  127750. * * 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
  127751. * * The optional parameter `colors` is an array of successive Color4, one per line point
  127752. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  127753. * * When updating an instance, remember that only point positions can change, not the number of points
  127754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127755. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  127756. * @param name defines the name of the new line system
  127757. * @param options defines the options used to create the line system
  127758. * @param scene defines the hosting scene
  127759. * @returns a new line mesh
  127760. */
  127761. static CreateLines(name: string, options: {
  127762. points: Vector3[];
  127763. updatable?: boolean;
  127764. instance?: Nullable<LinesMesh>;
  127765. colors?: Color4[];
  127766. useVertexAlpha?: boolean;
  127767. }, scene?: Nullable<Scene>): LinesMesh;
  127768. /**
  127769. * Creates a dashed line mesh
  127770. * * 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
  127771. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127772. * * The parameter `points` is an array successive Vector3
  127773. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  127774. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  127775. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  127776. * * 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
  127777. * * When updating an instance, remember that only point positions can change, not the number of points
  127778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127779. * @param name defines the name of the mesh
  127780. * @param options defines the options used to create the mesh
  127781. * @param scene defines the hosting scene
  127782. * @returns the dashed line mesh
  127783. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  127784. */
  127785. static CreateDashedLines(name: string, options: {
  127786. points: Vector3[];
  127787. dashSize?: number;
  127788. gapSize?: number;
  127789. dashNb?: number;
  127790. updatable?: boolean;
  127791. instance?: LinesMesh;
  127792. }, scene?: Nullable<Scene>): LinesMesh;
  127793. /**
  127794. * 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.
  127795. * * 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.
  127796. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127797. * * 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.
  127798. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  127799. * * 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
  127800. * * 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
  127801. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  127802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127803. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127804. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  127805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127806. * @param name defines the name of the mesh
  127807. * @param options defines the options used to create the mesh
  127808. * @param scene defines the hosting scene
  127809. * @returns the extruded shape mesh
  127810. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127811. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127812. */
  127813. static ExtrudeShape(name: string, options: {
  127814. shape: Vector3[];
  127815. path: Vector3[];
  127816. scale?: number;
  127817. rotation?: number;
  127818. cap?: number;
  127819. updatable?: boolean;
  127820. sideOrientation?: number;
  127821. frontUVs?: Vector4;
  127822. backUVs?: Vector4;
  127823. instance?: Mesh;
  127824. invertUV?: boolean;
  127825. }, scene?: Nullable<Scene>): Mesh;
  127826. /**
  127827. * Creates an custom extruded shape mesh.
  127828. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  127829. * * 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.
  127830. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127831. * * 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
  127832. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  127833. * * 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
  127834. * * It must returns a float value that will be the scale value applied to the shape on each path point
  127835. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  127836. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  127837. * * 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
  127838. * * 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
  127839. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  127840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127841. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127842. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127844. * @param name defines the name of the mesh
  127845. * @param options defines the options used to create the mesh
  127846. * @param scene defines the hosting scene
  127847. * @returns the custom extruded shape mesh
  127848. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  127849. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127850. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127851. */
  127852. static ExtrudeShapeCustom(name: string, options: {
  127853. shape: Vector3[];
  127854. path: Vector3[];
  127855. scaleFunction?: any;
  127856. rotationFunction?: any;
  127857. ribbonCloseArray?: boolean;
  127858. ribbonClosePath?: boolean;
  127859. cap?: number;
  127860. updatable?: boolean;
  127861. sideOrientation?: number;
  127862. frontUVs?: Vector4;
  127863. backUVs?: Vector4;
  127864. instance?: Mesh;
  127865. invertUV?: boolean;
  127866. }, scene?: Nullable<Scene>): Mesh;
  127867. /**
  127868. * Creates lathe mesh.
  127869. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  127870. * * 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
  127871. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  127872. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  127873. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  127874. * * 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
  127875. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  127876. * * 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
  127877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127878. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127879. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127881. * @param name defines the name of the mesh
  127882. * @param options defines the options used to create the mesh
  127883. * @param scene defines the hosting scene
  127884. * @returns the lathe mesh
  127885. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  127886. */
  127887. static CreateLathe(name: string, options: {
  127888. shape: Vector3[];
  127889. radius?: number;
  127890. tessellation?: number;
  127891. clip?: number;
  127892. arc?: number;
  127893. closed?: boolean;
  127894. updatable?: boolean;
  127895. sideOrientation?: number;
  127896. frontUVs?: Vector4;
  127897. backUVs?: Vector4;
  127898. cap?: number;
  127899. invertUV?: boolean;
  127900. }, scene?: Nullable<Scene>): Mesh;
  127901. /**
  127902. * Creates a tiled plane mesh
  127903. * * You can set a limited pattern arrangement with the tiles
  127904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127905. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127907. * @param name defines the name of the mesh
  127908. * @param options defines the options used to create the mesh
  127909. * @param scene defines the hosting scene
  127910. * @returns the plane mesh
  127911. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127912. */
  127913. static CreateTiledPlane(name: string, options: {
  127914. pattern?: number;
  127915. tileSize?: number;
  127916. tileWidth?: number;
  127917. tileHeight?: number;
  127918. size?: number;
  127919. width?: number;
  127920. height?: number;
  127921. alignHorizontal?: number;
  127922. alignVertical?: number;
  127923. sideOrientation?: number;
  127924. frontUVs?: Vector4;
  127925. backUVs?: Vector4;
  127926. updatable?: boolean;
  127927. }, scene?: Nullable<Scene>): Mesh;
  127928. /**
  127929. * Creates a plane mesh
  127930. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  127931. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  127932. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  127933. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127934. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127936. * @param name defines the name of the mesh
  127937. * @param options defines the options used to create the mesh
  127938. * @param scene defines the hosting scene
  127939. * @returns the plane mesh
  127940. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127941. */
  127942. static CreatePlane(name: string, options: {
  127943. size?: number;
  127944. width?: number;
  127945. height?: number;
  127946. sideOrientation?: number;
  127947. frontUVs?: Vector4;
  127948. backUVs?: Vector4;
  127949. updatable?: boolean;
  127950. sourcePlane?: Plane;
  127951. }, scene?: Nullable<Scene>): Mesh;
  127952. /**
  127953. * Creates a ground mesh
  127954. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  127955. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  127956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127957. * @param name defines the name of the mesh
  127958. * @param options defines the options used to create the mesh
  127959. * @param scene defines the hosting scene
  127960. * @returns the ground mesh
  127961. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  127962. */
  127963. static CreateGround(name: string, options: {
  127964. width?: number;
  127965. height?: number;
  127966. subdivisions?: number;
  127967. subdivisionsX?: number;
  127968. subdivisionsY?: number;
  127969. updatable?: boolean;
  127970. }, scene?: Nullable<Scene>): Mesh;
  127971. /**
  127972. * Creates a tiled ground mesh
  127973. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  127974. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  127975. * * 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
  127976. * * 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
  127977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127978. * @param name defines the name of the mesh
  127979. * @param options defines the options used to create the mesh
  127980. * @param scene defines the hosting scene
  127981. * @returns the tiled ground mesh
  127982. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  127983. */
  127984. static CreateTiledGround(name: string, options: {
  127985. xmin: number;
  127986. zmin: number;
  127987. xmax: number;
  127988. zmax: number;
  127989. subdivisions?: {
  127990. w: number;
  127991. h: number;
  127992. };
  127993. precision?: {
  127994. w: number;
  127995. h: number;
  127996. };
  127997. updatable?: boolean;
  127998. }, scene?: Nullable<Scene>): Mesh;
  127999. /**
  128000. * Creates a ground mesh from a height map
  128001. * * The parameter `url` sets the URL of the height map image resource.
  128002. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  128003. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  128004. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  128005. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  128006. * * 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.
  128007. * * 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).
  128008. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  128009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128010. * @param name defines the name of the mesh
  128011. * @param url defines the url to the height map
  128012. * @param options defines the options used to create the mesh
  128013. * @param scene defines the hosting scene
  128014. * @returns the ground mesh
  128015. * @see https://doc.babylonjs.com/babylon101/height_map
  128016. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  128017. */
  128018. static CreateGroundFromHeightMap(name: string, url: string, options: {
  128019. width?: number;
  128020. height?: number;
  128021. subdivisions?: number;
  128022. minHeight?: number;
  128023. maxHeight?: number;
  128024. colorFilter?: Color3;
  128025. alphaFilter?: number;
  128026. updatable?: boolean;
  128027. onReady?: (mesh: GroundMesh) => void;
  128028. }, scene?: Nullable<Scene>): GroundMesh;
  128029. /**
  128030. * Creates a polygon mesh
  128031. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  128032. * * 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
  128033. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  128034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128035. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  128036. * * Remember you can only change the shape positions, not their number when updating a polygon
  128037. * @param name defines the name of the mesh
  128038. * @param options defines the options used to create the mesh
  128039. * @param scene defines the hosting scene
  128040. * @param earcutInjection can be used to inject your own earcut reference
  128041. * @returns the polygon mesh
  128042. */
  128043. static CreatePolygon(name: string, options: {
  128044. shape: Vector3[];
  128045. holes?: Vector3[][];
  128046. depth?: number;
  128047. faceUV?: Vector4[];
  128048. faceColors?: Color4[];
  128049. updatable?: boolean;
  128050. sideOrientation?: number;
  128051. frontUVs?: Vector4;
  128052. backUVs?: Vector4;
  128053. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  128054. /**
  128055. * Creates an extruded polygon mesh, with depth in the Y direction.
  128056. * * 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)
  128057. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  128058. * @param name defines the name of the mesh
  128059. * @param options defines the options used to create the mesh
  128060. * @param scene defines the hosting scene
  128061. * @param earcutInjection can be used to inject your own earcut reference
  128062. * @returns the polygon mesh
  128063. */
  128064. static ExtrudePolygon(name: string, options: {
  128065. shape: Vector3[];
  128066. holes?: Vector3[][];
  128067. depth?: number;
  128068. faceUV?: Vector4[];
  128069. faceColors?: Color4[];
  128070. updatable?: boolean;
  128071. sideOrientation?: number;
  128072. frontUVs?: Vector4;
  128073. backUVs?: Vector4;
  128074. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  128075. /**
  128076. * Creates a tube mesh.
  128077. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128078. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  128079. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  128080. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  128081. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  128082. * * 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)
  128083. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  128084. * * 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
  128085. * * 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
  128086. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128087. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128088. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128090. * @param name defines the name of the mesh
  128091. * @param options defines the options used to create the mesh
  128092. * @param scene defines the hosting scene
  128093. * @returns the tube mesh
  128094. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128095. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  128096. */
  128097. static CreateTube(name: string, options: {
  128098. path: Vector3[];
  128099. radius?: number;
  128100. tessellation?: number;
  128101. radiusFunction?: {
  128102. (i: number, distance: number): number;
  128103. };
  128104. cap?: number;
  128105. arc?: number;
  128106. updatable?: boolean;
  128107. sideOrientation?: number;
  128108. frontUVs?: Vector4;
  128109. backUVs?: Vector4;
  128110. instance?: Mesh;
  128111. invertUV?: boolean;
  128112. }, scene?: Nullable<Scene>): Mesh;
  128113. /**
  128114. * Creates a polyhedron mesh
  128115. * * 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
  128116. * * The parameter `size` (positive float, default 1) sets the polygon size
  128117. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  128118. * * 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`
  128119. * * 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
  128120. * * 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)`)
  128121. * * 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
  128122. * * 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
  128123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128126. * @param name defines the name of the mesh
  128127. * @param options defines the options used to create the mesh
  128128. * @param scene defines the hosting scene
  128129. * @returns the polyhedron mesh
  128130. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  128131. */
  128132. static CreatePolyhedron(name: string, options: {
  128133. type?: number;
  128134. size?: number;
  128135. sizeX?: number;
  128136. sizeY?: number;
  128137. sizeZ?: number;
  128138. custom?: any;
  128139. faceUV?: Vector4[];
  128140. faceColors?: Color4[];
  128141. flat?: boolean;
  128142. updatable?: boolean;
  128143. sideOrientation?: number;
  128144. frontUVs?: Vector4;
  128145. backUVs?: Vector4;
  128146. }, scene?: Nullable<Scene>): Mesh;
  128147. /**
  128148. * Creates a decal mesh.
  128149. * 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
  128150. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  128151. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  128152. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  128153. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  128154. * @param name defines the name of the mesh
  128155. * @param sourceMesh defines the mesh where the decal must be applied
  128156. * @param options defines the options used to create the mesh
  128157. * @param scene defines the hosting scene
  128158. * @returns the decal mesh
  128159. * @see https://doc.babylonjs.com/how_to/decals
  128160. */
  128161. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  128162. position?: Vector3;
  128163. normal?: Vector3;
  128164. size?: Vector3;
  128165. angle?: number;
  128166. }): Mesh;
  128167. }
  128168. }
  128169. declare module BABYLON {
  128170. /**
  128171. * A simplifier interface for future simplification implementations
  128172. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  128173. */
  128174. export interface ISimplifier {
  128175. /**
  128176. * Simplification of a given mesh according to the given settings.
  128177. * Since this requires computation, it is assumed that the function runs async.
  128178. * @param settings The settings of the simplification, including quality and distance
  128179. * @param successCallback A callback that will be called after the mesh was simplified.
  128180. * @param errorCallback in case of an error, this callback will be called. optional.
  128181. */
  128182. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  128183. }
  128184. /**
  128185. * Expected simplification settings.
  128186. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  128187. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  128188. */
  128189. export interface ISimplificationSettings {
  128190. /**
  128191. * Gets or sets the expected quality
  128192. */
  128193. quality: number;
  128194. /**
  128195. * Gets or sets the distance when this optimized version should be used
  128196. */
  128197. distance: number;
  128198. /**
  128199. * Gets an already optimized mesh
  128200. */
  128201. optimizeMesh?: boolean;
  128202. }
  128203. /**
  128204. * Class used to specify simplification options
  128205. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  128206. */
  128207. export class SimplificationSettings implements ISimplificationSettings {
  128208. /** expected quality */
  128209. quality: number;
  128210. /** distance when this optimized version should be used */
  128211. distance: number;
  128212. /** already optimized mesh */
  128213. optimizeMesh?: boolean | undefined;
  128214. /**
  128215. * Creates a SimplificationSettings
  128216. * @param quality expected quality
  128217. * @param distance distance when this optimized version should be used
  128218. * @param optimizeMesh already optimized mesh
  128219. */
  128220. constructor(
  128221. /** expected quality */
  128222. quality: number,
  128223. /** distance when this optimized version should be used */
  128224. distance: number,
  128225. /** already optimized mesh */
  128226. optimizeMesh?: boolean | undefined);
  128227. }
  128228. /**
  128229. * Interface used to define a simplification task
  128230. */
  128231. export interface ISimplificationTask {
  128232. /**
  128233. * Array of settings
  128234. */
  128235. settings: Array<ISimplificationSettings>;
  128236. /**
  128237. * Simplification type
  128238. */
  128239. simplificationType: SimplificationType;
  128240. /**
  128241. * Mesh to simplify
  128242. */
  128243. mesh: Mesh;
  128244. /**
  128245. * Callback called on success
  128246. */
  128247. successCallback?: () => void;
  128248. /**
  128249. * Defines if parallel processing can be used
  128250. */
  128251. parallelProcessing: boolean;
  128252. }
  128253. /**
  128254. * Queue used to order the simplification tasks
  128255. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  128256. */
  128257. export class SimplificationQueue {
  128258. private _simplificationArray;
  128259. /**
  128260. * Gets a boolean indicating that the process is still running
  128261. */
  128262. running: boolean;
  128263. /**
  128264. * Creates a new queue
  128265. */
  128266. constructor();
  128267. /**
  128268. * Adds a new simplification task
  128269. * @param task defines a task to add
  128270. */
  128271. addTask(task: ISimplificationTask): void;
  128272. /**
  128273. * Execute next task
  128274. */
  128275. executeNext(): void;
  128276. /**
  128277. * Execute a simplification task
  128278. * @param task defines the task to run
  128279. */
  128280. runSimplification(task: ISimplificationTask): void;
  128281. private getSimplifier;
  128282. }
  128283. /**
  128284. * The implemented types of simplification
  128285. * At the moment only Quadratic Error Decimation is implemented
  128286. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  128287. */
  128288. export enum SimplificationType {
  128289. /** Quadratic error decimation */
  128290. QUADRATIC = 0
  128291. }
  128292. }
  128293. declare module BABYLON {
  128294. interface Scene {
  128295. /** @hidden (Backing field) */
  128296. _simplificationQueue: SimplificationQueue;
  128297. /**
  128298. * Gets or sets the simplification queue attached to the scene
  128299. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  128300. */
  128301. simplificationQueue: SimplificationQueue;
  128302. }
  128303. interface Mesh {
  128304. /**
  128305. * Simplify the mesh according to the given array of settings.
  128306. * Function will return immediately and will simplify async
  128307. * @param settings a collection of simplification settings
  128308. * @param parallelProcessing should all levels calculate parallel or one after the other
  128309. * @param simplificationType the type of simplification to run
  128310. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  128311. * @returns the current mesh
  128312. */
  128313. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  128314. }
  128315. /**
  128316. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  128317. * created in a scene
  128318. */
  128319. export class SimplicationQueueSceneComponent implements ISceneComponent {
  128320. /**
  128321. * The component name helpfull to identify the component in the list of scene components.
  128322. */
  128323. readonly name: string;
  128324. /**
  128325. * The scene the component belongs to.
  128326. */
  128327. scene: Scene;
  128328. /**
  128329. * Creates a new instance of the component for the given scene
  128330. * @param scene Defines the scene to register the component in
  128331. */
  128332. constructor(scene: Scene);
  128333. /**
  128334. * Registers the component in a given scene
  128335. */
  128336. register(): void;
  128337. /**
  128338. * Rebuilds the elements related to this component in case of
  128339. * context lost for instance.
  128340. */
  128341. rebuild(): void;
  128342. /**
  128343. * Disposes the component and the associated ressources
  128344. */
  128345. dispose(): void;
  128346. private _beforeCameraUpdate;
  128347. }
  128348. }
  128349. declare module BABYLON {
  128350. /**
  128351. * Navigation plugin interface to add navigation constrained by a navigation mesh
  128352. */
  128353. export interface INavigationEnginePlugin {
  128354. /**
  128355. * plugin name
  128356. */
  128357. name: string;
  128358. /**
  128359. * Creates a navigation mesh
  128360. * @param meshes array of all the geometry used to compute the navigatio mesh
  128361. * @param parameters bunch of parameters used to filter geometry
  128362. */
  128363. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  128364. /**
  128365. * Create a navigation mesh debug mesh
  128366. * @param scene is where the mesh will be added
  128367. * @returns debug display mesh
  128368. */
  128369. createDebugNavMesh(scene: Scene): Mesh;
  128370. /**
  128371. * Get a navigation mesh constrained position, closest to the parameter position
  128372. * @param position world position
  128373. * @returns the closest point to position constrained by the navigation mesh
  128374. */
  128375. getClosestPoint(position: Vector3): Vector3;
  128376. /**
  128377. * Get a navigation mesh constrained position, within a particular radius
  128378. * @param position world position
  128379. * @param maxRadius the maximum distance to the constrained world position
  128380. * @returns the closest point to position constrained by the navigation mesh
  128381. */
  128382. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  128383. /**
  128384. * Compute the final position from a segment made of destination-position
  128385. * @param position world position
  128386. * @param destination world position
  128387. * @returns the resulting point along the navmesh
  128388. */
  128389. moveAlong(position: Vector3, destination: Vector3): Vector3;
  128390. /**
  128391. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  128392. * @param start world position
  128393. * @param end world position
  128394. * @returns array containing world position composing the path
  128395. */
  128396. computePath(start: Vector3, end: Vector3): Vector3[];
  128397. /**
  128398. * If this plugin is supported
  128399. * @returns true if plugin is supported
  128400. */
  128401. isSupported(): boolean;
  128402. /**
  128403. * Create a new Crowd so you can add agents
  128404. * @param maxAgents the maximum agent count in the crowd
  128405. * @param maxAgentRadius the maximum radius an agent can have
  128406. * @param scene to attach the crowd to
  128407. * @returns the crowd you can add agents to
  128408. */
  128409. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  128410. /**
  128411. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  128412. * The queries will try to find a solution within those bounds
  128413. * default is (1,1,1)
  128414. * @param extent x,y,z value that define the extent around the queries point of reference
  128415. */
  128416. setDefaultQueryExtent(extent: Vector3): void;
  128417. /**
  128418. * Get the Bounding box extent specified by setDefaultQueryExtent
  128419. * @returns the box extent values
  128420. */
  128421. getDefaultQueryExtent(): Vector3;
  128422. /**
  128423. * Release all resources
  128424. */
  128425. dispose(): void;
  128426. }
  128427. /**
  128428. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  128429. */
  128430. export interface ICrowd {
  128431. /**
  128432. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  128433. * You can attach anything to that node. The node position is updated in the scene update tick.
  128434. * @param pos world position that will be constrained by the navigation mesh
  128435. * @param parameters agent parameters
  128436. * @param transform hooked to the agent that will be update by the scene
  128437. * @returns agent index
  128438. */
  128439. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  128440. /**
  128441. * Returns the agent position in world space
  128442. * @param index agent index returned by addAgent
  128443. * @returns world space position
  128444. */
  128445. getAgentPosition(index: number): Vector3;
  128446. /**
  128447. * Gets the agent velocity in world space
  128448. * @param index agent index returned by addAgent
  128449. * @returns world space velocity
  128450. */
  128451. getAgentVelocity(index: number): Vector3;
  128452. /**
  128453. * remove a particular agent previously created
  128454. * @param index agent index returned by addAgent
  128455. */
  128456. removeAgent(index: number): void;
  128457. /**
  128458. * get the list of all agents attached to this crowd
  128459. * @returns list of agent indices
  128460. */
  128461. getAgents(): number[];
  128462. /**
  128463. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  128464. * @param deltaTime in seconds
  128465. */
  128466. update(deltaTime: number): void;
  128467. /**
  128468. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  128469. * @param index agent index returned by addAgent
  128470. * @param destination targeted world position
  128471. */
  128472. agentGoto(index: number, destination: Vector3): void;
  128473. /**
  128474. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  128475. * The queries will try to find a solution within those bounds
  128476. * default is (1,1,1)
  128477. * @param extent x,y,z value that define the extent around the queries point of reference
  128478. */
  128479. setDefaultQueryExtent(extent: Vector3): void;
  128480. /**
  128481. * Get the Bounding box extent specified by setDefaultQueryExtent
  128482. * @returns the box extent values
  128483. */
  128484. getDefaultQueryExtent(): Vector3;
  128485. /**
  128486. * Release all resources
  128487. */
  128488. dispose(): void;
  128489. }
  128490. /**
  128491. * Configures an agent
  128492. */
  128493. export interface IAgentParameters {
  128494. /**
  128495. * Agent radius. [Limit: >= 0]
  128496. */
  128497. radius: number;
  128498. /**
  128499. * Agent height. [Limit: > 0]
  128500. */
  128501. height: number;
  128502. /**
  128503. * Maximum allowed acceleration. [Limit: >= 0]
  128504. */
  128505. maxAcceleration: number;
  128506. /**
  128507. * Maximum allowed speed. [Limit: >= 0]
  128508. */
  128509. maxSpeed: number;
  128510. /**
  128511. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  128512. */
  128513. collisionQueryRange: number;
  128514. /**
  128515. * The path visibility optimization range. [Limit: > 0]
  128516. */
  128517. pathOptimizationRange: number;
  128518. /**
  128519. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  128520. */
  128521. separationWeight: number;
  128522. }
  128523. /**
  128524. * Configures the navigation mesh creation
  128525. */
  128526. export interface INavMeshParameters {
  128527. /**
  128528. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  128529. */
  128530. cs: number;
  128531. /**
  128532. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  128533. */
  128534. ch: number;
  128535. /**
  128536. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  128537. */
  128538. walkableSlopeAngle: number;
  128539. /**
  128540. * Minimum floor to 'ceiling' height that will still allow the floor area to
  128541. * be considered walkable. [Limit: >= 3] [Units: vx]
  128542. */
  128543. walkableHeight: number;
  128544. /**
  128545. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  128546. */
  128547. walkableClimb: number;
  128548. /**
  128549. * The distance to erode/shrink the walkable area of the heightfield away from
  128550. * obstructions. [Limit: >=0] [Units: vx]
  128551. */
  128552. walkableRadius: number;
  128553. /**
  128554. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  128555. */
  128556. maxEdgeLen: number;
  128557. /**
  128558. * The maximum distance a simplfied contour's border edges should deviate
  128559. * the original raw contour. [Limit: >=0] [Units: vx]
  128560. */
  128561. maxSimplificationError: number;
  128562. /**
  128563. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  128564. */
  128565. minRegionArea: number;
  128566. /**
  128567. * Any regions with a span count smaller than this value will, if possible,
  128568. * be merged with larger regions. [Limit: >=0] [Units: vx]
  128569. */
  128570. mergeRegionArea: number;
  128571. /**
  128572. * The maximum number of vertices allowed for polygons generated during the
  128573. * contour to polygon conversion process. [Limit: >= 3]
  128574. */
  128575. maxVertsPerPoly: number;
  128576. /**
  128577. * Sets the sampling distance to use when generating the detail mesh.
  128578. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  128579. */
  128580. detailSampleDist: number;
  128581. /**
  128582. * The maximum distance the detail mesh surface should deviate from heightfield
  128583. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  128584. */
  128585. detailSampleMaxError: number;
  128586. }
  128587. }
  128588. declare module BABYLON {
  128589. /**
  128590. * RecastJS navigation plugin
  128591. */
  128592. export class RecastJSPlugin implements INavigationEnginePlugin {
  128593. /**
  128594. * Reference to the Recast library
  128595. */
  128596. bjsRECAST: any;
  128597. /**
  128598. * plugin name
  128599. */
  128600. name: string;
  128601. /**
  128602. * the first navmesh created. We might extend this to support multiple navmeshes
  128603. */
  128604. navMesh: any;
  128605. /**
  128606. * Initializes the recastJS plugin
  128607. * @param recastInjection can be used to inject your own recast reference
  128608. */
  128609. constructor(recastInjection?: any);
  128610. /**
  128611. * Creates a navigation mesh
  128612. * @param meshes array of all the geometry used to compute the navigatio mesh
  128613. * @param parameters bunch of parameters used to filter geometry
  128614. */
  128615. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  128616. /**
  128617. * Create a navigation mesh debug mesh
  128618. * @param scene is where the mesh will be added
  128619. * @returns debug display mesh
  128620. */
  128621. createDebugNavMesh(scene: Scene): Mesh;
  128622. /**
  128623. * Get a navigation mesh constrained position, closest to the parameter position
  128624. * @param position world position
  128625. * @returns the closest point to position constrained by the navigation mesh
  128626. */
  128627. getClosestPoint(position: Vector3): Vector3;
  128628. /**
  128629. * Get a navigation mesh constrained position, within a particular radius
  128630. * @param position world position
  128631. * @param maxRadius the maximum distance to the constrained world position
  128632. * @returns the closest point to position constrained by the navigation mesh
  128633. */
  128634. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  128635. /**
  128636. * Compute the final position from a segment made of destination-position
  128637. * @param position world position
  128638. * @param destination world position
  128639. * @returns the resulting point along the navmesh
  128640. */
  128641. moveAlong(position: Vector3, destination: Vector3): Vector3;
  128642. /**
  128643. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  128644. * @param start world position
  128645. * @param end world position
  128646. * @returns array containing world position composing the path
  128647. */
  128648. computePath(start: Vector3, end: Vector3): Vector3[];
  128649. /**
  128650. * Create a new Crowd so you can add agents
  128651. * @param maxAgents the maximum agent count in the crowd
  128652. * @param maxAgentRadius the maximum radius an agent can have
  128653. * @param scene to attach the crowd to
  128654. * @returns the crowd you can add agents to
  128655. */
  128656. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  128657. /**
  128658. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  128659. * The queries will try to find a solution within those bounds
  128660. * default is (1,1,1)
  128661. * @param extent x,y,z value that define the extent around the queries point of reference
  128662. */
  128663. setDefaultQueryExtent(extent: Vector3): void;
  128664. /**
  128665. * Get the Bounding box extent specified by setDefaultQueryExtent
  128666. * @returns the box extent values
  128667. */
  128668. getDefaultQueryExtent(): Vector3;
  128669. /**
  128670. * Disposes
  128671. */
  128672. dispose(): void;
  128673. /**
  128674. * If this plugin is supported
  128675. * @returns true if plugin is supported
  128676. */
  128677. isSupported(): boolean;
  128678. }
  128679. /**
  128680. * Recast detour crowd implementation
  128681. */
  128682. export class RecastJSCrowd implements ICrowd {
  128683. /**
  128684. * Recast/detour plugin
  128685. */
  128686. bjsRECASTPlugin: RecastJSPlugin;
  128687. /**
  128688. * Link to the detour crowd
  128689. */
  128690. recastCrowd: any;
  128691. /**
  128692. * One transform per agent
  128693. */
  128694. transforms: TransformNode[];
  128695. /**
  128696. * All agents created
  128697. */
  128698. agents: number[];
  128699. /**
  128700. * Link to the scene is kept to unregister the crowd from the scene
  128701. */
  128702. private _scene;
  128703. /**
  128704. * Observer for crowd updates
  128705. */
  128706. private _onBeforeAnimationsObserver;
  128707. /**
  128708. * Constructor
  128709. * @param plugin recastJS plugin
  128710. * @param maxAgents the maximum agent count in the crowd
  128711. * @param maxAgentRadius the maximum radius an agent can have
  128712. * @param scene to attach the crowd to
  128713. * @returns the crowd you can add agents to
  128714. */
  128715. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  128716. /**
  128717. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  128718. * You can attach anything to that node. The node position is updated in the scene update tick.
  128719. * @param pos world position that will be constrained by the navigation mesh
  128720. * @param parameters agent parameters
  128721. * @param transform hooked to the agent that will be update by the scene
  128722. * @returns agent index
  128723. */
  128724. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  128725. /**
  128726. * Returns the agent position in world space
  128727. * @param index agent index returned by addAgent
  128728. * @returns world space position
  128729. */
  128730. getAgentPosition(index: number): Vector3;
  128731. /**
  128732. * Returns the agent velocity in world space
  128733. * @param index agent index returned by addAgent
  128734. * @returns world space velocity
  128735. */
  128736. getAgentVelocity(index: number): Vector3;
  128737. /**
  128738. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  128739. * @param index agent index returned by addAgent
  128740. * @param destination targeted world position
  128741. */
  128742. agentGoto(index: number, destination: Vector3): void;
  128743. /**
  128744. * remove a particular agent previously created
  128745. * @param index agent index returned by addAgent
  128746. */
  128747. removeAgent(index: number): void;
  128748. /**
  128749. * get the list of all agents attached to this crowd
  128750. * @returns list of agent indices
  128751. */
  128752. getAgents(): number[];
  128753. /**
  128754. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  128755. * @param deltaTime in seconds
  128756. */
  128757. update(deltaTime: number): void;
  128758. /**
  128759. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  128760. * The queries will try to find a solution within those bounds
  128761. * default is (1,1,1)
  128762. * @param extent x,y,z value that define the extent around the queries point of reference
  128763. */
  128764. setDefaultQueryExtent(extent: Vector3): void;
  128765. /**
  128766. * Get the Bounding box extent specified by setDefaultQueryExtent
  128767. * @returns the box extent values
  128768. */
  128769. getDefaultQueryExtent(): Vector3;
  128770. /**
  128771. * Release all resources
  128772. */
  128773. dispose(): void;
  128774. }
  128775. }
  128776. declare module BABYLON {
  128777. /**
  128778. * Class used to enable access to IndexedDB
  128779. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  128780. */
  128781. export class Database implements IOfflineProvider {
  128782. private _callbackManifestChecked;
  128783. private _currentSceneUrl;
  128784. private _db;
  128785. private _enableSceneOffline;
  128786. private _enableTexturesOffline;
  128787. private _manifestVersionFound;
  128788. private _mustUpdateRessources;
  128789. private _hasReachedQuota;
  128790. private _isSupported;
  128791. private _idbFactory;
  128792. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  128793. private static IsUASupportingBlobStorage;
  128794. /**
  128795. * Gets a boolean indicating if Database storate is enabled (off by default)
  128796. */
  128797. static IDBStorageEnabled: boolean;
  128798. /**
  128799. * Gets a boolean indicating if scene must be saved in the database
  128800. */
  128801. readonly enableSceneOffline: boolean;
  128802. /**
  128803. * Gets a boolean indicating if textures must be saved in the database
  128804. */
  128805. readonly enableTexturesOffline: boolean;
  128806. /**
  128807. * Creates a new Database
  128808. * @param urlToScene defines the url to load the scene
  128809. * @param callbackManifestChecked defines the callback to use when manifest is checked
  128810. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  128811. */
  128812. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  128813. private static _ParseURL;
  128814. private static _ReturnFullUrlLocation;
  128815. private _checkManifestFile;
  128816. /**
  128817. * Open the database and make it available
  128818. * @param successCallback defines the callback to call on success
  128819. * @param errorCallback defines the callback to call on error
  128820. */
  128821. open(successCallback: () => void, errorCallback: () => void): void;
  128822. /**
  128823. * Loads an image from the database
  128824. * @param url defines the url to load from
  128825. * @param image defines the target DOM image
  128826. */
  128827. loadImage(url: string, image: HTMLImageElement): void;
  128828. private _loadImageFromDBAsync;
  128829. private _saveImageIntoDBAsync;
  128830. private _checkVersionFromDB;
  128831. private _loadVersionFromDBAsync;
  128832. private _saveVersionIntoDBAsync;
  128833. /**
  128834. * Loads a file from database
  128835. * @param url defines the URL to load from
  128836. * @param sceneLoaded defines a callback to call on success
  128837. * @param progressCallBack defines a callback to call when progress changed
  128838. * @param errorCallback defines a callback to call on error
  128839. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  128840. */
  128841. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  128842. private _loadFileAsync;
  128843. private _saveFileAsync;
  128844. /**
  128845. * Validates if xhr data is correct
  128846. * @param xhr defines the request to validate
  128847. * @param dataType defines the expected data type
  128848. * @returns true if data is correct
  128849. */
  128850. private static _ValidateXHRData;
  128851. }
  128852. }
  128853. declare module BABYLON {
  128854. /** @hidden */
  128855. export var gpuUpdateParticlesPixelShader: {
  128856. name: string;
  128857. shader: string;
  128858. };
  128859. }
  128860. declare module BABYLON {
  128861. /** @hidden */
  128862. export var gpuUpdateParticlesVertexShader: {
  128863. name: string;
  128864. shader: string;
  128865. };
  128866. }
  128867. declare module BABYLON {
  128868. /** @hidden */
  128869. export var clipPlaneFragmentDeclaration2: {
  128870. name: string;
  128871. shader: string;
  128872. };
  128873. }
  128874. declare module BABYLON {
  128875. /** @hidden */
  128876. export var gpuRenderParticlesPixelShader: {
  128877. name: string;
  128878. shader: string;
  128879. };
  128880. }
  128881. declare module BABYLON {
  128882. /** @hidden */
  128883. export var clipPlaneVertexDeclaration2: {
  128884. name: string;
  128885. shader: string;
  128886. };
  128887. }
  128888. declare module BABYLON {
  128889. /** @hidden */
  128890. export var gpuRenderParticlesVertexShader: {
  128891. name: string;
  128892. shader: string;
  128893. };
  128894. }
  128895. declare module BABYLON {
  128896. /**
  128897. * This represents a GPU particle system in Babylon
  128898. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  128899. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  128900. */
  128901. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  128902. /**
  128903. * The layer mask we are rendering the particles through.
  128904. */
  128905. layerMask: number;
  128906. private _capacity;
  128907. private _activeCount;
  128908. private _currentActiveCount;
  128909. private _accumulatedCount;
  128910. private _renderEffect;
  128911. private _updateEffect;
  128912. private _buffer0;
  128913. private _buffer1;
  128914. private _spriteBuffer;
  128915. private _updateVAO;
  128916. private _renderVAO;
  128917. private _targetIndex;
  128918. private _sourceBuffer;
  128919. private _targetBuffer;
  128920. private _engine;
  128921. private _currentRenderId;
  128922. private _started;
  128923. private _stopped;
  128924. private _timeDelta;
  128925. private _randomTexture;
  128926. private _randomTexture2;
  128927. private _attributesStrideSize;
  128928. private _updateEffectOptions;
  128929. private _randomTextureSize;
  128930. private _actualFrame;
  128931. private readonly _rawTextureWidth;
  128932. /**
  128933. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  128934. */
  128935. static readonly IsSupported: boolean;
  128936. /**
  128937. * An event triggered when the system is disposed.
  128938. */
  128939. onDisposeObservable: Observable<GPUParticleSystem>;
  128940. /**
  128941. * Gets the maximum number of particles active at the same time.
  128942. * @returns The max number of active particles.
  128943. */
  128944. getCapacity(): number;
  128945. /**
  128946. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  128947. * to override the particles.
  128948. */
  128949. forceDepthWrite: boolean;
  128950. /**
  128951. * Gets or set the number of active particles
  128952. */
  128953. activeParticleCount: number;
  128954. private _preWarmDone;
  128955. /**
  128956. * Is this system ready to be used/rendered
  128957. * @return true if the system is ready
  128958. */
  128959. isReady(): boolean;
  128960. /**
  128961. * Gets if the system has been started. (Note: this will still be true after stop is called)
  128962. * @returns True if it has been started, otherwise false.
  128963. */
  128964. isStarted(): boolean;
  128965. /**
  128966. * Starts the particle system and begins to emit
  128967. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  128968. */
  128969. start(delay?: number): void;
  128970. /**
  128971. * Stops the particle system.
  128972. */
  128973. stop(): void;
  128974. /**
  128975. * Remove all active particles
  128976. */
  128977. reset(): void;
  128978. /**
  128979. * Returns the string "GPUParticleSystem"
  128980. * @returns a string containing the class name
  128981. */
  128982. getClassName(): string;
  128983. private _colorGradientsTexture;
  128984. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  128985. /**
  128986. * Adds a new color gradient
  128987. * @param gradient defines the gradient to use (between 0 and 1)
  128988. * @param color1 defines the color to affect to the specified gradient
  128989. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  128990. * @returns the current particle system
  128991. */
  128992. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  128993. /**
  128994. * Remove a specific color gradient
  128995. * @param gradient defines the gradient to remove
  128996. * @returns the current particle system
  128997. */
  128998. removeColorGradient(gradient: number): GPUParticleSystem;
  128999. private _angularSpeedGradientsTexture;
  129000. private _sizeGradientsTexture;
  129001. private _velocityGradientsTexture;
  129002. private _limitVelocityGradientsTexture;
  129003. private _dragGradientsTexture;
  129004. private _addFactorGradient;
  129005. /**
  129006. * Adds a new size gradient
  129007. * @param gradient defines the gradient to use (between 0 and 1)
  129008. * @param factor defines the size factor to affect to the specified gradient
  129009. * @returns the current particle system
  129010. */
  129011. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  129012. /**
  129013. * Remove a specific size gradient
  129014. * @param gradient defines the gradient to remove
  129015. * @returns the current particle system
  129016. */
  129017. removeSizeGradient(gradient: number): GPUParticleSystem;
  129018. /**
  129019. * Adds a new angular speed gradient
  129020. * @param gradient defines the gradient to use (between 0 and 1)
  129021. * @param factor defines the angular speed to affect to the specified gradient
  129022. * @returns the current particle system
  129023. */
  129024. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  129025. /**
  129026. * Remove a specific angular speed gradient
  129027. * @param gradient defines the gradient to remove
  129028. * @returns the current particle system
  129029. */
  129030. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  129031. /**
  129032. * Adds a new velocity gradient
  129033. * @param gradient defines the gradient to use (between 0 and 1)
  129034. * @param factor defines the velocity to affect to the specified gradient
  129035. * @returns the current particle system
  129036. */
  129037. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  129038. /**
  129039. * Remove a specific velocity gradient
  129040. * @param gradient defines the gradient to remove
  129041. * @returns the current particle system
  129042. */
  129043. removeVelocityGradient(gradient: number): GPUParticleSystem;
  129044. /**
  129045. * Adds a new limit velocity gradient
  129046. * @param gradient defines the gradient to use (between 0 and 1)
  129047. * @param factor defines the limit velocity value to affect to the specified gradient
  129048. * @returns the current particle system
  129049. */
  129050. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  129051. /**
  129052. * Remove a specific limit velocity gradient
  129053. * @param gradient defines the gradient to remove
  129054. * @returns the current particle system
  129055. */
  129056. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  129057. /**
  129058. * Adds a new drag gradient
  129059. * @param gradient defines the gradient to use (between 0 and 1)
  129060. * @param factor defines the drag value to affect to the specified gradient
  129061. * @returns the current particle system
  129062. */
  129063. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  129064. /**
  129065. * Remove a specific drag gradient
  129066. * @param gradient defines the gradient to remove
  129067. * @returns the current particle system
  129068. */
  129069. removeDragGradient(gradient: number): GPUParticleSystem;
  129070. /**
  129071. * Not supported by GPUParticleSystem
  129072. * @param gradient defines the gradient to use (between 0 and 1)
  129073. * @param factor defines the emit rate value to affect to the specified gradient
  129074. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  129075. * @returns the current particle system
  129076. */
  129077. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  129078. /**
  129079. * Not supported by GPUParticleSystem
  129080. * @param gradient defines the gradient to remove
  129081. * @returns the current particle system
  129082. */
  129083. removeEmitRateGradient(gradient: number): IParticleSystem;
  129084. /**
  129085. * Not supported by GPUParticleSystem
  129086. * @param gradient defines the gradient to use (between 0 and 1)
  129087. * @param factor defines the start size value to affect to the specified gradient
  129088. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  129089. * @returns the current particle system
  129090. */
  129091. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  129092. /**
  129093. * Not supported by GPUParticleSystem
  129094. * @param gradient defines the gradient to remove
  129095. * @returns the current particle system
  129096. */
  129097. removeStartSizeGradient(gradient: number): IParticleSystem;
  129098. /**
  129099. * Not supported by GPUParticleSystem
  129100. * @param gradient defines the gradient to use (between 0 and 1)
  129101. * @param min defines the color remap minimal range
  129102. * @param max defines the color remap maximal range
  129103. * @returns the current particle system
  129104. */
  129105. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  129106. /**
  129107. * Not supported by GPUParticleSystem
  129108. * @param gradient defines the gradient to remove
  129109. * @returns the current particle system
  129110. */
  129111. removeColorRemapGradient(): IParticleSystem;
  129112. /**
  129113. * Not supported by GPUParticleSystem
  129114. * @param gradient defines the gradient to use (between 0 and 1)
  129115. * @param min defines the alpha remap minimal range
  129116. * @param max defines the alpha remap maximal range
  129117. * @returns the current particle system
  129118. */
  129119. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  129120. /**
  129121. * Not supported by GPUParticleSystem
  129122. * @param gradient defines the gradient to remove
  129123. * @returns the current particle system
  129124. */
  129125. removeAlphaRemapGradient(): IParticleSystem;
  129126. /**
  129127. * Not supported by GPUParticleSystem
  129128. * @param gradient defines the gradient to use (between 0 and 1)
  129129. * @param color defines the color to affect to the specified gradient
  129130. * @returns the current particle system
  129131. */
  129132. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  129133. /**
  129134. * Not supported by GPUParticleSystem
  129135. * @param gradient defines the gradient to remove
  129136. * @returns the current particle system
  129137. */
  129138. removeRampGradient(): IParticleSystem;
  129139. /**
  129140. * Not supported by GPUParticleSystem
  129141. * @returns the list of ramp gradients
  129142. */
  129143. getRampGradients(): Nullable<Array<Color3Gradient>>;
  129144. /**
  129145. * Not supported by GPUParticleSystem
  129146. * Gets or sets a boolean indicating that ramp gradients must be used
  129147. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  129148. */
  129149. useRampGradients: boolean;
  129150. /**
  129151. * Not supported by GPUParticleSystem
  129152. * @param gradient defines the gradient to use (between 0 and 1)
  129153. * @param factor defines the life time factor to affect to the specified gradient
  129154. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  129155. * @returns the current particle system
  129156. */
  129157. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  129158. /**
  129159. * Not supported by GPUParticleSystem
  129160. * @param gradient defines the gradient to remove
  129161. * @returns the current particle system
  129162. */
  129163. removeLifeTimeGradient(gradient: number): IParticleSystem;
  129164. /**
  129165. * Instantiates a GPU particle system.
  129166. * 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.
  129167. * @param name The name of the particle system
  129168. * @param options The options used to create the system
  129169. * @param scene The scene the particle system belongs to
  129170. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  129171. */
  129172. constructor(name: string, options: Partial<{
  129173. capacity: number;
  129174. randomTextureSize: number;
  129175. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  129176. protected _reset(): void;
  129177. private _createUpdateVAO;
  129178. private _createRenderVAO;
  129179. private _initialize;
  129180. /** @hidden */
  129181. _recreateUpdateEffect(): void;
  129182. /** @hidden */
  129183. _recreateRenderEffect(): void;
  129184. /**
  129185. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  129186. * @param preWarm defines if we are in the pre-warmimg phase
  129187. */
  129188. animate(preWarm?: boolean): void;
  129189. private _createFactorGradientTexture;
  129190. private _createSizeGradientTexture;
  129191. private _createAngularSpeedGradientTexture;
  129192. private _createVelocityGradientTexture;
  129193. private _createLimitVelocityGradientTexture;
  129194. private _createDragGradientTexture;
  129195. private _createColorGradientTexture;
  129196. /**
  129197. * Renders the particle system in its current state
  129198. * @param preWarm defines if the system should only update the particles but not render them
  129199. * @returns the current number of particles
  129200. */
  129201. render(preWarm?: boolean): number;
  129202. /**
  129203. * Rebuilds the particle system
  129204. */
  129205. rebuild(): void;
  129206. private _releaseBuffers;
  129207. private _releaseVAOs;
  129208. /**
  129209. * Disposes the particle system and free the associated resources
  129210. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  129211. */
  129212. dispose(disposeTexture?: boolean): void;
  129213. /**
  129214. * Clones the particle system.
  129215. * @param name The name of the cloned object
  129216. * @param newEmitter The new emitter to use
  129217. * @returns the cloned particle system
  129218. */
  129219. clone(name: string, newEmitter: any): GPUParticleSystem;
  129220. /**
  129221. * Serializes the particle system to a JSON object.
  129222. * @returns the JSON object
  129223. */
  129224. serialize(): any;
  129225. /**
  129226. * Parses a JSON object to create a GPU particle system.
  129227. * @param parsedParticleSystem The JSON object to parse
  129228. * @param scene The scene to create the particle system in
  129229. * @param rootUrl The root url to use to load external dependencies like texture
  129230. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  129231. * @returns the parsed GPU particle system
  129232. */
  129233. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  129234. }
  129235. }
  129236. declare module BABYLON {
  129237. /**
  129238. * Represents a set of particle systems working together to create a specific effect
  129239. */
  129240. export class ParticleSystemSet implements IDisposable {
  129241. /**
  129242. * Gets or sets base Assets URL
  129243. */
  129244. static BaseAssetsUrl: string;
  129245. private _emitterCreationOptions;
  129246. private _emitterNode;
  129247. /**
  129248. * Gets the particle system list
  129249. */
  129250. systems: IParticleSystem[];
  129251. /**
  129252. * Gets the emitter node used with this set
  129253. */
  129254. readonly emitterNode: Nullable<TransformNode>;
  129255. /**
  129256. * Creates a new emitter mesh as a sphere
  129257. * @param options defines the options used to create the sphere
  129258. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  129259. * @param scene defines the hosting scene
  129260. */
  129261. setEmitterAsSphere(options: {
  129262. diameter: number;
  129263. segments: number;
  129264. color: Color3;
  129265. }, renderingGroupId: number, scene: Scene): void;
  129266. /**
  129267. * Starts all particle systems of the set
  129268. * @param emitter defines an optional mesh to use as emitter for the particle systems
  129269. */
  129270. start(emitter?: AbstractMesh): void;
  129271. /**
  129272. * Release all associated resources
  129273. */
  129274. dispose(): void;
  129275. /**
  129276. * Serialize the set into a JSON compatible object
  129277. * @returns a JSON compatible representation of the set
  129278. */
  129279. serialize(): any;
  129280. /**
  129281. * Parse a new ParticleSystemSet from a serialized source
  129282. * @param data defines a JSON compatible representation of the set
  129283. * @param scene defines the hosting scene
  129284. * @param gpu defines if we want GPU particles or CPU particles
  129285. * @returns a new ParticleSystemSet
  129286. */
  129287. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  129288. }
  129289. }
  129290. declare module BABYLON {
  129291. /**
  129292. * This class is made for on one-liner static method to help creating particle system set.
  129293. */
  129294. export class ParticleHelper {
  129295. /**
  129296. * Gets or sets base Assets URL
  129297. */
  129298. static BaseAssetsUrl: string;
  129299. /**
  129300. * Create a default particle system that you can tweak
  129301. * @param emitter defines the emitter to use
  129302. * @param capacity defines the system capacity (default is 500 particles)
  129303. * @param scene defines the hosting scene
  129304. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  129305. * @returns the new Particle system
  129306. */
  129307. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  129308. /**
  129309. * This is the main static method (one-liner) of this helper to create different particle systems
  129310. * @param type This string represents the type to the particle system to create
  129311. * @param scene The scene where the particle system should live
  129312. * @param gpu If the system will use gpu
  129313. * @returns the ParticleSystemSet created
  129314. */
  129315. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  129316. /**
  129317. * Static function used to export a particle system to a ParticleSystemSet variable.
  129318. * Please note that the emitter shape is not exported
  129319. * @param systems defines the particle systems to export
  129320. * @returns the created particle system set
  129321. */
  129322. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  129323. }
  129324. }
  129325. declare module BABYLON {
  129326. interface Engine {
  129327. /**
  129328. * Create an effect to use with particle systems.
  129329. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  129330. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  129331. * @param uniformsNames defines a list of attribute names
  129332. * @param samplers defines an array of string used to represent textures
  129333. * @param defines defines the string containing the defines to use to compile the shaders
  129334. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  129335. * @param onCompiled defines a function to call when the effect creation is successful
  129336. * @param onError defines a function to call when the effect creation has failed
  129337. * @returns the new Effect
  129338. */
  129339. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  129340. }
  129341. interface Mesh {
  129342. /**
  129343. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  129344. * @returns an array of IParticleSystem
  129345. */
  129346. getEmittedParticleSystems(): IParticleSystem[];
  129347. /**
  129348. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  129349. * @returns an array of IParticleSystem
  129350. */
  129351. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  129352. }
  129353. /**
  129354. * @hidden
  129355. */
  129356. export var _IDoNeedToBeInTheBuild: number;
  129357. }
  129358. declare module BABYLON {
  129359. /** Defines the 4 color options */
  129360. export enum PointColor {
  129361. /** color value */
  129362. Color = 2,
  129363. /** uv value */
  129364. UV = 1,
  129365. /** random value */
  129366. Random = 0,
  129367. /** stated value */
  129368. Stated = 3
  129369. }
  129370. /**
  129371. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  129372. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  129373. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  129374. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  129375. *
  129376. * Full documentation here : TO BE ENTERED
  129377. */
  129378. export class PointsCloudSystem implements IDisposable {
  129379. /**
  129380. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  129381. * Example : var p = SPS.particles[i];
  129382. */
  129383. particles: CloudPoint[];
  129384. /**
  129385. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  129386. */
  129387. nbParticles: number;
  129388. /**
  129389. * This a counter for your own usage. It's not set by any SPS functions.
  129390. */
  129391. counter: number;
  129392. /**
  129393. * The PCS name. This name is also given to the underlying mesh.
  129394. */
  129395. name: string;
  129396. /**
  129397. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  129398. */
  129399. mesh: Mesh;
  129400. /**
  129401. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  129402. * Please read :
  129403. */
  129404. vars: any;
  129405. /**
  129406. * @hidden
  129407. */
  129408. _size: number;
  129409. private _scene;
  129410. private _promises;
  129411. private _positions;
  129412. private _indices;
  129413. private _normals;
  129414. private _colors;
  129415. private _uvs;
  129416. private _indices32;
  129417. private _positions32;
  129418. private _colors32;
  129419. private _uvs32;
  129420. private _updatable;
  129421. private _isVisibilityBoxLocked;
  129422. private _alwaysVisible;
  129423. private _groups;
  129424. private _groupCounter;
  129425. private _computeParticleColor;
  129426. private _computeParticleTexture;
  129427. private _computeParticleRotation;
  129428. private _computeBoundingBox;
  129429. private _isReady;
  129430. /**
  129431. * Creates a PCS (Points Cloud System) object
  129432. * @param name (String) is the PCS name, this will be the underlying mesh name
  129433. * @param pointSize (number) is the size for each point
  129434. * @param scene (Scene) is the scene in which the PCS is added
  129435. * @param options defines the options of the PCS e.g.
  129436. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  129437. */
  129438. constructor(name: string, pointSize: number, scene: Scene, options?: {
  129439. updatable?: boolean;
  129440. });
  129441. /**
  129442. * Builds the PCS underlying mesh. Returns a standard Mesh.
  129443. * If no points were added to the PCS, the returned mesh is just a single point.
  129444. * @returns a promise for the created mesh
  129445. */
  129446. buildMeshAsync(): Promise<Mesh>;
  129447. /**
  129448. * @hidden
  129449. */
  129450. private _buildMesh;
  129451. private _addParticle;
  129452. private _randomUnitVector;
  129453. private _getColorIndicesForCoord;
  129454. private _setPointsColorOrUV;
  129455. private _colorFromTexture;
  129456. private _calculateDensity;
  129457. /**
  129458. * Adds points to the PCS in random positions within a unit sphere
  129459. * @param nb (positive integer) the number of particles to be created from this model
  129460. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  129461. * @returns the number of groups in the system
  129462. */
  129463. addPoints(nb: number, pointFunction?: any): number;
  129464. /**
  129465. * Adds points to the PCS from the surface of the model shape
  129466. * @param mesh is any Mesh object that will be used as a surface model for the points
  129467. * @param nb (positive integer) the number of particles to be created from this model
  129468. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  129469. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  129470. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  129471. * @returns the number of groups in the system
  129472. */
  129473. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  129474. /**
  129475. * Adds points to the PCS inside the model shape
  129476. * @param mesh is any Mesh object that will be used as a surface model for the points
  129477. * @param nb (positive integer) the number of particles to be created from this model
  129478. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  129479. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  129480. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  129481. * @returns the number of groups in the system
  129482. */
  129483. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  129484. /**
  129485. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  129486. * This method calls `updateParticle()` for each particle of the SPS.
  129487. * For an animated SPS, it is usually called within the render loop.
  129488. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  129489. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  129490. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  129491. * @returns the PCS.
  129492. */
  129493. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  129494. /**
  129495. * Disposes the PCS.
  129496. */
  129497. dispose(): void;
  129498. /**
  129499. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  129500. * doc :
  129501. * @returns the PCS.
  129502. */
  129503. refreshVisibleSize(): PointsCloudSystem;
  129504. /**
  129505. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  129506. * @param size the size (float) of the visibility box
  129507. * note : this doesn't lock the PCS mesh bounding box.
  129508. * doc :
  129509. */
  129510. setVisibilityBox(size: number): void;
  129511. /**
  129512. * Gets whether the PCS is always visible or not
  129513. * doc :
  129514. */
  129515. /**
  129516. * Sets the PCS as always visible or not
  129517. * doc :
  129518. */
  129519. isAlwaysVisible: boolean;
  129520. /**
  129521. * Tells to `setParticles()` to compute the particle rotations or not
  129522. * Default value : false. The PCS is faster when it's set to false
  129523. * Note : particle rotations are only applied to parent particles
  129524. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  129525. */
  129526. computeParticleRotation: boolean;
  129527. /**
  129528. * Tells to `setParticles()` to compute the particle colors or not.
  129529. * Default value : true. The PCS is faster when it's set to false.
  129530. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  129531. */
  129532. /**
  129533. * Gets if `setParticles()` computes the particle colors or not.
  129534. * Default value : false. The PCS is faster when it's set to false.
  129535. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  129536. */
  129537. computeParticleColor: boolean;
  129538. /**
  129539. * Gets if `setParticles()` computes the particle textures or not.
  129540. * Default value : false. The PCS is faster when it's set to false.
  129541. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  129542. */
  129543. computeParticleTexture: boolean;
  129544. /**
  129545. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  129546. */
  129547. /**
  129548. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  129549. */
  129550. computeBoundingBox: boolean;
  129551. /**
  129552. * This function does nothing. It may be overwritten to set all the particle first values.
  129553. * The PCS doesn't call this function, you may have to call it by your own.
  129554. * doc :
  129555. */
  129556. initParticles(): void;
  129557. /**
  129558. * This function does nothing. It may be overwritten to recycle a particle
  129559. * The PCS doesn't call this function, you can to call it
  129560. * doc :
  129561. * @param particle The particle to recycle
  129562. * @returns the recycled particle
  129563. */
  129564. recycleParticle(particle: CloudPoint): CloudPoint;
  129565. /**
  129566. * Updates a particle : this function should be overwritten by the user.
  129567. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  129568. * doc :
  129569. * @example : just set a particle position or velocity and recycle conditions
  129570. * @param particle The particle to update
  129571. * @returns the updated particle
  129572. */
  129573. updateParticle(particle: CloudPoint): CloudPoint;
  129574. /**
  129575. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  129576. * This does nothing and may be overwritten by the user.
  129577. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  129578. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  129579. * @param update the boolean update value actually passed to setParticles()
  129580. */
  129581. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  129582. /**
  129583. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  129584. * This will be passed three parameters.
  129585. * This does nothing and may be overwritten by the user.
  129586. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  129587. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  129588. * @param update the boolean update value actually passed to setParticles()
  129589. */
  129590. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  129591. }
  129592. }
  129593. declare module BABYLON {
  129594. /**
  129595. * Represents one particle of a points cloud system.
  129596. */
  129597. export class CloudPoint {
  129598. /**
  129599. * particle global index
  129600. */
  129601. idx: number;
  129602. /**
  129603. * The color of the particle
  129604. */
  129605. color: Nullable<Color4>;
  129606. /**
  129607. * The world space position of the particle.
  129608. */
  129609. position: Vector3;
  129610. /**
  129611. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  129612. */
  129613. rotation: Vector3;
  129614. /**
  129615. * The world space rotation quaternion of the particle.
  129616. */
  129617. rotationQuaternion: Nullable<Quaternion>;
  129618. /**
  129619. * The uv of the particle.
  129620. */
  129621. uv: Nullable<Vector2>;
  129622. /**
  129623. * The current speed of the particle.
  129624. */
  129625. velocity: Vector3;
  129626. /**
  129627. * The pivot point in the particle local space.
  129628. */
  129629. pivot: Vector3;
  129630. /**
  129631. * Must the particle be translated from its pivot point in its local space ?
  129632. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  129633. * Default : false
  129634. */
  129635. translateFromPivot: boolean;
  129636. /**
  129637. * Index of this particle in the global "positions" array (Internal use)
  129638. * @hidden
  129639. */
  129640. _pos: number;
  129641. /**
  129642. * @hidden Index of this particle in the global "indices" array (Internal use)
  129643. */
  129644. _ind: number;
  129645. /**
  129646. * Group this particle belongs to
  129647. */
  129648. _group: PointsGroup;
  129649. /**
  129650. * Group id of this particle
  129651. */
  129652. groupId: number;
  129653. /**
  129654. * Index of the particle in its group id (Internal use)
  129655. */
  129656. idxInGroup: number;
  129657. /**
  129658. * @hidden Particle BoundingInfo object (Internal use)
  129659. */
  129660. _boundingInfo: BoundingInfo;
  129661. /**
  129662. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  129663. */
  129664. _pcs: PointsCloudSystem;
  129665. /**
  129666. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  129667. */
  129668. _stillInvisible: boolean;
  129669. /**
  129670. * @hidden Last computed particle rotation matrix
  129671. */
  129672. _rotationMatrix: number[];
  129673. /**
  129674. * Parent particle Id, if any.
  129675. * Default null.
  129676. */
  129677. parentId: Nullable<number>;
  129678. /**
  129679. * @hidden Internal global position in the PCS.
  129680. */
  129681. _globalPosition: Vector3;
  129682. /**
  129683. * Creates a Point Cloud object.
  129684. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  129685. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  129686. * @param group (PointsGroup) is the group the particle belongs to
  129687. * @param groupId (integer) is the group identifier in the PCS.
  129688. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  129689. * @param pcs defines the PCS it is associated to
  129690. */
  129691. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  129692. /**
  129693. * get point size
  129694. */
  129695. /**
  129696. * Set point size
  129697. */
  129698. size: Vector3;
  129699. /**
  129700. * Legacy support, changed quaternion to rotationQuaternion
  129701. */
  129702. /**
  129703. * Legacy support, changed quaternion to rotationQuaternion
  129704. */
  129705. quaternion: Nullable<Quaternion>;
  129706. /**
  129707. * Returns a boolean. True if the particle intersects a mesh, else false
  129708. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  129709. * @param target is the object (point or mesh) what the intersection is computed against
  129710. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  129711. * @returns true if it intersects
  129712. */
  129713. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  129714. /**
  129715. * get the rotation matrix of the particle
  129716. * @hidden
  129717. */
  129718. getRotationMatrix(m: Matrix): void;
  129719. }
  129720. /**
  129721. * Represents a group of points in a points cloud system
  129722. * * PCS internal tool, don't use it manually.
  129723. */
  129724. export class PointsGroup {
  129725. /**
  129726. * The group id
  129727. * @hidden
  129728. */
  129729. groupID: number;
  129730. /**
  129731. * image data for group (internal use)
  129732. * @hidden
  129733. */
  129734. _groupImageData: Nullable<ArrayBufferView>;
  129735. /**
  129736. * Image Width (internal use)
  129737. * @hidden
  129738. */
  129739. _groupImgWidth: number;
  129740. /**
  129741. * Image Height (internal use)
  129742. * @hidden
  129743. */
  129744. _groupImgHeight: number;
  129745. /**
  129746. * Custom position function (internal use)
  129747. * @hidden
  129748. */
  129749. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  129750. /**
  129751. * density per facet for surface points
  129752. * @hidden
  129753. */
  129754. _groupDensity: number[];
  129755. /**
  129756. * Only when points are colored by texture carries pointer to texture list array
  129757. * @hidden
  129758. */
  129759. _textureNb: number;
  129760. /**
  129761. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  129762. * PCS internal tool, don't use it manually.
  129763. * @hidden
  129764. */
  129765. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  129766. }
  129767. }
  129768. declare module BABYLON {
  129769. interface Scene {
  129770. /** @hidden (Backing field) */
  129771. _physicsEngine: Nullable<IPhysicsEngine>;
  129772. /** @hidden */
  129773. _physicsTimeAccumulator: number;
  129774. /**
  129775. * Gets the current physics engine
  129776. * @returns a IPhysicsEngine or null if none attached
  129777. */
  129778. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  129779. /**
  129780. * Enables physics to the current scene
  129781. * @param gravity defines the scene's gravity for the physics engine
  129782. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  129783. * @return a boolean indicating if the physics engine was initialized
  129784. */
  129785. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  129786. /**
  129787. * Disables and disposes the physics engine associated with the scene
  129788. */
  129789. disablePhysicsEngine(): void;
  129790. /**
  129791. * Gets a boolean indicating if there is an active physics engine
  129792. * @returns a boolean indicating if there is an active physics engine
  129793. */
  129794. isPhysicsEnabled(): boolean;
  129795. /**
  129796. * Deletes a physics compound impostor
  129797. * @param compound defines the compound to delete
  129798. */
  129799. deleteCompoundImpostor(compound: any): void;
  129800. /**
  129801. * An event triggered when physic simulation is about to be run
  129802. */
  129803. onBeforePhysicsObservable: Observable<Scene>;
  129804. /**
  129805. * An event triggered when physic simulation has been done
  129806. */
  129807. onAfterPhysicsObservable: Observable<Scene>;
  129808. }
  129809. interface AbstractMesh {
  129810. /** @hidden */
  129811. _physicsImpostor: Nullable<PhysicsImpostor>;
  129812. /**
  129813. * Gets or sets impostor used for physic simulation
  129814. * @see http://doc.babylonjs.com/features/physics_engine
  129815. */
  129816. physicsImpostor: Nullable<PhysicsImpostor>;
  129817. /**
  129818. * Gets the current physics impostor
  129819. * @see http://doc.babylonjs.com/features/physics_engine
  129820. * @returns a physics impostor or null
  129821. */
  129822. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  129823. /** Apply a physic impulse to the mesh
  129824. * @param force defines the force to apply
  129825. * @param contactPoint defines where to apply the force
  129826. * @returns the current mesh
  129827. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  129828. */
  129829. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  129830. /**
  129831. * Creates a physic joint between two meshes
  129832. * @param otherMesh defines the other mesh to use
  129833. * @param pivot1 defines the pivot to use on this mesh
  129834. * @param pivot2 defines the pivot to use on the other mesh
  129835. * @param options defines additional options (can be plugin dependent)
  129836. * @returns the current mesh
  129837. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  129838. */
  129839. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  129840. /** @hidden */
  129841. _disposePhysicsObserver: Nullable<Observer<Node>>;
  129842. }
  129843. /**
  129844. * Defines the physics engine scene component responsible to manage a physics engine
  129845. */
  129846. export class PhysicsEngineSceneComponent implements ISceneComponent {
  129847. /**
  129848. * The component name helpful to identify the component in the list of scene components.
  129849. */
  129850. readonly name: string;
  129851. /**
  129852. * The scene the component belongs to.
  129853. */
  129854. scene: Scene;
  129855. /**
  129856. * Creates a new instance of the component for the given scene
  129857. * @param scene Defines the scene to register the component in
  129858. */
  129859. constructor(scene: Scene);
  129860. /**
  129861. * Registers the component in a given scene
  129862. */
  129863. register(): void;
  129864. /**
  129865. * Rebuilds the elements related to this component in case of
  129866. * context lost for instance.
  129867. */
  129868. rebuild(): void;
  129869. /**
  129870. * Disposes the component and the associated ressources
  129871. */
  129872. dispose(): void;
  129873. }
  129874. }
  129875. declare module BABYLON {
  129876. /**
  129877. * A helper for physics simulations
  129878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129879. */
  129880. export class PhysicsHelper {
  129881. private _scene;
  129882. private _physicsEngine;
  129883. /**
  129884. * Initializes the Physics helper
  129885. * @param scene Babylon.js scene
  129886. */
  129887. constructor(scene: Scene);
  129888. /**
  129889. * Applies a radial explosion impulse
  129890. * @param origin the origin of the explosion
  129891. * @param radiusOrEventOptions the radius or the options of radial explosion
  129892. * @param strength the explosion strength
  129893. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129894. * @returns A physics radial explosion event, or null
  129895. */
  129896. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  129897. /**
  129898. * Applies a radial explosion force
  129899. * @param origin the origin of the explosion
  129900. * @param radiusOrEventOptions the radius or the options of radial explosion
  129901. * @param strength the explosion strength
  129902. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129903. * @returns A physics radial explosion event, or null
  129904. */
  129905. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  129906. /**
  129907. * Creates a gravitational field
  129908. * @param origin the origin of the explosion
  129909. * @param radiusOrEventOptions the radius or the options of radial explosion
  129910. * @param strength the explosion strength
  129911. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129912. * @returns A physics gravitational field event, or null
  129913. */
  129914. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  129915. /**
  129916. * Creates a physics updraft event
  129917. * @param origin the origin of the updraft
  129918. * @param radiusOrEventOptions the radius or the options of the updraft
  129919. * @param strength the strength of the updraft
  129920. * @param height the height of the updraft
  129921. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  129922. * @returns A physics updraft event, or null
  129923. */
  129924. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  129925. /**
  129926. * Creates a physics vortex event
  129927. * @param origin the of the vortex
  129928. * @param radiusOrEventOptions the radius or the options of the vortex
  129929. * @param strength the strength of the vortex
  129930. * @param height the height of the vortex
  129931. * @returns a Physics vortex event, or null
  129932. * A physics vortex event or null
  129933. */
  129934. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  129935. }
  129936. /**
  129937. * Represents a physics radial explosion event
  129938. */
  129939. class PhysicsRadialExplosionEvent {
  129940. private _scene;
  129941. private _options;
  129942. private _sphere;
  129943. private _dataFetched;
  129944. /**
  129945. * Initializes a radial explosioin event
  129946. * @param _scene BabylonJS scene
  129947. * @param _options The options for the vortex event
  129948. */
  129949. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  129950. /**
  129951. * Returns the data related to the radial explosion event (sphere).
  129952. * @returns The radial explosion event data
  129953. */
  129954. getData(): PhysicsRadialExplosionEventData;
  129955. /**
  129956. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  129957. * @param impostor A physics imposter
  129958. * @param origin the origin of the explosion
  129959. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  129960. */
  129961. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  129962. /**
  129963. * Triggers affecterd impostors callbacks
  129964. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  129965. */
  129966. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  129967. /**
  129968. * Disposes the sphere.
  129969. * @param force Specifies if the sphere should be disposed by force
  129970. */
  129971. dispose(force?: boolean): void;
  129972. /*** Helpers ***/
  129973. private _prepareSphere;
  129974. private _intersectsWithSphere;
  129975. }
  129976. /**
  129977. * Represents a gravitational field event
  129978. */
  129979. class PhysicsGravitationalFieldEvent {
  129980. private _physicsHelper;
  129981. private _scene;
  129982. private _origin;
  129983. private _options;
  129984. private _tickCallback;
  129985. private _sphere;
  129986. private _dataFetched;
  129987. /**
  129988. * Initializes the physics gravitational field event
  129989. * @param _physicsHelper A physics helper
  129990. * @param _scene BabylonJS scene
  129991. * @param _origin The origin position of the gravitational field event
  129992. * @param _options The options for the vortex event
  129993. */
  129994. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  129995. /**
  129996. * Returns the data related to the gravitational field event (sphere).
  129997. * @returns A gravitational field event
  129998. */
  129999. getData(): PhysicsGravitationalFieldEventData;
  130000. /**
  130001. * Enables the gravitational field.
  130002. */
  130003. enable(): void;
  130004. /**
  130005. * Disables the gravitational field.
  130006. */
  130007. disable(): void;
  130008. /**
  130009. * Disposes the sphere.
  130010. * @param force The force to dispose from the gravitational field event
  130011. */
  130012. dispose(force?: boolean): void;
  130013. private _tick;
  130014. }
  130015. /**
  130016. * Represents a physics updraft event
  130017. */
  130018. class PhysicsUpdraftEvent {
  130019. private _scene;
  130020. private _origin;
  130021. private _options;
  130022. private _physicsEngine;
  130023. private _originTop;
  130024. private _originDirection;
  130025. private _tickCallback;
  130026. private _cylinder;
  130027. private _cylinderPosition;
  130028. private _dataFetched;
  130029. /**
  130030. * Initializes the physics updraft event
  130031. * @param _scene BabylonJS scene
  130032. * @param _origin The origin position of the updraft
  130033. * @param _options The options for the updraft event
  130034. */
  130035. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  130036. /**
  130037. * Returns the data related to the updraft event (cylinder).
  130038. * @returns A physics updraft event
  130039. */
  130040. getData(): PhysicsUpdraftEventData;
  130041. /**
  130042. * Enables the updraft.
  130043. */
  130044. enable(): void;
  130045. /**
  130046. * Disables the updraft.
  130047. */
  130048. disable(): void;
  130049. /**
  130050. * Disposes the cylinder.
  130051. * @param force Specifies if the updraft should be disposed by force
  130052. */
  130053. dispose(force?: boolean): void;
  130054. private getImpostorHitData;
  130055. private _tick;
  130056. /*** Helpers ***/
  130057. private _prepareCylinder;
  130058. private _intersectsWithCylinder;
  130059. }
  130060. /**
  130061. * Represents a physics vortex event
  130062. */
  130063. class PhysicsVortexEvent {
  130064. private _scene;
  130065. private _origin;
  130066. private _options;
  130067. private _physicsEngine;
  130068. private _originTop;
  130069. private _tickCallback;
  130070. private _cylinder;
  130071. private _cylinderPosition;
  130072. private _dataFetched;
  130073. /**
  130074. * Initializes the physics vortex event
  130075. * @param _scene The BabylonJS scene
  130076. * @param _origin The origin position of the vortex
  130077. * @param _options The options for the vortex event
  130078. */
  130079. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  130080. /**
  130081. * Returns the data related to the vortex event (cylinder).
  130082. * @returns The physics vortex event data
  130083. */
  130084. getData(): PhysicsVortexEventData;
  130085. /**
  130086. * Enables the vortex.
  130087. */
  130088. enable(): void;
  130089. /**
  130090. * Disables the cortex.
  130091. */
  130092. disable(): void;
  130093. /**
  130094. * Disposes the sphere.
  130095. * @param force
  130096. */
  130097. dispose(force?: boolean): void;
  130098. private getImpostorHitData;
  130099. private _tick;
  130100. /*** Helpers ***/
  130101. private _prepareCylinder;
  130102. private _intersectsWithCylinder;
  130103. }
  130104. /**
  130105. * Options fot the radial explosion event
  130106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  130107. */
  130108. export class PhysicsRadialExplosionEventOptions {
  130109. /**
  130110. * The radius of the sphere for the radial explosion.
  130111. */
  130112. radius: number;
  130113. /**
  130114. * The strenth of the explosion.
  130115. */
  130116. strength: number;
  130117. /**
  130118. * The strenght of the force in correspondence to the distance of the affected object
  130119. */
  130120. falloff: PhysicsRadialImpulseFalloff;
  130121. /**
  130122. * Sphere options for the radial explosion.
  130123. */
  130124. sphere: {
  130125. segments: number;
  130126. diameter: number;
  130127. };
  130128. /**
  130129. * Sphere options for the radial explosion.
  130130. */
  130131. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  130132. }
  130133. /**
  130134. * Options fot the updraft event
  130135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  130136. */
  130137. export class PhysicsUpdraftEventOptions {
  130138. /**
  130139. * The radius of the cylinder for the vortex
  130140. */
  130141. radius: number;
  130142. /**
  130143. * The strenth of the updraft.
  130144. */
  130145. strength: number;
  130146. /**
  130147. * The height of the cylinder for the updraft.
  130148. */
  130149. height: number;
  130150. /**
  130151. * The mode for the the updraft.
  130152. */
  130153. updraftMode: PhysicsUpdraftMode;
  130154. }
  130155. /**
  130156. * Options fot the vortex event
  130157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  130158. */
  130159. export class PhysicsVortexEventOptions {
  130160. /**
  130161. * The radius of the cylinder for the vortex
  130162. */
  130163. radius: number;
  130164. /**
  130165. * The strenth of the vortex.
  130166. */
  130167. strength: number;
  130168. /**
  130169. * The height of the cylinder for the vortex.
  130170. */
  130171. height: number;
  130172. /**
  130173. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  130174. */
  130175. centripetalForceThreshold: number;
  130176. /**
  130177. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  130178. */
  130179. centripetalForceMultiplier: number;
  130180. /**
  130181. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  130182. */
  130183. centrifugalForceMultiplier: number;
  130184. /**
  130185. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  130186. */
  130187. updraftForceMultiplier: number;
  130188. }
  130189. /**
  130190. * The strenght of the force in correspondence to the distance of the affected object
  130191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  130192. */
  130193. export enum PhysicsRadialImpulseFalloff {
  130194. /** Defines that impulse is constant in strength across it's whole radius */
  130195. Constant = 0,
  130196. /** Defines that impulse gets weaker if it's further from the origin */
  130197. Linear = 1
  130198. }
  130199. /**
  130200. * The strength of the force in correspondence to the distance of the affected object
  130201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  130202. */
  130203. export enum PhysicsUpdraftMode {
  130204. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  130205. Center = 0,
  130206. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  130207. Perpendicular = 1
  130208. }
  130209. /**
  130210. * Interface for a physics hit data
  130211. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  130212. */
  130213. export interface PhysicsHitData {
  130214. /**
  130215. * The force applied at the contact point
  130216. */
  130217. force: Vector3;
  130218. /**
  130219. * The contact point
  130220. */
  130221. contactPoint: Vector3;
  130222. /**
  130223. * The distance from the origin to the contact point
  130224. */
  130225. distanceFromOrigin: number;
  130226. }
  130227. /**
  130228. * Interface for radial explosion event data
  130229. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  130230. */
  130231. export interface PhysicsRadialExplosionEventData {
  130232. /**
  130233. * A sphere used for the radial explosion event
  130234. */
  130235. sphere: Mesh;
  130236. }
  130237. /**
  130238. * Interface for gravitational field event data
  130239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  130240. */
  130241. export interface PhysicsGravitationalFieldEventData {
  130242. /**
  130243. * A sphere mesh used for the gravitational field event
  130244. */
  130245. sphere: Mesh;
  130246. }
  130247. /**
  130248. * Interface for updraft event data
  130249. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  130250. */
  130251. export interface PhysicsUpdraftEventData {
  130252. /**
  130253. * A cylinder used for the updraft event
  130254. */
  130255. cylinder: Mesh;
  130256. }
  130257. /**
  130258. * Interface for vortex event data
  130259. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  130260. */
  130261. export interface PhysicsVortexEventData {
  130262. /**
  130263. * A cylinder used for the vortex event
  130264. */
  130265. cylinder: Mesh;
  130266. }
  130267. /**
  130268. * Interface for an affected physics impostor
  130269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  130270. */
  130271. export interface PhysicsAffectedImpostorWithData {
  130272. /**
  130273. * The impostor affected by the effect
  130274. */
  130275. impostor: PhysicsImpostor;
  130276. /**
  130277. * The data about the hit/horce from the explosion
  130278. */
  130279. hitData: PhysicsHitData;
  130280. }
  130281. }
  130282. declare module BABYLON {
  130283. /** @hidden */
  130284. export var blackAndWhitePixelShader: {
  130285. name: string;
  130286. shader: string;
  130287. };
  130288. }
  130289. declare module BABYLON {
  130290. /**
  130291. * Post process used to render in black and white
  130292. */
  130293. export class BlackAndWhitePostProcess extends PostProcess {
  130294. /**
  130295. * Linear about to convert he result to black and white (default: 1)
  130296. */
  130297. degree: number;
  130298. /**
  130299. * Creates a black and white post process
  130300. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  130301. * @param name The name of the effect.
  130302. * @param options The required width/height ratio to downsize to before computing the render pass.
  130303. * @param camera The camera to apply the render pass to.
  130304. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130305. * @param engine The engine which the post process will be applied. (default: current engine)
  130306. * @param reusable If the post process can be reused on the same frame. (default: false)
  130307. */
  130308. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130309. }
  130310. }
  130311. declare module BABYLON {
  130312. /**
  130313. * This represents a set of one or more post processes in Babylon.
  130314. * A post process can be used to apply a shader to a texture after it is rendered.
  130315. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130316. */
  130317. export class PostProcessRenderEffect {
  130318. private _postProcesses;
  130319. private _getPostProcesses;
  130320. private _singleInstance;
  130321. private _cameras;
  130322. private _indicesForCamera;
  130323. /**
  130324. * Name of the effect
  130325. * @hidden
  130326. */
  130327. _name: string;
  130328. /**
  130329. * Instantiates a post process render effect.
  130330. * A post process can be used to apply a shader to a texture after it is rendered.
  130331. * @param engine The engine the effect is tied to
  130332. * @param name The name of the effect
  130333. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  130334. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  130335. */
  130336. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  130337. /**
  130338. * Checks if all the post processes in the effect are supported.
  130339. */
  130340. readonly isSupported: boolean;
  130341. /**
  130342. * Updates the current state of the effect
  130343. * @hidden
  130344. */
  130345. _update(): void;
  130346. /**
  130347. * Attaches the effect on cameras
  130348. * @param cameras The camera to attach to.
  130349. * @hidden
  130350. */
  130351. _attachCameras(cameras: Camera): void;
  130352. /**
  130353. * Attaches the effect on cameras
  130354. * @param cameras The camera to attach to.
  130355. * @hidden
  130356. */
  130357. _attachCameras(cameras: Camera[]): void;
  130358. /**
  130359. * Detaches the effect on cameras
  130360. * @param cameras The camera to detatch from.
  130361. * @hidden
  130362. */
  130363. _detachCameras(cameras: Camera): void;
  130364. /**
  130365. * Detatches the effect on cameras
  130366. * @param cameras The camera to detatch from.
  130367. * @hidden
  130368. */
  130369. _detachCameras(cameras: Camera[]): void;
  130370. /**
  130371. * Enables the effect on given cameras
  130372. * @param cameras The camera to enable.
  130373. * @hidden
  130374. */
  130375. _enable(cameras: Camera): void;
  130376. /**
  130377. * Enables the effect on given cameras
  130378. * @param cameras The camera to enable.
  130379. * @hidden
  130380. */
  130381. _enable(cameras: Nullable<Camera[]>): void;
  130382. /**
  130383. * Disables the effect on the given cameras
  130384. * @param cameras The camera to disable.
  130385. * @hidden
  130386. */
  130387. _disable(cameras: Camera): void;
  130388. /**
  130389. * Disables the effect on the given cameras
  130390. * @param cameras The camera to disable.
  130391. * @hidden
  130392. */
  130393. _disable(cameras: Nullable<Camera[]>): void;
  130394. /**
  130395. * Gets a list of the post processes contained in the effect.
  130396. * @param camera The camera to get the post processes on.
  130397. * @returns The list of the post processes in the effect.
  130398. */
  130399. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  130400. }
  130401. }
  130402. declare module BABYLON {
  130403. /** @hidden */
  130404. export var extractHighlightsPixelShader: {
  130405. name: string;
  130406. shader: string;
  130407. };
  130408. }
  130409. declare module BABYLON {
  130410. /**
  130411. * 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.
  130412. */
  130413. export class ExtractHighlightsPostProcess extends PostProcess {
  130414. /**
  130415. * The luminance threshold, pixels below this value will be set to black.
  130416. */
  130417. threshold: number;
  130418. /** @hidden */
  130419. _exposure: number;
  130420. /**
  130421. * Post process which has the input texture to be used when performing highlight extraction
  130422. * @hidden
  130423. */
  130424. _inputPostProcess: Nullable<PostProcess>;
  130425. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130426. }
  130427. }
  130428. declare module BABYLON {
  130429. /** @hidden */
  130430. export var bloomMergePixelShader: {
  130431. name: string;
  130432. shader: string;
  130433. };
  130434. }
  130435. declare module BABYLON {
  130436. /**
  130437. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  130438. */
  130439. export class BloomMergePostProcess extends PostProcess {
  130440. /** Weight of the bloom to be added to the original input. */
  130441. weight: number;
  130442. /**
  130443. * Creates a new instance of @see BloomMergePostProcess
  130444. * @param name The name of the effect.
  130445. * @param originalFromInput Post process which's input will be used for the merge.
  130446. * @param blurred Blurred highlights post process which's output will be used.
  130447. * @param weight Weight of the bloom to be added to the original input.
  130448. * @param options The required width/height ratio to downsize to before computing the render pass.
  130449. * @param camera The camera to apply the render pass to.
  130450. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130451. * @param engine The engine which the post process will be applied. (default: current engine)
  130452. * @param reusable If the post process can be reused on the same frame. (default: false)
  130453. * @param textureType Type of textures used when performing the post process. (default: 0)
  130454. * @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)
  130455. */
  130456. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  130457. /** Weight of the bloom to be added to the original input. */
  130458. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130459. }
  130460. }
  130461. declare module BABYLON {
  130462. /**
  130463. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  130464. */
  130465. export class BloomEffect extends PostProcessRenderEffect {
  130466. private bloomScale;
  130467. /**
  130468. * @hidden Internal
  130469. */
  130470. _effects: Array<PostProcess>;
  130471. /**
  130472. * @hidden Internal
  130473. */
  130474. _downscale: ExtractHighlightsPostProcess;
  130475. private _blurX;
  130476. private _blurY;
  130477. private _merge;
  130478. /**
  130479. * The luminance threshold to find bright areas of the image to bloom.
  130480. */
  130481. threshold: number;
  130482. /**
  130483. * The strength of the bloom.
  130484. */
  130485. weight: number;
  130486. /**
  130487. * Specifies the size of the bloom blur kernel, relative to the final output size
  130488. */
  130489. kernel: number;
  130490. /**
  130491. * Creates a new instance of @see BloomEffect
  130492. * @param scene The scene the effect belongs to.
  130493. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  130494. * @param bloomKernel The size of the kernel to be used when applying the blur.
  130495. * @param bloomWeight The the strength of bloom.
  130496. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  130497. * @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)
  130498. */
  130499. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  130500. /**
  130501. * Disposes each of the internal effects for a given camera.
  130502. * @param camera The camera to dispose the effect on.
  130503. */
  130504. disposeEffects(camera: Camera): void;
  130505. /**
  130506. * @hidden Internal
  130507. */
  130508. _updateEffects(): void;
  130509. /**
  130510. * Internal
  130511. * @returns if all the contained post processes are ready.
  130512. * @hidden
  130513. */
  130514. _isReady(): boolean;
  130515. }
  130516. }
  130517. declare module BABYLON {
  130518. /** @hidden */
  130519. export var chromaticAberrationPixelShader: {
  130520. name: string;
  130521. shader: string;
  130522. };
  130523. }
  130524. declare module BABYLON {
  130525. /**
  130526. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  130527. */
  130528. export class ChromaticAberrationPostProcess extends PostProcess {
  130529. /**
  130530. * The amount of seperation of rgb channels (default: 30)
  130531. */
  130532. aberrationAmount: number;
  130533. /**
  130534. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  130535. */
  130536. radialIntensity: number;
  130537. /**
  130538. * 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))
  130539. */
  130540. direction: Vector2;
  130541. /**
  130542. * 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))
  130543. */
  130544. centerPosition: Vector2;
  130545. /**
  130546. * Creates a new instance ChromaticAberrationPostProcess
  130547. * @param name The name of the effect.
  130548. * @param screenWidth The width of the screen to apply the effect on.
  130549. * @param screenHeight The height of the screen to apply the effect on.
  130550. * @param options The required width/height ratio to downsize to before computing the render pass.
  130551. * @param camera The camera to apply the render pass to.
  130552. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130553. * @param engine The engine which the post process will be applied. (default: current engine)
  130554. * @param reusable If the post process can be reused on the same frame. (default: false)
  130555. * @param textureType Type of textures used when performing the post process. (default: 0)
  130556. * @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)
  130557. */
  130558. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130559. }
  130560. }
  130561. declare module BABYLON {
  130562. /** @hidden */
  130563. export var circleOfConfusionPixelShader: {
  130564. name: string;
  130565. shader: string;
  130566. };
  130567. }
  130568. declare module BABYLON {
  130569. /**
  130570. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  130571. */
  130572. export class CircleOfConfusionPostProcess extends PostProcess {
  130573. /**
  130574. * 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.
  130575. */
  130576. lensSize: number;
  130577. /**
  130578. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  130579. */
  130580. fStop: number;
  130581. /**
  130582. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  130583. */
  130584. focusDistance: number;
  130585. /**
  130586. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  130587. */
  130588. focalLength: number;
  130589. private _depthTexture;
  130590. /**
  130591. * Creates a new instance CircleOfConfusionPostProcess
  130592. * @param name The name of the effect.
  130593. * @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.
  130594. * @param options The required width/height ratio to downsize to before computing the render pass.
  130595. * @param camera The camera to apply the render pass to.
  130596. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130597. * @param engine The engine which the post process will be applied. (default: current engine)
  130598. * @param reusable If the post process can be reused on the same frame. (default: false)
  130599. * @param textureType Type of textures used when performing the post process. (default: 0)
  130600. * @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)
  130601. */
  130602. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130603. /**
  130604. * 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.
  130605. */
  130606. depthTexture: RenderTargetTexture;
  130607. }
  130608. }
  130609. declare module BABYLON {
  130610. /** @hidden */
  130611. export var colorCorrectionPixelShader: {
  130612. name: string;
  130613. shader: string;
  130614. };
  130615. }
  130616. declare module BABYLON {
  130617. /**
  130618. *
  130619. * This post-process allows the modification of rendered colors by using
  130620. * a 'look-up table' (LUT). This effect is also called Color Grading.
  130621. *
  130622. * The object needs to be provided an url to a texture containing the color
  130623. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  130624. * Use an image editing software to tweak the LUT to match your needs.
  130625. *
  130626. * For an example of a color LUT, see here:
  130627. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  130628. * For explanations on color grading, see here:
  130629. * @see http://udn.epicgames.com/Three/ColorGrading.html
  130630. *
  130631. */
  130632. export class ColorCorrectionPostProcess extends PostProcess {
  130633. private _colorTableTexture;
  130634. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130635. }
  130636. }
  130637. declare module BABYLON {
  130638. /** @hidden */
  130639. export var convolutionPixelShader: {
  130640. name: string;
  130641. shader: string;
  130642. };
  130643. }
  130644. declare module BABYLON {
  130645. /**
  130646. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  130647. * input texture to perform effects such as edge detection or sharpening
  130648. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  130649. */
  130650. export class ConvolutionPostProcess extends PostProcess {
  130651. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  130652. kernel: number[];
  130653. /**
  130654. * Creates a new instance ConvolutionPostProcess
  130655. * @param name The name of the effect.
  130656. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  130657. * @param options The required width/height ratio to downsize to before computing the render pass.
  130658. * @param camera The camera to apply the render pass to.
  130659. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130660. * @param engine The engine which the post process will be applied. (default: current engine)
  130661. * @param reusable If the post process can be reused on the same frame. (default: false)
  130662. * @param textureType Type of textures used when performing the post process. (default: 0)
  130663. */
  130664. constructor(name: string,
  130665. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  130666. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  130667. /**
  130668. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130669. */
  130670. static EdgeDetect0Kernel: number[];
  130671. /**
  130672. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130673. */
  130674. static EdgeDetect1Kernel: number[];
  130675. /**
  130676. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130677. */
  130678. static EdgeDetect2Kernel: number[];
  130679. /**
  130680. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130681. */
  130682. static SharpenKernel: number[];
  130683. /**
  130684. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130685. */
  130686. static EmbossKernel: number[];
  130687. /**
  130688. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130689. */
  130690. static GaussianKernel: number[];
  130691. }
  130692. }
  130693. declare module BABYLON {
  130694. /**
  130695. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  130696. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  130697. * based on samples that have a large difference in distance than the center pixel.
  130698. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  130699. */
  130700. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  130701. direction: Vector2;
  130702. /**
  130703. * Creates a new instance CircleOfConfusionPostProcess
  130704. * @param name The name of the effect.
  130705. * @param scene The scene the effect belongs to.
  130706. * @param direction The direction the blur should be applied.
  130707. * @param kernel The size of the kernel used to blur.
  130708. * @param options The required width/height ratio to downsize to before computing the render pass.
  130709. * @param camera The camera to apply the render pass to.
  130710. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  130711. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  130712. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130713. * @param engine The engine which the post process will be applied. (default: current engine)
  130714. * @param reusable If the post process can be reused on the same frame. (default: false)
  130715. * @param textureType Type of textures used when performing the post process. (default: 0)
  130716. * @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)
  130717. */
  130718. 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);
  130719. }
  130720. }
  130721. declare module BABYLON {
  130722. /** @hidden */
  130723. export var depthOfFieldMergePixelShader: {
  130724. name: string;
  130725. shader: string;
  130726. };
  130727. }
  130728. declare module BABYLON {
  130729. /**
  130730. * Options to be set when merging outputs from the default pipeline.
  130731. */
  130732. export class DepthOfFieldMergePostProcessOptions {
  130733. /**
  130734. * The original image to merge on top of
  130735. */
  130736. originalFromInput: PostProcess;
  130737. /**
  130738. * Parameters to perform the merge of the depth of field effect
  130739. */
  130740. depthOfField?: {
  130741. circleOfConfusion: PostProcess;
  130742. blurSteps: Array<PostProcess>;
  130743. };
  130744. /**
  130745. * Parameters to perform the merge of bloom effect
  130746. */
  130747. bloom?: {
  130748. blurred: PostProcess;
  130749. weight: number;
  130750. };
  130751. }
  130752. /**
  130753. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  130754. */
  130755. export class DepthOfFieldMergePostProcess extends PostProcess {
  130756. private blurSteps;
  130757. /**
  130758. * Creates a new instance of DepthOfFieldMergePostProcess
  130759. * @param name The name of the effect.
  130760. * @param originalFromInput Post process which's input will be used for the merge.
  130761. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  130762. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  130763. * @param options The required width/height ratio to downsize to before computing the render pass.
  130764. * @param camera The camera to apply the render pass to.
  130765. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130766. * @param engine The engine which the post process will be applied. (default: current engine)
  130767. * @param reusable If the post process can be reused on the same frame. (default: false)
  130768. * @param textureType Type of textures used when performing the post process. (default: 0)
  130769. * @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)
  130770. */
  130771. 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);
  130772. /**
  130773. * Updates the effect with the current post process compile time values and recompiles the shader.
  130774. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  130775. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  130776. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  130777. * @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
  130778. * @param onCompiled Called when the shader has been compiled.
  130779. * @param onError Called if there is an error when compiling a shader.
  130780. */
  130781. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  130782. }
  130783. }
  130784. declare module BABYLON {
  130785. /**
  130786. * Specifies the level of max blur that should be applied when using the depth of field effect
  130787. */
  130788. export enum DepthOfFieldEffectBlurLevel {
  130789. /**
  130790. * Subtle blur
  130791. */
  130792. Low = 0,
  130793. /**
  130794. * Medium blur
  130795. */
  130796. Medium = 1,
  130797. /**
  130798. * Large blur
  130799. */
  130800. High = 2
  130801. }
  130802. /**
  130803. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  130804. */
  130805. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  130806. private _circleOfConfusion;
  130807. /**
  130808. * @hidden Internal, blurs from high to low
  130809. */
  130810. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  130811. private _depthOfFieldBlurY;
  130812. private _dofMerge;
  130813. /**
  130814. * @hidden Internal post processes in depth of field effect
  130815. */
  130816. _effects: Array<PostProcess>;
  130817. /**
  130818. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  130819. */
  130820. focalLength: number;
  130821. /**
  130822. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  130823. */
  130824. fStop: number;
  130825. /**
  130826. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  130827. */
  130828. focusDistance: number;
  130829. /**
  130830. * 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.
  130831. */
  130832. lensSize: number;
  130833. /**
  130834. * Creates a new instance DepthOfFieldEffect
  130835. * @param scene The scene the effect belongs to.
  130836. * @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.
  130837. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  130838. * @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)
  130839. */
  130840. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  130841. /**
  130842. * Get the current class name of the current effet
  130843. * @returns "DepthOfFieldEffect"
  130844. */
  130845. getClassName(): string;
  130846. /**
  130847. * 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.
  130848. */
  130849. depthTexture: RenderTargetTexture;
  130850. /**
  130851. * Disposes each of the internal effects for a given camera.
  130852. * @param camera The camera to dispose the effect on.
  130853. */
  130854. disposeEffects(camera: Camera): void;
  130855. /**
  130856. * @hidden Internal
  130857. */
  130858. _updateEffects(): void;
  130859. /**
  130860. * Internal
  130861. * @returns if all the contained post processes are ready.
  130862. * @hidden
  130863. */
  130864. _isReady(): boolean;
  130865. }
  130866. }
  130867. declare module BABYLON {
  130868. /** @hidden */
  130869. export var displayPassPixelShader: {
  130870. name: string;
  130871. shader: string;
  130872. };
  130873. }
  130874. declare module BABYLON {
  130875. /**
  130876. * DisplayPassPostProcess which produces an output the same as it's input
  130877. */
  130878. export class DisplayPassPostProcess extends PostProcess {
  130879. /**
  130880. * Creates the DisplayPassPostProcess
  130881. * @param name The name of the effect.
  130882. * @param options The required width/height ratio to downsize to before computing the render pass.
  130883. * @param camera The camera to apply the render pass to.
  130884. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130885. * @param engine The engine which the post process will be applied. (default: current engine)
  130886. * @param reusable If the post process can be reused on the same frame. (default: false)
  130887. */
  130888. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130889. }
  130890. }
  130891. declare module BABYLON {
  130892. /** @hidden */
  130893. export var filterPixelShader: {
  130894. name: string;
  130895. shader: string;
  130896. };
  130897. }
  130898. declare module BABYLON {
  130899. /**
  130900. * Applies a kernel filter to the image
  130901. */
  130902. export class FilterPostProcess extends PostProcess {
  130903. /** The matrix to be applied to the image */
  130904. kernelMatrix: Matrix;
  130905. /**
  130906. *
  130907. * @param name The name of the effect.
  130908. * @param kernelMatrix The matrix to be applied to the image
  130909. * @param options The required width/height ratio to downsize to before computing the render pass.
  130910. * @param camera The camera to apply the render pass to.
  130911. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130912. * @param engine The engine which the post process will be applied. (default: current engine)
  130913. * @param reusable If the post process can be reused on the same frame. (default: false)
  130914. */
  130915. constructor(name: string,
  130916. /** The matrix to be applied to the image */
  130917. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130918. }
  130919. }
  130920. declare module BABYLON {
  130921. /** @hidden */
  130922. export var fxaaPixelShader: {
  130923. name: string;
  130924. shader: string;
  130925. };
  130926. }
  130927. declare module BABYLON {
  130928. /** @hidden */
  130929. export var fxaaVertexShader: {
  130930. name: string;
  130931. shader: string;
  130932. };
  130933. }
  130934. declare module BABYLON {
  130935. /**
  130936. * Fxaa post process
  130937. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  130938. */
  130939. export class FxaaPostProcess extends PostProcess {
  130940. /** @hidden */
  130941. texelWidth: number;
  130942. /** @hidden */
  130943. texelHeight: number;
  130944. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  130945. private _getDefines;
  130946. }
  130947. }
  130948. declare module BABYLON {
  130949. /** @hidden */
  130950. export var grainPixelShader: {
  130951. name: string;
  130952. shader: string;
  130953. };
  130954. }
  130955. declare module BABYLON {
  130956. /**
  130957. * The GrainPostProcess adds noise to the image at mid luminance levels
  130958. */
  130959. export class GrainPostProcess extends PostProcess {
  130960. /**
  130961. * The intensity of the grain added (default: 30)
  130962. */
  130963. intensity: number;
  130964. /**
  130965. * If the grain should be randomized on every frame
  130966. */
  130967. animated: boolean;
  130968. /**
  130969. * Creates a new instance of @see GrainPostProcess
  130970. * @param name The name of the effect.
  130971. * @param options The required width/height ratio to downsize to before computing the render pass.
  130972. * @param camera The camera to apply the render pass to.
  130973. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130974. * @param engine The engine which the post process will be applied. (default: current engine)
  130975. * @param reusable If the post process can be reused on the same frame. (default: false)
  130976. * @param textureType Type of textures used when performing the post process. (default: 0)
  130977. * @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)
  130978. */
  130979. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130980. }
  130981. }
  130982. declare module BABYLON {
  130983. /** @hidden */
  130984. export var highlightsPixelShader: {
  130985. name: string;
  130986. shader: string;
  130987. };
  130988. }
  130989. declare module BABYLON {
  130990. /**
  130991. * Extracts highlights from the image
  130992. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  130993. */
  130994. export class HighlightsPostProcess extends PostProcess {
  130995. /**
  130996. * Extracts highlights from the image
  130997. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  130998. * @param name The name of the effect.
  130999. * @param options The required width/height ratio to downsize to before computing the render pass.
  131000. * @param camera The camera to apply the render pass to.
  131001. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131002. * @param engine The engine which the post process will be applied. (default: current engine)
  131003. * @param reusable If the post process can be reused on the same frame. (default: false)
  131004. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  131005. */
  131006. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  131007. }
  131008. }
  131009. declare module BABYLON {
  131010. /** @hidden */
  131011. export var mrtFragmentDeclaration: {
  131012. name: string;
  131013. shader: string;
  131014. };
  131015. }
  131016. declare module BABYLON {
  131017. /** @hidden */
  131018. export var geometryPixelShader: {
  131019. name: string;
  131020. shader: string;
  131021. };
  131022. }
  131023. declare module BABYLON {
  131024. /** @hidden */
  131025. export var geometryVertexShader: {
  131026. name: string;
  131027. shader: string;
  131028. };
  131029. }
  131030. declare module BABYLON {
  131031. /** @hidden */
  131032. interface ISavedTransformationMatrix {
  131033. world: Matrix;
  131034. viewProjection: Matrix;
  131035. }
  131036. /**
  131037. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  131038. */
  131039. export class GeometryBufferRenderer {
  131040. /**
  131041. * Constant used to retrieve the position texture index in the G-Buffer textures array
  131042. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  131043. */
  131044. static readonly POSITION_TEXTURE_TYPE: number;
  131045. /**
  131046. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  131047. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  131048. */
  131049. static readonly VELOCITY_TEXTURE_TYPE: number;
  131050. /**
  131051. * Dictionary used to store the previous transformation matrices of each rendered mesh
  131052. * in order to compute objects velocities when enableVelocity is set to "true"
  131053. * @hidden
  131054. */
  131055. _previousTransformationMatrices: {
  131056. [index: number]: ISavedTransformationMatrix;
  131057. };
  131058. /**
  131059. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  131060. * in order to compute objects velocities when enableVelocity is set to "true"
  131061. * @hidden
  131062. */
  131063. _previousBonesTransformationMatrices: {
  131064. [index: number]: Float32Array;
  131065. };
  131066. /**
  131067. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  131068. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  131069. */
  131070. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  131071. private _scene;
  131072. private _multiRenderTarget;
  131073. private _ratio;
  131074. private _enablePosition;
  131075. private _enableVelocity;
  131076. private _positionIndex;
  131077. private _velocityIndex;
  131078. protected _effect: Effect;
  131079. protected _cachedDefines: string;
  131080. /**
  131081. * Set the render list (meshes to be rendered) used in the G buffer.
  131082. */
  131083. renderList: Mesh[];
  131084. /**
  131085. * Gets wether or not G buffer are supported by the running hardware.
  131086. * This requires draw buffer supports
  131087. */
  131088. readonly isSupported: boolean;
  131089. /**
  131090. * Returns the index of the given texture type in the G-Buffer textures array
  131091. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  131092. * @returns the index of the given texture type in the G-Buffer textures array
  131093. */
  131094. getTextureIndex(textureType: number): number;
  131095. /**
  131096. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  131097. */
  131098. /**
  131099. * Sets whether or not objects positions are enabled for the G buffer.
  131100. */
  131101. enablePosition: boolean;
  131102. /**
  131103. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  131104. */
  131105. /**
  131106. * Sets wether or not objects velocities are enabled for the G buffer.
  131107. */
  131108. enableVelocity: boolean;
  131109. /**
  131110. * Gets the scene associated with the buffer.
  131111. */
  131112. readonly scene: Scene;
  131113. /**
  131114. * Gets the ratio used by the buffer during its creation.
  131115. * How big is the buffer related to the main canvas.
  131116. */
  131117. readonly ratio: number;
  131118. /** @hidden */
  131119. static _SceneComponentInitialization: (scene: Scene) => void;
  131120. /**
  131121. * Creates a new G Buffer for the scene
  131122. * @param scene The scene the buffer belongs to
  131123. * @param ratio How big is the buffer related to the main canvas.
  131124. */
  131125. constructor(scene: Scene, ratio?: number);
  131126. /**
  131127. * Checks wether everything is ready to render a submesh to the G buffer.
  131128. * @param subMesh the submesh to check readiness for
  131129. * @param useInstances is the mesh drawn using instance or not
  131130. * @returns true if ready otherwise false
  131131. */
  131132. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  131133. /**
  131134. * Gets the current underlying G Buffer.
  131135. * @returns the buffer
  131136. */
  131137. getGBuffer(): MultiRenderTarget;
  131138. /**
  131139. * Gets the number of samples used to render the buffer (anti aliasing).
  131140. */
  131141. /**
  131142. * Sets the number of samples used to render the buffer (anti aliasing).
  131143. */
  131144. samples: number;
  131145. /**
  131146. * Disposes the renderer and frees up associated resources.
  131147. */
  131148. dispose(): void;
  131149. protected _createRenderTargets(): void;
  131150. private _copyBonesTransformationMatrices;
  131151. }
  131152. }
  131153. declare module BABYLON {
  131154. interface Scene {
  131155. /** @hidden (Backing field) */
  131156. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  131157. /**
  131158. * Gets or Sets the current geometry buffer associated to the scene.
  131159. */
  131160. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  131161. /**
  131162. * Enables a GeometryBufferRender and associates it with the scene
  131163. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  131164. * @returns the GeometryBufferRenderer
  131165. */
  131166. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  131167. /**
  131168. * Disables the GeometryBufferRender associated with the scene
  131169. */
  131170. disableGeometryBufferRenderer(): void;
  131171. }
  131172. /**
  131173. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  131174. * in several rendering techniques.
  131175. */
  131176. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  131177. /**
  131178. * The component name helpful to identify the component in the list of scene components.
  131179. */
  131180. readonly name: string;
  131181. /**
  131182. * The scene the component belongs to.
  131183. */
  131184. scene: Scene;
  131185. /**
  131186. * Creates a new instance of the component for the given scene
  131187. * @param scene Defines the scene to register the component in
  131188. */
  131189. constructor(scene: Scene);
  131190. /**
  131191. * Registers the component in a given scene
  131192. */
  131193. register(): void;
  131194. /**
  131195. * Rebuilds the elements related to this component in case of
  131196. * context lost for instance.
  131197. */
  131198. rebuild(): void;
  131199. /**
  131200. * Disposes the component and the associated ressources
  131201. */
  131202. dispose(): void;
  131203. private _gatherRenderTargets;
  131204. }
  131205. }
  131206. declare module BABYLON {
  131207. /** @hidden */
  131208. export var motionBlurPixelShader: {
  131209. name: string;
  131210. shader: string;
  131211. };
  131212. }
  131213. declare module BABYLON {
  131214. /**
  131215. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  131216. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  131217. * As an example, all you have to do is to create the post-process:
  131218. * var mb = new BABYLON.MotionBlurPostProcess(
  131219. * 'mb', // The name of the effect.
  131220. * scene, // The scene containing the objects to blur according to their velocity.
  131221. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  131222. * camera // The camera to apply the render pass to.
  131223. * );
  131224. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  131225. */
  131226. export class MotionBlurPostProcess extends PostProcess {
  131227. /**
  131228. * Defines how much the image is blurred by the movement. Default value is equal to 1
  131229. */
  131230. motionStrength: number;
  131231. /**
  131232. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  131233. */
  131234. /**
  131235. * Sets the number of iterations to be used for motion blur quality
  131236. */
  131237. motionBlurSamples: number;
  131238. private _motionBlurSamples;
  131239. private _geometryBufferRenderer;
  131240. /**
  131241. * Creates a new instance MotionBlurPostProcess
  131242. * @param name The name of the effect.
  131243. * @param scene The scene containing the objects to blur according to their velocity.
  131244. * @param options The required width/height ratio to downsize to before computing the render pass.
  131245. * @param camera The camera to apply the render pass to.
  131246. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131247. * @param engine The engine which the post process will be applied. (default: current engine)
  131248. * @param reusable If the post process can be reused on the same frame. (default: false)
  131249. * @param textureType Type of textures used when performing the post process. (default: 0)
  131250. * @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)
  131251. */
  131252. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  131253. /**
  131254. * Excludes the given skinned mesh from computing bones velocities.
  131255. * 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.
  131256. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  131257. */
  131258. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  131259. /**
  131260. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  131261. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  131262. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  131263. */
  131264. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  131265. /**
  131266. * Disposes the post process.
  131267. * @param camera The camera to dispose the post process on.
  131268. */
  131269. dispose(camera?: Camera): void;
  131270. }
  131271. }
  131272. declare module BABYLON {
  131273. /** @hidden */
  131274. export var refractionPixelShader: {
  131275. name: string;
  131276. shader: string;
  131277. };
  131278. }
  131279. declare module BABYLON {
  131280. /**
  131281. * Post process which applies a refractin texture
  131282. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  131283. */
  131284. export class RefractionPostProcess extends PostProcess {
  131285. /** the base color of the refraction (used to taint the rendering) */
  131286. color: Color3;
  131287. /** simulated refraction depth */
  131288. depth: number;
  131289. /** the coefficient of the base color (0 to remove base color tainting) */
  131290. colorLevel: number;
  131291. private _refTexture;
  131292. private _ownRefractionTexture;
  131293. /**
  131294. * Gets or sets the refraction texture
  131295. * Please note that you are responsible for disposing the texture if you set it manually
  131296. */
  131297. refractionTexture: Texture;
  131298. /**
  131299. * Initializes the RefractionPostProcess
  131300. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  131301. * @param name The name of the effect.
  131302. * @param refractionTextureUrl Url of the refraction texture to use
  131303. * @param color the base color of the refraction (used to taint the rendering)
  131304. * @param depth simulated refraction depth
  131305. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  131306. * @param camera The camera to apply the render pass to.
  131307. * @param options The required width/height ratio to downsize to before computing the render pass.
  131308. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131309. * @param engine The engine which the post process will be applied. (default: current engine)
  131310. * @param reusable If the post process can be reused on the same frame. (default: false)
  131311. */
  131312. constructor(name: string, refractionTextureUrl: string,
  131313. /** the base color of the refraction (used to taint the rendering) */
  131314. color: Color3,
  131315. /** simulated refraction depth */
  131316. depth: number,
  131317. /** the coefficient of the base color (0 to remove base color tainting) */
  131318. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  131319. /**
  131320. * Disposes of the post process
  131321. * @param camera Camera to dispose post process on
  131322. */
  131323. dispose(camera: Camera): void;
  131324. }
  131325. }
  131326. declare module BABYLON {
  131327. /** @hidden */
  131328. export var sharpenPixelShader: {
  131329. name: string;
  131330. shader: string;
  131331. };
  131332. }
  131333. declare module BABYLON {
  131334. /**
  131335. * The SharpenPostProcess applies a sharpen kernel to every pixel
  131336. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  131337. */
  131338. export class SharpenPostProcess extends PostProcess {
  131339. /**
  131340. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  131341. */
  131342. colorAmount: number;
  131343. /**
  131344. * How much sharpness should be applied (default: 0.3)
  131345. */
  131346. edgeAmount: number;
  131347. /**
  131348. * Creates a new instance ConvolutionPostProcess
  131349. * @param name The name of the effect.
  131350. * @param options The required width/height ratio to downsize to before computing the render pass.
  131351. * @param camera The camera to apply the render pass to.
  131352. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131353. * @param engine The engine which the post process will be applied. (default: current engine)
  131354. * @param reusable If the post process can be reused on the same frame. (default: false)
  131355. * @param textureType Type of textures used when performing the post process. (default: 0)
  131356. * @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)
  131357. */
  131358. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  131359. }
  131360. }
  131361. declare module BABYLON {
  131362. /**
  131363. * PostProcessRenderPipeline
  131364. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  131365. */
  131366. export class PostProcessRenderPipeline {
  131367. private engine;
  131368. private _renderEffects;
  131369. private _renderEffectsForIsolatedPass;
  131370. /**
  131371. * List of inspectable custom properties (used by the Inspector)
  131372. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  131373. */
  131374. inspectableCustomProperties: IInspectable[];
  131375. /**
  131376. * @hidden
  131377. */
  131378. protected _cameras: Camera[];
  131379. /** @hidden */
  131380. _name: string;
  131381. /**
  131382. * Gets pipeline name
  131383. */
  131384. readonly name: string;
  131385. /** Gets the list of attached cameras */
  131386. readonly cameras: Camera[];
  131387. /**
  131388. * Initializes a PostProcessRenderPipeline
  131389. * @param engine engine to add the pipeline to
  131390. * @param name name of the pipeline
  131391. */
  131392. constructor(engine: Engine, name: string);
  131393. /**
  131394. * Gets the class name
  131395. * @returns "PostProcessRenderPipeline"
  131396. */
  131397. getClassName(): string;
  131398. /**
  131399. * If all the render effects in the pipeline are supported
  131400. */
  131401. readonly isSupported: boolean;
  131402. /**
  131403. * Adds an effect to the pipeline
  131404. * @param renderEffect the effect to add
  131405. */
  131406. addEffect(renderEffect: PostProcessRenderEffect): void;
  131407. /** @hidden */
  131408. _rebuild(): void;
  131409. /** @hidden */
  131410. _enableEffect(renderEffectName: string, cameras: Camera): void;
  131411. /** @hidden */
  131412. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  131413. /** @hidden */
  131414. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  131415. /** @hidden */
  131416. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  131417. /** @hidden */
  131418. _attachCameras(cameras: Camera, unique: boolean): void;
  131419. /** @hidden */
  131420. _attachCameras(cameras: Camera[], unique: boolean): void;
  131421. /** @hidden */
  131422. _detachCameras(cameras: Camera): void;
  131423. /** @hidden */
  131424. _detachCameras(cameras: Nullable<Camera[]>): void;
  131425. /** @hidden */
  131426. _update(): void;
  131427. /** @hidden */
  131428. _reset(): void;
  131429. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  131430. /**
  131431. * Disposes of the pipeline
  131432. */
  131433. dispose(): void;
  131434. }
  131435. }
  131436. declare module BABYLON {
  131437. /**
  131438. * PostProcessRenderPipelineManager class
  131439. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  131440. */
  131441. export class PostProcessRenderPipelineManager {
  131442. private _renderPipelines;
  131443. /**
  131444. * Initializes a PostProcessRenderPipelineManager
  131445. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  131446. */
  131447. constructor();
  131448. /**
  131449. * Gets the list of supported render pipelines
  131450. */
  131451. readonly supportedPipelines: PostProcessRenderPipeline[];
  131452. /**
  131453. * Adds a pipeline to the manager
  131454. * @param renderPipeline The pipeline to add
  131455. */
  131456. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  131457. /**
  131458. * Attaches a camera to the pipeline
  131459. * @param renderPipelineName The name of the pipeline to attach to
  131460. * @param cameras the camera to attach
  131461. * @param unique if the camera can be attached multiple times to the pipeline
  131462. */
  131463. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  131464. /**
  131465. * Detaches a camera from the pipeline
  131466. * @param renderPipelineName The name of the pipeline to detach from
  131467. * @param cameras the camera to detach
  131468. */
  131469. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  131470. /**
  131471. * Enables an effect by name on a pipeline
  131472. * @param renderPipelineName the name of the pipeline to enable the effect in
  131473. * @param renderEffectName the name of the effect to enable
  131474. * @param cameras the cameras that the effect should be enabled on
  131475. */
  131476. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  131477. /**
  131478. * Disables an effect by name on a pipeline
  131479. * @param renderPipelineName the name of the pipeline to disable the effect in
  131480. * @param renderEffectName the name of the effect to disable
  131481. * @param cameras the cameras that the effect should be disabled on
  131482. */
  131483. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  131484. /**
  131485. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  131486. */
  131487. update(): void;
  131488. /** @hidden */
  131489. _rebuild(): void;
  131490. /**
  131491. * Disposes of the manager and pipelines
  131492. */
  131493. dispose(): void;
  131494. }
  131495. }
  131496. declare module BABYLON {
  131497. interface Scene {
  131498. /** @hidden (Backing field) */
  131499. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  131500. /**
  131501. * Gets the postprocess render pipeline manager
  131502. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  131503. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  131504. */
  131505. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  131506. }
  131507. /**
  131508. * Defines the Render Pipeline scene component responsible to rendering pipelines
  131509. */
  131510. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  131511. /**
  131512. * The component name helpfull to identify the component in the list of scene components.
  131513. */
  131514. readonly name: string;
  131515. /**
  131516. * The scene the component belongs to.
  131517. */
  131518. scene: Scene;
  131519. /**
  131520. * Creates a new instance of the component for the given scene
  131521. * @param scene Defines the scene to register the component in
  131522. */
  131523. constructor(scene: Scene);
  131524. /**
  131525. * Registers the component in a given scene
  131526. */
  131527. register(): void;
  131528. /**
  131529. * Rebuilds the elements related to this component in case of
  131530. * context lost for instance.
  131531. */
  131532. rebuild(): void;
  131533. /**
  131534. * Disposes the component and the associated ressources
  131535. */
  131536. dispose(): void;
  131537. private _gatherRenderTargets;
  131538. }
  131539. }
  131540. declare module BABYLON {
  131541. /**
  131542. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  131543. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  131544. */
  131545. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  131546. private _scene;
  131547. private _camerasToBeAttached;
  131548. /**
  131549. * ID of the sharpen post process,
  131550. */
  131551. private readonly SharpenPostProcessId;
  131552. /**
  131553. * @ignore
  131554. * ID of the image processing post process;
  131555. */
  131556. readonly ImageProcessingPostProcessId: string;
  131557. /**
  131558. * @ignore
  131559. * ID of the Fast Approximate Anti-Aliasing post process;
  131560. */
  131561. readonly FxaaPostProcessId: string;
  131562. /**
  131563. * ID of the chromatic aberration post process,
  131564. */
  131565. private readonly ChromaticAberrationPostProcessId;
  131566. /**
  131567. * ID of the grain post process
  131568. */
  131569. private readonly GrainPostProcessId;
  131570. /**
  131571. * Sharpen post process which will apply a sharpen convolution to enhance edges
  131572. */
  131573. sharpen: SharpenPostProcess;
  131574. private _sharpenEffect;
  131575. private bloom;
  131576. /**
  131577. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  131578. */
  131579. depthOfField: DepthOfFieldEffect;
  131580. /**
  131581. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  131582. */
  131583. fxaa: FxaaPostProcess;
  131584. /**
  131585. * Image post processing pass used to perform operations such as tone mapping or color grading.
  131586. */
  131587. imageProcessing: ImageProcessingPostProcess;
  131588. /**
  131589. * Chromatic aberration post process which will shift rgb colors in the image
  131590. */
  131591. chromaticAberration: ChromaticAberrationPostProcess;
  131592. private _chromaticAberrationEffect;
  131593. /**
  131594. * Grain post process which add noise to the image
  131595. */
  131596. grain: GrainPostProcess;
  131597. private _grainEffect;
  131598. /**
  131599. * Glow post process which adds a glow to emissive areas of the image
  131600. */
  131601. private _glowLayer;
  131602. /**
  131603. * Animations which can be used to tweak settings over a period of time
  131604. */
  131605. animations: Animation[];
  131606. private _imageProcessingConfigurationObserver;
  131607. private _sharpenEnabled;
  131608. private _bloomEnabled;
  131609. private _depthOfFieldEnabled;
  131610. private _depthOfFieldBlurLevel;
  131611. private _fxaaEnabled;
  131612. private _imageProcessingEnabled;
  131613. private _defaultPipelineTextureType;
  131614. private _bloomScale;
  131615. private _chromaticAberrationEnabled;
  131616. private _grainEnabled;
  131617. private _buildAllowed;
  131618. /**
  131619. * Gets active scene
  131620. */
  131621. readonly scene: Scene;
  131622. /**
  131623. * Enable or disable the sharpen process from the pipeline
  131624. */
  131625. sharpenEnabled: boolean;
  131626. private _resizeObserver;
  131627. private _hardwareScaleLevel;
  131628. private _bloomKernel;
  131629. /**
  131630. * Specifies the size of the bloom blur kernel, relative to the final output size
  131631. */
  131632. bloomKernel: number;
  131633. /**
  131634. * Specifies the weight of the bloom in the final rendering
  131635. */
  131636. private _bloomWeight;
  131637. /**
  131638. * Specifies the luma threshold for the area that will be blurred by the bloom
  131639. */
  131640. private _bloomThreshold;
  131641. private _hdr;
  131642. /**
  131643. * The strength of the bloom.
  131644. */
  131645. bloomWeight: number;
  131646. /**
  131647. * The strength of the bloom.
  131648. */
  131649. bloomThreshold: number;
  131650. /**
  131651. * The scale of the bloom, lower value will provide better performance.
  131652. */
  131653. bloomScale: number;
  131654. /**
  131655. * Enable or disable the bloom from the pipeline
  131656. */
  131657. bloomEnabled: boolean;
  131658. private _rebuildBloom;
  131659. /**
  131660. * If the depth of field is enabled.
  131661. */
  131662. depthOfFieldEnabled: boolean;
  131663. /**
  131664. * Blur level of the depth of field effect. (Higher blur will effect performance)
  131665. */
  131666. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  131667. /**
  131668. * If the anti aliasing is enabled.
  131669. */
  131670. fxaaEnabled: boolean;
  131671. private _samples;
  131672. /**
  131673. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  131674. */
  131675. samples: number;
  131676. /**
  131677. * If image processing is enabled.
  131678. */
  131679. imageProcessingEnabled: boolean;
  131680. /**
  131681. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  131682. */
  131683. glowLayerEnabled: boolean;
  131684. /**
  131685. * Gets the glow layer (or null if not defined)
  131686. */
  131687. readonly glowLayer: Nullable<GlowLayer>;
  131688. /**
  131689. * Enable or disable the chromaticAberration process from the pipeline
  131690. */
  131691. chromaticAberrationEnabled: boolean;
  131692. /**
  131693. * Enable or disable the grain process from the pipeline
  131694. */
  131695. grainEnabled: boolean;
  131696. /**
  131697. * @constructor
  131698. * @param name - The rendering pipeline name (default: "")
  131699. * @param hdr - If high dynamic range textures should be used (default: true)
  131700. * @param scene - The scene linked to this pipeline (default: the last created scene)
  131701. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  131702. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  131703. */
  131704. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  131705. /**
  131706. * Get the class name
  131707. * @returns "DefaultRenderingPipeline"
  131708. */
  131709. getClassName(): string;
  131710. /**
  131711. * Force the compilation of the entire pipeline.
  131712. */
  131713. prepare(): void;
  131714. private _hasCleared;
  131715. private _prevPostProcess;
  131716. private _prevPrevPostProcess;
  131717. private _setAutoClearAndTextureSharing;
  131718. private _depthOfFieldSceneObserver;
  131719. private _buildPipeline;
  131720. private _disposePostProcesses;
  131721. /**
  131722. * Adds a camera to the pipeline
  131723. * @param camera the camera to be added
  131724. */
  131725. addCamera(camera: Camera): void;
  131726. /**
  131727. * Removes a camera from the pipeline
  131728. * @param camera the camera to remove
  131729. */
  131730. removeCamera(camera: Camera): void;
  131731. /**
  131732. * Dispose of the pipeline and stop all post processes
  131733. */
  131734. dispose(): void;
  131735. /**
  131736. * Serialize the rendering pipeline (Used when exporting)
  131737. * @returns the serialized object
  131738. */
  131739. serialize(): any;
  131740. /**
  131741. * Parse the serialized pipeline
  131742. * @param source Source pipeline.
  131743. * @param scene The scene to load the pipeline to.
  131744. * @param rootUrl The URL of the serialized pipeline.
  131745. * @returns An instantiated pipeline from the serialized object.
  131746. */
  131747. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  131748. }
  131749. }
  131750. declare module BABYLON {
  131751. /** @hidden */
  131752. export var lensHighlightsPixelShader: {
  131753. name: string;
  131754. shader: string;
  131755. };
  131756. }
  131757. declare module BABYLON {
  131758. /** @hidden */
  131759. export var depthOfFieldPixelShader: {
  131760. name: string;
  131761. shader: string;
  131762. };
  131763. }
  131764. declare module BABYLON {
  131765. /**
  131766. * BABYLON.JS Chromatic Aberration GLSL Shader
  131767. * Author: Olivier Guyot
  131768. * Separates very slightly R, G and B colors on the edges of the screen
  131769. * Inspired by Francois Tarlier & Martins Upitis
  131770. */
  131771. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  131772. /**
  131773. * @ignore
  131774. * The chromatic aberration PostProcess id in the pipeline
  131775. */
  131776. LensChromaticAberrationEffect: string;
  131777. /**
  131778. * @ignore
  131779. * The highlights enhancing PostProcess id in the pipeline
  131780. */
  131781. HighlightsEnhancingEffect: string;
  131782. /**
  131783. * @ignore
  131784. * The depth-of-field PostProcess id in the pipeline
  131785. */
  131786. LensDepthOfFieldEffect: string;
  131787. private _scene;
  131788. private _depthTexture;
  131789. private _grainTexture;
  131790. private _chromaticAberrationPostProcess;
  131791. private _highlightsPostProcess;
  131792. private _depthOfFieldPostProcess;
  131793. private _edgeBlur;
  131794. private _grainAmount;
  131795. private _chromaticAberration;
  131796. private _distortion;
  131797. private _highlightsGain;
  131798. private _highlightsThreshold;
  131799. private _dofDistance;
  131800. private _dofAperture;
  131801. private _dofDarken;
  131802. private _dofPentagon;
  131803. private _blurNoise;
  131804. /**
  131805. * @constructor
  131806. *
  131807. * Effect parameters are as follow:
  131808. * {
  131809. * chromatic_aberration: number; // from 0 to x (1 for realism)
  131810. * edge_blur: number; // from 0 to x (1 for realism)
  131811. * distortion: number; // from 0 to x (1 for realism)
  131812. * grain_amount: number; // from 0 to 1
  131813. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  131814. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  131815. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  131816. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  131817. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  131818. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  131819. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  131820. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  131821. * }
  131822. * Note: if an effect parameter is unset, effect is disabled
  131823. *
  131824. * @param name The rendering pipeline name
  131825. * @param parameters - An object containing all parameters (see above)
  131826. * @param scene The scene linked to this pipeline
  131827. * @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)
  131828. * @param cameras The array of cameras that the rendering pipeline will be attached to
  131829. */
  131830. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  131831. /**
  131832. * Get the class name
  131833. * @returns "LensRenderingPipeline"
  131834. */
  131835. getClassName(): string;
  131836. /**
  131837. * Gets associated scene
  131838. */
  131839. readonly scene: Scene;
  131840. /**
  131841. * Gets or sets the edge blur
  131842. */
  131843. edgeBlur: number;
  131844. /**
  131845. * Gets or sets the grain amount
  131846. */
  131847. grainAmount: number;
  131848. /**
  131849. * Gets or sets the chromatic aberration amount
  131850. */
  131851. chromaticAberration: number;
  131852. /**
  131853. * Gets or sets the depth of field aperture
  131854. */
  131855. dofAperture: number;
  131856. /**
  131857. * Gets or sets the edge distortion
  131858. */
  131859. edgeDistortion: number;
  131860. /**
  131861. * Gets or sets the depth of field distortion
  131862. */
  131863. dofDistortion: number;
  131864. /**
  131865. * Gets or sets the darken out of focus amount
  131866. */
  131867. darkenOutOfFocus: number;
  131868. /**
  131869. * Gets or sets a boolean indicating if blur noise is enabled
  131870. */
  131871. blurNoise: boolean;
  131872. /**
  131873. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  131874. */
  131875. pentagonBokeh: boolean;
  131876. /**
  131877. * Gets or sets the highlight grain amount
  131878. */
  131879. highlightsGain: number;
  131880. /**
  131881. * Gets or sets the highlight threshold
  131882. */
  131883. highlightsThreshold: number;
  131884. /**
  131885. * Sets the amount of blur at the edges
  131886. * @param amount blur amount
  131887. */
  131888. setEdgeBlur(amount: number): void;
  131889. /**
  131890. * Sets edge blur to 0
  131891. */
  131892. disableEdgeBlur(): void;
  131893. /**
  131894. * Sets the amout of grain
  131895. * @param amount Amount of grain
  131896. */
  131897. setGrainAmount(amount: number): void;
  131898. /**
  131899. * Set grain amount to 0
  131900. */
  131901. disableGrain(): void;
  131902. /**
  131903. * Sets the chromatic aberration amount
  131904. * @param amount amount of chromatic aberration
  131905. */
  131906. setChromaticAberration(amount: number): void;
  131907. /**
  131908. * Sets chromatic aberration amount to 0
  131909. */
  131910. disableChromaticAberration(): void;
  131911. /**
  131912. * Sets the EdgeDistortion amount
  131913. * @param amount amount of EdgeDistortion
  131914. */
  131915. setEdgeDistortion(amount: number): void;
  131916. /**
  131917. * Sets edge distortion to 0
  131918. */
  131919. disableEdgeDistortion(): void;
  131920. /**
  131921. * Sets the FocusDistance amount
  131922. * @param amount amount of FocusDistance
  131923. */
  131924. setFocusDistance(amount: number): void;
  131925. /**
  131926. * Disables depth of field
  131927. */
  131928. disableDepthOfField(): void;
  131929. /**
  131930. * Sets the Aperture amount
  131931. * @param amount amount of Aperture
  131932. */
  131933. setAperture(amount: number): void;
  131934. /**
  131935. * Sets the DarkenOutOfFocus amount
  131936. * @param amount amount of DarkenOutOfFocus
  131937. */
  131938. setDarkenOutOfFocus(amount: number): void;
  131939. private _pentagonBokehIsEnabled;
  131940. /**
  131941. * Creates a pentagon bokeh effect
  131942. */
  131943. enablePentagonBokeh(): void;
  131944. /**
  131945. * Disables the pentagon bokeh effect
  131946. */
  131947. disablePentagonBokeh(): void;
  131948. /**
  131949. * Enables noise blur
  131950. */
  131951. enableNoiseBlur(): void;
  131952. /**
  131953. * Disables noise blur
  131954. */
  131955. disableNoiseBlur(): void;
  131956. /**
  131957. * Sets the HighlightsGain amount
  131958. * @param amount amount of HighlightsGain
  131959. */
  131960. setHighlightsGain(amount: number): void;
  131961. /**
  131962. * Sets the HighlightsThreshold amount
  131963. * @param amount amount of HighlightsThreshold
  131964. */
  131965. setHighlightsThreshold(amount: number): void;
  131966. /**
  131967. * Disables highlights
  131968. */
  131969. disableHighlights(): void;
  131970. /**
  131971. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  131972. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  131973. */
  131974. dispose(disableDepthRender?: boolean): void;
  131975. private _createChromaticAberrationPostProcess;
  131976. private _createHighlightsPostProcess;
  131977. private _createDepthOfFieldPostProcess;
  131978. private _createGrainTexture;
  131979. }
  131980. }
  131981. declare module BABYLON {
  131982. /** @hidden */
  131983. export var ssao2PixelShader: {
  131984. name: string;
  131985. shader: string;
  131986. };
  131987. }
  131988. declare module BABYLON {
  131989. /** @hidden */
  131990. export var ssaoCombinePixelShader: {
  131991. name: string;
  131992. shader: string;
  131993. };
  131994. }
  131995. declare module BABYLON {
  131996. /**
  131997. * Render pipeline to produce ssao effect
  131998. */
  131999. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  132000. /**
  132001. * @ignore
  132002. * The PassPostProcess id in the pipeline that contains the original scene color
  132003. */
  132004. SSAOOriginalSceneColorEffect: string;
  132005. /**
  132006. * @ignore
  132007. * The SSAO PostProcess id in the pipeline
  132008. */
  132009. SSAORenderEffect: string;
  132010. /**
  132011. * @ignore
  132012. * The horizontal blur PostProcess id in the pipeline
  132013. */
  132014. SSAOBlurHRenderEffect: string;
  132015. /**
  132016. * @ignore
  132017. * The vertical blur PostProcess id in the pipeline
  132018. */
  132019. SSAOBlurVRenderEffect: string;
  132020. /**
  132021. * @ignore
  132022. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  132023. */
  132024. SSAOCombineRenderEffect: string;
  132025. /**
  132026. * The output strength of the SSAO post-process. Default value is 1.0.
  132027. */
  132028. totalStrength: number;
  132029. /**
  132030. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  132031. */
  132032. maxZ: number;
  132033. /**
  132034. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  132035. */
  132036. minZAspect: number;
  132037. private _samples;
  132038. /**
  132039. * Number of samples used for the SSAO calculations. Default value is 8
  132040. */
  132041. samples: number;
  132042. private _textureSamples;
  132043. /**
  132044. * Number of samples to use for antialiasing
  132045. */
  132046. textureSamples: number;
  132047. /**
  132048. * Ratio object used for SSAO ratio and blur ratio
  132049. */
  132050. private _ratio;
  132051. /**
  132052. * Dynamically generated sphere sampler.
  132053. */
  132054. private _sampleSphere;
  132055. /**
  132056. * Blur filter offsets
  132057. */
  132058. private _samplerOffsets;
  132059. private _expensiveBlur;
  132060. /**
  132061. * If bilateral blur should be used
  132062. */
  132063. expensiveBlur: boolean;
  132064. /**
  132065. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  132066. */
  132067. radius: number;
  132068. /**
  132069. * The base color of the SSAO post-process
  132070. * The final result is "base + ssao" between [0, 1]
  132071. */
  132072. base: number;
  132073. /**
  132074. * Support test.
  132075. */
  132076. static readonly IsSupported: boolean;
  132077. private _scene;
  132078. private _depthTexture;
  132079. private _normalTexture;
  132080. private _randomTexture;
  132081. private _originalColorPostProcess;
  132082. private _ssaoPostProcess;
  132083. private _blurHPostProcess;
  132084. private _blurVPostProcess;
  132085. private _ssaoCombinePostProcess;
  132086. /**
  132087. * Gets active scene
  132088. */
  132089. readonly scene: Scene;
  132090. /**
  132091. * @constructor
  132092. * @param name The rendering pipeline name
  132093. * @param scene The scene linked to this pipeline
  132094. * @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 }
  132095. * @param cameras The array of cameras that the rendering pipeline will be attached to
  132096. */
  132097. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  132098. /**
  132099. * Get the class name
  132100. * @returns "SSAO2RenderingPipeline"
  132101. */
  132102. getClassName(): string;
  132103. /**
  132104. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  132105. */
  132106. dispose(disableGeometryBufferRenderer?: boolean): void;
  132107. private _createBlurPostProcess;
  132108. /** @hidden */
  132109. _rebuild(): void;
  132110. private _bits;
  132111. private _radicalInverse_VdC;
  132112. private _hammersley;
  132113. private _hemisphereSample_uniform;
  132114. private _generateHemisphere;
  132115. private _createSSAOPostProcess;
  132116. private _createSSAOCombinePostProcess;
  132117. private _createRandomTexture;
  132118. /**
  132119. * Serialize the rendering pipeline (Used when exporting)
  132120. * @returns the serialized object
  132121. */
  132122. serialize(): any;
  132123. /**
  132124. * Parse the serialized pipeline
  132125. * @param source Source pipeline.
  132126. * @param scene The scene to load the pipeline to.
  132127. * @param rootUrl The URL of the serialized pipeline.
  132128. * @returns An instantiated pipeline from the serialized object.
  132129. */
  132130. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  132131. }
  132132. }
  132133. declare module BABYLON {
  132134. /** @hidden */
  132135. export var ssaoPixelShader: {
  132136. name: string;
  132137. shader: string;
  132138. };
  132139. }
  132140. declare module BABYLON {
  132141. /**
  132142. * Render pipeline to produce ssao effect
  132143. */
  132144. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  132145. /**
  132146. * @ignore
  132147. * The PassPostProcess id in the pipeline that contains the original scene color
  132148. */
  132149. SSAOOriginalSceneColorEffect: string;
  132150. /**
  132151. * @ignore
  132152. * The SSAO PostProcess id in the pipeline
  132153. */
  132154. SSAORenderEffect: string;
  132155. /**
  132156. * @ignore
  132157. * The horizontal blur PostProcess id in the pipeline
  132158. */
  132159. SSAOBlurHRenderEffect: string;
  132160. /**
  132161. * @ignore
  132162. * The vertical blur PostProcess id in the pipeline
  132163. */
  132164. SSAOBlurVRenderEffect: string;
  132165. /**
  132166. * @ignore
  132167. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  132168. */
  132169. SSAOCombineRenderEffect: string;
  132170. /**
  132171. * The output strength of the SSAO post-process. Default value is 1.0.
  132172. */
  132173. totalStrength: number;
  132174. /**
  132175. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  132176. */
  132177. radius: number;
  132178. /**
  132179. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  132180. * Must not be equal to fallOff and superior to fallOff.
  132181. * Default value is 0.0075
  132182. */
  132183. area: number;
  132184. /**
  132185. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  132186. * Must not be equal to area and inferior to area.
  132187. * Default value is 0.000001
  132188. */
  132189. fallOff: number;
  132190. /**
  132191. * The base color of the SSAO post-process
  132192. * The final result is "base + ssao" between [0, 1]
  132193. */
  132194. base: number;
  132195. private _scene;
  132196. private _depthTexture;
  132197. private _randomTexture;
  132198. private _originalColorPostProcess;
  132199. private _ssaoPostProcess;
  132200. private _blurHPostProcess;
  132201. private _blurVPostProcess;
  132202. private _ssaoCombinePostProcess;
  132203. private _firstUpdate;
  132204. /**
  132205. * Gets active scene
  132206. */
  132207. readonly scene: Scene;
  132208. /**
  132209. * @constructor
  132210. * @param name - The rendering pipeline name
  132211. * @param scene - The scene linked to this pipeline
  132212. * @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 }
  132213. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  132214. */
  132215. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  132216. /**
  132217. * Get the class name
  132218. * @returns "SSAORenderingPipeline"
  132219. */
  132220. getClassName(): string;
  132221. /**
  132222. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  132223. */
  132224. dispose(disableDepthRender?: boolean): void;
  132225. private _createBlurPostProcess;
  132226. /** @hidden */
  132227. _rebuild(): void;
  132228. private _createSSAOPostProcess;
  132229. private _createSSAOCombinePostProcess;
  132230. private _createRandomTexture;
  132231. }
  132232. }
  132233. declare module BABYLON {
  132234. /** @hidden */
  132235. export var standardPixelShader: {
  132236. name: string;
  132237. shader: string;
  132238. };
  132239. }
  132240. declare module BABYLON {
  132241. /**
  132242. * Standard rendering pipeline
  132243. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  132244. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  132245. */
  132246. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  132247. /**
  132248. * Public members
  132249. */
  132250. /**
  132251. * Post-process which contains the original scene color before the pipeline applies all the effects
  132252. */
  132253. originalPostProcess: Nullable<PostProcess>;
  132254. /**
  132255. * Post-process used to down scale an image x4
  132256. */
  132257. downSampleX4PostProcess: Nullable<PostProcess>;
  132258. /**
  132259. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  132260. */
  132261. brightPassPostProcess: Nullable<PostProcess>;
  132262. /**
  132263. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  132264. */
  132265. blurHPostProcesses: PostProcess[];
  132266. /**
  132267. * Post-process array storing all the vertical blur post-processes used by the pipeline
  132268. */
  132269. blurVPostProcesses: PostProcess[];
  132270. /**
  132271. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  132272. */
  132273. textureAdderPostProcess: Nullable<PostProcess>;
  132274. /**
  132275. * Post-process used to create volumetric lighting effect
  132276. */
  132277. volumetricLightPostProcess: Nullable<PostProcess>;
  132278. /**
  132279. * Post-process used to smooth the previous volumetric light post-process on the X axis
  132280. */
  132281. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  132282. /**
  132283. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  132284. */
  132285. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  132286. /**
  132287. * Post-process used to merge the volumetric light effect and the real scene color
  132288. */
  132289. volumetricLightMergePostProces: Nullable<PostProcess>;
  132290. /**
  132291. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  132292. */
  132293. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  132294. /**
  132295. * Base post-process used to calculate the average luminance of the final image for HDR
  132296. */
  132297. luminancePostProcess: Nullable<PostProcess>;
  132298. /**
  132299. * Post-processes used to create down sample post-processes in order to get
  132300. * the average luminance of the final image for HDR
  132301. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  132302. */
  132303. luminanceDownSamplePostProcesses: PostProcess[];
  132304. /**
  132305. * Post-process used to create a HDR effect (light adaptation)
  132306. */
  132307. hdrPostProcess: Nullable<PostProcess>;
  132308. /**
  132309. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  132310. */
  132311. textureAdderFinalPostProcess: Nullable<PostProcess>;
  132312. /**
  132313. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  132314. */
  132315. lensFlareFinalPostProcess: Nullable<PostProcess>;
  132316. /**
  132317. * Post-process used to merge the final HDR post-process and the real scene color
  132318. */
  132319. hdrFinalPostProcess: Nullable<PostProcess>;
  132320. /**
  132321. * Post-process used to create a lens flare effect
  132322. */
  132323. lensFlarePostProcess: Nullable<PostProcess>;
  132324. /**
  132325. * Post-process that merges the result of the lens flare post-process and the real scene color
  132326. */
  132327. lensFlareComposePostProcess: Nullable<PostProcess>;
  132328. /**
  132329. * Post-process used to create a motion blur effect
  132330. */
  132331. motionBlurPostProcess: Nullable<PostProcess>;
  132332. /**
  132333. * Post-process used to create a depth of field effect
  132334. */
  132335. depthOfFieldPostProcess: Nullable<PostProcess>;
  132336. /**
  132337. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  132338. */
  132339. fxaaPostProcess: Nullable<FxaaPostProcess>;
  132340. /**
  132341. * Represents the brightness threshold in order to configure the illuminated surfaces
  132342. */
  132343. brightThreshold: number;
  132344. /**
  132345. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  132346. */
  132347. blurWidth: number;
  132348. /**
  132349. * Sets if the blur for highlighted surfaces must be only horizontal
  132350. */
  132351. horizontalBlur: boolean;
  132352. /**
  132353. * Gets the overall exposure used by the pipeline
  132354. */
  132355. /**
  132356. * Sets the overall exposure used by the pipeline
  132357. */
  132358. exposure: number;
  132359. /**
  132360. * Texture used typically to simulate "dirty" on camera lens
  132361. */
  132362. lensTexture: Nullable<Texture>;
  132363. /**
  132364. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  132365. */
  132366. volumetricLightCoefficient: number;
  132367. /**
  132368. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  132369. */
  132370. volumetricLightPower: number;
  132371. /**
  132372. * Used the set the blur intensity to smooth the volumetric lights
  132373. */
  132374. volumetricLightBlurScale: number;
  132375. /**
  132376. * Light (spot or directional) used to generate the volumetric lights rays
  132377. * The source light must have a shadow generate so the pipeline can get its
  132378. * depth map
  132379. */
  132380. sourceLight: Nullable<SpotLight | DirectionalLight>;
  132381. /**
  132382. * For eye adaptation, represents the minimum luminance the eye can see
  132383. */
  132384. hdrMinimumLuminance: number;
  132385. /**
  132386. * For eye adaptation, represents the decrease luminance speed
  132387. */
  132388. hdrDecreaseRate: number;
  132389. /**
  132390. * For eye adaptation, represents the increase luminance speed
  132391. */
  132392. hdrIncreaseRate: number;
  132393. /**
  132394. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  132395. */
  132396. /**
  132397. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  132398. */
  132399. hdrAutoExposure: boolean;
  132400. /**
  132401. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  132402. */
  132403. lensColorTexture: Nullable<Texture>;
  132404. /**
  132405. * The overall strengh for the lens flare effect
  132406. */
  132407. lensFlareStrength: number;
  132408. /**
  132409. * Dispersion coefficient for lens flare ghosts
  132410. */
  132411. lensFlareGhostDispersal: number;
  132412. /**
  132413. * Main lens flare halo width
  132414. */
  132415. lensFlareHaloWidth: number;
  132416. /**
  132417. * Based on the lens distortion effect, defines how much the lens flare result
  132418. * is distorted
  132419. */
  132420. lensFlareDistortionStrength: number;
  132421. /**
  132422. * Configures the blur intensity used for for lens flare (halo)
  132423. */
  132424. lensFlareBlurWidth: number;
  132425. /**
  132426. * Lens star texture must be used to simulate rays on the flares and is available
  132427. * in the documentation
  132428. */
  132429. lensStarTexture: Nullable<Texture>;
  132430. /**
  132431. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  132432. * flare effect by taking account of the dirt texture
  132433. */
  132434. lensFlareDirtTexture: Nullable<Texture>;
  132435. /**
  132436. * Represents the focal length for the depth of field effect
  132437. */
  132438. depthOfFieldDistance: number;
  132439. /**
  132440. * Represents the blur intensity for the blurred part of the depth of field effect
  132441. */
  132442. depthOfFieldBlurWidth: number;
  132443. /**
  132444. * Gets how much the image is blurred by the movement while using the motion blur post-process
  132445. */
  132446. /**
  132447. * Sets how much the image is blurred by the movement while using the motion blur post-process
  132448. */
  132449. motionStrength: number;
  132450. /**
  132451. * Gets wether or not the motion blur post-process is object based or screen based.
  132452. */
  132453. /**
  132454. * Sets wether or not the motion blur post-process should be object based or screen based
  132455. */
  132456. objectBasedMotionBlur: boolean;
  132457. /**
  132458. * List of animations for the pipeline (IAnimatable implementation)
  132459. */
  132460. animations: Animation[];
  132461. /**
  132462. * Private members
  132463. */
  132464. private _scene;
  132465. private _currentDepthOfFieldSource;
  132466. private _basePostProcess;
  132467. private _fixedExposure;
  132468. private _currentExposure;
  132469. private _hdrAutoExposure;
  132470. private _hdrCurrentLuminance;
  132471. private _motionStrength;
  132472. private _isObjectBasedMotionBlur;
  132473. private _floatTextureType;
  132474. private _camerasToBeAttached;
  132475. private _ratio;
  132476. private _bloomEnabled;
  132477. private _depthOfFieldEnabled;
  132478. private _vlsEnabled;
  132479. private _lensFlareEnabled;
  132480. private _hdrEnabled;
  132481. private _motionBlurEnabled;
  132482. private _fxaaEnabled;
  132483. private _motionBlurSamples;
  132484. private _volumetricLightStepsCount;
  132485. private _samples;
  132486. /**
  132487. * @ignore
  132488. * Specifies if the bloom pipeline is enabled
  132489. */
  132490. BloomEnabled: boolean;
  132491. /**
  132492. * @ignore
  132493. * Specifies if the depth of field pipeline is enabed
  132494. */
  132495. DepthOfFieldEnabled: boolean;
  132496. /**
  132497. * @ignore
  132498. * Specifies if the lens flare pipeline is enabed
  132499. */
  132500. LensFlareEnabled: boolean;
  132501. /**
  132502. * @ignore
  132503. * Specifies if the HDR pipeline is enabled
  132504. */
  132505. HDREnabled: boolean;
  132506. /**
  132507. * @ignore
  132508. * Specifies if the volumetric lights scattering effect is enabled
  132509. */
  132510. VLSEnabled: boolean;
  132511. /**
  132512. * @ignore
  132513. * Specifies if the motion blur effect is enabled
  132514. */
  132515. MotionBlurEnabled: boolean;
  132516. /**
  132517. * Specifies if anti-aliasing is enabled
  132518. */
  132519. fxaaEnabled: boolean;
  132520. /**
  132521. * Specifies the number of steps used to calculate the volumetric lights
  132522. * Typically in interval [50, 200]
  132523. */
  132524. volumetricLightStepsCount: number;
  132525. /**
  132526. * Specifies the number of samples used for the motion blur effect
  132527. * Typically in interval [16, 64]
  132528. */
  132529. motionBlurSamples: number;
  132530. /**
  132531. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  132532. */
  132533. samples: number;
  132534. /**
  132535. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  132536. * @constructor
  132537. * @param name The rendering pipeline name
  132538. * @param scene The scene linked to this pipeline
  132539. * @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)
  132540. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  132541. * @param cameras The array of cameras that the rendering pipeline will be attached to
  132542. */
  132543. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  132544. private _buildPipeline;
  132545. private _createDownSampleX4PostProcess;
  132546. private _createBrightPassPostProcess;
  132547. private _createBlurPostProcesses;
  132548. private _createTextureAdderPostProcess;
  132549. private _createVolumetricLightPostProcess;
  132550. private _createLuminancePostProcesses;
  132551. private _createHdrPostProcess;
  132552. private _createLensFlarePostProcess;
  132553. private _createDepthOfFieldPostProcess;
  132554. private _createMotionBlurPostProcess;
  132555. private _getDepthTexture;
  132556. private _disposePostProcesses;
  132557. /**
  132558. * Dispose of the pipeline and stop all post processes
  132559. */
  132560. dispose(): void;
  132561. /**
  132562. * Serialize the rendering pipeline (Used when exporting)
  132563. * @returns the serialized object
  132564. */
  132565. serialize(): any;
  132566. /**
  132567. * Parse the serialized pipeline
  132568. * @param source Source pipeline.
  132569. * @param scene The scene to load the pipeline to.
  132570. * @param rootUrl The URL of the serialized pipeline.
  132571. * @returns An instantiated pipeline from the serialized object.
  132572. */
  132573. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  132574. /**
  132575. * Luminance steps
  132576. */
  132577. static LuminanceSteps: number;
  132578. }
  132579. }
  132580. declare module BABYLON {
  132581. /** @hidden */
  132582. export var tonemapPixelShader: {
  132583. name: string;
  132584. shader: string;
  132585. };
  132586. }
  132587. declare module BABYLON {
  132588. /** Defines operator used for tonemapping */
  132589. export enum TonemappingOperator {
  132590. /** Hable */
  132591. Hable = 0,
  132592. /** Reinhard */
  132593. Reinhard = 1,
  132594. /** HejiDawson */
  132595. HejiDawson = 2,
  132596. /** Photographic */
  132597. Photographic = 3
  132598. }
  132599. /**
  132600. * Defines a post process to apply tone mapping
  132601. */
  132602. export class TonemapPostProcess extends PostProcess {
  132603. private _operator;
  132604. /** Defines the required exposure adjustement */
  132605. exposureAdjustment: number;
  132606. /**
  132607. * Creates a new TonemapPostProcess
  132608. * @param name defines the name of the postprocess
  132609. * @param _operator defines the operator to use
  132610. * @param exposureAdjustment defines the required exposure adjustement
  132611. * @param camera defines the camera to use (can be null)
  132612. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  132613. * @param engine defines the hosting engine (can be ignore if camera is set)
  132614. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  132615. */
  132616. constructor(name: string, _operator: TonemappingOperator,
  132617. /** Defines the required exposure adjustement */
  132618. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  132619. }
  132620. }
  132621. declare module BABYLON {
  132622. /** @hidden */
  132623. export var depthVertexShader: {
  132624. name: string;
  132625. shader: string;
  132626. };
  132627. }
  132628. declare module BABYLON {
  132629. /** @hidden */
  132630. export var volumetricLightScatteringPixelShader: {
  132631. name: string;
  132632. shader: string;
  132633. };
  132634. }
  132635. declare module BABYLON {
  132636. /** @hidden */
  132637. export var volumetricLightScatteringPassVertexShader: {
  132638. name: string;
  132639. shader: string;
  132640. };
  132641. }
  132642. declare module BABYLON {
  132643. /** @hidden */
  132644. export var volumetricLightScatteringPassPixelShader: {
  132645. name: string;
  132646. shader: string;
  132647. };
  132648. }
  132649. declare module BABYLON {
  132650. /**
  132651. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  132652. */
  132653. export class VolumetricLightScatteringPostProcess extends PostProcess {
  132654. private _volumetricLightScatteringPass;
  132655. private _volumetricLightScatteringRTT;
  132656. private _viewPort;
  132657. private _screenCoordinates;
  132658. private _cachedDefines;
  132659. /**
  132660. * If not undefined, the mesh position is computed from the attached node position
  132661. */
  132662. attachedNode: {
  132663. position: Vector3;
  132664. };
  132665. /**
  132666. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  132667. */
  132668. customMeshPosition: Vector3;
  132669. /**
  132670. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  132671. */
  132672. useCustomMeshPosition: boolean;
  132673. /**
  132674. * If the post-process should inverse the light scattering direction
  132675. */
  132676. invert: boolean;
  132677. /**
  132678. * The internal mesh used by the post-process
  132679. */
  132680. mesh: Mesh;
  132681. /**
  132682. * @hidden
  132683. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  132684. */
  132685. useDiffuseColor: boolean;
  132686. /**
  132687. * Array containing the excluded meshes not rendered in the internal pass
  132688. */
  132689. excludedMeshes: AbstractMesh[];
  132690. /**
  132691. * Controls the overall intensity of the post-process
  132692. */
  132693. exposure: number;
  132694. /**
  132695. * Dissipates each sample's contribution in range [0, 1]
  132696. */
  132697. decay: number;
  132698. /**
  132699. * Controls the overall intensity of each sample
  132700. */
  132701. weight: number;
  132702. /**
  132703. * Controls the density of each sample
  132704. */
  132705. density: number;
  132706. /**
  132707. * @constructor
  132708. * @param name The post-process name
  132709. * @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)
  132710. * @param camera The camera that the post-process will be attached to
  132711. * @param mesh The mesh used to create the light scattering
  132712. * @param samples The post-process quality, default 100
  132713. * @param samplingModeThe post-process filtering mode
  132714. * @param engine The babylon engine
  132715. * @param reusable If the post-process is reusable
  132716. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  132717. */
  132718. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  132719. /**
  132720. * Returns the string "VolumetricLightScatteringPostProcess"
  132721. * @returns "VolumetricLightScatteringPostProcess"
  132722. */
  132723. getClassName(): string;
  132724. private _isReady;
  132725. /**
  132726. * Sets the new light position for light scattering effect
  132727. * @param position The new custom light position
  132728. */
  132729. setCustomMeshPosition(position: Vector3): void;
  132730. /**
  132731. * Returns the light position for light scattering effect
  132732. * @return Vector3 The custom light position
  132733. */
  132734. getCustomMeshPosition(): Vector3;
  132735. /**
  132736. * Disposes the internal assets and detaches the post-process from the camera
  132737. */
  132738. dispose(camera: Camera): void;
  132739. /**
  132740. * Returns the render target texture used by the post-process
  132741. * @return the render target texture used by the post-process
  132742. */
  132743. getPass(): RenderTargetTexture;
  132744. private _meshExcluded;
  132745. private _createPass;
  132746. private _updateMeshScreenCoordinates;
  132747. /**
  132748. * Creates a default mesh for the Volumeric Light Scattering post-process
  132749. * @param name The mesh name
  132750. * @param scene The scene where to create the mesh
  132751. * @return the default mesh
  132752. */
  132753. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  132754. }
  132755. }
  132756. declare module BABYLON {
  132757. interface Scene {
  132758. /** @hidden (Backing field) */
  132759. _boundingBoxRenderer: BoundingBoxRenderer;
  132760. /** @hidden (Backing field) */
  132761. _forceShowBoundingBoxes: boolean;
  132762. /**
  132763. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  132764. */
  132765. forceShowBoundingBoxes: boolean;
  132766. /**
  132767. * Gets the bounding box renderer associated with the scene
  132768. * @returns a BoundingBoxRenderer
  132769. */
  132770. getBoundingBoxRenderer(): BoundingBoxRenderer;
  132771. }
  132772. interface AbstractMesh {
  132773. /** @hidden (Backing field) */
  132774. _showBoundingBox: boolean;
  132775. /**
  132776. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  132777. */
  132778. showBoundingBox: boolean;
  132779. }
  132780. /**
  132781. * Component responsible of rendering the bounding box of the meshes in a scene.
  132782. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  132783. */
  132784. export class BoundingBoxRenderer implements ISceneComponent {
  132785. /**
  132786. * The component name helpfull to identify the component in the list of scene components.
  132787. */
  132788. readonly name: string;
  132789. /**
  132790. * The scene the component belongs to.
  132791. */
  132792. scene: Scene;
  132793. /**
  132794. * Color of the bounding box lines placed in front of an object
  132795. */
  132796. frontColor: Color3;
  132797. /**
  132798. * Color of the bounding box lines placed behind an object
  132799. */
  132800. backColor: Color3;
  132801. /**
  132802. * Defines if the renderer should show the back lines or not
  132803. */
  132804. showBackLines: boolean;
  132805. /**
  132806. * @hidden
  132807. */
  132808. renderList: SmartArray<BoundingBox>;
  132809. private _colorShader;
  132810. private _vertexBuffers;
  132811. private _indexBuffer;
  132812. private _fillIndexBuffer;
  132813. private _fillIndexData;
  132814. /**
  132815. * Instantiates a new bounding box renderer in a scene.
  132816. * @param scene the scene the renderer renders in
  132817. */
  132818. constructor(scene: Scene);
  132819. /**
  132820. * Registers the component in a given scene
  132821. */
  132822. register(): void;
  132823. private _evaluateSubMesh;
  132824. private _activeMesh;
  132825. private _prepareRessources;
  132826. private _createIndexBuffer;
  132827. /**
  132828. * Rebuilds the elements related to this component in case of
  132829. * context lost for instance.
  132830. */
  132831. rebuild(): void;
  132832. /**
  132833. * @hidden
  132834. */
  132835. reset(): void;
  132836. /**
  132837. * Render the bounding boxes of a specific rendering group
  132838. * @param renderingGroupId defines the rendering group to render
  132839. */
  132840. render(renderingGroupId: number): void;
  132841. /**
  132842. * In case of occlusion queries, we can render the occlusion bounding box through this method
  132843. * @param mesh Define the mesh to render the occlusion bounding box for
  132844. */
  132845. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  132846. /**
  132847. * Dispose and release the resources attached to this renderer.
  132848. */
  132849. dispose(): void;
  132850. }
  132851. }
  132852. declare module BABYLON {
  132853. /** @hidden */
  132854. export var depthPixelShader: {
  132855. name: string;
  132856. shader: string;
  132857. };
  132858. }
  132859. declare module BABYLON {
  132860. /**
  132861. * This represents a depth renderer in Babylon.
  132862. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  132863. */
  132864. export class DepthRenderer {
  132865. private _scene;
  132866. private _depthMap;
  132867. private _effect;
  132868. private readonly _storeNonLinearDepth;
  132869. private readonly _clearColor;
  132870. /** Get if the depth renderer is using packed depth or not */
  132871. readonly isPacked: boolean;
  132872. private _cachedDefines;
  132873. private _camera;
  132874. /**
  132875. * Specifiess that the depth renderer will only be used within
  132876. * the camera it is created for.
  132877. * This can help forcing its rendering during the camera processing.
  132878. */
  132879. useOnlyInActiveCamera: boolean;
  132880. /** @hidden */
  132881. static _SceneComponentInitialization: (scene: Scene) => void;
  132882. /**
  132883. * Instantiates a depth renderer
  132884. * @param scene The scene the renderer belongs to
  132885. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  132886. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  132887. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  132888. */
  132889. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  132890. /**
  132891. * Creates the depth rendering effect and checks if the effect is ready.
  132892. * @param subMesh The submesh to be used to render the depth map of
  132893. * @param useInstances If multiple world instances should be used
  132894. * @returns if the depth renderer is ready to render the depth map
  132895. */
  132896. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  132897. /**
  132898. * Gets the texture which the depth map will be written to.
  132899. * @returns The depth map texture
  132900. */
  132901. getDepthMap(): RenderTargetTexture;
  132902. /**
  132903. * Disposes of the depth renderer.
  132904. */
  132905. dispose(): void;
  132906. }
  132907. }
  132908. declare module BABYLON {
  132909. interface Scene {
  132910. /** @hidden (Backing field) */
  132911. _depthRenderer: {
  132912. [id: string]: DepthRenderer;
  132913. };
  132914. /**
  132915. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  132916. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  132917. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  132918. * @returns the created depth renderer
  132919. */
  132920. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  132921. /**
  132922. * Disables a depth renderer for a given camera
  132923. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  132924. */
  132925. disableDepthRenderer(camera?: Nullable<Camera>): void;
  132926. }
  132927. /**
  132928. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  132929. * in several rendering techniques.
  132930. */
  132931. export class DepthRendererSceneComponent implements ISceneComponent {
  132932. /**
  132933. * The component name helpfull to identify the component in the list of scene components.
  132934. */
  132935. readonly name: string;
  132936. /**
  132937. * The scene the component belongs to.
  132938. */
  132939. scene: Scene;
  132940. /**
  132941. * Creates a new instance of the component for the given scene
  132942. * @param scene Defines the scene to register the component in
  132943. */
  132944. constructor(scene: Scene);
  132945. /**
  132946. * Registers the component in a given scene
  132947. */
  132948. register(): void;
  132949. /**
  132950. * Rebuilds the elements related to this component in case of
  132951. * context lost for instance.
  132952. */
  132953. rebuild(): void;
  132954. /**
  132955. * Disposes the component and the associated ressources
  132956. */
  132957. dispose(): void;
  132958. private _gatherRenderTargets;
  132959. private _gatherActiveCameraRenderTargets;
  132960. }
  132961. }
  132962. declare module BABYLON {
  132963. /** @hidden */
  132964. export var outlinePixelShader: {
  132965. name: string;
  132966. shader: string;
  132967. };
  132968. }
  132969. declare module BABYLON {
  132970. /** @hidden */
  132971. export var outlineVertexShader: {
  132972. name: string;
  132973. shader: string;
  132974. };
  132975. }
  132976. declare module BABYLON {
  132977. interface Scene {
  132978. /** @hidden */
  132979. _outlineRenderer: OutlineRenderer;
  132980. /**
  132981. * Gets the outline renderer associated with the scene
  132982. * @returns a OutlineRenderer
  132983. */
  132984. getOutlineRenderer(): OutlineRenderer;
  132985. }
  132986. interface AbstractMesh {
  132987. /** @hidden (Backing field) */
  132988. _renderOutline: boolean;
  132989. /**
  132990. * Gets or sets a boolean indicating if the outline must be rendered as well
  132991. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  132992. */
  132993. renderOutline: boolean;
  132994. /** @hidden (Backing field) */
  132995. _renderOverlay: boolean;
  132996. /**
  132997. * Gets or sets a boolean indicating if the overlay must be rendered as well
  132998. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  132999. */
  133000. renderOverlay: boolean;
  133001. }
  133002. /**
  133003. * This class is responsible to draw bothe outline/overlay of meshes.
  133004. * It should not be used directly but through the available method on mesh.
  133005. */
  133006. export class OutlineRenderer implements ISceneComponent {
  133007. /**
  133008. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  133009. */
  133010. private static _StencilReference;
  133011. /**
  133012. * The name of the component. Each component must have a unique name.
  133013. */
  133014. name: string;
  133015. /**
  133016. * The scene the component belongs to.
  133017. */
  133018. scene: Scene;
  133019. /**
  133020. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  133021. */
  133022. zOffset: number;
  133023. private _engine;
  133024. private _effect;
  133025. private _cachedDefines;
  133026. private _savedDepthWrite;
  133027. /**
  133028. * Instantiates a new outline renderer. (There could be only one per scene).
  133029. * @param scene Defines the scene it belongs to
  133030. */
  133031. constructor(scene: Scene);
  133032. /**
  133033. * Register the component to one instance of a scene.
  133034. */
  133035. register(): void;
  133036. /**
  133037. * Rebuilds the elements related to this component in case of
  133038. * context lost for instance.
  133039. */
  133040. rebuild(): void;
  133041. /**
  133042. * Disposes the component and the associated ressources.
  133043. */
  133044. dispose(): void;
  133045. /**
  133046. * Renders the outline in the canvas.
  133047. * @param subMesh Defines the sumesh to render
  133048. * @param batch Defines the batch of meshes in case of instances
  133049. * @param useOverlay Defines if the rendering is for the overlay or the outline
  133050. */
  133051. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  133052. /**
  133053. * Returns whether or not the outline renderer is ready for a given submesh.
  133054. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  133055. * @param subMesh Defines the submesh to check readyness for
  133056. * @param useInstances Defines wheter wee are trying to render instances or not
  133057. * @returns true if ready otherwise false
  133058. */
  133059. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  133060. private _beforeRenderingMesh;
  133061. private _afterRenderingMesh;
  133062. }
  133063. }
  133064. declare module BABYLON {
  133065. /**
  133066. * Defines the basic options interface of a Sprite Frame Source Size.
  133067. */
  133068. export interface ISpriteJSONSpriteSourceSize {
  133069. /**
  133070. * number of the original width of the Frame
  133071. */
  133072. w: number;
  133073. /**
  133074. * number of the original height of the Frame
  133075. */
  133076. h: number;
  133077. }
  133078. /**
  133079. * Defines the basic options interface of a Sprite Frame Data.
  133080. */
  133081. export interface ISpriteJSONSpriteFrameData {
  133082. /**
  133083. * number of the x offset of the Frame
  133084. */
  133085. x: number;
  133086. /**
  133087. * number of the y offset of the Frame
  133088. */
  133089. y: number;
  133090. /**
  133091. * number of the width of the Frame
  133092. */
  133093. w: number;
  133094. /**
  133095. * number of the height of the Frame
  133096. */
  133097. h: number;
  133098. }
  133099. /**
  133100. * Defines the basic options interface of a JSON Sprite.
  133101. */
  133102. export interface ISpriteJSONSprite {
  133103. /**
  133104. * string name of the Frame
  133105. */
  133106. filename: string;
  133107. /**
  133108. * ISpriteJSONSpriteFrame basic object of the frame data
  133109. */
  133110. frame: ISpriteJSONSpriteFrameData;
  133111. /**
  133112. * boolean to flag is the frame was rotated.
  133113. */
  133114. rotated: boolean;
  133115. /**
  133116. * boolean to flag is the frame was trimmed.
  133117. */
  133118. trimmed: boolean;
  133119. /**
  133120. * ISpriteJSONSpriteFrame basic object of the source data
  133121. */
  133122. spriteSourceSize: ISpriteJSONSpriteFrameData;
  133123. /**
  133124. * ISpriteJSONSpriteFrame basic object of the source data
  133125. */
  133126. sourceSize: ISpriteJSONSpriteSourceSize;
  133127. }
  133128. /**
  133129. * Defines the basic options interface of a JSON atlas.
  133130. */
  133131. export interface ISpriteJSONAtlas {
  133132. /**
  133133. * Array of objects that contain the frame data.
  133134. */
  133135. frames: Array<ISpriteJSONSprite>;
  133136. /**
  133137. * object basic object containing the sprite meta data.
  133138. */
  133139. meta?: object;
  133140. }
  133141. }
  133142. declare module BABYLON {
  133143. /** @hidden */
  133144. export var spriteMapPixelShader: {
  133145. name: string;
  133146. shader: string;
  133147. };
  133148. }
  133149. declare module BABYLON {
  133150. /** @hidden */
  133151. export var spriteMapVertexShader: {
  133152. name: string;
  133153. shader: string;
  133154. };
  133155. }
  133156. declare module BABYLON {
  133157. /**
  133158. * Defines the basic options interface of a SpriteMap
  133159. */
  133160. export interface ISpriteMapOptions {
  133161. /**
  133162. * Vector2 of the number of cells in the grid.
  133163. */
  133164. stageSize?: Vector2;
  133165. /**
  133166. * Vector2 of the size of the output plane in World Units.
  133167. */
  133168. outputSize?: Vector2;
  133169. /**
  133170. * Vector3 of the position of the output plane in World Units.
  133171. */
  133172. outputPosition?: Vector3;
  133173. /**
  133174. * Vector3 of the rotation of the output plane.
  133175. */
  133176. outputRotation?: Vector3;
  133177. /**
  133178. * number of layers that the system will reserve in resources.
  133179. */
  133180. layerCount?: number;
  133181. /**
  133182. * number of max animation frames a single cell will reserve in resources.
  133183. */
  133184. maxAnimationFrames?: number;
  133185. /**
  133186. * number cell index of the base tile when the system compiles.
  133187. */
  133188. baseTile?: number;
  133189. /**
  133190. * boolean flip the sprite after its been repositioned by the framing data.
  133191. */
  133192. flipU?: boolean;
  133193. /**
  133194. * Vector3 scalar of the global RGB values of the SpriteMap.
  133195. */
  133196. colorMultiply?: Vector3;
  133197. }
  133198. /**
  133199. * Defines the IDisposable interface in order to be cleanable from resources.
  133200. */
  133201. export interface ISpriteMap extends IDisposable {
  133202. /**
  133203. * String name of the SpriteMap.
  133204. */
  133205. name: string;
  133206. /**
  133207. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  133208. */
  133209. atlasJSON: ISpriteJSONAtlas;
  133210. /**
  133211. * Texture of the SpriteMap.
  133212. */
  133213. spriteSheet: Texture;
  133214. /**
  133215. * The parameters to initialize the SpriteMap with.
  133216. */
  133217. options: ISpriteMapOptions;
  133218. }
  133219. /**
  133220. * Class used to manage a grid restricted sprite deployment on an Output plane.
  133221. */
  133222. export class SpriteMap implements ISpriteMap {
  133223. /** The Name of the spriteMap */
  133224. name: string;
  133225. /** The JSON file with the frame and meta data */
  133226. atlasJSON: ISpriteJSONAtlas;
  133227. /** The systems Sprite Sheet Texture */
  133228. spriteSheet: Texture;
  133229. /** Arguments passed with the Constructor */
  133230. options: ISpriteMapOptions;
  133231. /** Public Sprite Storage array, parsed from atlasJSON */
  133232. sprites: Array<ISpriteJSONSprite>;
  133233. /** Returns the Number of Sprites in the System */
  133234. readonly spriteCount: number;
  133235. /** Returns the Position of Output Plane*/
  133236. /** Returns the Position of Output Plane*/
  133237. position: Vector3;
  133238. /** Returns the Rotation of Output Plane*/
  133239. /** Returns the Rotation of Output Plane*/
  133240. rotation: Vector3;
  133241. /** Sets the AnimationMap*/
  133242. /** Sets the AnimationMap*/
  133243. animationMap: RawTexture;
  133244. /** Scene that the SpriteMap was created in */
  133245. private _scene;
  133246. /** Texture Buffer of Float32 that holds tile frame data*/
  133247. private _frameMap;
  133248. /** Texture Buffers of Float32 that holds tileMap data*/
  133249. private _tileMaps;
  133250. /** Texture Buffer of Float32 that holds Animation Data*/
  133251. private _animationMap;
  133252. /** Custom ShaderMaterial Central to the System*/
  133253. private _material;
  133254. /** Custom ShaderMaterial Central to the System*/
  133255. private _output;
  133256. /** Systems Time Ticker*/
  133257. private _time;
  133258. /**
  133259. * Creates a new SpriteMap
  133260. * @param name defines the SpriteMaps Name
  133261. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  133262. * @param spriteSheet is the Texture that the Sprites are on.
  133263. * @param options a basic deployment configuration
  133264. * @param scene The Scene that the map is deployed on
  133265. */
  133266. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  133267. /**
  133268. * Returns tileID location
  133269. * @returns Vector2 the cell position ID
  133270. */
  133271. getTileID(): Vector2;
  133272. /**
  133273. * Gets the UV location of the mouse over the SpriteMap.
  133274. * @returns Vector2 the UV position of the mouse interaction
  133275. */
  133276. getMousePosition(): Vector2;
  133277. /**
  133278. * Creates the "frame" texture Buffer
  133279. * -------------------------------------
  133280. * Structure of frames
  133281. * "filename": "Falling-Water-2.png",
  133282. * "frame": {"x":69,"y":103,"w":24,"h":32},
  133283. * "rotated": true,
  133284. * "trimmed": true,
  133285. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  133286. * "sourceSize": {"w":32,"h":32}
  133287. * @returns RawTexture of the frameMap
  133288. */
  133289. private _createFrameBuffer;
  133290. /**
  133291. * Creates the tileMap texture Buffer
  133292. * @param buffer normally and array of numbers, or a false to generate from scratch
  133293. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  133294. * @returns RawTexture of the tileMap
  133295. */
  133296. private _createTileBuffer;
  133297. /**
  133298. * Modifies the data of the tileMaps
  133299. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  133300. * @param pos is the iVector2 Coordinates of the Tile
  133301. * @param tile The SpriteIndex of the new Tile
  133302. */
  133303. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  133304. /**
  133305. * Creates the animationMap texture Buffer
  133306. * @param buffer normally and array of numbers, or a false to generate from scratch
  133307. * @returns RawTexture of the animationMap
  133308. */
  133309. private _createTileAnimationBuffer;
  133310. /**
  133311. * Modifies the data of the animationMap
  133312. * @param cellID is the Index of the Sprite
  133313. * @param _frame is the target Animation frame
  133314. * @param toCell is the Target Index of the next frame of the animation
  133315. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  133316. * @param speed is a global scalar of the time variable on the map.
  133317. */
  133318. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  133319. /**
  133320. * Exports the .tilemaps file
  133321. */
  133322. saveTileMaps(): void;
  133323. /**
  133324. * Imports the .tilemaps file
  133325. * @param url of the .tilemaps file
  133326. */
  133327. loadTileMaps(url: string): void;
  133328. /**
  133329. * Release associated resources
  133330. */
  133331. dispose(): void;
  133332. }
  133333. }
  133334. declare module BABYLON {
  133335. /**
  133336. * Class used to manage multiple sprites of different sizes on the same spritesheet
  133337. * @see http://doc.babylonjs.com/babylon101/sprites
  133338. */
  133339. export class SpritePackedManager extends SpriteManager {
  133340. /** defines the packed manager's name */
  133341. name: string;
  133342. /**
  133343. * Creates a new sprite manager from a packed sprite sheet
  133344. * @param name defines the manager's name
  133345. * @param imgUrl defines the sprite sheet url
  133346. * @param capacity defines the maximum allowed number of sprites
  133347. * @param scene defines the hosting scene
  133348. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  133349. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  133350. * @param samplingMode defines the smapling mode to use with spritesheet
  133351. * @param fromPacked set to true; do not alter
  133352. */
  133353. constructor(
  133354. /** defines the packed manager's name */
  133355. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  133356. }
  133357. }
  133358. declare module BABYLON {
  133359. /**
  133360. * Defines the list of states available for a task inside a AssetsManager
  133361. */
  133362. export enum AssetTaskState {
  133363. /**
  133364. * Initialization
  133365. */
  133366. INIT = 0,
  133367. /**
  133368. * Running
  133369. */
  133370. RUNNING = 1,
  133371. /**
  133372. * Done
  133373. */
  133374. DONE = 2,
  133375. /**
  133376. * Error
  133377. */
  133378. ERROR = 3
  133379. }
  133380. /**
  133381. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  133382. */
  133383. export abstract class AbstractAssetTask {
  133384. /**
  133385. * Task name
  133386. */ name: string;
  133387. /**
  133388. * Callback called when the task is successful
  133389. */
  133390. onSuccess: (task: any) => void;
  133391. /**
  133392. * Callback called when the task is not successful
  133393. */
  133394. onError: (task: any, message?: string, exception?: any) => void;
  133395. /**
  133396. * Creates a new AssetsManager
  133397. * @param name defines the name of the task
  133398. */
  133399. constructor(
  133400. /**
  133401. * Task name
  133402. */ name: string);
  133403. private _isCompleted;
  133404. private _taskState;
  133405. private _errorObject;
  133406. /**
  133407. * Get if the task is completed
  133408. */
  133409. readonly isCompleted: boolean;
  133410. /**
  133411. * Gets the current state of the task
  133412. */
  133413. readonly taskState: AssetTaskState;
  133414. /**
  133415. * Gets the current error object (if task is in error)
  133416. */
  133417. readonly errorObject: {
  133418. message?: string;
  133419. exception?: any;
  133420. };
  133421. /**
  133422. * Internal only
  133423. * @hidden
  133424. */
  133425. _setErrorObject(message?: string, exception?: any): void;
  133426. /**
  133427. * Execute the current task
  133428. * @param scene defines the scene where you want your assets to be loaded
  133429. * @param onSuccess is a callback called when the task is successfully executed
  133430. * @param onError is a callback called if an error occurs
  133431. */
  133432. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133433. /**
  133434. * Execute the current task
  133435. * @param scene defines the scene where you want your assets to be loaded
  133436. * @param onSuccess is a callback called when the task is successfully executed
  133437. * @param onError is a callback called if an error occurs
  133438. */
  133439. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133440. /**
  133441. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  133442. * This can be used with failed tasks that have the reason for failure fixed.
  133443. */
  133444. reset(): void;
  133445. private onErrorCallback;
  133446. private onDoneCallback;
  133447. }
  133448. /**
  133449. * Define the interface used by progress events raised during assets loading
  133450. */
  133451. export interface IAssetsProgressEvent {
  133452. /**
  133453. * Defines the number of remaining tasks to process
  133454. */
  133455. remainingCount: number;
  133456. /**
  133457. * Defines the total number of tasks
  133458. */
  133459. totalCount: number;
  133460. /**
  133461. * Defines the task that was just processed
  133462. */
  133463. task: AbstractAssetTask;
  133464. }
  133465. /**
  133466. * Class used to share progress information about assets loading
  133467. */
  133468. export class AssetsProgressEvent implements IAssetsProgressEvent {
  133469. /**
  133470. * Defines the number of remaining tasks to process
  133471. */
  133472. remainingCount: number;
  133473. /**
  133474. * Defines the total number of tasks
  133475. */
  133476. totalCount: number;
  133477. /**
  133478. * Defines the task that was just processed
  133479. */
  133480. task: AbstractAssetTask;
  133481. /**
  133482. * Creates a AssetsProgressEvent
  133483. * @param remainingCount defines the number of remaining tasks to process
  133484. * @param totalCount defines the total number of tasks
  133485. * @param task defines the task that was just processed
  133486. */
  133487. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  133488. }
  133489. /**
  133490. * Define a task used by AssetsManager to load meshes
  133491. */
  133492. export class MeshAssetTask extends AbstractAssetTask {
  133493. /**
  133494. * Defines the name of the task
  133495. */
  133496. name: string;
  133497. /**
  133498. * Defines the list of mesh's names you want to load
  133499. */
  133500. meshesNames: any;
  133501. /**
  133502. * Defines the root url to use as a base to load your meshes and associated resources
  133503. */
  133504. rootUrl: string;
  133505. /**
  133506. * Defines the filename of the scene to load from
  133507. */
  133508. sceneFilename: string;
  133509. /**
  133510. * Gets the list of loaded meshes
  133511. */
  133512. loadedMeshes: Array<AbstractMesh>;
  133513. /**
  133514. * Gets the list of loaded particle systems
  133515. */
  133516. loadedParticleSystems: Array<IParticleSystem>;
  133517. /**
  133518. * Gets the list of loaded skeletons
  133519. */
  133520. loadedSkeletons: Array<Skeleton>;
  133521. /**
  133522. * Gets the list of loaded animation groups
  133523. */
  133524. loadedAnimationGroups: Array<AnimationGroup>;
  133525. /**
  133526. * Callback called when the task is successful
  133527. */
  133528. onSuccess: (task: MeshAssetTask) => void;
  133529. /**
  133530. * Callback called when the task is successful
  133531. */
  133532. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  133533. /**
  133534. * Creates a new MeshAssetTask
  133535. * @param name defines the name of the task
  133536. * @param meshesNames defines the list of mesh's names you want to load
  133537. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  133538. * @param sceneFilename defines the filename of the scene to load from
  133539. */
  133540. constructor(
  133541. /**
  133542. * Defines the name of the task
  133543. */
  133544. name: string,
  133545. /**
  133546. * Defines the list of mesh's names you want to load
  133547. */
  133548. meshesNames: any,
  133549. /**
  133550. * Defines the root url to use as a base to load your meshes and associated resources
  133551. */
  133552. rootUrl: string,
  133553. /**
  133554. * Defines the filename of the scene to load from
  133555. */
  133556. sceneFilename: string);
  133557. /**
  133558. * Execute the current task
  133559. * @param scene defines the scene where you want your assets to be loaded
  133560. * @param onSuccess is a callback called when the task is successfully executed
  133561. * @param onError is a callback called if an error occurs
  133562. */
  133563. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133564. }
  133565. /**
  133566. * Define a task used by AssetsManager to load text content
  133567. */
  133568. export class TextFileAssetTask extends AbstractAssetTask {
  133569. /**
  133570. * Defines the name of the task
  133571. */
  133572. name: string;
  133573. /**
  133574. * Defines the location of the file to load
  133575. */
  133576. url: string;
  133577. /**
  133578. * Gets the loaded text string
  133579. */
  133580. text: string;
  133581. /**
  133582. * Callback called when the task is successful
  133583. */
  133584. onSuccess: (task: TextFileAssetTask) => void;
  133585. /**
  133586. * Callback called when the task is successful
  133587. */
  133588. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  133589. /**
  133590. * Creates a new TextFileAssetTask object
  133591. * @param name defines the name of the task
  133592. * @param url defines the location of the file to load
  133593. */
  133594. constructor(
  133595. /**
  133596. * Defines the name of the task
  133597. */
  133598. name: string,
  133599. /**
  133600. * Defines the location of the file to load
  133601. */
  133602. url: string);
  133603. /**
  133604. * Execute the current task
  133605. * @param scene defines the scene where you want your assets to be loaded
  133606. * @param onSuccess is a callback called when the task is successfully executed
  133607. * @param onError is a callback called if an error occurs
  133608. */
  133609. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133610. }
  133611. /**
  133612. * Define a task used by AssetsManager to load binary data
  133613. */
  133614. export class BinaryFileAssetTask extends AbstractAssetTask {
  133615. /**
  133616. * Defines the name of the task
  133617. */
  133618. name: string;
  133619. /**
  133620. * Defines the location of the file to load
  133621. */
  133622. url: string;
  133623. /**
  133624. * Gets the lodaded data (as an array buffer)
  133625. */
  133626. data: ArrayBuffer;
  133627. /**
  133628. * Callback called when the task is successful
  133629. */
  133630. onSuccess: (task: BinaryFileAssetTask) => void;
  133631. /**
  133632. * Callback called when the task is successful
  133633. */
  133634. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  133635. /**
  133636. * Creates a new BinaryFileAssetTask object
  133637. * @param name defines the name of the new task
  133638. * @param url defines the location of the file to load
  133639. */
  133640. constructor(
  133641. /**
  133642. * Defines the name of the task
  133643. */
  133644. name: string,
  133645. /**
  133646. * Defines the location of the file to load
  133647. */
  133648. url: string);
  133649. /**
  133650. * Execute the current task
  133651. * @param scene defines the scene where you want your assets to be loaded
  133652. * @param onSuccess is a callback called when the task is successfully executed
  133653. * @param onError is a callback called if an error occurs
  133654. */
  133655. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133656. }
  133657. /**
  133658. * Define a task used by AssetsManager to load images
  133659. */
  133660. export class ImageAssetTask extends AbstractAssetTask {
  133661. /**
  133662. * Defines the name of the task
  133663. */
  133664. name: string;
  133665. /**
  133666. * Defines the location of the image to load
  133667. */
  133668. url: string;
  133669. /**
  133670. * Gets the loaded images
  133671. */
  133672. image: HTMLImageElement;
  133673. /**
  133674. * Callback called when the task is successful
  133675. */
  133676. onSuccess: (task: ImageAssetTask) => void;
  133677. /**
  133678. * Callback called when the task is successful
  133679. */
  133680. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  133681. /**
  133682. * Creates a new ImageAssetTask
  133683. * @param name defines the name of the task
  133684. * @param url defines the location of the image to load
  133685. */
  133686. constructor(
  133687. /**
  133688. * Defines the name of the task
  133689. */
  133690. name: string,
  133691. /**
  133692. * Defines the location of the image to load
  133693. */
  133694. url: string);
  133695. /**
  133696. * Execute the current task
  133697. * @param scene defines the scene where you want your assets to be loaded
  133698. * @param onSuccess is a callback called when the task is successfully executed
  133699. * @param onError is a callback called if an error occurs
  133700. */
  133701. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133702. }
  133703. /**
  133704. * Defines the interface used by texture loading tasks
  133705. */
  133706. export interface ITextureAssetTask<TEX extends BaseTexture> {
  133707. /**
  133708. * Gets the loaded texture
  133709. */
  133710. texture: TEX;
  133711. }
  133712. /**
  133713. * Define a task used by AssetsManager to load 2D textures
  133714. */
  133715. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  133716. /**
  133717. * Defines the name of the task
  133718. */
  133719. name: string;
  133720. /**
  133721. * Defines the location of the file to load
  133722. */
  133723. url: string;
  133724. /**
  133725. * Defines if mipmap should not be generated (default is false)
  133726. */
  133727. noMipmap?: boolean | undefined;
  133728. /**
  133729. * Defines if texture must be inverted on Y axis (default is false)
  133730. */
  133731. invertY?: boolean | undefined;
  133732. /**
  133733. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  133734. */
  133735. samplingMode: number;
  133736. /**
  133737. * Gets the loaded texture
  133738. */
  133739. texture: Texture;
  133740. /**
  133741. * Callback called when the task is successful
  133742. */
  133743. onSuccess: (task: TextureAssetTask) => void;
  133744. /**
  133745. * Callback called when the task is successful
  133746. */
  133747. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  133748. /**
  133749. * Creates a new TextureAssetTask object
  133750. * @param name defines the name of the task
  133751. * @param url defines the location of the file to load
  133752. * @param noMipmap defines if mipmap should not be generated (default is false)
  133753. * @param invertY defines if texture must be inverted on Y axis (default is false)
  133754. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  133755. */
  133756. constructor(
  133757. /**
  133758. * Defines the name of the task
  133759. */
  133760. name: string,
  133761. /**
  133762. * Defines the location of the file to load
  133763. */
  133764. url: string,
  133765. /**
  133766. * Defines if mipmap should not be generated (default is false)
  133767. */
  133768. noMipmap?: boolean | undefined,
  133769. /**
  133770. * Defines if texture must be inverted on Y axis (default is false)
  133771. */
  133772. invertY?: boolean | undefined,
  133773. /**
  133774. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  133775. */
  133776. samplingMode?: number);
  133777. /**
  133778. * Execute the current task
  133779. * @param scene defines the scene where you want your assets to be loaded
  133780. * @param onSuccess is a callback called when the task is successfully executed
  133781. * @param onError is a callback called if an error occurs
  133782. */
  133783. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133784. }
  133785. /**
  133786. * Define a task used by AssetsManager to load cube textures
  133787. */
  133788. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  133789. /**
  133790. * Defines the name of the task
  133791. */
  133792. name: string;
  133793. /**
  133794. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  133795. */
  133796. url: string;
  133797. /**
  133798. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  133799. */
  133800. extensions?: string[] | undefined;
  133801. /**
  133802. * Defines if mipmaps should not be generated (default is false)
  133803. */
  133804. noMipmap?: boolean | undefined;
  133805. /**
  133806. * Defines the explicit list of files (undefined by default)
  133807. */
  133808. files?: string[] | undefined;
  133809. /**
  133810. * Gets the loaded texture
  133811. */
  133812. texture: CubeTexture;
  133813. /**
  133814. * Callback called when the task is successful
  133815. */
  133816. onSuccess: (task: CubeTextureAssetTask) => void;
  133817. /**
  133818. * Callback called when the task is successful
  133819. */
  133820. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  133821. /**
  133822. * Creates a new CubeTextureAssetTask
  133823. * @param name defines the name of the task
  133824. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  133825. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  133826. * @param noMipmap defines if mipmaps should not be generated (default is false)
  133827. * @param files defines the explicit list of files (undefined by default)
  133828. */
  133829. constructor(
  133830. /**
  133831. * Defines the name of the task
  133832. */
  133833. name: string,
  133834. /**
  133835. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  133836. */
  133837. url: string,
  133838. /**
  133839. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  133840. */
  133841. extensions?: string[] | undefined,
  133842. /**
  133843. * Defines if mipmaps should not be generated (default is false)
  133844. */
  133845. noMipmap?: boolean | undefined,
  133846. /**
  133847. * Defines the explicit list of files (undefined by default)
  133848. */
  133849. files?: string[] | undefined);
  133850. /**
  133851. * Execute the current task
  133852. * @param scene defines the scene where you want your assets to be loaded
  133853. * @param onSuccess is a callback called when the task is successfully executed
  133854. * @param onError is a callback called if an error occurs
  133855. */
  133856. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133857. }
  133858. /**
  133859. * Define a task used by AssetsManager to load HDR cube textures
  133860. */
  133861. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  133862. /**
  133863. * Defines the name of the task
  133864. */
  133865. name: string;
  133866. /**
  133867. * Defines the location of the file to load
  133868. */
  133869. url: string;
  133870. /**
  133871. * Defines the desired size (the more it increases the longer the generation will be)
  133872. */
  133873. size: number;
  133874. /**
  133875. * Defines if mipmaps should not be generated (default is false)
  133876. */
  133877. noMipmap: boolean;
  133878. /**
  133879. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  133880. */
  133881. generateHarmonics: boolean;
  133882. /**
  133883. * 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)
  133884. */
  133885. gammaSpace: boolean;
  133886. /**
  133887. * Internal Use Only
  133888. */
  133889. reserved: boolean;
  133890. /**
  133891. * Gets the loaded texture
  133892. */
  133893. texture: HDRCubeTexture;
  133894. /**
  133895. * Callback called when the task is successful
  133896. */
  133897. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  133898. /**
  133899. * Callback called when the task is successful
  133900. */
  133901. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  133902. /**
  133903. * Creates a new HDRCubeTextureAssetTask object
  133904. * @param name defines the name of the task
  133905. * @param url defines the location of the file to load
  133906. * @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.
  133907. * @param noMipmap defines if mipmaps should not be generated (default is false)
  133908. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  133909. * @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)
  133910. * @param reserved Internal use only
  133911. */
  133912. constructor(
  133913. /**
  133914. * Defines the name of the task
  133915. */
  133916. name: string,
  133917. /**
  133918. * Defines the location of the file to load
  133919. */
  133920. url: string,
  133921. /**
  133922. * Defines the desired size (the more it increases the longer the generation will be)
  133923. */
  133924. size: number,
  133925. /**
  133926. * Defines if mipmaps should not be generated (default is false)
  133927. */
  133928. noMipmap?: boolean,
  133929. /**
  133930. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  133931. */
  133932. generateHarmonics?: boolean,
  133933. /**
  133934. * 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)
  133935. */
  133936. gammaSpace?: boolean,
  133937. /**
  133938. * Internal Use Only
  133939. */
  133940. reserved?: boolean);
  133941. /**
  133942. * Execute the current task
  133943. * @param scene defines the scene where you want your assets to be loaded
  133944. * @param onSuccess is a callback called when the task is successfully executed
  133945. * @param onError is a callback called if an error occurs
  133946. */
  133947. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133948. }
  133949. /**
  133950. * Define a task used by AssetsManager to load Equirectangular cube textures
  133951. */
  133952. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  133953. /**
  133954. * Defines the name of the task
  133955. */
  133956. name: string;
  133957. /**
  133958. * Defines the location of the file to load
  133959. */
  133960. url: string;
  133961. /**
  133962. * Defines the desired size (the more it increases the longer the generation will be)
  133963. */
  133964. size: number;
  133965. /**
  133966. * Defines if mipmaps should not be generated (default is false)
  133967. */
  133968. noMipmap: boolean;
  133969. /**
  133970. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  133971. * but the standard material would require them in Gamma space) (default is true)
  133972. */
  133973. gammaSpace: boolean;
  133974. /**
  133975. * Gets the loaded texture
  133976. */
  133977. texture: EquiRectangularCubeTexture;
  133978. /**
  133979. * Callback called when the task is successful
  133980. */
  133981. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  133982. /**
  133983. * Callback called when the task is successful
  133984. */
  133985. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  133986. /**
  133987. * Creates a new EquiRectangularCubeTextureAssetTask object
  133988. * @param name defines the name of the task
  133989. * @param url defines the location of the file to load
  133990. * @param size defines the desired size (the more it increases the longer the generation will be)
  133991. * If the size is omitted this implies you are using a preprocessed cubemap.
  133992. * @param noMipmap defines if mipmaps should not be generated (default is false)
  133993. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  133994. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  133995. * (default is true)
  133996. */
  133997. constructor(
  133998. /**
  133999. * Defines the name of the task
  134000. */
  134001. name: string,
  134002. /**
  134003. * Defines the location of the file to load
  134004. */
  134005. url: string,
  134006. /**
  134007. * Defines the desired size (the more it increases the longer the generation will be)
  134008. */
  134009. size: number,
  134010. /**
  134011. * Defines if mipmaps should not be generated (default is false)
  134012. */
  134013. noMipmap?: boolean,
  134014. /**
  134015. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  134016. * but the standard material would require them in Gamma space) (default is true)
  134017. */
  134018. gammaSpace?: boolean);
  134019. /**
  134020. * Execute the current task
  134021. * @param scene defines the scene where you want your assets to be loaded
  134022. * @param onSuccess is a callback called when the task is successfully executed
  134023. * @param onError is a callback called if an error occurs
  134024. */
  134025. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  134026. }
  134027. /**
  134028. * This class can be used to easily import assets into a scene
  134029. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  134030. */
  134031. export class AssetsManager {
  134032. private _scene;
  134033. private _isLoading;
  134034. protected _tasks: AbstractAssetTask[];
  134035. protected _waitingTasksCount: number;
  134036. protected _totalTasksCount: number;
  134037. /**
  134038. * Callback called when all tasks are processed
  134039. */
  134040. onFinish: (tasks: AbstractAssetTask[]) => void;
  134041. /**
  134042. * Callback called when a task is successful
  134043. */
  134044. onTaskSuccess: (task: AbstractAssetTask) => void;
  134045. /**
  134046. * Callback called when a task had an error
  134047. */
  134048. onTaskError: (task: AbstractAssetTask) => void;
  134049. /**
  134050. * Callback called when a task is done (whatever the result is)
  134051. */
  134052. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  134053. /**
  134054. * Observable called when all tasks are processed
  134055. */
  134056. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  134057. /**
  134058. * Observable called when a task had an error
  134059. */
  134060. onTaskErrorObservable: Observable<AbstractAssetTask>;
  134061. /**
  134062. * Observable called when all tasks were executed
  134063. */
  134064. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  134065. /**
  134066. * Observable called when a task is done (whatever the result is)
  134067. */
  134068. onProgressObservable: Observable<IAssetsProgressEvent>;
  134069. /**
  134070. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  134071. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  134072. */
  134073. useDefaultLoadingScreen: boolean;
  134074. /**
  134075. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  134076. * when all assets have been downloaded.
  134077. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  134078. */
  134079. autoHideLoadingUI: boolean;
  134080. /**
  134081. * Creates a new AssetsManager
  134082. * @param scene defines the scene to work on
  134083. */
  134084. constructor(scene: Scene);
  134085. /**
  134086. * Add a MeshAssetTask to the list of active tasks
  134087. * @param taskName defines the name of the new task
  134088. * @param meshesNames defines the name of meshes to load
  134089. * @param rootUrl defines the root url to use to locate files
  134090. * @param sceneFilename defines the filename of the scene file
  134091. * @returns a new MeshAssetTask object
  134092. */
  134093. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  134094. /**
  134095. * Add a TextFileAssetTask to the list of active tasks
  134096. * @param taskName defines the name of the new task
  134097. * @param url defines the url of the file to load
  134098. * @returns a new TextFileAssetTask object
  134099. */
  134100. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  134101. /**
  134102. * Add a BinaryFileAssetTask to the list of active tasks
  134103. * @param taskName defines the name of the new task
  134104. * @param url defines the url of the file to load
  134105. * @returns a new BinaryFileAssetTask object
  134106. */
  134107. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  134108. /**
  134109. * Add a ImageAssetTask to the list of active tasks
  134110. * @param taskName defines the name of the new task
  134111. * @param url defines the url of the file to load
  134112. * @returns a new ImageAssetTask object
  134113. */
  134114. addImageTask(taskName: string, url: string): ImageAssetTask;
  134115. /**
  134116. * Add a TextureAssetTask to the list of active tasks
  134117. * @param taskName defines the name of the new task
  134118. * @param url defines the url of the file to load
  134119. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  134120. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  134121. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  134122. * @returns a new TextureAssetTask object
  134123. */
  134124. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  134125. /**
  134126. * Add a CubeTextureAssetTask to the list of active tasks
  134127. * @param taskName defines the name of the new task
  134128. * @param url defines the url of the file to load
  134129. * @param extensions defines the extension to use to load the cube map (can be null)
  134130. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  134131. * @param files defines the list of files to load (can be null)
  134132. * @returns a new CubeTextureAssetTask object
  134133. */
  134134. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  134135. /**
  134136. *
  134137. * Add a HDRCubeTextureAssetTask to the list of active tasks
  134138. * @param taskName defines the name of the new task
  134139. * @param url defines the url of the file to load
  134140. * @param size defines the size you want for the cubemap (can be null)
  134141. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  134142. * @param generateHarmonics defines if you want to automatically generate (true by default)
  134143. * @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)
  134144. * @param reserved Internal use only
  134145. * @returns a new HDRCubeTextureAssetTask object
  134146. */
  134147. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  134148. /**
  134149. *
  134150. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  134151. * @param taskName defines the name of the new task
  134152. * @param url defines the url of the file to load
  134153. * @param size defines the size you want for the cubemap (can be null)
  134154. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  134155. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  134156. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  134157. * @returns a new EquiRectangularCubeTextureAssetTask object
  134158. */
  134159. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  134160. /**
  134161. * Remove a task from the assets manager.
  134162. * @param task the task to remove
  134163. */
  134164. removeTask(task: AbstractAssetTask): void;
  134165. private _decreaseWaitingTasksCount;
  134166. private _runTask;
  134167. /**
  134168. * Reset the AssetsManager and remove all tasks
  134169. * @return the current instance of the AssetsManager
  134170. */
  134171. reset(): AssetsManager;
  134172. /**
  134173. * Start the loading process
  134174. * @return the current instance of the AssetsManager
  134175. */
  134176. load(): AssetsManager;
  134177. /**
  134178. * Start the loading process as an async operation
  134179. * @return a promise returning the list of failed tasks
  134180. */
  134181. loadAsync(): Promise<void>;
  134182. }
  134183. }
  134184. declare module BABYLON {
  134185. /**
  134186. * Wrapper class for promise with external resolve and reject.
  134187. */
  134188. export class Deferred<T> {
  134189. /**
  134190. * The promise associated with this deferred object.
  134191. */
  134192. readonly promise: Promise<T>;
  134193. private _resolve;
  134194. private _reject;
  134195. /**
  134196. * The resolve method of the promise associated with this deferred object.
  134197. */
  134198. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  134199. /**
  134200. * The reject method of the promise associated with this deferred object.
  134201. */
  134202. readonly reject: (reason?: any) => void;
  134203. /**
  134204. * Constructor for this deferred object.
  134205. */
  134206. constructor();
  134207. }
  134208. }
  134209. declare module BABYLON {
  134210. /**
  134211. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  134212. */
  134213. export class MeshExploder {
  134214. private _centerMesh;
  134215. private _meshes;
  134216. private _meshesOrigins;
  134217. private _toCenterVectors;
  134218. private _scaledDirection;
  134219. private _newPosition;
  134220. private _centerPosition;
  134221. /**
  134222. * Explodes meshes from a center mesh.
  134223. * @param meshes The meshes to explode.
  134224. * @param centerMesh The mesh to be center of explosion.
  134225. */
  134226. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  134227. private _setCenterMesh;
  134228. /**
  134229. * Get class name
  134230. * @returns "MeshExploder"
  134231. */
  134232. getClassName(): string;
  134233. /**
  134234. * "Exploded meshes"
  134235. * @returns Array of meshes with the centerMesh at index 0.
  134236. */
  134237. getMeshes(): Array<Mesh>;
  134238. /**
  134239. * Explodes meshes giving a specific direction
  134240. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  134241. */
  134242. explode(direction?: number): void;
  134243. }
  134244. }
  134245. declare module BABYLON {
  134246. /**
  134247. * Class used to help managing file picking and drag'n'drop
  134248. */
  134249. export class FilesInput {
  134250. /**
  134251. * List of files ready to be loaded
  134252. */
  134253. static readonly FilesToLoad: {
  134254. [key: string]: File;
  134255. };
  134256. /**
  134257. * Callback called when a file is processed
  134258. */
  134259. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  134260. private _engine;
  134261. private _currentScene;
  134262. private _sceneLoadedCallback;
  134263. private _progressCallback;
  134264. private _additionalRenderLoopLogicCallback;
  134265. private _textureLoadingCallback;
  134266. private _startingProcessingFilesCallback;
  134267. private _onReloadCallback;
  134268. private _errorCallback;
  134269. private _elementToMonitor;
  134270. private _sceneFileToLoad;
  134271. private _filesToLoad;
  134272. /**
  134273. * Creates a new FilesInput
  134274. * @param engine defines the rendering engine
  134275. * @param scene defines the hosting scene
  134276. * @param sceneLoadedCallback callback called when scene is loaded
  134277. * @param progressCallback callback called to track progress
  134278. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  134279. * @param textureLoadingCallback callback called when a texture is loading
  134280. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  134281. * @param onReloadCallback callback called when a reload is requested
  134282. * @param errorCallback callback call if an error occurs
  134283. */
  134284. 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);
  134285. private _dragEnterHandler;
  134286. private _dragOverHandler;
  134287. private _dropHandler;
  134288. /**
  134289. * Calls this function to listen to drag'n'drop events on a specific DOM element
  134290. * @param elementToMonitor defines the DOM element to track
  134291. */
  134292. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  134293. /**
  134294. * Release all associated resources
  134295. */
  134296. dispose(): void;
  134297. private renderFunction;
  134298. private drag;
  134299. private drop;
  134300. private _traverseFolder;
  134301. private _processFiles;
  134302. /**
  134303. * Load files from a drop event
  134304. * @param event defines the drop event to use as source
  134305. */
  134306. loadFiles(event: any): void;
  134307. private _processReload;
  134308. /**
  134309. * Reload the current scene from the loaded files
  134310. */
  134311. reload(): void;
  134312. }
  134313. }
  134314. declare module BABYLON {
  134315. /**
  134316. * Defines the root class used to create scene optimization to use with SceneOptimizer
  134317. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134318. */
  134319. export class SceneOptimization {
  134320. /**
  134321. * Defines the priority of this optimization (0 by default which means first in the list)
  134322. */
  134323. priority: number;
  134324. /**
  134325. * Gets a string describing the action executed by the current optimization
  134326. * @returns description string
  134327. */
  134328. getDescription(): string;
  134329. /**
  134330. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134331. * @param scene defines the current scene where to apply this optimization
  134332. * @param optimizer defines the current optimizer
  134333. * @returns true if everything that can be done was applied
  134334. */
  134335. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134336. /**
  134337. * Creates the SceneOptimization object
  134338. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  134339. * @param desc defines the description associated with the optimization
  134340. */
  134341. constructor(
  134342. /**
  134343. * Defines the priority of this optimization (0 by default which means first in the list)
  134344. */
  134345. priority?: number);
  134346. }
  134347. /**
  134348. * Defines an optimization used to reduce the size of render target textures
  134349. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134350. */
  134351. export class TextureOptimization extends SceneOptimization {
  134352. /**
  134353. * Defines the priority of this optimization (0 by default which means first in the list)
  134354. */
  134355. priority: number;
  134356. /**
  134357. * 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
  134358. */
  134359. maximumSize: number;
  134360. /**
  134361. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  134362. */
  134363. step: number;
  134364. /**
  134365. * Gets a string describing the action executed by the current optimization
  134366. * @returns description string
  134367. */
  134368. getDescription(): string;
  134369. /**
  134370. * Creates the TextureOptimization object
  134371. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  134372. * @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
  134373. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  134374. */
  134375. constructor(
  134376. /**
  134377. * Defines the priority of this optimization (0 by default which means first in the list)
  134378. */
  134379. priority?: number,
  134380. /**
  134381. * 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
  134382. */
  134383. maximumSize?: number,
  134384. /**
  134385. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  134386. */
  134387. step?: number);
  134388. /**
  134389. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134390. * @param scene defines the current scene where to apply this optimization
  134391. * @param optimizer defines the current optimizer
  134392. * @returns true if everything that can be done was applied
  134393. */
  134394. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134395. }
  134396. /**
  134397. * Defines an optimization used to increase or decrease the rendering resolution
  134398. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134399. */
  134400. export class HardwareScalingOptimization extends SceneOptimization {
  134401. /**
  134402. * Defines the priority of this optimization (0 by default which means first in the list)
  134403. */
  134404. priority: number;
  134405. /**
  134406. * Defines the maximum scale to use (2 by default)
  134407. */
  134408. maximumScale: number;
  134409. /**
  134410. * Defines the step to use between two passes (0.5 by default)
  134411. */
  134412. step: number;
  134413. private _currentScale;
  134414. private _directionOffset;
  134415. /**
  134416. * Gets a string describing the action executed by the current optimization
  134417. * @return description string
  134418. */
  134419. getDescription(): string;
  134420. /**
  134421. * Creates the HardwareScalingOptimization object
  134422. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  134423. * @param maximumScale defines the maximum scale to use (2 by default)
  134424. * @param step defines the step to use between two passes (0.5 by default)
  134425. */
  134426. constructor(
  134427. /**
  134428. * Defines the priority of this optimization (0 by default which means first in the list)
  134429. */
  134430. priority?: number,
  134431. /**
  134432. * Defines the maximum scale to use (2 by default)
  134433. */
  134434. maximumScale?: number,
  134435. /**
  134436. * Defines the step to use between two passes (0.5 by default)
  134437. */
  134438. step?: number);
  134439. /**
  134440. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134441. * @param scene defines the current scene where to apply this optimization
  134442. * @param optimizer defines the current optimizer
  134443. * @returns true if everything that can be done was applied
  134444. */
  134445. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134446. }
  134447. /**
  134448. * Defines an optimization used to remove shadows
  134449. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134450. */
  134451. export class ShadowsOptimization extends SceneOptimization {
  134452. /**
  134453. * Gets a string describing the action executed by the current optimization
  134454. * @return description string
  134455. */
  134456. getDescription(): string;
  134457. /**
  134458. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134459. * @param scene defines the current scene where to apply this optimization
  134460. * @param optimizer defines the current optimizer
  134461. * @returns true if everything that can be done was applied
  134462. */
  134463. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134464. }
  134465. /**
  134466. * Defines an optimization used to turn post-processes off
  134467. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134468. */
  134469. export class PostProcessesOptimization extends SceneOptimization {
  134470. /**
  134471. * Gets a string describing the action executed by the current optimization
  134472. * @return description string
  134473. */
  134474. getDescription(): string;
  134475. /**
  134476. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134477. * @param scene defines the current scene where to apply this optimization
  134478. * @param optimizer defines the current optimizer
  134479. * @returns true if everything that can be done was applied
  134480. */
  134481. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134482. }
  134483. /**
  134484. * Defines an optimization used to turn lens flares off
  134485. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134486. */
  134487. export class LensFlaresOptimization extends SceneOptimization {
  134488. /**
  134489. * Gets a string describing the action executed by the current optimization
  134490. * @return description string
  134491. */
  134492. getDescription(): string;
  134493. /**
  134494. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134495. * @param scene defines the current scene where to apply this optimization
  134496. * @param optimizer defines the current optimizer
  134497. * @returns true if everything that can be done was applied
  134498. */
  134499. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134500. }
  134501. /**
  134502. * Defines an optimization based on user defined callback.
  134503. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134504. */
  134505. export class CustomOptimization extends SceneOptimization {
  134506. /**
  134507. * Callback called to apply the custom optimization.
  134508. */
  134509. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  134510. /**
  134511. * Callback called to get custom description
  134512. */
  134513. onGetDescription: () => string;
  134514. /**
  134515. * Gets a string describing the action executed by the current optimization
  134516. * @returns description string
  134517. */
  134518. getDescription(): string;
  134519. /**
  134520. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134521. * @param scene defines the current scene where to apply this optimization
  134522. * @param optimizer defines the current optimizer
  134523. * @returns true if everything that can be done was applied
  134524. */
  134525. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134526. }
  134527. /**
  134528. * Defines an optimization used to turn particles off
  134529. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134530. */
  134531. export class ParticlesOptimization extends SceneOptimization {
  134532. /**
  134533. * Gets a string describing the action executed by the current optimization
  134534. * @return description string
  134535. */
  134536. getDescription(): string;
  134537. /**
  134538. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134539. * @param scene defines the current scene where to apply this optimization
  134540. * @param optimizer defines the current optimizer
  134541. * @returns true if everything that can be done was applied
  134542. */
  134543. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134544. }
  134545. /**
  134546. * Defines an optimization used to turn render targets off
  134547. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134548. */
  134549. export class RenderTargetsOptimization extends SceneOptimization {
  134550. /**
  134551. * Gets a string describing the action executed by the current optimization
  134552. * @return description string
  134553. */
  134554. getDescription(): string;
  134555. /**
  134556. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134557. * @param scene defines the current scene where to apply this optimization
  134558. * @param optimizer defines the current optimizer
  134559. * @returns true if everything that can be done was applied
  134560. */
  134561. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134562. }
  134563. /**
  134564. * Defines an optimization used to merge meshes with compatible materials
  134565. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134566. */
  134567. export class MergeMeshesOptimization extends SceneOptimization {
  134568. private static _UpdateSelectionTree;
  134569. /**
  134570. * Gets or sets a boolean which defines if optimization octree has to be updated
  134571. */
  134572. /**
  134573. * Gets or sets a boolean which defines if optimization octree has to be updated
  134574. */
  134575. static UpdateSelectionTree: boolean;
  134576. /**
  134577. * Gets a string describing the action executed by the current optimization
  134578. * @return description string
  134579. */
  134580. getDescription(): string;
  134581. private _canBeMerged;
  134582. /**
  134583. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134584. * @param scene defines the current scene where to apply this optimization
  134585. * @param optimizer defines the current optimizer
  134586. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  134587. * @returns true if everything that can be done was applied
  134588. */
  134589. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  134590. }
  134591. /**
  134592. * Defines a list of options used by SceneOptimizer
  134593. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134594. */
  134595. export class SceneOptimizerOptions {
  134596. /**
  134597. * Defines the target frame rate to reach (60 by default)
  134598. */
  134599. targetFrameRate: number;
  134600. /**
  134601. * Defines the interval between two checkes (2000ms by default)
  134602. */
  134603. trackerDuration: number;
  134604. /**
  134605. * Gets the list of optimizations to apply
  134606. */
  134607. optimizations: SceneOptimization[];
  134608. /**
  134609. * Creates a new list of options used by SceneOptimizer
  134610. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  134611. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  134612. */
  134613. constructor(
  134614. /**
  134615. * Defines the target frame rate to reach (60 by default)
  134616. */
  134617. targetFrameRate?: number,
  134618. /**
  134619. * Defines the interval between two checkes (2000ms by default)
  134620. */
  134621. trackerDuration?: number);
  134622. /**
  134623. * Add a new optimization
  134624. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  134625. * @returns the current SceneOptimizerOptions
  134626. */
  134627. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  134628. /**
  134629. * Add a new custom optimization
  134630. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  134631. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  134632. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  134633. * @returns the current SceneOptimizerOptions
  134634. */
  134635. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  134636. /**
  134637. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  134638. * @param targetFrameRate defines the target frame rate (60 by default)
  134639. * @returns a SceneOptimizerOptions object
  134640. */
  134641. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  134642. /**
  134643. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  134644. * @param targetFrameRate defines the target frame rate (60 by default)
  134645. * @returns a SceneOptimizerOptions object
  134646. */
  134647. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  134648. /**
  134649. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  134650. * @param targetFrameRate defines the target frame rate (60 by default)
  134651. * @returns a SceneOptimizerOptions object
  134652. */
  134653. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  134654. }
  134655. /**
  134656. * Class used to run optimizations in order to reach a target frame rate
  134657. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134658. */
  134659. export class SceneOptimizer implements IDisposable {
  134660. private _isRunning;
  134661. private _options;
  134662. private _scene;
  134663. private _currentPriorityLevel;
  134664. private _targetFrameRate;
  134665. private _trackerDuration;
  134666. private _currentFrameRate;
  134667. private _sceneDisposeObserver;
  134668. private _improvementMode;
  134669. /**
  134670. * Defines an observable called when the optimizer reaches the target frame rate
  134671. */
  134672. onSuccessObservable: Observable<SceneOptimizer>;
  134673. /**
  134674. * Defines an observable called when the optimizer enables an optimization
  134675. */
  134676. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  134677. /**
  134678. * Defines an observable called when the optimizer is not able to reach the target frame rate
  134679. */
  134680. onFailureObservable: Observable<SceneOptimizer>;
  134681. /**
  134682. * Gets a boolean indicating if the optimizer is in improvement mode
  134683. */
  134684. readonly isInImprovementMode: boolean;
  134685. /**
  134686. * Gets the current priority level (0 at start)
  134687. */
  134688. readonly currentPriorityLevel: number;
  134689. /**
  134690. * Gets the current frame rate checked by the SceneOptimizer
  134691. */
  134692. readonly currentFrameRate: number;
  134693. /**
  134694. * Gets or sets the current target frame rate (60 by default)
  134695. */
  134696. /**
  134697. * Gets or sets the current target frame rate (60 by default)
  134698. */
  134699. targetFrameRate: number;
  134700. /**
  134701. * Gets or sets the current interval between two checks (every 2000ms by default)
  134702. */
  134703. /**
  134704. * Gets or sets the current interval between two checks (every 2000ms by default)
  134705. */
  134706. trackerDuration: number;
  134707. /**
  134708. * Gets the list of active optimizations
  134709. */
  134710. readonly optimizations: SceneOptimization[];
  134711. /**
  134712. * Creates a new SceneOptimizer
  134713. * @param scene defines the scene to work on
  134714. * @param options defines the options to use with the SceneOptimizer
  134715. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  134716. * @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)
  134717. */
  134718. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  134719. /**
  134720. * Stops the current optimizer
  134721. */
  134722. stop(): void;
  134723. /**
  134724. * Reset the optimizer to initial step (current priority level = 0)
  134725. */
  134726. reset(): void;
  134727. /**
  134728. * Start the optimizer. By default it will try to reach a specific framerate
  134729. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  134730. */
  134731. start(): void;
  134732. private _checkCurrentState;
  134733. /**
  134734. * Release all resources
  134735. */
  134736. dispose(): void;
  134737. /**
  134738. * Helper function to create a SceneOptimizer with one single line of code
  134739. * @param scene defines the scene to work on
  134740. * @param options defines the options to use with the SceneOptimizer
  134741. * @param onSuccess defines a callback to call on success
  134742. * @param onFailure defines a callback to call on failure
  134743. * @returns the new SceneOptimizer object
  134744. */
  134745. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  134746. }
  134747. }
  134748. declare module BABYLON {
  134749. /**
  134750. * Class used to serialize a scene into a string
  134751. */
  134752. export class SceneSerializer {
  134753. /**
  134754. * Clear cache used by a previous serialization
  134755. */
  134756. static ClearCache(): void;
  134757. /**
  134758. * Serialize a scene into a JSON compatible object
  134759. * @param scene defines the scene to serialize
  134760. * @returns a JSON compatible object
  134761. */
  134762. static Serialize(scene: Scene): any;
  134763. /**
  134764. * Serialize a mesh into a JSON compatible object
  134765. * @param toSerialize defines the mesh to serialize
  134766. * @param withParents defines if parents must be serialized as well
  134767. * @param withChildren defines if children must be serialized as well
  134768. * @returns a JSON compatible object
  134769. */
  134770. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  134771. }
  134772. }
  134773. declare module BABYLON {
  134774. /**
  134775. * Class used to host texture specific utilities
  134776. */
  134777. export class TextureTools {
  134778. /**
  134779. * Uses the GPU to create a copy texture rescaled at a given size
  134780. * @param texture Texture to copy from
  134781. * @param width defines the desired width
  134782. * @param height defines the desired height
  134783. * @param useBilinearMode defines if bilinear mode has to be used
  134784. * @return the generated texture
  134785. */
  134786. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  134787. }
  134788. }
  134789. declare module BABYLON {
  134790. /**
  134791. * This represents the different options available for the video capture.
  134792. */
  134793. export interface VideoRecorderOptions {
  134794. /** Defines the mime type of the video. */
  134795. mimeType: string;
  134796. /** Defines the FPS the video should be recorded at. */
  134797. fps: number;
  134798. /** Defines the chunk size for the recording data. */
  134799. recordChunckSize: number;
  134800. /** The audio tracks to attach to the recording. */
  134801. audioTracks?: MediaStreamTrack[];
  134802. }
  134803. /**
  134804. * This can help with recording videos from BabylonJS.
  134805. * This is based on the available WebRTC functionalities of the browser.
  134806. *
  134807. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  134808. */
  134809. export class VideoRecorder {
  134810. private static readonly _defaultOptions;
  134811. /**
  134812. * Returns whether or not the VideoRecorder is available in your browser.
  134813. * @param engine Defines the Babylon Engine.
  134814. * @returns true if supported otherwise false.
  134815. */
  134816. static IsSupported(engine: Engine): boolean;
  134817. private readonly _options;
  134818. private _canvas;
  134819. private _mediaRecorder;
  134820. private _recordedChunks;
  134821. private _fileName;
  134822. private _resolve;
  134823. private _reject;
  134824. /**
  134825. * True when a recording is already in progress.
  134826. */
  134827. readonly isRecording: boolean;
  134828. /**
  134829. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  134830. * @param engine Defines the BabylonJS Engine you wish to record.
  134831. * @param options Defines options that can be used to customize the capture.
  134832. */
  134833. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  134834. /**
  134835. * Stops the current recording before the default capture timeout passed in the startRecording function.
  134836. */
  134837. stopRecording(): void;
  134838. /**
  134839. * Starts recording the canvas for a max duration specified in parameters.
  134840. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  134841. * If null no automatic download will start and you can rely on the promise to get the data back.
  134842. * @param maxDuration Defines the maximum recording time in seconds.
  134843. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  134844. * @return A promise callback at the end of the recording with the video data in Blob.
  134845. */
  134846. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  134847. /**
  134848. * Releases internal resources used during the recording.
  134849. */
  134850. dispose(): void;
  134851. private _handleDataAvailable;
  134852. private _handleError;
  134853. private _handleStop;
  134854. }
  134855. }
  134856. declare module BABYLON {
  134857. /**
  134858. * Class containing a set of static utilities functions for screenshots
  134859. */
  134860. export class ScreenshotTools {
  134861. /**
  134862. * Captures a screenshot of the current rendering
  134863. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  134864. * @param engine defines the rendering engine
  134865. * @param camera defines the source camera
  134866. * @param size This parameter can be set to a single number or to an object with the
  134867. * following (optional) properties: precision, width, height. If a single number is passed,
  134868. * it will be used for both width and height. If an object is passed, the screenshot size
  134869. * will be derived from the parameters. The precision property is a multiplier allowing
  134870. * rendering at a higher or lower resolution
  134871. * @param successCallback defines the callback receives a single parameter which contains the
  134872. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  134873. * src parameter of an <img> to display it
  134874. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  134875. * Check your browser for supported MIME types
  134876. */
  134877. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  134878. /**
  134879. * Captures a screenshot of the current rendering
  134880. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  134881. * @param engine defines the rendering engine
  134882. * @param camera defines the source camera
  134883. * @param size This parameter can be set to a single number or to an object with the
  134884. * following (optional) properties: precision, width, height. If a single number is passed,
  134885. * it will be used for both width and height. If an object is passed, the screenshot size
  134886. * will be derived from the parameters. The precision property is a multiplier allowing
  134887. * rendering at a higher or lower resolution
  134888. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  134889. * Check your browser for supported MIME types
  134890. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  134891. * to the src parameter of an <img> to display it
  134892. */
  134893. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  134894. /**
  134895. * Generates an image screenshot from the specified camera.
  134896. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  134897. * @param engine The engine to use for rendering
  134898. * @param camera The camera to use for rendering
  134899. * @param size This parameter can be set to a single number or to an object with the
  134900. * following (optional) properties: precision, width, height. If a single number is passed,
  134901. * it will be used for both width and height. If an object is passed, the screenshot size
  134902. * will be derived from the parameters. The precision property is a multiplier allowing
  134903. * rendering at a higher or lower resolution
  134904. * @param successCallback The callback receives a single parameter which contains the
  134905. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  134906. * src parameter of an <img> to display it
  134907. * @param mimeType The MIME type of the screenshot image (default: image/png).
  134908. * Check your browser for supported MIME types
  134909. * @param samples Texture samples (default: 1)
  134910. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  134911. * @param fileName A name for for the downloaded file.
  134912. */
  134913. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  134914. /**
  134915. * Generates an image screenshot from the specified camera.
  134916. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  134917. * @param engine The engine to use for rendering
  134918. * @param camera The camera to use for rendering
  134919. * @param size This parameter can be set to a single number or to an object with the
  134920. * following (optional) properties: precision, width, height. If a single number is passed,
  134921. * it will be used for both width and height. If an object is passed, the screenshot size
  134922. * will be derived from the parameters. The precision property is a multiplier allowing
  134923. * rendering at a higher or lower resolution
  134924. * @param mimeType The MIME type of the screenshot image (default: image/png).
  134925. * Check your browser for supported MIME types
  134926. * @param samples Texture samples (default: 1)
  134927. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  134928. * @param fileName A name for for the downloaded file.
  134929. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  134930. * to the src parameter of an <img> to display it
  134931. */
  134932. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  134933. /**
  134934. * Gets height and width for screenshot size
  134935. * @private
  134936. */
  134937. private static _getScreenshotSize;
  134938. }
  134939. }
  134940. declare module BABYLON {
  134941. /**
  134942. * Interface for a data buffer
  134943. */
  134944. export interface IDataBuffer {
  134945. /**
  134946. * Reads bytes from the data buffer.
  134947. * @param byteOffset The byte offset to read
  134948. * @param byteLength The byte length to read
  134949. * @returns A promise that resolves when the bytes are read
  134950. */
  134951. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  134952. /**
  134953. * The byte length of the buffer.
  134954. */
  134955. readonly byteLength: number;
  134956. }
  134957. /**
  134958. * Utility class for reading from a data buffer
  134959. */
  134960. export class DataReader {
  134961. /**
  134962. * The data buffer associated with this data reader.
  134963. */
  134964. readonly buffer: IDataBuffer;
  134965. /**
  134966. * The current byte offset from the beginning of the data buffer.
  134967. */
  134968. byteOffset: number;
  134969. private _dataView;
  134970. private _dataByteOffset;
  134971. /**
  134972. * Constructor
  134973. * @param buffer The buffer to read
  134974. */
  134975. constructor(buffer: IDataBuffer);
  134976. /**
  134977. * Loads the given byte length.
  134978. * @param byteLength The byte length to load
  134979. * @returns A promise that resolves when the load is complete
  134980. */
  134981. loadAsync(byteLength: number): Promise<void>;
  134982. /**
  134983. * Read a unsigned 32-bit integer from the currently loaded data range.
  134984. * @returns The 32-bit integer read
  134985. */
  134986. readUint32(): number;
  134987. /**
  134988. * Read a byte array from the currently loaded data range.
  134989. * @param byteLength The byte length to read
  134990. * @returns The byte array read
  134991. */
  134992. readUint8Array(byteLength: number): Uint8Array;
  134993. /**
  134994. * Read a string from the currently loaded data range.
  134995. * @param byteLength The byte length to read
  134996. * @returns The string read
  134997. */
  134998. readString(byteLength: number): string;
  134999. /**
  135000. * Skips the given byte length the currently loaded data range.
  135001. * @param byteLength The byte length to skip
  135002. */
  135003. skipBytes(byteLength: number): void;
  135004. }
  135005. }
  135006. declare module BABYLON {
  135007. /**
  135008. * A cursor which tracks a point on a path
  135009. */
  135010. export class PathCursor {
  135011. private path;
  135012. /**
  135013. * Stores path cursor callbacks for when an onchange event is triggered
  135014. */
  135015. private _onchange;
  135016. /**
  135017. * The value of the path cursor
  135018. */
  135019. value: number;
  135020. /**
  135021. * The animation array of the path cursor
  135022. */
  135023. animations: Animation[];
  135024. /**
  135025. * Initializes the path cursor
  135026. * @param path The path to track
  135027. */
  135028. constructor(path: Path2);
  135029. /**
  135030. * Gets the cursor point on the path
  135031. * @returns A point on the path cursor at the cursor location
  135032. */
  135033. getPoint(): Vector3;
  135034. /**
  135035. * Moves the cursor ahead by the step amount
  135036. * @param step The amount to move the cursor forward
  135037. * @returns This path cursor
  135038. */
  135039. moveAhead(step?: number): PathCursor;
  135040. /**
  135041. * Moves the cursor behind by the step amount
  135042. * @param step The amount to move the cursor back
  135043. * @returns This path cursor
  135044. */
  135045. moveBack(step?: number): PathCursor;
  135046. /**
  135047. * Moves the cursor by the step amount
  135048. * If the step amount is greater than one, an exception is thrown
  135049. * @param step The amount to move the cursor
  135050. * @returns This path cursor
  135051. */
  135052. move(step: number): PathCursor;
  135053. /**
  135054. * Ensures that the value is limited between zero and one
  135055. * @returns This path cursor
  135056. */
  135057. private ensureLimits;
  135058. /**
  135059. * Runs onchange callbacks on change (used by the animation engine)
  135060. * @returns This path cursor
  135061. */
  135062. private raiseOnChange;
  135063. /**
  135064. * Executes a function on change
  135065. * @param f A path cursor onchange callback
  135066. * @returns This path cursor
  135067. */
  135068. onchange(f: (cursor: PathCursor) => void): PathCursor;
  135069. }
  135070. }
  135071. declare module BABYLON {
  135072. /** @hidden */
  135073. export var blurPixelShader: {
  135074. name: string;
  135075. shader: string;
  135076. };
  135077. }
  135078. declare module BABYLON {
  135079. /** @hidden */
  135080. export var pointCloudVertexDeclaration: {
  135081. name: string;
  135082. shader: string;
  135083. };
  135084. }
  135085. // Mixins
  135086. interface Window {
  135087. mozIndexedDB: IDBFactory;
  135088. webkitIndexedDB: IDBFactory;
  135089. msIndexedDB: IDBFactory;
  135090. webkitURL: typeof URL;
  135091. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  135092. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  135093. WebGLRenderingContext: WebGLRenderingContext;
  135094. MSGesture: MSGesture;
  135095. CANNON: any;
  135096. AudioContext: AudioContext;
  135097. webkitAudioContext: AudioContext;
  135098. PointerEvent: any;
  135099. Math: Math;
  135100. Uint8Array: Uint8ArrayConstructor;
  135101. Float32Array: Float32ArrayConstructor;
  135102. mozURL: typeof URL;
  135103. msURL: typeof URL;
  135104. VRFrameData: any; // WebVR, from specs 1.1
  135105. DracoDecoderModule: any;
  135106. setImmediate(handler: (...args: any[]) => void): number;
  135107. }
  135108. interface HTMLCanvasElement {
  135109. requestPointerLock(): void;
  135110. msRequestPointerLock?(): void;
  135111. mozRequestPointerLock?(): void;
  135112. webkitRequestPointerLock?(): void;
  135113. /** Track wether a record is in progress */
  135114. isRecording: boolean;
  135115. /** Capture Stream method defined by some browsers */
  135116. captureStream(fps?: number): MediaStream;
  135117. }
  135118. interface CanvasRenderingContext2D {
  135119. msImageSmoothingEnabled: boolean;
  135120. }
  135121. interface MouseEvent {
  135122. mozMovementX: number;
  135123. mozMovementY: number;
  135124. webkitMovementX: number;
  135125. webkitMovementY: number;
  135126. msMovementX: number;
  135127. msMovementY: number;
  135128. }
  135129. interface Navigator {
  135130. mozGetVRDevices: (any: any) => any;
  135131. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  135132. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  135133. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  135134. webkitGetGamepads(): Gamepad[];
  135135. msGetGamepads(): Gamepad[];
  135136. webkitGamepads(): Gamepad[];
  135137. }
  135138. interface HTMLVideoElement {
  135139. mozSrcObject: any;
  135140. }
  135141. interface Math {
  135142. fround(x: number): number;
  135143. imul(a: number, b: number): number;
  135144. }
  135145. interface WebGLRenderingContext {
  135146. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  135147. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  135148. vertexAttribDivisor(index: number, divisor: number): void;
  135149. createVertexArray(): any;
  135150. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  135151. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  135152. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  135153. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  135154. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  135155. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  135156. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  135157. // Queries
  135158. createQuery(): WebGLQuery;
  135159. deleteQuery(query: WebGLQuery): void;
  135160. beginQuery(target: number, query: WebGLQuery): void;
  135161. endQuery(target: number): void;
  135162. getQueryParameter(query: WebGLQuery, pname: number): any;
  135163. getQuery(target: number, pname: number): any;
  135164. MAX_SAMPLES: number;
  135165. RGBA8: number;
  135166. READ_FRAMEBUFFER: number;
  135167. DRAW_FRAMEBUFFER: number;
  135168. UNIFORM_BUFFER: number;
  135169. HALF_FLOAT_OES: number;
  135170. RGBA16F: number;
  135171. RGBA32F: number;
  135172. R32F: number;
  135173. RG32F: number;
  135174. RGB32F: number;
  135175. R16F: number;
  135176. RG16F: number;
  135177. RGB16F: number;
  135178. RED: number;
  135179. RG: number;
  135180. R8: number;
  135181. RG8: number;
  135182. UNSIGNED_INT_24_8: number;
  135183. DEPTH24_STENCIL8: number;
  135184. MIN: number;
  135185. MAX: number;
  135186. /* Multiple Render Targets */
  135187. drawBuffers(buffers: number[]): void;
  135188. readBuffer(src: number): void;
  135189. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  135190. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  135191. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  135192. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  135193. // Occlusion Query
  135194. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  135195. ANY_SAMPLES_PASSED: number;
  135196. QUERY_RESULT_AVAILABLE: number;
  135197. QUERY_RESULT: number;
  135198. }
  135199. interface WebGLProgram {
  135200. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  135201. }
  135202. interface EXT_disjoint_timer_query {
  135203. QUERY_COUNTER_BITS_EXT: number;
  135204. TIME_ELAPSED_EXT: number;
  135205. TIMESTAMP_EXT: number;
  135206. GPU_DISJOINT_EXT: number;
  135207. QUERY_RESULT_EXT: number;
  135208. QUERY_RESULT_AVAILABLE_EXT: number;
  135209. queryCounterEXT(query: WebGLQuery, target: number): void;
  135210. createQueryEXT(): WebGLQuery;
  135211. beginQueryEXT(target: number, query: WebGLQuery): void;
  135212. endQueryEXT(target: number): void;
  135213. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  135214. deleteQueryEXT(query: WebGLQuery): void;
  135215. }
  135216. interface WebGLUniformLocation {
  135217. _currentState: any;
  135218. }
  135219. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  135220. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  135221. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  135222. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  135223. interface WebGLRenderingContext {
  135224. readonly RASTERIZER_DISCARD: number;
  135225. readonly DEPTH_COMPONENT24: number;
  135226. readonly TEXTURE_3D: number;
  135227. readonly TEXTURE_2D_ARRAY: number;
  135228. readonly TEXTURE_COMPARE_FUNC: number;
  135229. readonly TEXTURE_COMPARE_MODE: number;
  135230. readonly COMPARE_REF_TO_TEXTURE: number;
  135231. readonly TEXTURE_WRAP_R: number;
  135232. readonly HALF_FLOAT: number;
  135233. readonly RGB8: number;
  135234. readonly RED_INTEGER: number;
  135235. readonly RG_INTEGER: number;
  135236. readonly RGB_INTEGER: number;
  135237. readonly RGBA_INTEGER: number;
  135238. readonly R8_SNORM: number;
  135239. readonly RG8_SNORM: number;
  135240. readonly RGB8_SNORM: number;
  135241. readonly RGBA8_SNORM: number;
  135242. readonly R8I: number;
  135243. readonly RG8I: number;
  135244. readonly RGB8I: number;
  135245. readonly RGBA8I: number;
  135246. readonly R8UI: number;
  135247. readonly RG8UI: number;
  135248. readonly RGB8UI: number;
  135249. readonly RGBA8UI: number;
  135250. readonly R16I: number;
  135251. readonly RG16I: number;
  135252. readonly RGB16I: number;
  135253. readonly RGBA16I: number;
  135254. readonly R16UI: number;
  135255. readonly RG16UI: number;
  135256. readonly RGB16UI: number;
  135257. readonly RGBA16UI: number;
  135258. readonly R32I: number;
  135259. readonly RG32I: number;
  135260. readonly RGB32I: number;
  135261. readonly RGBA32I: number;
  135262. readonly R32UI: number;
  135263. readonly RG32UI: number;
  135264. readonly RGB32UI: number;
  135265. readonly RGBA32UI: number;
  135266. readonly RGB10_A2UI: number;
  135267. readonly R11F_G11F_B10F: number;
  135268. readonly RGB9_E5: number;
  135269. readonly RGB10_A2: number;
  135270. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  135271. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  135272. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  135273. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  135274. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  135275. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  135276. 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;
  135277. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  135278. readonly TRANSFORM_FEEDBACK: number;
  135279. readonly INTERLEAVED_ATTRIBS: number;
  135280. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  135281. createTransformFeedback(): WebGLTransformFeedback;
  135282. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  135283. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  135284. beginTransformFeedback(primitiveMode: number): void;
  135285. endTransformFeedback(): void;
  135286. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  135287. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  135288. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  135289. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  135290. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  135291. }
  135292. interface ImageBitmap {
  135293. readonly width: number;
  135294. readonly height: number;
  135295. close(): void;
  135296. }
  135297. interface WebGLQuery extends WebGLObject {
  135298. }
  135299. declare var WebGLQuery: {
  135300. prototype: WebGLQuery;
  135301. new(): WebGLQuery;
  135302. };
  135303. interface WebGLSampler extends WebGLObject {
  135304. }
  135305. declare var WebGLSampler: {
  135306. prototype: WebGLSampler;
  135307. new(): WebGLSampler;
  135308. };
  135309. interface WebGLSync extends WebGLObject {
  135310. }
  135311. declare var WebGLSync: {
  135312. prototype: WebGLSync;
  135313. new(): WebGLSync;
  135314. };
  135315. interface WebGLTransformFeedback extends WebGLObject {
  135316. }
  135317. declare var WebGLTransformFeedback: {
  135318. prototype: WebGLTransformFeedback;
  135319. new(): WebGLTransformFeedback;
  135320. };
  135321. interface WebGLVertexArrayObject extends WebGLObject {
  135322. }
  135323. declare var WebGLVertexArrayObject: {
  135324. prototype: WebGLVertexArrayObject;
  135325. new(): WebGLVertexArrayObject;
  135326. };
  135327. // Type definitions for WebVR API
  135328. // Project: https://w3c.github.io/webvr/
  135329. // Definitions by: six a <https://github.com/lostfictions>
  135330. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  135331. interface VRDisplay extends EventTarget {
  135332. /**
  135333. * Dictionary of capabilities describing the VRDisplay.
  135334. */
  135335. readonly capabilities: VRDisplayCapabilities;
  135336. /**
  135337. * z-depth defining the far plane of the eye view frustum
  135338. * enables mapping of values in the render target depth
  135339. * attachment to scene coordinates. Initially set to 10000.0.
  135340. */
  135341. depthFar: number;
  135342. /**
  135343. * z-depth defining the near plane of the eye view frustum
  135344. * enables mapping of values in the render target depth
  135345. * attachment to scene coordinates. Initially set to 0.01.
  135346. */
  135347. depthNear: number;
  135348. /**
  135349. * An identifier for this distinct VRDisplay. Used as an
  135350. * association point in the Gamepad API.
  135351. */
  135352. readonly displayId: number;
  135353. /**
  135354. * A display name, a user-readable name identifying it.
  135355. */
  135356. readonly displayName: string;
  135357. readonly isConnected: boolean;
  135358. readonly isPresenting: boolean;
  135359. /**
  135360. * If this VRDisplay supports room-scale experiences, the optional
  135361. * stage attribute contains details on the room-scale parameters.
  135362. */
  135363. readonly stageParameters: VRStageParameters | null;
  135364. /**
  135365. * Passing the value returned by `requestAnimationFrame` to
  135366. * `cancelAnimationFrame` will unregister the callback.
  135367. * @param handle Define the hanle of the request to cancel
  135368. */
  135369. cancelAnimationFrame(handle: number): void;
  135370. /**
  135371. * Stops presenting to the VRDisplay.
  135372. * @returns a promise to know when it stopped
  135373. */
  135374. exitPresent(): Promise<void>;
  135375. /**
  135376. * Return the current VREyeParameters for the given eye.
  135377. * @param whichEye Define the eye we want the parameter for
  135378. * @returns the eye parameters
  135379. */
  135380. getEyeParameters(whichEye: string): VREyeParameters;
  135381. /**
  135382. * Populates the passed VRFrameData with the information required to render
  135383. * the current frame.
  135384. * @param frameData Define the data structure to populate
  135385. * @returns true if ok otherwise false
  135386. */
  135387. getFrameData(frameData: VRFrameData): boolean;
  135388. /**
  135389. * Get the layers currently being presented.
  135390. * @returns the list of VR layers
  135391. */
  135392. getLayers(): VRLayer[];
  135393. /**
  135394. * Return a VRPose containing the future predicted pose of the VRDisplay
  135395. * when the current frame will be presented. The value returned will not
  135396. * change until JavaScript has returned control to the browser.
  135397. *
  135398. * The VRPose will contain the position, orientation, velocity,
  135399. * and acceleration of each of these properties.
  135400. * @returns the pose object
  135401. */
  135402. getPose(): VRPose;
  135403. /**
  135404. * Return the current instantaneous pose of the VRDisplay, with no
  135405. * prediction applied.
  135406. * @returns the current instantaneous pose
  135407. */
  135408. getImmediatePose(): VRPose;
  135409. /**
  135410. * The callback passed to `requestAnimationFrame` will be called
  135411. * any time a new frame should be rendered. When the VRDisplay is
  135412. * presenting the callback will be called at the native refresh
  135413. * rate of the HMD. When not presenting this function acts
  135414. * identically to how window.requestAnimationFrame acts. Content should
  135415. * make no assumptions of frame rate or vsync behavior as the HMD runs
  135416. * asynchronously from other displays and at differing refresh rates.
  135417. * @param callback Define the eaction to run next frame
  135418. * @returns the request handle it
  135419. */
  135420. requestAnimationFrame(callback: FrameRequestCallback): number;
  135421. /**
  135422. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  135423. * Repeat calls while already presenting will update the VRLayers being displayed.
  135424. * @param layers Define the list of layer to present
  135425. * @returns a promise to know when the request has been fulfilled
  135426. */
  135427. requestPresent(layers: VRLayer[]): Promise<void>;
  135428. /**
  135429. * Reset the pose for this display, treating its current position and
  135430. * orientation as the "origin/zero" values. VRPose.position,
  135431. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  135432. * updated when calling resetPose(). This should be called in only
  135433. * sitting-space experiences.
  135434. */
  135435. resetPose(): void;
  135436. /**
  135437. * The VRLayer provided to the VRDisplay will be captured and presented
  135438. * in the HMD. Calling this function has the same effect on the source
  135439. * canvas as any other operation that uses its source image, and canvases
  135440. * created without preserveDrawingBuffer set to true will be cleared.
  135441. * @param pose Define the pose to submit
  135442. */
  135443. submitFrame(pose?: VRPose): void;
  135444. }
  135445. declare var VRDisplay: {
  135446. prototype: VRDisplay;
  135447. new(): VRDisplay;
  135448. };
  135449. interface VRLayer {
  135450. leftBounds?: number[] | Float32Array | null;
  135451. rightBounds?: number[] | Float32Array | null;
  135452. source?: HTMLCanvasElement | null;
  135453. }
  135454. interface VRDisplayCapabilities {
  135455. readonly canPresent: boolean;
  135456. readonly hasExternalDisplay: boolean;
  135457. readonly hasOrientation: boolean;
  135458. readonly hasPosition: boolean;
  135459. readonly maxLayers: number;
  135460. }
  135461. interface VREyeParameters {
  135462. /** @deprecated */
  135463. readonly fieldOfView: VRFieldOfView;
  135464. readonly offset: Float32Array;
  135465. readonly renderHeight: number;
  135466. readonly renderWidth: number;
  135467. }
  135468. interface VRFieldOfView {
  135469. readonly downDegrees: number;
  135470. readonly leftDegrees: number;
  135471. readonly rightDegrees: number;
  135472. readonly upDegrees: number;
  135473. }
  135474. interface VRFrameData {
  135475. readonly leftProjectionMatrix: Float32Array;
  135476. readonly leftViewMatrix: Float32Array;
  135477. readonly pose: VRPose;
  135478. readonly rightProjectionMatrix: Float32Array;
  135479. readonly rightViewMatrix: Float32Array;
  135480. readonly timestamp: number;
  135481. }
  135482. interface VRPose {
  135483. readonly angularAcceleration: Float32Array | null;
  135484. readonly angularVelocity: Float32Array | null;
  135485. readonly linearAcceleration: Float32Array | null;
  135486. readonly linearVelocity: Float32Array | null;
  135487. readonly orientation: Float32Array | null;
  135488. readonly position: Float32Array | null;
  135489. readonly timestamp: number;
  135490. }
  135491. interface VRStageParameters {
  135492. sittingToStandingTransform?: Float32Array;
  135493. sizeX?: number;
  135494. sizeY?: number;
  135495. }
  135496. interface Navigator {
  135497. getVRDisplays(): Promise<VRDisplay[]>;
  135498. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  135499. }
  135500. interface Window {
  135501. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  135502. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  135503. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  135504. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  135505. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  135506. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  135507. }
  135508. interface Gamepad {
  135509. readonly displayId: number;
  135510. }
  135511. type XRSessionMode =
  135512. | "inline"
  135513. | "immersive-vr"
  135514. | "immersive-ar";
  135515. type XRReferenceSpaceType =
  135516. | "viewer"
  135517. | "local"
  135518. | "local-floor"
  135519. | "bounded-floor"
  135520. | "unbounded";
  135521. type XREnvironmentBlendMode =
  135522. | "opaque"
  135523. | "additive"
  135524. | "alpha-blend";
  135525. type XRVisibilityState =
  135526. | "visible"
  135527. | "visible-blurred"
  135528. | "hidden";
  135529. type XRHandedness =
  135530. | "none"
  135531. | "left"
  135532. | "right";
  135533. type XRTargetRayMode =
  135534. | "gaze"
  135535. | "tracked-pointer"
  135536. | "screen";
  135537. type XREye =
  135538. | "none"
  135539. | "left"
  135540. | "right";
  135541. interface XRSpace extends EventTarget {
  135542. }
  135543. interface XRRenderState {
  135544. depthNear?: number;
  135545. depthFar?: number;
  135546. inlineVerticalFieldOfView?: number;
  135547. baseLayer?: XRWebGLLayer;
  135548. }
  135549. interface XRInputSource {
  135550. handedness: XRHandedness;
  135551. targetRayMode: XRTargetRayMode;
  135552. targetRaySpace: XRSpace;
  135553. gripSpace: XRSpace | undefined;
  135554. gamepad: Gamepad | undefined;
  135555. profiles: Array<string>;
  135556. }
  135557. interface XRSession {
  135558. addEventListener: Function;
  135559. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  135560. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  135561. requestAnimationFrame: Function;
  135562. end(): Promise<void>;
  135563. renderState: XRRenderState;
  135564. inputSources: Array<XRInputSource>;
  135565. }
  135566. interface XRReferenceSpace extends XRSpace {
  135567. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  135568. onreset: any;
  135569. }
  135570. interface XRFrame {
  135571. session: XRSession;
  135572. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  135573. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  135574. }
  135575. interface XRViewerPose extends XRPose {
  135576. views: Array<XRView>;
  135577. }
  135578. interface XRPose {
  135579. transform: XRRigidTransform;
  135580. emulatedPosition: boolean;
  135581. }
  135582. interface XRWebGLLayerOptions {
  135583. antialias ?: boolean;
  135584. depth ?: boolean;
  135585. stencil ?: boolean;
  135586. alpha ?: boolean;
  135587. multiview ?: boolean;
  135588. framebufferScaleFactor ?: number;
  135589. }
  135590. declare var XRWebGLLayer: {
  135591. prototype: XRWebGLLayer;
  135592. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  135593. };
  135594. interface XRWebGLLayer {
  135595. framebuffer: WebGLFramebuffer;
  135596. framebufferWidth: number;
  135597. framebufferHeight: number;
  135598. getViewport: Function;
  135599. }
  135600. interface XRRigidTransform {
  135601. position: DOMPointReadOnly;
  135602. orientation: DOMPointReadOnly;
  135603. matrix: Float32Array;
  135604. inverse: XRRigidTransform;
  135605. }
  135606. interface XRView {
  135607. eye: XREye;
  135608. projectionMatrix: Float32Array;
  135609. transform: XRRigidTransform;
  135610. }
  135611. interface XRInputSourceChangeEvent {
  135612. session: XRSession;
  135613. removed: Array<XRInputSource>;
  135614. added: Array<XRInputSource>;
  135615. }
  135616. interface XRInputSourceEvent extends Event {
  135617. readonly frame: XRFrame;
  135618. readonly inputSource: XRInputSource;
  135619. }